test
This commit is contained in:
40
src/kubectl/deployment.go
Normal file
40
src/kubectl/deployment.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package kubectl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"errors"
|
||||
"encoding/json"
|
||||
|
||||
log "oc-deploy/log_wrapper"
|
||||
)
|
||||
|
||||
func (this KubectlCommand) getDeployment(data KubectlObject) (map[string]any, error) {
|
||||
bin := this.Bin
|
||||
|
||||
msg := fmt.Sprintf("%s get deployment %s -o json", bin, data.Name)
|
||||
log.Log().Debug().Msg(msg)
|
||||
|
||||
m := make(map[string]any)
|
||||
|
||||
cmd_args := strings.Split(msg, " ")
|
||||
cmd := this.Exec(cmd_args[0], cmd_args[1:]...)
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return m, errors.New(string(stdout))
|
||||
}
|
||||
|
||||
var objmap getOutput
|
||||
|
||||
json.Unmarshal(stdout, &objmap)
|
||||
|
||||
kind := objmap.Kind
|
||||
status := objmap.Status
|
||||
|
||||
m["name"] = data.Name
|
||||
m["kind"] = kind
|
||||
m["replicas"] = status.Replicas
|
||||
m["UnavailableReplicas"] = status.UnavailableReplicas
|
||||
|
||||
return m, nil
|
||||
}
|
Reference in New Issue
Block a user