Skip to content

Commit 5fc9ce3

Browse files
committed
feat(label-cmd): add Label model
Add Label model for workflow-cli new command Label. Labels are general key value string to each app just for administration purpose. See workflow#597
1 parent 27bab7c commit 5fc9ce3

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

api/appsettings.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package api
22

33
import (
44
"bytes"
5+
"fmt"
56
"text/template"
67
)
78

@@ -24,6 +25,7 @@ type AppSettings struct {
2425
Routable *bool `json:"routable,omitempty"`
2526
Whitelist []string `json:"whitelist,omitempty"`
2627
Autoscale map[string]*Autoscale `json:"autoscale,omitempty"`
28+
Label Labels `json:"label,omitempty"`
2729
}
2830

2931
// NewRoutable returns a default value for the AppSettings.Routable field.
@@ -61,3 +63,17 @@ type Autoscale struct {
6163
Max int `json:"max"`
6264
CPUPercent int `json:"cpu_percent"`
6365
}
66+
67+
// Labels can contain any user-defined key value
68+
type Labels map[string]interface{}
69+
70+
func (l Labels) String() string {
71+
var buffer bytes.Buffer
72+
for k, v := range l {
73+
if buffer.Len() > 0 {
74+
buffer.WriteString("\n")
75+
}
76+
buffer.WriteString(fmt.Sprintf("%-16s %s", k+":", v))
77+
}
78+
return buffer.String()
79+
}

0 commit comments

Comments
 (0)