Skip to content

Commit 191d64b

Browse files
authored
Merge pull request #43 from banzaicloud/pdb-diff
PDB selector diff fix
2 parents af0ea18 + d3b5173 commit 191d64b

File tree

10 files changed

+759
-91
lines changed

10 files changed

+759
-91
lines changed

.circleci/config.yml

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
integration-test-environment: &integration-test-environment
44
GO_VERSION: "1.15.2"
55
KUBECONFIG: /home/circleci/.kube/config
6-
MINIKUBE_VERSION: v1.13.1
6+
MINIKUBE_VERSION: v1.22.0
77
MINIKUBE_WANTUPDATENOTIFICATION: false
88
MINIKUBE_WANTREPORTERRORPROMPT: false
99
MINIKUBE_HOME: /home/circleci
@@ -38,7 +38,7 @@ integration-test-base: &integration-test-base
3838
- run:
3939
name: Setup kubectl
4040
command: |
41-
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
41+
curl -Lo kubectl "https://dl.k8s.io/release/${K8S_VERSION}/bin/linux/amd64/kubectl" && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
4242
mkdir -p ${HOME}/.kube
4343
touch ${HOME}/.kube/config
4444
@@ -145,80 +145,53 @@ jobs:
145145
name: Run verification
146146
command: make
147147

148-
integration-test-k8s1-19:
149-
<<: *integration-test-base
150-
environment:
151-
<<: *integration-test-environment
152-
K8S_VERSION: v1.19.2
153-
154-
integration-test-k8s1-18:
155-
<<: *integration-test-base
156-
environment:
157-
<<: *integration-test-environment
158-
K8S_VERSION: v1.18.9
159-
160-
integration-test-k8s1-17:
161-
<<: *integration-test-base
162-
environment:
163-
<<: *integration-test-environment
164-
K8S_VERSION: v1.17.12
165-
166-
integration-test-k8s1-16:
148+
integration-test-k8s1-21:
167149
<<: *integration-test-base
168150
environment:
169151
<<: *integration-test-environment
170-
K8S_VERSION: v1.16.15
152+
K8S_VERSION: v1.21.3
171153

172-
integration-test-k8s1-15:
154+
integration-test-k8s1-20:
173155
<<: *integration-test-base
174156
environment:
175157
<<: *integration-test-environment
176-
K8S_VERSION: v1.15.7
158+
K8S_VERSION: v1.20.9
177159

178-
integration-test-k8s1-14:
179-
<<: *integration-test-base
180-
environment:
181-
<<: *integration-test-environment
182-
K8S_VERSION: v1.14.2
183-
184-
integration-test-k8s1-13:
160+
integration-test-k8s1-19:
185161
<<: *integration-test-base
186162
environment:
187163
<<: *integration-test-environment
188-
K8S_VERSION: v1.13.6
164+
K8S_VERSION: v1.19.2
189165

190-
integration-test-k8s1-12:
166+
integration-test-k8s1-18:
191167
<<: *integration-test-base
192168
environment:
193169
<<: *integration-test-environment
194-
K8S_VERSION: v1.12.9
170+
K8S_VERSION: v1.18.9
195171

196-
integration-test-k8s1-11:
172+
integration-test-k8s1-17:
197173
<<: *integration-test-base
198174
environment:
199175
<<: *integration-test-environment
200-
K8S_VERSION: v1.11.9
176+
K8S_VERSION: v1.17.12
201177

202178
workflows:
203179
version: 2
204180
ci:
205181
jobs:
206182
- check
207-
- integration-test-k8s1-19:
183+
- integration-test-k8s1-21:
208184
requires:
209185
- check
210-
- integration-test-k8s1-18:
186+
- integration-test-k8s1-20:
211187
requires:
212188
- check
213-
- integration-test-k8s1-17:
214-
requires:
215-
- check
216-
- integration-test-k8s1-16:
189+
- integration-test-k8s1-19:
217190
requires:
218191
- check
219-
- integration-test-k8s1-15:
192+
- integration-test-k8s1-18:
220193
requires:
221194
- check
222-
- integration-test-k8s1-14:
195+
- integration-test-k8s1-17:
223196
requires:
224197
- check

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LICENSEI_VERSION = 0.3.1
1+
LICENSEI_VERSION = 0.4.0
22
GOLANGCI_VERSION = 1.16.0
33

44
all: license fmt vet test

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,39 @@ if !patchResult.IsEmpty() {
5858

5959
```
6060

61+
### CalculateOptions
62+
63+
In certain cases there is a need to filter out certain fields when the patch generated by the library is false positive.
64+
To help in these scenarios there are the following options to be used when calculating diffs:
65+
- `IgnoreStatusFields`
66+
- `IgnoreVolumeClaimTemplateTypeMetaAndStatus`
67+
- `IgnorePDBSelector`
68+
69+
Example:
70+
```
71+
opts := []patch.CalculateOption{
72+
patch.IgnoreStatusFields(),
73+
}
74+
75+
patchResult, err := patch.DefaultPatchMaker.Calculate(existing.(runtime.Object), newObject.(runtime.Object), opts...)
76+
if err != nil {
77+
return err
78+
}
79+
```
80+
81+
#### IgnoreStatusFields
82+
83+
This CalculateOptions removes status fields from both objects before comparing.
84+
85+
#### IgnoreVolumeClaimTemplateTypeMetaAndStatus
86+
87+
This CalculateOption clears volumeClaimTemplate fields from both objects before comparing (applies to statefulsets).
88+
89+
#### IgnorePdbSelector
90+
91+
Checks `selector` fields of PDB objects before comparing and removes them if they match. `reflect.DeepEquals` is used for the equality check.
92+
This is required because map fields using `patchStrategy:"replace"` will always diff regardless if they are otherwise equal.
93+
6194
## Contributing
6295

6396
If you find this project useful here's how you can help:

go.mod

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
module github.com/banzaicloud/k8s-objectmatcher
22

3-
go 1.13
3+
go 1.15
44

55
require (
66
emperror.dev/errors v0.8.0
7-
github.com/json-iterator/go v1.1.10
8-
k8s.io/api v0.19.2
7+
github.com/json-iterator/go v1.1.11
98
k8s.io/apimachinery v0.19.2
109
)

0 commit comments

Comments
 (0)