Skip to content

Commit

Permalink
Merge pull request #637 from fsommar/status-policy-conversion
Browse files Browse the repository at this point in the history
Add conversion func for status-policy
  • Loading branch information
k8s-ci-robot authored May 4, 2024
2 parents 7928dbf + cbc090d commit 227a03f
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 227a03f

Please sign in to comment.