Skip to content

Commit

Permalink
chore: lots of small squashed twicks and fixes
Browse files Browse the repository at this point in the history
Update internal/provider/resource_kubernetes_cloud.go

chore: extend cloud name description

Co-authored-by: hmlanigan <[email protected]>

Update internal/provider/resource_kubernetes_cloud.go

chore: extend parent cloud name description

Co-authored-by: hmlanigan <[email protected]>

Update internal/provider/resource_kubernetes_cloud.go

chore: extend parent cloud region description

Co-authored-by: hmlanigan <[email protected]>

chore: added method comment headers

chore: added "id" to the schema to handle imports

chore: delete test file (until it's used)

chore: delete clouds_test unit it's used

chore: remane cloudsClient --> kubernetesCloudClient
  • Loading branch information
anvial committed Sep 27, 2024
1 parent e8ac402 commit c7d2617
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 65 deletions.
4 changes: 2 additions & 2 deletions internal/juju/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type ControllerConfiguration struct {
type Client struct {
Applications applicationsClient
Machines machinesClient
Clouds cloudsClient
Clouds kubernetesCloudsClient
Credentials credentialsClient
Integrations integrationsClient
Models modelsClient
Expand Down Expand Up @@ -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),
Expand Down
48 changes: 0 additions & 48 deletions internal/juju/clouds.go

This file was deleted.

4 changes: 0 additions & 4 deletions internal/juju/clouds_test.go

This file was deleted.

52 changes: 52 additions & 0 deletions internal/juju/kubernetes_clouds.go
Original file line number Diff line number Diff line change
@@ -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
}
30 changes: 20 additions & 10 deletions internal/provider/resource_kubernetes_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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(),
Expand All @@ -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)
}
1 change: 0 additions & 1 deletion internal/provider/resource_kubernetes_cloud_test.go

This file was deleted.

0 comments on commit c7d2617

Please sign in to comment.