mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Change GetTranslatedStackType to use StackType instead of Stack
This commit is contained in:
parent
c0cc50c81a
commit
f82f116e1b
@ -7,11 +7,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// GetTranslatedStackType returns a stack's Type field (int) translated to it's human readable form (string)
|
// GetTranslatedStackType returns a stack's Type field (int) translated to it's human readable form (string)
|
||||||
func GetTranslatedStackType(s portainer.Stack) string {
|
func GetTranslatedStackType(t portainer.StackType) string {
|
||||||
switch s.Type {
|
switch t {
|
||||||
case 1:
|
case portainer.DockerSwarmStack:
|
||||||
return "swarm"
|
return "swarm"
|
||||||
case 2:
|
case portainer.DockerComposeStack:
|
||||||
return "compose"
|
return "compose"
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
func TestGetTranslatedStackType(t *testing.T) {
|
func TestGetTranslatedStackType(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
s portainer.Stack
|
t portainer.StackType
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -19,34 +19,28 @@ func TestGetTranslatedStackType(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "swarm stack type",
|
name: "swarm stack type",
|
||||||
args: args{
|
args: args{
|
||||||
s: portainer.Stack{
|
t: portainer.DockerSwarmStack,
|
||||||
Type: 1,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
want: "swarm",
|
want: "swarm",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "compose stack type",
|
name: "compose stack type",
|
||||||
args: args{
|
args: args{
|
||||||
s: portainer.Stack{
|
t: portainer.DockerComposeStack,
|
||||||
Type: 2,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
want: "compose",
|
want: "compose",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "unknown stack type",
|
name: "unknown stack type",
|
||||||
args: args{
|
args: args{
|
||||||
s: portainer.Stack{
|
t: 100,
|
||||||
Type: 100,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
want: "",
|
want: "",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
assert.Equal(t, tt.want, GetTranslatedStackType(tt.args.s))
|
assert.Equal(t, tt.want, GetTranslatedStackType(tt.args.t))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ var stackInspectCmd = &cobra.Command{
|
|||||||
"%v\t%s\t%v\t%s",
|
"%v\t%s\t%v\t%s",
|
||||||
stack.ID,
|
stack.ID,
|
||||||
stack.Name,
|
stack.Name,
|
||||||
client.GetTranslatedStackType(stack),
|
client.GetTranslatedStackType(stack.Type),
|
||||||
endpoint.Name,
|
endpoint.Name,
|
||||||
))
|
))
|
||||||
common.CheckError(err)
|
common.CheckError(err)
|
||||||
|
@ -89,7 +89,7 @@ var stackListCmd = &cobra.Command{
|
|||||||
"%v\t%s\t%v\t%s",
|
"%v\t%s\t%v\t%s",
|
||||||
s.ID,
|
s.ID,
|
||||||
s.Name,
|
s.Name,
|
||||||
client.GetTranslatedStackType(s),
|
client.GetTranslatedStackType(s.Type),
|
||||||
stackEndpoint.Name,
|
stackEndpoint.Name,
|
||||||
))
|
))
|
||||||
common.CheckError(err)
|
common.CheckError(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user