mirror of https://github.com/fluxcd/cli-utils.git
Merge pull request #407 from haiyanmeng/adoptall
Add a new flag value `force-adopt` to the `--inventory-policy` flag
This commit is contained in:
commit
f72f0008ce
|
|
@ -58,7 +58,7 @@ func GetApplyRunner(factory cmdutil.Factory, invFactory inventory.InventoryClien
|
|||
"Timeout threshold for waiting for all pruned resources to be deleted")
|
||||
cmd.Flags().StringVar(&r.inventoryPolicy, flagutils.InventoryPolicyFlag, flagutils.InventoryPolicyStrict,
|
||||
"It determines the behavior when the resources don't belong to current inventory. Available options "+
|
||||
fmt.Sprintf("%q and %q.", flagutils.InventoryPolicyStrict, flagutils.InventoryPolicyAdopt))
|
||||
fmt.Sprintf("%q, %q and %q.", flagutils.InventoryPolicyStrict, flagutils.InventoryPolicyAdopt, flagutils.InventoryPolicyForceAdopt))
|
||||
|
||||
r.Command = cmd
|
||||
return r
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func GetDestroyRunner(factory cmdutil.Factory, invFactory inventory.InventoryCli
|
|||
fmt.Sprintf("Output format, must be one of %s", strings.Join(printers.SupportedPrinters(), ",")))
|
||||
cmd.Flags().StringVar(&r.inventoryPolicy, flagutils.InventoryPolicyFlag, flagutils.InventoryPolicyStrict,
|
||||
"It determines the behavior when the resources don't belong to current inventory. Available options "+
|
||||
fmt.Sprintf("%q and %q.", flagutils.InventoryPolicyStrict, flagutils.InventoryPolicyAdopt))
|
||||
fmt.Sprintf("%q, %q and %q.", flagutils.InventoryPolicyStrict, flagutils.InventoryPolicyAdopt, flagutils.InventoryPolicyForceAdopt))
|
||||
cmd.Flags().DurationVar(&r.deleteTimeout, "delete-timeout", time.Duration(0),
|
||||
"Timeout threshold for waiting for all deleted resources to complete deletion")
|
||||
cmd.Flags().StringVar(&r.deletePropagationPolicy, "delete-propagation-policy",
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
InventoryPolicyFlag = "inventory-policy"
|
||||
InventoryPolicyStrict = "strict"
|
||||
InventoryPolicyAdopt = "adopt"
|
||||
InventoryPolicyFlag = "inventory-policy"
|
||||
InventoryPolicyStrict = "strict"
|
||||
InventoryPolicyAdopt = "adopt"
|
||||
InventoryPolicyForceAdopt = "force-adopt"
|
||||
)
|
||||
|
||||
// ConvertPropagationPolicy converts a propagationPolicy described as a
|
||||
|
|
@ -38,6 +39,8 @@ func ConvertInventoryPolicy(policy string) (inventory.InventoryPolicy, error) {
|
|||
return inventory.InventoryPolicyMustMatch, nil
|
||||
case InventoryPolicyAdopt:
|
||||
return inventory.AdoptIfNoInventory, nil
|
||||
case InventoryPolicyForceAdopt:
|
||||
return inventory.AdoptAll, nil
|
||||
default:
|
||||
return inventory.InventoryPolicyMustMatch, fmt.Errorf(
|
||||
"inventory policy must be one of strict, adopt")
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ func TestConvertInventoryPolicy(t *testing.T) {
|
|||
value: "adopt",
|
||||
policy: inventory.AdoptIfNoInventory,
|
||||
},
|
||||
{
|
||||
value: "force-adopt",
|
||||
policy: inventory.AdoptAll,
|
||||
},
|
||||
{
|
||||
value: "random",
|
||||
err: fmt.Errorf("inventory policy must be one of strict, adopt"),
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ func GetPreviewRunner(factory cmdutil.Factory, invFactory inventory.InventoryCli
|
|||
fmt.Sprintf("Output format, must be one of %s", strings.Join(printers.SupportedPrinters(), ",")))
|
||||
cmd.Flags().StringVar(&r.inventoryPolicy, flagutils.InventoryPolicyFlag, flagutils.InventoryPolicyStrict,
|
||||
"It determines the behavior when the resources don't belong to current inventory. Available options "+
|
||||
fmt.Sprintf("%q and %q.", flagutils.InventoryPolicyStrict, flagutils.InventoryPolicyAdopt))
|
||||
fmt.Sprintf("%q, %q and %q.", flagutils.InventoryPolicyStrict, flagutils.InventoryPolicyAdopt, flagutils.InventoryPolicyForceAdopt))
|
||||
|
||||
r.Command = cmd
|
||||
return r
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright 2021 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Code generated by "stringer -type=ActionGroupEventType"; DO NOT EDIT.
|
||||
|
||||
package event
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright 2021 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Code generated by "stringer -type=ApplyEventOperation"; DO NOT EDIT.
|
||||
|
||||
package event
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright 2021 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Code generated by "stringer -type=DeleteEventOperation"; DO NOT EDIT.
|
||||
|
||||
package event
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright 2021 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Code generated by "stringer -type=PruneEventOperation"; DO NOT EDIT.
|
||||
|
||||
package event
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright 2021 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Code generated by "stringer -type=ResourceAction"; DO NOT EDIT.
|
||||
|
||||
package event
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright 2021 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Code generated by "stringer -type=Type"; DO NOT EDIT.
|
||||
|
||||
package event
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright 2021 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Code generated by "stringer -type=EventType"; DO NOT EDIT.
|
||||
|
||||
package event
|
||||
|
|
|
|||
Loading…
Reference in New Issue