Skip to content

Commit

Permalink
add util func for isreq
Browse files Browse the repository at this point in the history
  • Loading branch information
taigrr committed Oct 3, 2023
1 parent 9422758 commit fc7757d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ingredients/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@ func (f File) PropertiesForMethod(method string) (map[string]string, error) {
"name": "string",
}, nil
case "symlink":
// return ingredients.MethodPropsSet{
// ingredients.MethodProps{Key: "name", Val: "string", IsReq: true},
// }.ToMap(), nil
return map[string]string{
"name": "string", "target": "string", "force": "bool", "backupname": "string",
"makedirs": "bool", "user": "string", "group": "string", "mode": "string",
Expand Down
21 changes: 21 additions & 0 deletions ingredients/ingredients.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@ func init() {
ingMap = make(map[types.Ingredient]map[string]types.RecipeCooker)
}

type MethodProps struct {
Key string
Val string
IsReq bool
}

type MethodPropsSet []MethodProps

func (m MethodPropsSet) ToMap() map[string]string {
ret := make(map[string]string)
for _, v := range m {
ret[v.Key] = v.Val
if v.IsReq {
ret[v.Key] = ret[v.Key] + ",req"
} else {
ret[v.Key] = ret[v.Key] + ",opt"
}
}
return ret
}

func RegisterAllMethods(step types.RecipeCooker) {
ingTex.Lock()
defer ingTex.Unlock()
Expand Down

0 comments on commit fc7757d

Please sign in to comment.