Skip to content

Commit

Permalink
Remove TODOs & refactor MFKE
Browse files Browse the repository at this point in the history
  • Loading branch information
ducvm29 committed Oct 7, 2024
1 parent cd3d25c commit c316d65
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
1 change: 0 additions & 1 deletion fptcloud/database/resource_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
1 change: 0 additions & 1 deletion fptcloud/database/resource_database_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
1 change: 0 additions & 1 deletion fptcloud/dfke/resource_dfke_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 13 additions & 10 deletions fptcloud/mfke/resource_mfke.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ var (
}
)

const (
errorCallingApi = "Error calling API"
)

type resourceManagedKubernetesEngine struct {
client *commons.Client
mfkeClient *MfkeApiClient
Expand All @@ -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()

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
}
Expand All @@ -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
}

Expand All @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down

0 comments on commit c316d65

Please sign in to comment.