-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(clouds): add initial implementation for clouds client
- Introduced `cloudsClient` struct with methods for creating, reading, updating, and destroying clouds. - Added input and output structs for `CreateCloud`, `ReadCloud`, `UpdateCloud`, and `DestroyCloud` operations. - Integrated `cloudsClient` with `SharedClient` for shared functionality. This change sets up the basic structure for managing clouds within the Juju client.
- Loading branch information
Showing
5 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2024 Canonical Ltd. | ||
// Licensed under the Apache License, Version 2.0, see LICENCE file for details. | ||
|
||
package juju | ||
|
||
type cloudsClient struct { | ||
SharedClient | ||
} | ||
|
||
type CreateCloudInput struct { | ||
} | ||
|
||
type CreateCloudOutput struct { | ||
} | ||
|
||
type ReadCloudInput struct { | ||
} | ||
|
||
type ReadCloudOutput struct { | ||
} | ||
|
||
type UpdateCloudInput struct { | ||
} | ||
|
||
type DestroyCloudInput struct { | ||
} | ||
|
||
func newCloudsClient(sc SharedClient) *cloudsClient { | ||
return &cloudsClient{ | ||
SharedClient: sc, | ||
} | ||
} | ||
|
||
func (c *cloudsClient) CreateCloud(input *CreateCloudInput) (*CreateCloudOutput, error) { | ||
return nil, nil | ||
} | ||
|
||
func (c *cloudsClient) ReadCloud(input *ReadCloudInput) (*ReadCloudOutput, error) { | ||
return nil, nil | ||
} | ||
|
||
func (c *cloudsClient) UpdateCloud(input *UpdateCloudInput) error { | ||
return nil | ||
} | ||
|
||
func (c *cloudsClient) DestroyCloud(input *DestroyCloudInput) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright 2024 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package juju |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright 2024 Canonical Ltd. | ||
// Licensed under the Apache License, Version 2.0, see LICENCE file for details. | ||
|
||
package provider | ||
|
||
import ( | ||
"context" | ||
"github.com/hashicorp/terraform-plugin-framework/path" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/resource" | ||
"github.com/hashicorp/terraform-plugin-framework/resource/schema" | ||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" | ||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
|
||
"github.com/juju/terraform-provider-juju/internal/juju" | ||
) | ||
|
||
// Ensure provider defined types fully satisfy framework interfaces. | ||
var _ resource.Resource = &kubernetesCloudResource{} | ||
var _ resource.ResourceWithConfigure = &kubernetesCloudResource{} | ||
var _ resource.ResourceWithImportState = &kubernetesCloudResource{} | ||
|
||
func NewKubernetesCloudResource() resource.Resource { | ||
return &kubernetesCloudResource{} | ||
} | ||
|
||
type kubernetesCloudResource struct { | ||
client *juju.Client | ||
|
||
// subCtx is the context created with the new tflog subsystem for applications. | ||
subCtx context.Context | ||
} | ||
|
||
type kubernetesCloudResourceModel struct { | ||
CloudName types.String `tfsdk:"name"` | ||
KubeConfig types.String `tfsdk:"kubeconfig"` | ||
ParentCloudName types.String `tfsdk:"parentcloudname"` | ||
ParentCloudRegion types.String `tfsdk:"parentcloudregion"` | ||
} | ||
|
||
func (o *kubernetesCloudResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { | ||
resp.TypeName = req.ProviderTypeName + "_kubernetes_cloud" | ||
} | ||
|
||
func (o *kubernetesCloudResource) Schema(_ context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { | ||
resp.Schema = schema.Schema{ | ||
Description: "A resource that represent a Juju Cloud for existing controller.", | ||
Attributes: map[string]schema.Attribute{ | ||
"name": schema.StringAttribute{ | ||
Description: "The name of the cloud.", | ||
Required: true, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.RequiresReplace(), | ||
}, | ||
}, | ||
"kubeconfig": schema.StringAttribute{ | ||
Description: "The kubeconfig file path for the cloud.", | ||
Optional: true, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.UseStateForUnknown(), | ||
}, | ||
}, | ||
"parentcloudname": schema.StringAttribute{ | ||
Description: "The parent cloud name in case adding k8s cluster from existed cloud.", | ||
Optional: true, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.RequiresReplace(), | ||
}, | ||
}, | ||
"parentcloudregion": schema.StringAttribute{ | ||
Description: "The parent cloud region name in case adding k8s cluster from existed cloud.", | ||
Optional: true, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.RequiresReplace(), | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (o *kubernetesCloudResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { | ||
} | ||
|
||
func (o *kubernetesCloudResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { | ||
} | ||
|
||
func (o *kubernetesCloudResource) Update(context.Context, resource.UpdateRequest, *resource.UpdateResponse) { | ||
} | ||
|
||
func (o *kubernetesCloudResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { | ||
} | ||
|
||
func (o *kubernetesCloudResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { | ||
} | ||
|
||
func (o *kubernetesCloudResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { | ||
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package provider |