Skip to content

Commit

Permalink
Added flags for keepLastAttempt, maxProvidersRetry
Browse files Browse the repository at this point in the history
  • Loading branch information
maricaantonacci committed Oct 16, 2018
1 parent 1e8962d commit 8ab8f99
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions orchent.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"strings"
)

const OrchentVersion string = "1.2.0"
const OrchentVersion string = "1.2.1"

var (
app = kingpin.New("orchent", "The orchestrator client. \n \nPlease either store your access token in 'ORCHENT_TOKEN' or set the account to use with oidc-agent in the 'ORCHENT_AGENT_ACCOUNT' and the socket of the oidc-agent in the 'OIDC_SOCK' environment variable: \n export ORCHENT_TOKEN=<your access token> \n OR \n export OIDC_SOCK=<path to the oidc-agent socket> (usually this is already exported) \n export ORCHENT_AGENT_ACCOUNT=<account to use> \nIf you need to specify the file containing the trusted root CAs use the 'ORCHENT_CAFILE' environment variable: \n export ORCHENT_CAFILE=<path to file containing trusted CAs>\n \n").Version(OrchentVersion)
Expand All @@ -32,16 +32,20 @@ var (
showDep = app.Command("depshow", "show a specific deployment")
showDepUuid = showDep.Arg("uuid", "the uuid of the deployment to display").Required().String()

createDep = app.Command("depcreate", "create a new deployment")
createDepCallback = createDep.Flag("callback", "the callback url").Default("").String()
createDepTemplate = createDep.Arg("template", "the tosca template file").Required().File()
createDepParameter = createDep.Arg("parameter", "the parameter to set (json object)").Required().String()

updateDep = app.Command("depupdate", "update the given deployment")
updateDepCallback = updateDep.Flag("callback", "the callback url").Default("").String()
updateDepUuid = updateDep.Arg("uuid", "the uuid of the deployment to update").Required().String()
updateDepTemplate = updateDep.Arg("template", "the tosca template file").Required().File()
updateDepParameter = updateDep.Arg("parameter", "the parameter to set (json object)").Required().String()
createDep = app.Command("depcreate", "create a new deployment")
createDepCallback = createDep.Flag("callback", "the callback url").Default("").String()
createDepMaxProvidersRetry = createDep.Flag("maxProvidersRetry", "Maximum number of cloud providers to be used in case of failure (Default: UNBOUNDED).").Uint8()
createDepKeepLastAttempt = createDep.Flag("keepLastAttempt", "In case of failure, keep the resources allocated in the last try (Default: true).").Default("true").Enum("true", "false")
createDepTemplate = createDep.Arg("template", "the tosca template file").Required().File()
createDepParameter = createDep.Arg("parameter", "the parameter to set (json object)").Required().String()

updateDep = app.Command("depupdate", "update the given deployment")
updateDepCallback = updateDep.Flag("callback", "the callback url").Default("").String()
updateDepMaxProvidersRetry = updateDep.Flag("maxProvidersRetry", "Maximum number of cloud providers to be used in case of failure (Default: UNBOUNDED).").Uint8()
updateDepKeepLastAttempt = updateDep.Flag("keepLastAttempt", "In case of failure, keep the resources allocated in the last try (Default: true).").Default("true").Enum("true", "false")
updateDepUuid = updateDep.Arg("uuid", "the uuid of the deployment to update").Required().String()
updateDepTemplate = updateDep.Arg("template", "the tosca template file").Required().File()
updateDepParameter = updateDep.Arg("parameter", "the parameter to set (json object)").Required().String()

depTemplate = app.Command("deptemplate", "show the template of the given deployment")
templateDepUuid = depTemplate.Arg("uuid", "the uuid of the deployment to get the template").Required().String()
Expand Down Expand Up @@ -177,9 +181,11 @@ type OrchentResourceList struct {
}

type OrchentCreateRequest struct {
Template string `json:"template"`
Parameters map[string]interface{} `json:"parameters"`
Callback string `json:"callback,omitempty"`
Template string `json:"template"`
Parameters map[string]interface{} `json:"parameters"`
Callback string `json:"callback,omitempty"`
MaxProvidersRetry uint8 `json:"maxProvidersRetry,omitempty"`
KeepLastAttempt string `json:"keepLastAttempt,omitempty"`
}

func (depList OrchentDeploymentList) String() string {
Expand Down Expand Up @@ -371,7 +377,8 @@ func receive_and_print_deploymentlist(complete *sling.Sling, before int, after i
}
}

func deployment_create_update(templateFile *os.File, parameter string, callback string, depUuid *string, base *sling.Sling) {
func deployment_create_update(templateFile *os.File, parameter string, callback string, maxProvidersRetry uint8, keepLastAttempt string, depUuid *string, base *sling.Sling) {

var parameterMap map[string]interface{}
paramErr := json.Unmarshal([]byte(parameter), &parameterMap)
if paramErr != nil {
Expand All @@ -396,6 +403,8 @@ func deployment_create_update(templateFile *os.File, parameter string, callback
Template: template,
Parameters: parameterMap,
Callback: callback,
MaxProvidersRetry: maxProvidersRetry,
KeepLastAttempt: keepLastAttempt,
}
deployment := new(OrchentDeployment)
orchentError := new(OrchentError)
Expand Down Expand Up @@ -700,13 +709,13 @@ func main() {
case createDep.FullCommand():
baseUrl := get_base_url()
base := base_connection(baseUrl)
deployment_create_update(*createDepTemplate, *createDepParameter, *createDepCallback, nil, base)
deployment_create_update(*createDepTemplate, *createDepParameter, *createDepCallback, *createDepMaxProvidersRetry, *createDepKeepLastAttempt, nil, base)

case updateDep.FullCommand():
baseUrl := get_base_url()
base := base_connection(baseUrl)
uuid := try_alias_uuid(*updateDepUuid, aliases)
deployment_create_update(*updateDepTemplate, *updateDepParameter, *updateDepCallback, &uuid, base)
deployment_create_update(*updateDepTemplate, *updateDepParameter, *updateDepCallback, *updateDepMaxProvidersRetry, *updateDepKeepLastAttempt, &uuid, base)

case depTemplate.FullCommand():
baseUrl := get_base_url()
Expand Down

0 comments on commit 8ab8f99

Please sign in to comment.