Skip to content

Commit

Permalink
[Fix] Modify cluster resources to changes in gopher
Browse files Browse the repository at this point in the history
  • Loading branch information
muneeb-jan committed Nov 28, 2024
1 parent 43185f9 commit ee5d074
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/jmespath/go-jmespath v0.4.0
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
github.com/mitchellh/go-homedir v1.1.0
github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241125090636-639d0490ef08
github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241128154844-619dec1def86
github.com/unknwon/com v1.0.1
golang.org/x/crypto v0.23.0
golang.org/x/sync v0.1.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241125090636-639d0490ef08 h1:wG3Uy3CD7vTtjJmqTl4zgqzwK5RzkgIrFcNBj4W3bRg=
github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241125090636-639d0490ef08/go.mod h1:M1F6OfSRZRzAmAFKQqSLClX952at5hx5rHe4UTEykgg=
github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241128134222-2cac4439faaf h1:mxOARqH8JRMkDMHuid4crDbPUE/Hz86h9w+CMhVePf4=
github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241128134222-2cac4439faaf/go.mod h1:M1F6OfSRZRzAmAFKQqSLClX952at5hx5rHe4UTEykgg=
github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241128154844-619dec1def86 h1:1gz0JdzJjgb03MkTpwZzVIbtJWkFpm5gxJkiS135lYU=
github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241128154844-619dec1def86/go.mod h1:M1F6OfSRZRzAmAFKQqSLClX952at5hx5rHe4UTEykgg=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
4 changes: 2 additions & 2 deletions opentelekomcloud/acceptance/cce/shared/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func deleteSharedCluster(t *testing.T) {
client, err := config.CceV3Client(env.OS_REGION_NAME)
th.AssertNoErr(t, err)

th.AssertNoErr(t, clusters.Delete(client, sharedClusterID).ExtractErr())
th.AssertNoErr(t, clusters.Delete(client, sharedClusterID, clusters.DeleteQueryParams{}))

stateConf := &resource.StateChangeConf{
Pending: []string{"Deleting", "Available", "Unavailable"},
Expand Down Expand Up @@ -137,7 +137,7 @@ func CreateSharedCluster(t *testing.T, client *golangsdk.ServiceClient, subnet *
SubnetId: subnet.ID,
},
},
}).Extract()
})
th.AssertNoErr(t, err)
sharedClusterID = job.Metadata.Id

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func dataSourceCCEClusterKubeConfigV3Read(_ context.Context, d *schema.ResourceD
Duration: duration,
}

