diff --git a/internal/juju/client.go b/internal/juju/client.go index bf8af75a..cff12f12 100644 --- a/internal/juju/client.go +++ b/internal/juju/client.go @@ -42,7 +42,7 @@ type ControllerConfiguration struct { type Client struct { Applications applicationsClient Machines machinesClient - Clouds cloudsClient + Clouds kubernetesCloudsClient Credentials credentialsClient Integrations integrationsClient Models modelsClient @@ -86,7 +86,7 @@ func NewClient(ctx context.Context, config ControllerConfiguration) (*Client, er return &Client{ Applications: *newApplicationClient(sc), - Clouds: *newCloudsClient(sc), + Clouds: *newKubernetesCloudsClient(sc), Credentials: *newCredentialsClient(sc), Integrations: *newIntegrationsClient(sc), Machines: *newMachinesClient(sc), diff --git a/internal/juju/clouds.go b/internal/juju/clouds.go deleted file mode 100644 index 45b66b3d..00000000 --- a/internal/juju/clouds.go +++ /dev/null @@ -1,48 +0,0 @@ -// 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 -} diff --git a/internal/juju/clouds_test.go b/internal/juju/clouds_test.go deleted file mode 100644 index 1957d204..00000000 --- a/internal/juju/clouds_test.go +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2024 Canonical Ltd. -// Licensed under the AGPLv3, see LICENCE file for details. - -package juju diff --git a/internal/juju/kubernetes_clouds.go b/internal/juju/kubernetes_clouds.go new file mode 100644 index 00000000..7ceff8d2 --- /dev/null +++ b/internal/juju/kubernetes_clouds.go @@ -0,0 +1,52 @@ +// Copyright 2024 Canonical Ltd. +// Licensed under the Apache License, Version 2.0, see LICENCE file for details. + +package juju + +type kubernetesCloudsClient struct { + SharedClient +} + +type CreateKubernetesCloudInput struct { +} + +type CreateKubernetesCloudOutput struct { +} + +type ReadKubernetesCloudInput struct { +} + +type ReadKubernetesCloudOutput struct { +} + +type UpdateKubernetesCloudInput struct { +} + +type DestroyKubernetesCloudInput struct { +} + +func newKubernetesCloudsClient(sc SharedClient) *kubernetesCloudsClient { + return &kubernetesCloudsClient{ + SharedClient: sc, + } +} + +// CreateKubernetesCloud creates a new Kubernetes cloud with juju cloud facade. +func (c *kubernetesCloudsClient) CreateKubernetesCloud(input *CreateKubernetesCloudInput) (*CreateKubernetesCloudOutput, error) { + return nil, nil +} + +// ReadKubernetesCloud reads a Kubernetes cloud with juju cloud facade. +func (c *kubernetesCloudsClient) ReadKubernetesCloud(input *ReadKubernetesCloudInput) (*ReadKubernetesCloudOutput, error) { + return nil, nil +} + +// UpdateKubernetesCloud updates a Kubernetes cloud with juju cloud facade. +func (c *kubernetesCloudsClient) UpdateKubernetesCloud(input *UpdateKubernetesCloudInput) error { + return nil +} + +// DestroyKubernetesCloud destroys a Kubernetes cloud with juju cloud facade. +func (c *kubernetesCloudsClient) DestroyKubernetesCloud(input *DestroyKubernetesCloudInput) error { + return nil +} diff --git a/internal/provider/resource_kubernetes_cloud.go b/internal/provider/resource_kubernetes_cloud.go index d0cf7d9b..ebd46b57 100644 --- a/internal/provider/resource_kubernetes_cloud.go +++ b/internal/provider/resource_kubernetes_cloud.go @@ -39,6 +39,13 @@ type kubernetesCloudResourceModel struct { ParentCloudRegion types.String `tfsdk:"parentcloudregion"` } +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) +} + func (o *kubernetesCloudResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_kubernetes_cloud" } @@ -48,7 +55,7 @@ func (o *kubernetesCloudResource) Schema(_ context.Context, req resource.SchemaR 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.", + Description: "The name of the cloud. Changing this value will cause the cloud to be destroyed and recreated by terraform.", Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), @@ -62,38 +69,41 @@ func (o *kubernetesCloudResource) Schema(_ context.Context, req resource.SchemaR }, }, "parentcloudname": schema.StringAttribute{ - Description: "The parent cloud name in case adding k8s cluster from existed cloud.", + Description: "The parent cloud name in case adding k8s cluster from existed cloud. Changing this value will cause the cloud to be destroyed and recreated by terraform.", Optional: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), }, }, "parentcloudregion": schema.StringAttribute{ - Description: "The parent cloud region name in case adding k8s cluster from existed cloud.", + Description: "The parent cloud region name in case adding k8s cluster from existed cloud. Changing this value will cause the cloud to be destroyed and recreated by terraform.", Optional: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), }, }, + "id": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, }, } } +// Create adds a new kubernetes cloud to controllers used now by Terraform provider. func (o *kubernetesCloudResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { } +// Read reads the current state of the kubernetes cloud. func (o *kubernetesCloudResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { } +// Update updates the kubernetes cloud on the controller used by Terraform provider. func (o *kubernetesCloudResource) Update(context.Context, resource.UpdateRequest, *resource.UpdateResponse) { } +// Delete removes the kubernetes cloud from the controller used by Terraform provider. 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) -} diff --git a/internal/provider/resource_kubernetes_cloud_test.go b/internal/provider/resource_kubernetes_cloud_test.go deleted file mode 100644 index 4f504f66..00000000 --- a/internal/provider/resource_kubernetes_cloud_test.go +++ /dev/null @@ -1 +0,0 @@ -package provider