Skip to content

Commit

Permalink
patch action on apps
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimutant committed Dec 4, 2024
1 parent 01847c4 commit 0185d42
Show file tree
Hide file tree
Showing 4 changed files with 395 additions and 0 deletions.
15 changes: 15 additions & 0 deletions client/calm/calm_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Service interface {
AppRunlogs(ctx context.Context, appUUID, runlogUUID string) (*AppRunlogsResponse, error)
ListBlueprint(ctx context.Context, filter *BlueprintListInput) (*BlueprintListResponse, error)
GetRuntimeEditables(ctx context.Context, bpUUID string) (*RuntimeEditablesResponse, error)
PatchApp(ctx context.Context, appUUID string, patchUUID string, input *PatchInput) (*AppPatchResponse, error)
}

func (op Operations) ProvisionBlueprint(ctx context.Context, bpUUID string, input *BlueprintProvisionInput) (*AppProvisionTaskOutput, error) {
Expand Down Expand Up @@ -139,3 +140,17 @@ func (op Operations) GetRuntimeEditables(ctx context.Context, bpUUID string) (*R

return appResponse, op.client.Do(ctx, req, appResponse)
}

func (op Operations) PatchApp(ctx context.Context, appUUID string, patchUUID string, input *PatchInput) (*AppPatchResponse, error) {
path := fmt.Sprintf("/apps/%s/patch/%s/run", appUUID, patchUUID)

req, err := op.client.NewRequest(ctx, http.MethodPost, path, input)

appResponse := new(AppPatchResponse)

if err != nil {
return nil, err
}

return appResponse, op.client.Do(ctx, req, appResponse)
}
33 changes: 33 additions & 0 deletions client/calm/calm_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,36 @@ type RuntimeSpec struct {
Type *string `json:"type,omitempty"`
UUID *string `json:"uuid,omitempty"`
}
type PatchInput struct {
Spec PatchSpec `json:"spec"`
APIVersion string `json:"api_version"`
Metadata map[string]interface{} `json:"metadata"`
}

type PatchSpec struct {
Args ArgsSpec `json:"args"`
TargetUUID string `json:"target_uuid"`
TargetKind string `json:"target_kind"`
}

type ArgsSpec struct {
Variables []*VariableList `json:"variables"`
Patch map[string]interface{} `json:"patch"`
}

type VariableList struct {
TaskUUID string `json:"task_uuid,omitempty"`
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
}

type AppPatchResponse struct {
Status ActionRunStatus `json:"status"`
Spec json.RawMessage `json:"spec"`
APIVersion string `json:"api_version"`
Metadata json.RawMessage `json:"metadata"`
}

type ActionRunStatus struct {
RunlogUUID string `json:"runlog_uuid"`
}
1 change: 1 addition & 0 deletions nutanix/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ func Provider() *schema.Provider {
"nutanix_ndb_cluster": resourceNutanixNDBCluster(),
"nutanix_karbon_worker_nodepool": resourceNutanixKarbonWorkerNodePool(),
"nutanix_calm_app_provision": resourceNutanixCalmAppProvision(),
"nutanix_calm_app_patch": resourceNutanixCalmAppPatch(),
},
ConfigureContextFunc: providerConfigure,
}
Expand Down
Loading

0 comments on commit 0185d42

Please sign in to comment.