kubeconfig, err := clusters.GetCertWithExpiration(client, clusterID, expiryOpts).ExtractMap()
kubeconfig, err := clusters.GetCertWithExpiration(client, clusterID, expiryOpts)
if err != nil {
return fmterr.Errorf("unable to retrieve cluster kubeconfig: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func dataSourceCCEClusterV3Read(_ context.Context, d *schema.ResourceData, meta
return diag.FromErr(err)
}

cert, err := clusters.GetCert(cceClient, d.Id()).Extract()
cert, err := clusters.GetCert(cceClient, d.Id())
if err != nil {
return fmterr.Errorf("error retrieving opentelekomcloud CCE cluster cert: %s", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ func resourceCCEClusterV3Create(ctx context.Context, d *schema.ResourceData, met
createOpts.Spec.EniNetwork = &eniNetwork
}

create, err := clusters.Create(client, createOpts).Extract()
create, err := clusters.Create(client, createOpts)

if err != nil {
if isAuthRequired(err) {
Expand Down Expand Up @@ -498,7 +498,7 @@ func resourceCCEClusterV3Read(ctx context.Context, d *schema.ResourceData, meta
return fmterr.Errorf(cceClientError, err)
}

cluster, err := clusters.Get(client, d.Id()).Extract()
cluster, err := clusters.Get(client, d.Id())
if err != nil {
if _, ok := err.(golangsdk.ErrDefault404); ok {
d.SetId("")
Expand Down Expand Up @@ -546,7 +546,7 @@ func resourceCCEClusterV3Read(ctx context.Context, d *schema.ResourceData, meta
return fmterr.Errorf("error setting cce cluster fields: %w", err)
}

cert, err := clusters.GetCert(client, d.Id()).Extract()
cert, err := clusters.GetCert(client, d.Id())
if err != nil {
return fmterr.Errorf("error retrieving opentelekomcloud CCE cluster cert: %w", err)
}
Expand Down Expand Up @@ -652,7 +652,7 @@ func resourceCCEClusterV3Update(ctx context.Context, d *schema.ResourceData, met

if d.HasChange("description") {
updateOpts.Spec.Description = d.Get("description").(string)
_, err = clusters.Update(client, d.Id(), updateOpts).Extract()
_, err = clusters.Update(client, d.Id(), updateOpts)
if err != nil {
return fmterr.Errorf("error updating opentelekomcloud CCE: %w", err)
}
Expand All @@ -676,7 +676,7 @@ func resourceCCEClusterV3Update(ctx context.Context, d *schema.ResourceData, met
updateIpOpts := clusters.UpdateIpOpts{
Action: "unbind",
}
err = clusters.UpdateMasterIp(client, d.Id(), updateIpOpts).ExtractErr()
err = clusters.UpdateMasterIp(client, d.Id(), updateIpOpts)
if err != nil {
return fmterr.Errorf("error unbinding EIP to opentelekomcloud CCE: %w", err)
}
Expand All @@ -687,7 +687,7 @@ func resourceCCEClusterV3Update(ctx context.Context, d *schema.ResourceData, met
ElasticIp: newEipStr,
}
updateIpOpts.Spec.ID = fipId
err = clusters.UpdateMasterIp(client, d.Id(), updateIpOpts).ExtractErr()
err = clusters.UpdateMasterIp(client, d.Id(), updateIpOpts)
if err != nil {
return fmterr.Errorf("error binding EIP to opentelekomcloud CCE: %w", err)
}
Expand All @@ -707,7 +707,7 @@ func resourceCCEClusterV3Delete(ctx context.Context, d *schema.ResourceData, met
return fmterr.Errorf(cceClientError, err)
}

deleteOpts := clusters.DeleteOpts{}
deleteOpts := clusters.DeleteQueryParams{}
var deleteAll bool
if v, ok := d.GetOk("delete_all_storage"); ok && v.(string) != "false" {
deleteOpt := d.Get("delete_all_storage").(string)
Expand All @@ -733,7 +733,7 @@ func resourceCCEClusterV3Delete(ctx context.Context, d *schema.ResourceData, met
deleteOpts.DeleteSfs = d.Get("delete_sfs").(string)
}

err = clusters.DeleteWithOpts(client, d.Id(), deleteOpts)
err = clusters.Delete(client, d.Id(), deleteOpts)
if err != nil {
return fmterr.Errorf("error deleting opentelekomcloud CCE Cluster: %w", err)
}
Expand All @@ -758,7 +758,7 @@ func resourceCCEClusterV3Delete(ctx context.Context, d *schema.ResourceData, met

func WaitForCCEClusterActive(cceClient *golangsdk.ServiceClient, clusterId string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
n, err := clusters.Get(cceClient, clusterId).Extract()
n, err := clusters.Get(cceClient, clusterId)
if err != nil {
return nil, "", fmt.Errorf("error waiting for CCE cluster to become active: %w", err)
}
Expand All @@ -771,7 +771,7 @@ func WaitForCCEClusterDelete(client *golangsdk.ServiceClient, clusterId string)
return func() (interface{}, string, error) {
log.Printf("[DEBUG] Attempting to delete CCE cluster %s.\n", clusterId)

r, err := clusters.Get(client, clusterId).Extract()
r, err := clusters.Get(client, clusterId)

if err != nil {
if _, ok := err.(golangsdk.ErrDefault404); ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ func waitForCceNodeDelete(cceClient *golangsdk.ServiceClient, clusterId, nodeId
func waitForClusterAvailable(cceClient *golangsdk.ServiceClient, clusterId string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
log.Printf("[INFO] Waiting for OpenTelekomCloud Cluster to be available %s.\n", clusterId)
n, err := clusters.Get(cceClient, clusterId).Extract()
n, err := clusters.Get(cceClient, clusterId)

if err != nil {
return nil, "", err
Expand Down

0 comments on commit ee5d074

Please sign in to comment.