From fff8db04e6fc356c5d6a8c3bd6d4887b6e55ca7f Mon Sep 17 00:00:00 2001 From: Marica Antonacci Date: Wed, 28 Sep 2022 12:36:42 +0200 Subject: [PATCH] Devel (#59) * Implement #56 * Implement #58 * Update gopkg.in/yaml.v2 * Update version for new release * Update doc * Restore go.sum --- CHANGELOG.md | 5 ++++- README.md | 5 ++++- gitbook/user.md | 12 ++++++++++++ go.mod | 1 + go.sum | 25 ++----------------------- orchent.go | 38 ++++++++++++++++++++++++++++++++++++-- 6 files changed, 59 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84e5b12..0a6b3fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ## v1.2.9 - +### Added + +- command `depreset` to reset the status of a given deployment + ### Changed - command `depshow` and `depcreate` now support option `--ojson` that formats the command output in json diff --git a/README.md b/README.md index 9b61d7e..d1bbe1c 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,10 @@ Commands: depdel delete a given deployment - resls + depreset [] + reset the state of a given deployment + + resls list the resources of a given deployment resshow diff --git a/gitbook/user.md b/gitbook/user.md index 825b724..7194e8c 100644 --- a/gitbook/user.md +++ b/gitbook/user.md @@ -306,6 +306,18 @@ Example: $ orchent depdel 12345678-1234-1234-1234-123456789abc deletion of deployment 12345678-1234-1234-1234-123456789abc successfully triggered ``` +#### Reset The State Of A Given Deployment - depreset +The command `depreset` can be used to reset the deployment state given the deployment id. +Usage tips: If a deployment remains stuck in DELETE_IN_PROGRESS, you can use this command to manually reset the state of the deployment to DELETE_FAILED. You can then try to delete the deployment again. + +``` +$ orchent depreset [--status=DELETE_FAILED] +``` +Example: +``` +$ orchent depreset 11ed3ce7-ba36-5c2e-9808-02424e495bee +reset of deployment 11ed3ce7-ba36-5c2e-9808-02424e495bee successfully triggered +``` #### Get The Resources Of A Deployment - resls Listing all the resources of a deployment is very similar to listing all deployments, only that a deployment uuid must be passed: diff --git a/go.mod b/go.mod index 82fdb1e..5735656 100644 --- a/go.mod +++ b/go.mod @@ -24,4 +24,5 @@ require ( gopkg.in/alecthomas/kingpin.v2 v2.2.3 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.62.0 + gopkg.in/yaml.v2 v2.2.8 ) diff --git a/go.sum b/go.sum index b143004..3e78320 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,7 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U= github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI= -github.com/alecthomas/colour v0.1.0 h1:nOE9rJm6dsZ66RGWYSFrXw461ZIt9A6+nHgL7FRrDUk= github.com/alecthomas/colour v0.1.0/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= -github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142 h1:8Uy0oSf5co/NZXje7U1z8Mpep++QJOldL2hs/sBQf48= github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -12,10 +9,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZq github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/codegangsta/cli v1.19.2-0.20170706194625-4b90d79a682b h1:jdaVzhgBSmuyj7++RPxjNf/fgDT9+5VqfxpFzjXkv38= github.com/codegangsta/cli v1.19.2-0.20170706194625-4b90d79a682b/go.mod h1:/qJNoX69yVSKu5o4jLyXAENLRyk1uhi7zkbQ3slBdOA= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dghubble/sling v1.1.0 h1:DLu20Bq2qsB9cI5Hldaxj+TMPEaPpPE8IR2kvD22Atg= github.com/dghubble/sling v1.1.0/go.mod h1:ZcPRuLm0qrcULW2gOrjXrAWgf76sahqSyxXyVOvkunE= @@ -25,44 +20,30 @@ github.com/go-ini/ini v1.28.1 h1:31infb1d2q1XtBq7msGogTnG0vODN/5poMiHg+cpXQw= github.com/go-ini/ini v1.28.1/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/google/go-querystring v0.0.0-20160401233042-9235644dd9e5 h1:oERTZ1buOUYlpmKaqlO5fYmz8cZ1rYu5DieJzF4ZVmU= github.com/google/go-querystring v0.0.0-20160401233042-9235644dd9e5/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/indigo-dc/liboidcagent-go v0.0.0-20190403081110-5a786cab8df1 h1:eyi3Cgh6GTNrBp56ml40TVyNrGGGpIJu682lmjCRv4A= github.com/indigo-dc/liboidcagent-go v0.0.0-20190403081110-5a786cab8df1/go.mod h1:G3U0gH8up4cWD5qhUwYndL6ZTdjpiiJXhguC2BEWj28= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU= github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/zpatrick/go-config v0.0.0-20161118202931-710646a45582 h1:BRcrJZ7F4D3CO/LIoSJHqNl1QF9lNoRWKv94ootMiLA= github.com/zpatrick/go-config v0.0.0-20161118202931-710646a45582/go.mod h1:N7O1arBXMtrvgkF3kTwZdytK4gsAf13kfqv9Z6vk47Q= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -70,12 +51,10 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.3 h1:/L3oK40poPRwke0Ipa6qqf8n+awu60Vl3DMe+3j gopkg.in/alecthomas/kingpin.v2 v2.2.3/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/orchent.go b/orchent.go index df6adab..768edee 100644 --- a/orchent.go +++ b/orchent.go @@ -61,6 +61,10 @@ var ( delDep = app.Command("depdel", "delete a given deployment") delDepUuid = delDep.Arg("uuid", "the uuid of the deployment to delete").Required().String() + resetDep = app.Command("depreset", "reset the state of a given deployment") + resetDepUuid = resetDep.Arg("uuid", "the uuid of the deployment to reset").Required().String() + resetDepStatus = resetDep.Flag("status", "the state of the deployment to be set forcefully (allowed values: DELETE_FAILED)").Default("DELETE_FAILED").Enum("DELETE_FAILED") + logDep = app.Command("deplog", "get the log for given deployment") logDepUuid = logDep.Arg("uuid", "the uuid of the deployment").Required().String() @@ -217,7 +221,7 @@ func (depList OrchentDeploymentList) String() string { for _, link := range depList.Links { output = output + fmt.Sprintf(" %s\n", link) } - output = output + fmt.Sprintln("\n") + output = output + fmt.Sprintf("\n") for _, dep := range depList.Deployments { output = output + deployment_to_string(dep, 0) } @@ -522,7 +526,7 @@ func get_deployment_extra_info(uuid string) { } else { json.NewDecoder(resp.Body).Decode(orchentError) - fmt.Printf("error processing extra info of %s:\n %s\n", uuid, resp.StatusCode) + fmt.Printf("error processing extra info of %s:\n %d\n", uuid, resp.StatusCode) } } @@ -596,6 +600,30 @@ func deployment_delete(uuid string, base *sling.Sling) { } } +type StatusReset struct { + Status string `json:"status,omitempty"` +} + +func deployment_reset(uuid string, status string, base *sling.Sling) { + orchentError := new(OrchentError) + + body := &StatusReset { + Status: status, + } + base = base.BodyJSON(body).Patch("./deployments/" + uuid) + _, err := base.Receive(nil, orchentError) + if err != nil { + fmt.Printf("error resetting state for deployment %s:\n %s\n", uuid, err) + return + } + if is_error(orchentError) { + fmt.Printf("error resetting state for deployment %s:\n %s\n", uuid, orchentError) + } else { + fmt.Printf("reset of deployment %s successfully triggered\n", uuid) + } + +} + func deployment_log(uuid string, base *sling.Sling) { orchentError := new(OrchentError) req, err := base.Get("./deployments/" + uuid + "/log").Request() @@ -850,6 +878,12 @@ func main() { uuid := try_alias_uuid(*delDepUuid, aliases) deployment_delete(uuid, base) + case resetDep.FullCommand(): + baseUrl := get_base_url() + base := base_connection(baseUrl) + uuid := try_alias_uuid(*resetDepUuid, aliases) + deployment_reset(uuid, *resetDepStatus, base) + case logDep.FullCommand(): baseUrl := get_base_url() base := base_connection(baseUrl)