Skip to content

Commit

Permalink
feat: add support parent cloud namd and region in the create func
Browse files Browse the repository at this point in the history
  • Loading branch information
anvial committed Oct 3, 2024
1 parent 988feb7 commit b96479c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion internal/juju/kubernetes_clouds.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,19 @@ func (c *kubernetesCloudsClient) UpdateKubernetesCloud(input UpdateKubernetesClo
k8sContextName = input.KubernetesContextName
}

var hostCloudRegion string
if input.ParentCloudName != "" || input.ParentCloudRegion != "" {
hostCloudRegion = input.ParentCloudName + "/" + input.ParentCloudRegion
} else {
hostCloudRegion = k8s.K8sCloudOther
}

newCloud, err := k8scloud.CloudFromKubeConfigContext(
k8sContextName,
&apiConf,
k8scloud.CloudParamaters{
Name: input.Name,
HostCloudRegion: k8s.K8sCloudOther,
HostCloudRegion: hostCloudRegion,
},
)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_kubernetes_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ func (r *kubernetesCloudResource) Schema(_ context.Context, req resource.SchemaR
stringplanmodifier.RequiresReplace(),
},
},
"kubernetesconfig": schema.StringAttribute{
"kubernetes_config": schema.StringAttribute{
Description: "The kubernetes config file path for the cloud.",
Optional: true,
Sensitive: true,
},
"parentcloudname": schema.StringAttribute{
"parent_cloud_name": schema.StringAttribute{
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{
"parent_cloud_region": schema.StringAttribute{
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{
Expand Down

0 comments on commit b96479c

Please sign in to comment.