From c316d65efdbd272521e1c263d89b4da507617ddb Mon Sep 17 00:00:00 2001 From: ducvm29 Date: Mon, 7 Oct 2024 12:17:59 +0700 Subject: [PATCH] Remove TODOs & refactor MFKE --- fptcloud/database/resource_database.go | 1 - fptcloud/database/resource_database_status.go | 1 - fptcloud/dfke/resource_dfke_state.go | 1 - fptcloud/mfke/resource_mfke.go | 23 +++++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fptcloud/database/resource_database.go b/fptcloud/database/resource_database.go index eefa5b2..479d804 100644 --- a/fptcloud/database/resource_database.go +++ b/fptcloud/database/resource_database.go @@ -449,7 +449,6 @@ func (r *resourceDatabase) remap(from *databaseResourceModel, to *databaseJson) to.WorkerCount = int(from.WorkerCount.ValueInt64()) to.NodeCore = int(from.NodeCore.ValueInt64()) - // TODO: Lấy theo Flavor to.NodeCpu = int(from.NodeCpu.ValueInt64()) to.NodeRam = int(from.NodeRam.ValueInt64()) diff --git a/fptcloud/database/resource_database_status.go b/fptcloud/database/resource_database_status.go index 26c177b..cbc2195 100644 --- a/fptcloud/database/resource_database_status.go +++ b/fptcloud/database/resource_database_status.go @@ -117,7 +117,6 @@ func (r *resourceDatabaseStatus) Read(ctx context.Context, request resource.Read } func (r *resourceDatabaseStatus) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) { - //TODO implement me panic("implement me") } diff --git a/fptcloud/dfke/resource_dfke_state.go b/fptcloud/dfke/resource_dfke_state.go index fa7a7ff..f161db5 100644 --- a/fptcloud/dfke/resource_dfke_state.go +++ b/fptcloud/dfke/resource_dfke_state.go @@ -35,7 +35,6 @@ func (r *resourceDedicatedKubernetesEngineState) ImportState(ctx context.Context var state dedicatedKubernetesEngineState state.Id = types.StringValue(request.ID) - // TODO fix state.VpcId = types.StringValue("188af427-269b-418a-90bb-0cb27afc6c1e") err := r.internalRead(ctx, request.ID, &state) diff --git a/fptcloud/mfke/resource_mfke.go b/fptcloud/mfke/resource_mfke.go index 6c13b0b..ea8e0a5 100644 --- a/fptcloud/mfke/resource_mfke.go +++ b/fptcloud/mfke/resource_mfke.go @@ -40,6 +40,10 @@ var ( } ) +const ( + errorCallingApi = "Error calling API" +) + type resourceManagedKubernetesEngine struct { client *commons.Client mfkeClient *MfkeApiClient @@ -51,10 +55,10 @@ func NewResourceManagedKubernetesEngine() resource.Resource { return &resourceManagedKubernetesEngine{} } -func (r *resourceManagedKubernetesEngine) Metadata(ctx context.Context, request resource.MetadataRequest, response *resource.MetadataResponse) { +func (r *resourceManagedKubernetesEngine) Metadata(_ context.Context, request resource.MetadataRequest, response *resource.MetadataResponse) { response.TypeName = request.ProviderTypeName + "_managed_kubernetes_engine_v1" } -func (r *resourceManagedKubernetesEngine) Schema(ctx context.Context, request resource.SchemaRequest, response *resource.SchemaResponse) { +func (r *resourceManagedKubernetesEngine) Schema(_ context.Context, _ resource.SchemaRequest, response *resource.SchemaResponse) { topLevelAttributes := r.topFields() poolAttributes := r.poolFields() @@ -156,7 +160,7 @@ func (r *resourceManagedKubernetesEngine) Create(ctx context.Context, request re a, err := r.mfkeClient.sendPost(path, platform, f) if err != nil { - response.Diagnostics.Append(diag2.NewErrorDiagnostic("Error calling API", err.Error())) + response.Diagnostics.Append(diag2.NewErrorDiagnostic(errorCallingApi, err.Error())) return } @@ -199,7 +203,7 @@ func (r *resourceManagedKubernetesEngine) Read(ctx context.Context, request reso _, err := r.internalRead(ctx, state.Id.ValueString(), &state) if err != nil { - response.Diagnostics.Append(diag2.NewErrorDiagnostic("Error calling API", err.Error())) + response.Diagnostics.Append(diag2.NewErrorDiagnostic(errorCallingApi, err.Error())) return } @@ -259,7 +263,7 @@ func (r *resourceManagedKubernetesEngine) Delete(ctx context.Context, request re commons.ApiPath.ManagedFKEDelete(state.VpcId.ValueString(), "vmw", state.ClusterName.ValueString()), ) if err != nil { - response.Diagnostics.Append(diag2.NewErrorDiagnostic("Error calling API", err.Error())) + response.Diagnostics.Append(diag2.NewErrorDiagnostic(errorCallingApi, err.Error())) return } } @@ -284,7 +288,7 @@ func (r *resourceManagedKubernetesEngine) ImportState(ctx context.Context, reque _, err := r.internalRead(ctx, clusterId, &state) if err != nil { - response.Diagnostics.Append(diag2.NewErrorDiagnostic("Error calling API", err.Error())) + response.Diagnostics.Append(diag2.NewErrorDiagnostic(errorCallingApi, err.Error())) return } @@ -294,7 +298,7 @@ func (r *resourceManagedKubernetesEngine) ImportState(ctx context.Context, reque return } } -func (r *resourceManagedKubernetesEngine) Configure(ctx context.Context, request resource.ConfigureRequest, response *resource.ConfigureResponse) { +func (r *resourceManagedKubernetesEngine) Configure(_ context.Context, request resource.ConfigureRequest, response *resource.ConfigureResponse) { if request.ProviderData == nil { return } @@ -548,7 +552,6 @@ func (r *resourceManagedKubernetesEngine) diff(ctx context.Context, from *manage } } if from.NetworkNodePrefix != to.NetworkNodePrefix { - // TODO: patch it to retrieve data from API from.NetworkNodePrefix = to.NetworkNodePrefix } @@ -779,7 +782,7 @@ func (r *resourceManagedKubernetesEngine) getOsVersion(ctx context.Context, vers res, err := r.mfkeClient.sendGet(path, platform) if err != nil { - diag := diag2.NewErrorDiagnostic("Error calling API", err.Error()) + diag := diag2.NewErrorDiagnostic(errorCallingApi, err.Error()) return nil, &diag } @@ -790,7 +793,7 @@ func (r *resourceManagedKubernetesEngine) getOsVersion(ctx context.Context, vers var list managedKubernetesEngineOsVersionResponse if err = json.Unmarshal(res, &list); err != nil { - diag := diag2.NewErrorDiagnostic("Error calling API", err.Error()) + diag := diag2.NewErrorDiagnostic(errorCallingApi, err.Error()) return nil, &diag }