Skip to content

Commit

Permalink
Fix missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
ducvm29 committed Oct 22, 2024
1 parent a4e6393 commit 9dbbe54
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 21 deletions.
24 changes: 19 additions & 5 deletions commons/api_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ var ApiPath = struct {
DedicatedFKEUpgradeVersion func(vpcId string, clusterId string) string
DedicatedFKEManagement func(vpcId string, clusterId string) string

ManagedFKEList func(vpcId string, page int, pageSize int, infraType string) string
ManagedFKEGet func(vpcId string, platform string, clusterId string) string
ManagedFKEDelete func(vpcId string, platform string, clusterName string) string
ManagedFKECreate func(vpcId string, platform string) string
GetFKEOSVersion func(vpcId string, platform string) string
ManagedFKEList func(vpcId string, page int, pageSize int, infraType string) string
ManagedFKEGet func(vpcId string, platform string, clusterId string) string
ManagedFKEDelete func(vpcId string, platform string, clusterName string) string
ManagedFKECreate func(vpcId string, platform string) string
ManagedFKEHibernate func(vpcId, platform, clusterId string) string
ManagedFKEWakeup func(vpcId, platform, clusterId string) string
GetFKEOSVersion func(vpcId string, platform string) string
}{
SSH: "/v1/user/sshs",
Storage: func(vpcId string) string {
Expand Down Expand Up @@ -216,6 +218,18 @@ var ApiPath = struct {
vpcId, platform, clusterId,
)
},
ManagedFKEHibernate: func(vpcId, platform, clusterId string) string {
return fmt.Sprintf(
"/v1/xplat/fke/vpc/%s/m-fke/%s/hibernation-cluster/shoots/%s/hibernate",
vpcId, platform, clusterId,
)
},
ManagedFKEWakeup: func(vpcId, platform, clusterId string) string {
return fmt.Sprintf(
"/v1/xplat/fke/vpc/%s/m-fke/%s/hibernation-cluster/shoots/%s/wakeup",
vpcId, platform, clusterId,
)
},
GetFKEOSVersion: func(vpcId string, platform string) string {
return fmt.Sprintf("/v1/xplat/fke/vpc/%s/m-fke/%s/get_k8s_versions", vpcId, platform)
},
Expand Down
7 changes: 6 additions & 1 deletion fptcloud/dfke/resource_dfke_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,14 @@ func (r *resourceDedicatedKubernetesEngineState) Update(ctx context.Context, req
return
}

target := "stop"
if !state.IsRunning.ValueBool() {
target = "start"
}

management := dedicatedKubernetesEngineManagement{
ClusterId: state.Id.ValueString(),
MgmtAction: "stop",
MgmtAction: target,
DiskExtend: "0",
ExtendType: "",
Flavor: "",
Expand Down
40 changes: 25 additions & 15 deletions fptcloud/mfke/resource_mfke.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,21 +456,7 @@ func (r *resourceManagedKubernetesEngine) remapPools(item *managedKubernetesEngi
}

func (r *resourceManagedKubernetesEngine) checkForError(a []byte) *diag2.ErrorDiagnostic {
var re map[string]interface{}
err := json.Unmarshal(a, &re)
if err != nil {
res := diag2.NewErrorDiagnostic("Error unmarshalling response", err.Error())
return &res
}

if e, ok := re["error"]; ok {
if e == true {
res := diag2.NewErrorDiagnostic("Response contained an error field", "Response body was "+string(a))
return &res
}
}

return nil
return checkForError(a)
}

func (r *resourceManagedKubernetesEngine) diff(ctx context.Context, from *managedKubernetesEngine, to *managedKubernetesEngine) *diag2.ErrorDiagnostic {
Expand Down Expand Up @@ -787,6 +773,24 @@ func parseNumber(s string) int {
return f
}

func checkForError(a []byte) *diag2.ErrorDiagnostic {
var re map[string]interface{}
err := json.Unmarshal(a, &re)
if err != nil {
res := diag2.NewErrorDiagnostic("Error unmarshalling response", err.Error())
return &res
}

if e, ok := re["error"]; ok {
if e == true {
res := diag2.NewErrorDiagnostic("Response contained an error field", "Response body was "+string(a))
return &res
}
}

return nil
}

type managedKubernetesEngine struct {
Id types.String `tfsdk:"id"`
VpcId types.String `tfsdk:"vpc_id"`
Expand Down Expand Up @@ -946,6 +950,12 @@ type managedKubernetesEngineDataSpec struct {
} `json:"infrastructureConfig"`
Workers []*managedKubernetesEngineDataWorker `json:"workers"`
} `json:"provider"`

Hibernation *managedKubernetesEngineDataSpecHibernate `json:"hibernation"`
}

type managedKubernetesEngineDataSpecHibernate struct {
Enabled *bool `json:"enabled"`
}

type managedKubernetesEngineDataWorker struct {
Expand Down

0 comments on commit 9dbbe54

Please sign in to comment.