Allow to customize inventory policy for applier
Change-Id: I6943cddee52bcb605ce63adc21ce56f6afaadc5b Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
This commit is contained in:
parent
c2d08a4b83
commit
0401bd644c
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,13 +20,14 @@ import (
|
||||
|
||||
// ApplyConfig provides instructions on how to apply resources to kubernetes cluster
|
||||
type ApplyConfig struct {
|
||||
WaitOptions ApplyWaitOptions `json:"waitOptions,omitempty"`
|
||||
PruneOptions ApplyPruneOptions `json:"pruneOptions,omitempty"`
|
||||
Kubeconfig string `json:"kubeconfig,omitempty"`
|
||||
Context string `json:"context,omitempty"`
|
||||
DryRun bool `json:"druRun,omitempty"`
|
||||
Debug bool `json:"debug,omitempty"`
|
||||
PhaseName string `json:"phaseName,omitempty"`
|
||||
WaitOptions ApplyWaitOptions `json:"waitOptions,omitempty"`
|
||||
PruneOptions ApplyPruneOptions `json:"pruneOptions,omitempty"`
|
||||
Kubeconfig string `json:"kubeconfig,omitempty"`
|
||||
Context string `json:"context,omitempty"`
|
||||
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
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user