Replace calls to viper.GetUint32() with viper.GetInt32()

Viper doesn't have uint support until v1.4.0
This commit is contained in:
Juan Carlos Mejías Rodríguez 2019-08-08 19:00:01 -04:00
parent 3bb570b9ef
commit d458e5d379
3 changed files with 14 additions and 14 deletions

View File

@ -31,8 +31,8 @@ var stackDeployCmd = &cobra.Command{
common.CheckError(clientRetrievalErr)
stackName := args[0]
endpointId := viper.GetUint32("stack.deploy.endpoint")
endpointSwarmClusterId, selectionErr := common.GetEndpointSwarmClusterId(endpointId)
endpointId := viper.GetInt32("stack.deploy.endpoint")
endpointSwarmClusterId, selectionErr := common.GetEndpointSwarmClusterId(uint32(endpointId))
switch selectionErr.(type) {
case nil:
// It's a swarm cluster
@ -48,7 +48,7 @@ var stackDeployCmd = &cobra.Command{
"endpoint": endpointId,
"swarm": endpointSwarmClusterId,
}).Debug("Getting stack")
retrievedStack, stackRetrievalErr := common.GetStackByName(stackName, endpointSwarmClusterId, endpointId)
retrievedStack, stackRetrievalErr := common.GetStackByName(stackName, endpointSwarmClusterId, uint32(endpointId))
switch stackRetrievalErr.(type) {
case nil:
// We are updating an existing stack
@ -94,7 +94,7 @@ var stackDeployCmd = &cobra.Command{
logrus.WithFields(logrus.Fields{
"stack": retrievedStack.Name,
}).Info("Updating stack")
err := portainerClient.UpdateStack(retrievedStack, newEnvironmentVariables, stackFileContent, viper.GetBool("stack.deploy.prune"), endpointId)
err := portainerClient.UpdateStack(retrievedStack, newEnvironmentVariables, stackFileContent, viper.GetBool("stack.deploy.prune"), uint32(endpointId))
common.CheckError(err)
case *common.StackNotFoundError:
// We are deploying a new stack
@ -117,7 +117,7 @@ var stackDeployCmd = &cobra.Command{
"endpoint": endpointId,
"cluster": endpointSwarmClusterId,
}).Info("Creating stack")
deploymentErr := portainerClient.CreateSwarmStack(stackName, loadedEnvironmentVariables, stackFileContent, endpointSwarmClusterId, endpointId)
deploymentErr := portainerClient.CreateSwarmStack(stackName, loadedEnvironmentVariables, stackFileContent, endpointSwarmClusterId, uint32(endpointId))
common.CheckError(deploymentErr)
} else {
// It's not a swarm cluster
@ -125,7 +125,7 @@ var stackDeployCmd = &cobra.Command{
"stack": stackName,
"endpoint": endpointId,
}).Info("Creating stack")
deploymentErr := portainerClient.CreateComposeStack(stackName, loadedEnvironmentVariables, stackFileContent, endpointId)
deploymentErr := portainerClient.CreateComposeStack(stackName, loadedEnvironmentVariables, stackFileContent, uint32(endpointId))
common.CheckError(deploymentErr)
}
default:

View File

@ -24,12 +24,12 @@ var stackListCmd = &cobra.Command{
portainerClient, err := common.GetClient()
common.CheckError(err)
endpointId := viper.GetUint32("stack.list.endpoint")
endpointId := viper.GetInt32("stack.list.endpoint")
var endpointSwarmClusterId string
var stacks []client.Stack
if endpointId != 0 {
var selectionErr error
endpointSwarmClusterId, selectionErr = common.GetEndpointSwarmClusterId(endpointId)
endpointSwarmClusterId, selectionErr = common.GetEndpointSwarmClusterId(uint32(endpointId))
switch selectionErr.(type) {
case nil:
// It's a swarm cluster
@ -37,14 +37,14 @@ var stackListCmd = &cobra.Command{
"endpoint": endpointId,
"swarm": endpointSwarmClusterId,
}).Debug("Getting stacks")
stacks, err = portainerClient.GetStacks(endpointSwarmClusterId, endpointId)
stacks, err = portainerClient.GetStacks(endpointSwarmClusterId, uint32(endpointId))
common.CheckError(err)
case *common.StackClusterNotFoundError:
// It's not a swarm cluster
logrus.WithFields(logrus.Fields{
"endpoint": endpointId,
}).Debug("Getting stacks")
stacks, err = portainerClient.GetStacks("", endpointId)
stacks, err = portainerClient.GetStacks("", uint32(endpointId))
common.CheckError(err)
default:
// Something else happened

View File

@ -17,7 +17,7 @@ var stackRemoveCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
stackName := args[0]
endpointId := viper.GetUint32("stack.remove.endpoint")
endpointId := viper.GetInt32("stack.remove.endpoint")
var endpointSwarmClusterId string
var stack client.Stack
if endpointId == 0 {
@ -26,7 +26,7 @@ var stackRemoveCmd = &cobra.Command{
}).Fatal("Provide required flag")
} else {
var selectionErr, stackRetrievalErr error
endpointSwarmClusterId, selectionErr = common.GetEndpointSwarmClusterId(endpointId)
endpointSwarmClusterId, selectionErr = common.GetEndpointSwarmClusterId(uint32(endpointId))
switch selectionErr.(type) {
case nil:
// It's a swarm cluster
@ -35,7 +35,7 @@ var stackRemoveCmd = &cobra.Command{
"endpoint": endpointId,
"swarm": endpointSwarmClusterId,
}).Debug("Getting stack")
stack, stackRetrievalErr = common.GetStackByName(stackName, endpointSwarmClusterId, endpointId)
stack, stackRetrievalErr = common.GetStackByName(stackName, endpointSwarmClusterId, uint32(endpointId))
common.CheckError(stackRetrievalErr)
case *common.StackClusterNotFoundError:
// It's not a swarm cluster
@ -43,7 +43,7 @@ var stackRemoveCmd = &cobra.Command{
"stack": stackName,
"endpoint": endpointId,
}).Debug("Getting stack")
stack, stackRetrievalErr = common.GetStackByName(stackName, "", endpointId)
stack, stackRetrievalErr = common.GetStackByName(stackName, "", uint32(endpointId))
common.CheckError(stackRetrievalErr)
default:
// Something else happened