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)
|
||||
func GetTranslatedStackType(s portainer.Stack) string {
|
||||
switch s.Type {
|
||||
case 1:
|
||||
func GetTranslatedStackType(t portainer.StackType) string {
|
||||
switch t {
|
||||
case portainer.DockerSwarmStack:
|
||||
return "swarm"
|
||||
case 2:
|
||||
case portainer.DockerComposeStack:
|
||||
return "compose"
|
||||
default:
|
||||
return ""
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
func TestGetTranslatedStackType(t *testing.T) {
|
||||
type args struct {
|
||||
s portainer.Stack
|
||||
t portainer.StackType
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -19,34 +19,28 @@ func TestGetTranslatedStackType(t *testing.T) {
|
||||
{
|
||||
name: "swarm stack type",
|
||||
args: args{
|
||||
s: portainer.Stack{
|
||||
Type: 1,
|
||||
},
|
||||
t: portainer.DockerSwarmStack,
|
||||
},
|
||||
want: "swarm",
|
||||
},
|
||||
{
|
||||
name: "compose stack type",
|
||||
args: args{
|
||||
s: portainer.Stack{
|
||||
Type: 2,
|
||||
},
|
||||
t: portainer.DockerComposeStack,
|
||||
},
|
||||
want: "compose",
|
||||
},
|
||||
{
|
||||
name: "unknown stack type",
|
||||
args: args{
|
||||
s: portainer.Stack{
|
||||
Type: 100,
|
||||
},
|
||||
t: 100,
|
||||
},
|
||||
want: "",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
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",
|
||||
stack.ID,
|
||||
stack.Name,
|
||||
client.GetTranslatedStackType(stack),
|
||||
client.GetTranslatedStackType(stack.Type),
|
||||
endpoint.Name,
|
||||
))
|
||||
common.CheckError(err)
|
||||
|
@ -89,7 +89,7 @@ var stackListCmd = &cobra.Command{
|
||||
"%v\t%s\t%v\t%s",
|
||||
s.ID,
|
||||
s.Name,
|
||||
client.GetTranslatedStackType(s),
|
||||
client.GetTranslatedStackType(s.Type),
|
||||
stackEndpoint.Name,
|
||||
))
|
||||
common.CheckError(err)
|
||||
|
Loading…
Reference in New Issue
Block a user