MCPcopy Index your code
hub / github.com/cortexlabs/cortex / Delete

Function Delete

cli/cluster/delete.go:32–57  ·  view source on GitHub ↗
(operatorConfig OperatorConfig, apiName string, keepCache bool, force bool)

Source from the content-addressed store, hash-verified

30)
31
32func Delete(operatorConfig OperatorConfig, apiName string, keepCache bool, force bool) (schema.DeleteResponse, error) {
33 if !force {
34 readyReplicas := getReadyRealtimeAPIReplicasOrNil(operatorConfig, apiName)
35 if readyReplicas != nil && *readyReplicas > 2 {
36 prompt.YesOrExit(fmt.Sprintf("are you sure you want to delete %s (which has %d live replicas)?", apiName, *readyReplicas), "", "")
37 }
38 }
39
40 params := map[string]string{
41 "apiName": apiName,
42 "keepCache": s.Bool(keepCache),
43 }
44
45 httpRes, err := HTTPDelete(operatorConfig, "/delete/"+apiName, params)
46 if err != nil {
47 return schema.DeleteResponse{}, err
48 }
49
50 var deleteRes schema.DeleteResponse
51 err = json.Unmarshal(httpRes, &deleteRes)
52 if err != nil {
53 return schema.DeleteResponse{}, errors.Wrap(err, "/delete", string(httpRes))
54 }
55
56 return deleteRes, nil
57}
58
59func getReadyRealtimeAPIReplicasOrNil(operatorConfig OperatorConfig, apiName string) *int32 {
60 httpRes, err := HTTPGet(operatorConfig, "/get/"+apiName)

Callers 1

delete.goFile · 0.92

Calls 5

YesOrExitFunction · 0.92
UnmarshalFunction · 0.92
WrapFunction · 0.92
HTTPDeleteFunction · 0.85

Tested by

no test coverage detected