Skip to content

Commit 227a03f

Browse files
authored
Merge pull request #637 from fsommar/status-policy-conversion
Add conversion func for status-policy
2 parents 7928dbf + cbc090d commit 227a03f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

cmd/flagutils/utils.go

+16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const (
1515
InventoryPolicyStrict = "strict"
1616
InventoryPolicyAdopt = "adopt"
1717
InventoryPolicyForceAdopt = "force-adopt"
18+
StatusPolicyFlag = "status-policy"
19+
StatusPolicyAll = "all"
20+
StatusPolicyNone = "none"
1821
)
1922

2023
// ConvertPropagationPolicy converts a propagationPolicy described as a
@@ -47,6 +50,19 @@ func ConvertInventoryPolicy(policy string) (inventory.Policy, error) {
4750
}
4851
}
4952

53+
// ConvertStatusPolicy converts as status policy described as a string to a
54+
// StatusPolicy type that is passed into the Applier.
55+
func ConvertStatusPolicy(policy string) (inventory.StatusPolicy, error) {
56+
switch policy {
57+
case StatusPolicyNone:
58+
return inventory.StatusPolicyNone, nil
59+
case StatusPolicyAll:
60+
return inventory.StatusPolicyAll, nil
61+
default:
62+
return inventory.StatusPolicyAll, fmt.Errorf("status policy must be one of none, all")
63+
}
64+
}
65+
5066
// PathFromArgs returns the path which is a positional arg from args list
5167
// returns "-" if there is length of args is 0, which implies no path is provided
5268
func PathFromArgs(args []string) string {

0 commit comments

Comments
 (0)