Browse Source

Merge "Allow to customize inventory policy for applier"

v2.1
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
0dc707359a
  1. 7
      krm-functions/applier/image/main.go
  2. 15
      krm-functions/applier/image/types/types.go
  3. 6
      manifests/function/airshipctl-schemas/airshipit.org_kubernetesapplies.yaml
  4. 5
      pkg/api/v1alpha1/kubernetes_apply_types.go

7
krm-functions/applier/image/main.go

@ -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,
}
}

15
krm-functions/applier/image/types/types.go

@ -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

6
manifests/function/airshipctl-schemas/airshipit.org_kubernetesapplies.yaml

@ -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:

5
pkg/api/v1alpha1/kubernetes_apply_types.go

@ -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…
Cancel
Save