Skip to content

Commit

Permalink
Merge pull request #341 from gianlucam76/ignore-drift
Browse files Browse the repository at this point in the history
(feat) add patches to ResourceSummary
  • Loading branch information
gianlucam76 authored Jul 31, 2024
2 parents 8ddead6 + 474bebd commit 0659845
Show file tree
Hide file tree
Showing 10 changed files with 575 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # tag=v4.1.5
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # tag=v5.0.1
with:
go-version: 1.22.0
- name: Build
Expand All @@ -33,9 +33,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # tag=v4.1.5
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # tag=v5.0.1
with:
go-version: 1.22.0
- name: ut
Expand Down
58 changes: 58 additions & 0 deletions api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,61 @@ type ResourceSelector struct {
// +optional
Evaluate string `json:"evaluate,omitempty"`
}

type PatchSelector struct {

// Version of the API Group to select resources from.
// Together with Group and Kind it is capable of unambiguously identifying and/or selecting resources.
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
// +optional
Version string `json:"version,omitempty"`

// Group is the API group to select resources from.
// Together with Version and Kind it is capable of unambiguously identifying and/or selecting resources.
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
// +optional
Group string `json:"group,omitempty"`

// Kind of the API Group to select resources from.
// Together with Group and Version it is capable of unambiguously
// identifying and/or selecting resources.
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
// +optional
Kind string `json:"kind,omitempty"`

// Namespace to select resources from.
// +optional
Namespace string `json:"namespace,omitempty"`

// Name to match resources with.
// +optional
Name string `json:"name,omitempty"`

// AnnotationSelector is a string that follows the label selection expression
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
// It matches with the resource annotations.
// +optional
AnnotationSelector string `json:"annotationSelector,omitempty"`

// LabelSelector is a string that follows the label selection expression
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
// It matches with the resource labels.
// +optional
LabelSelector string `json:"labelSelector,omitempty"`
}

// Patch contains an inline StrategicMerge or JSON6902 patch, and the target the patch should
// be applied to.
type Patch struct {
// Patch contains an inline StrategicMerge patch or an inline JSON6902 patch with
// an array of operation objects.
// These values can be static or leverage Go templates for dynamic customization.
// When expressed as templates, the values are filled in using information from
// resources within the management cluster before deployment (Cluster and TemplateResourceRefs)
// +required
Patch string `json:"patch"`

// Target points to the resources that the patch document should be applied to.
// +optional
Target *PatchSelector `json:"target,omitempty"`
}
5 changes: 5 additions & 0 deletions api/v1alpha1/resourcesummary_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ type ResourceSummarySpec struct {
// Resources deployed by ClusterSummary because of referenced Helm charts
// +optional
ChartResources []HelmResources `json:"chartResources,omitempty"`

// Defines additional inline patches specifically designed to exclude certain fields from
// configuration drift evaluation.
// +optional
Patches []Patch `json:"patches,omitempty"`
}

// ResourceSummaryStatus defines the status of ResourceSummary
Expand Down
76 changes: 76 additions & 0 deletions api/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions api/v1beta1/resourcesummary_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ type ResourceSummarySpec struct {
// Resources deployed by ClusterSummary because of referenced Helm charts
// +optional
ChartResources []HelmResources `json:"chartResources,omitempty"`

// Defines additional inline patches specifically designed to exclude certain fields from
// configuration drift evaluation.
// +optional
Patches []Patch `json:"patches,omitempty"`
}

// ResourceSummaryStatus defines the status of ResourceSummary
Expand Down
7 changes: 7 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0659845

Please sign in to comment.