mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Replace calls to viper.GetUint32() with viper.GetInt32()
Viper doesn't have uint support until v1.4.0
This commit is contained in:
parent
3bb570b9ef
commit
d458e5d379
@ -31,8 +31,8 @@ var stackDeployCmd = &cobra.Command{
|
|||||||
common.CheckError(clientRetrievalErr)
|
common.CheckError(clientRetrievalErr)
|
||||||
|
|
||||||
stackName := args[0]
|
stackName := args[0]
|
||||||
endpointId := viper.GetUint32("stack.deploy.endpoint")
|
endpointId := viper.GetInt32("stack.deploy.endpoint")
|
||||||
endpointSwarmClusterId, selectionErr := common.GetEndpointSwarmClusterId(endpointId)
|
endpointSwarmClusterId, selectionErr := common.GetEndpointSwarmClusterId(uint32(endpointId))
|
||||||
switch selectionErr.(type) {
|
switch selectionErr.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
// It's a swarm cluster
|
// It's a swarm cluster
|
||||||
@ -48,7 +48,7 @@ var stackDeployCmd = &cobra.Command{
|
|||||||
"endpoint": endpointId,
|
"endpoint": endpointId,
|
||||||
"swarm": endpointSwarmClusterId,
|
"swarm": endpointSwarmClusterId,
|
||||||
}).Debug("Getting stack")
|
}).Debug("Getting stack")
|
||||||
retrievedStack, stackRetrievalErr := common.GetStackByName(stackName, endpointSwarmClusterId, endpointId)
|
retrievedStack, stackRetrievalErr := common.GetStackByName(stackName, endpointSwarmClusterId, uint32(endpointId))
|
||||||
switch stackRetrievalErr.(type) {
|
switch stackRetrievalErr.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
// We are updating an existing stack
|
// We are updating an existing stack
|
||||||
@ -94,7 +94,7 @@ var stackDeployCmd = &cobra.Command{
|
|||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"stack": retrievedStack.Name,
|
"stack": retrievedStack.Name,
|
||||||
}).Info("Updating stack")
|
}).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)
|
common.CheckError(err)
|
||||||
case *common.StackNotFoundError:
|
case *common.StackNotFoundError:
|
||||||
// We are deploying a new stack
|
// We are deploying a new stack
|
||||||
@ -117,7 +117,7 @@ var stackDeployCmd = &cobra.Command{
|
|||||||
"endpoint": endpointId,
|
"endpoint": endpointId,
|
||||||
"cluster": endpointSwarmClusterId,
|
"cluster": endpointSwarmClusterId,
|
||||||
}).Info("Creating stack")
|
}).Info("Creating stack")
|
||||||
deploymentErr := portainerClient.CreateSwarmStack(stackName, loadedEnvironmentVariables, stackFileContent, endpointSwarmClusterId, endpointId)
|
deploymentErr := portainerClient.CreateSwarmStack(stackName, loadedEnvironmentVariables, stackFileContent, endpointSwarmClusterId, uint32(endpointId))
|
||||||
common.CheckError(deploymentErr)
|
common.CheckError(deploymentErr)
|
||||||
} else {
|
} else {
|
||||||
// It's not a swarm cluster
|
// It's not a swarm cluster
|
||||||
@ -125,7 +125,7 @@ var stackDeployCmd = &cobra.Command{
|
|||||||
"stack": stackName,
|
"stack": stackName,
|
||||||
"endpoint": endpointId,
|
"endpoint": endpointId,
|
||||||
}).Info("Creating stack")
|
}).Info("Creating stack")
|
||||||
deploymentErr := portainerClient.CreateComposeStack(stackName, loadedEnvironmentVariables, stackFileContent, endpointId)
|
deploymentErr := portainerClient.CreateComposeStack(stackName, loadedEnvironmentVariables, stackFileContent, uint32(endpointId))
|
||||||
common.CheckError(deploymentErr)
|
common.CheckError(deploymentErr)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -24,12 +24,12 @@ var stackListCmd = &cobra.Command{
|
|||||||
portainerClient, err := common.GetClient()
|
portainerClient, err := common.GetClient()
|
||||||
common.CheckError(err)
|
common.CheckError(err)
|
||||||
|
|
||||||
endpointId := viper.GetUint32("stack.list.endpoint")
|
endpointId := viper.GetInt32("stack.list.endpoint")
|
||||||
var endpointSwarmClusterId string
|
var endpointSwarmClusterId string
|
||||||
var stacks []client.Stack
|
var stacks []client.Stack
|
||||||
if endpointId != 0 {
|
if endpointId != 0 {
|
||||||
var selectionErr error
|
var selectionErr error
|
||||||
endpointSwarmClusterId, selectionErr = common.GetEndpointSwarmClusterId(endpointId)
|
endpointSwarmClusterId, selectionErr = common.GetEndpointSwarmClusterId(uint32(endpointId))
|
||||||
switch selectionErr.(type) {
|
switch selectionErr.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
// It's a swarm cluster
|
// It's a swarm cluster
|
||||||
@ -37,14 +37,14 @@ var stackListCmd = &cobra.Command{
|
|||||||
"endpoint": endpointId,
|
"endpoint": endpointId,
|
||||||
"swarm": endpointSwarmClusterId,
|
"swarm": endpointSwarmClusterId,
|
||||||
}).Debug("Getting stacks")
|
}).Debug("Getting stacks")
|
||||||
stacks, err = portainerClient.GetStacks(endpointSwarmClusterId, endpointId)
|
stacks, err = portainerClient.GetStacks(endpointSwarmClusterId, uint32(endpointId))
|
||||||
common.CheckError(err)
|
common.CheckError(err)
|
||||||
case *common.StackClusterNotFoundError:
|
case *common.StackClusterNotFoundError:
|
||||||
// It's not a swarm cluster
|
// It's not a swarm cluster
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"endpoint": endpointId,
|
"endpoint": endpointId,
|
||||||
}).Debug("Getting stacks")
|
}).Debug("Getting stacks")
|
||||||
stacks, err = portainerClient.GetStacks("", endpointId)
|
stacks, err = portainerClient.GetStacks("", uint32(endpointId))
|
||||||
common.CheckError(err)
|
common.CheckError(err)
|
||||||
default:
|
default:
|
||||||
// Something else happened
|
// Something else happened
|
||||||
|
@ -17,7 +17,7 @@ var stackRemoveCmd = &cobra.Command{
|
|||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
stackName := args[0]
|
stackName := args[0]
|
||||||
endpointId := viper.GetUint32("stack.remove.endpoint")
|
endpointId := viper.GetInt32("stack.remove.endpoint")
|
||||||
var endpointSwarmClusterId string
|
var endpointSwarmClusterId string
|
||||||
var stack client.Stack
|
var stack client.Stack
|
||||||
if endpointId == 0 {
|
if endpointId == 0 {
|
||||||
@ -26,7 +26,7 @@ var stackRemoveCmd = &cobra.Command{
|
|||||||
}).Fatal("Provide required flag")
|
}).Fatal("Provide required flag")
|
||||||
} else {
|
} else {
|
||||||
var selectionErr, stackRetrievalErr error
|
var selectionErr, stackRetrievalErr error
|
||||||
endpointSwarmClusterId, selectionErr = common.GetEndpointSwarmClusterId(endpointId)
|
endpointSwarmClusterId, selectionErr = common.GetEndpointSwarmClusterId(uint32(endpointId))
|
||||||
switch selectionErr.(type) {
|
switch selectionErr.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
// It's a swarm cluster
|
// It's a swarm cluster
|
||||||
@ -35,7 +35,7 @@ var stackRemoveCmd = &cobra.Command{
|
|||||||
"endpoint": endpointId,
|
"endpoint": endpointId,
|
||||||
"swarm": endpointSwarmClusterId,
|
"swarm": endpointSwarmClusterId,
|
||||||
}).Debug("Getting stack")
|
}).Debug("Getting stack")
|
||||||
stack, stackRetrievalErr = common.GetStackByName(stackName, endpointSwarmClusterId, endpointId)
|
stack, stackRetrievalErr = common.GetStackByName(stackName, endpointSwarmClusterId, uint32(endpointId))
|
||||||
common.CheckError(stackRetrievalErr)
|
common.CheckError(stackRetrievalErr)
|
||||||
case *common.StackClusterNotFoundError:
|
case *common.StackClusterNotFoundError:
|
||||||
// It's not a swarm cluster
|
// It's not a swarm cluster
|
||||||
@ -43,7 +43,7 @@ var stackRemoveCmd = &cobra.Command{
|
|||||||
"stack": stackName,
|
"stack": stackName,
|
||||||
"endpoint": endpointId,
|
"endpoint": endpointId,
|
||||||
}).Debug("Getting stack")
|
}).Debug("Getting stack")
|
||||||
stack, stackRetrievalErr = common.GetStackByName(stackName, "", endpointId)
|
stack, stackRetrievalErr = common.GetStackByName(stackName, "", uint32(endpointId))
|
||||||
common.CheckError(stackRetrievalErr)
|
common.CheckError(stackRetrievalErr)
|
||||||
default:
|
default:
|
||||||
// Something else happened
|
// Something else happened
|
||||||
|
Loading…
Reference in New Issue
Block a user