Skip to content

Commit

Permalink
Add conversion func for status-policy
Browse files Browse the repository at this point in the history
  • Loading branch information
fsommar committed Mar 15, 2024
1 parent 7928dbf commit cbc090d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/flagutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const (
InventoryPolicyStrict = "strict"
InventoryPolicyAdopt = "adopt"
InventoryPolicyForceAdopt = "force-adopt"
StatusPolicyFlag = "status-policy"
StatusPolicyAll = "all"
StatusPolicyNone = "none"
)

// ConvertPropagationPolicy converts a propagationPolicy described as a
Expand Down Expand Up @@ -47,6 +50,19 @@ func ConvertInventoryPolicy(policy string) (inventory.Policy, error) {
}
}

// ConvertStatusPolicy converts as status policy described as a string to a
// StatusPolicy type that is passed into the Applier.
func ConvertStatusPolicy(policy string) (inventory.StatusPolicy, error) {
switch policy {
case StatusPolicyNone:
return inventory.StatusPolicyNone, nil
case StatusPolicyAll:
return inventory.StatusPolicyAll, nil
default:
return inventory.StatusPolicyAll, fmt.Errorf("status policy must be one of none, all")
}
}

// PathFromArgs returns the path which is a positional arg from args list
// returns "-" if there is length of args is 0, which implies no path is provided
func PathFromArgs(args []string) string {
Expand Down

0 comments on commit cbc090d

Please sign in to comment.