Merge "Allow to customize inventory policy for applier"

This commit is contained in:
Zuul 2021-11-19 23:24:09 +00:00 committed by Gerrit Code Review
commit 0dc707359a
4 changed files with 26 additions and 7 deletions

View File

@ -27,6 +27,7 @@ import (
v1 "k8s.io/client-go/applyconfigurations/core/v1"
"k8s.io/klog/v2"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"sigs.k8s.io/cli-utils/cmd/flagutils"
"sigs.k8s.io/cli-utils/cmd/printers"
"sigs.k8s.io/cli-utils/pkg/apply"
"sigs.k8s.io/cli-utils/pkg/common"
@ -136,12 +137,18 @@ func (c *Config) toCliOptions() apply.Options {
emitStatusEvents = true
}
inventoryPolicy, err := flagutils.ConvertInventoryPolicy(c.InventoryPolicy)
if err != nil {
klog.V(2).Infof("%s or force-adopt, using the default one (strict)", err.Error())
}
return apply.Options{
DryRunStrategy: dryRunStrategy,
NoPrune: !c.PruneOptions.Prune,
EmitStatusEvents: emitStatusEvents,
ReconcileTimeout: timeout,
PollInterval: pollInterval,
InventoryPolicy: inventoryPolicy,
}
}

View File

@ -27,6 +27,7 @@ type ApplyConfig struct {
DryRun bool `json:"druRun,omitempty"`
Debug bool `json:"debug,omitempty"`
PhaseName string `json:"phaseName,omitempty"`
InventoryPolicy string `json:"inventoryPolicy,omitempty"`
}
// ApplyWaitOptions provides instructions how to wait for kubernetes resources

View File

@ -37,6 +37,12 @@ spec:
type: boolean
druRun:
type: boolean
inventoryPolicy:
description: 'InventoryPolicy defines if an inventory object can take
over objects that belong to another inventory object or don''t belong
to any inventory object. Possible values are: "strict", "adopt"
or "force-adopt"'
type: string
kubeconfig:
type: string
phaseName:

View File

@ -37,6 +37,11 @@ type ApplyConfig struct {
DryRun bool `json:"druRun,omitempty"`
Debug bool `json:"debug,omitempty"`
PhaseName string `json:"phaseName,omitempty"`
// InventoryPolicy defines if an inventory object can take over objects that belong to another
// inventory object or don't belong to any inventory object. Possible values are:
// "strict", "adopt" or "force-adopt"
InventoryPolicy string `json:"inventoryPolicy,omitempty"`
}
// ApplyWaitOptions provides instructions how to wait for kubernetes resources