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"
|
v1 "k8s.io/client-go/applyconfigurations/core/v1"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
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/cmd/printers"
|
||||||
"sigs.k8s.io/cli-utils/pkg/apply"
|
"sigs.k8s.io/cli-utils/pkg/apply"
|
||||||
"sigs.k8s.io/cli-utils/pkg/common"
|
"sigs.k8s.io/cli-utils/pkg/common"
|
||||||
@ -136,12 +137,18 @@ func (c *Config) toCliOptions() apply.Options {
|
|||||||
emitStatusEvents = true
|
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{
|
return apply.Options{
|
||||||
DryRunStrategy: dryRunStrategy,
|
DryRunStrategy: dryRunStrategy,
|
||||||
NoPrune: !c.PruneOptions.Prune,
|
NoPrune: !c.PruneOptions.Prune,
|
||||||
EmitStatusEvents: emitStatusEvents,
|
EmitStatusEvents: emitStatusEvents,
|
||||||
ReconcileTimeout: timeout,
|
ReconcileTimeout: timeout,
|
||||||
PollInterval: pollInterval,
|
PollInterval: pollInterval,
|
||||||
|
InventoryPolicy: inventoryPolicy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ type ApplyConfig struct {
|
|||||||
DryRun bool `json:"druRun,omitempty"`
|
DryRun bool `json:"druRun,omitempty"`
|
||||||
Debug bool `json:"debug,omitempty"`
|
Debug bool `json:"debug,omitempty"`
|
||||||
PhaseName string `json:"phaseName,omitempty"`
|
PhaseName string `json:"phaseName,omitempty"`
|
||||||
|
InventoryPolicy string `json:"inventoryPolicy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApplyWaitOptions provides instructions how to wait for kubernetes resources
|
// ApplyWaitOptions provides instructions how to wait for kubernetes resources
|
||||||
|
@ -37,6 +37,12 @@ spec:
|
|||||||
type: boolean
|
type: boolean
|
||||||
druRun:
|
druRun:
|
||||||
type: boolean
|
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:
|
kubeconfig:
|
||||||
type: string
|
type: string
|
||||||
phaseName:
|
phaseName:
|
||||||
|
@ -37,6 +37,11 @@ type ApplyConfig struct {
|
|||||||
DryRun bool `json:"druRun,omitempty"`
|
DryRun bool `json:"druRun,omitempty"`
|
||||||
Debug bool `json:"debug,omitempty"`
|
Debug bool `json:"debug,omitempty"`
|
||||||
PhaseName string `json:"phaseName,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
|
// ApplyWaitOptions provides instructions how to wait for kubernetes resources
|
||||||
|
Loading…
Reference in New Issue
Block a user