From cbc090daecc7c8af5df61bf7dcdde333d184766d Mon Sep 17 00:00:00 2001 From: Fredrik Sommar Date: Fri, 15 Mar 2024 13:50:12 +0100 Subject: [PATCH] Add conversion func for status-policy --- cmd/flagutils/utils.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmd/flagutils/utils.go b/cmd/flagutils/utils.go index 3d80cd9f..3fed8878 100644 --- a/cmd/flagutils/utils.go +++ b/cmd/flagutils/utils.go @@ -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 @@ -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 {