Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Rename detection for Kubernetes resources #409

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions assets/kubernetes/multi-docs-file-level/expected-dyff.human
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

metadata (v1/Service/foo)
+ one map entry added:
annotations:
foo: bar

(root level) (v1/Service/foo-2)
- one document removed:
---
apiVersion: v1
kind: Service
metadata:
name: foo-2
spec:
selector:
kubernetes.io/app: foo-2

(root level) (v1/Service/bar)
+ one document added:
---
apiVersion: v1
kind: Service
metadata:
name: bar
spec:
selector:
kubernetes.io/app: bar

(root level) (v1/Service/baz)
+ one document added:
---
apiVersion: v1
kind: Service
metadata:
name: baz
spec:
selector:
kubernetes.io/app: baz

16 changes: 16 additions & 0 deletions assets/kubernetes/multi-docs-file-level/from.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: foo
spec:
selector:
kubernetes.io/app: foo

---
apiVersion: v1
kind: Service
metadata:
name: foo-2
spec:
selector:
kubernetes.io/app: foo-2
27 changes: 27 additions & 0 deletions assets/kubernetes/multi-docs-file-level/to.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v1
kind: Service
metadata:
name: foo
annotations:
foo: bar
spec:
selector:
kubernetes.io/app: foo

---
apiVersion: v1
kind: Service
metadata:
name: bar
spec:
selector:
kubernetes.io/app: bar

---
apiVersion: v1
kind: Service
metadata:
name: baz
spec:
selector:
kubernetes.io/app: baz
34 changes: 34 additions & 0 deletions assets/kubernetes/rename/expected-dyff.human
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

data.pinniped.yaml
± value change in multiline text (one insert, no deletions)
discovery:
url: null
api:
servingCertificate:

[two lines unchanged)]

apiGroupSuffix: pinniped.dev
# aggregatedAPIServerPort may be set here, although other YAML references to the default port (10250) may also need to be updated
# impersonationProxyServerPort may be set here, although other YAML references to the default port (8444) may also need to be updated
names:
+ # Example comment
servingCertificateSecret: pinniped-concierge-api-tls-serving-certificate
credentialIssuer: pinniped-concierge-config
apiService: pinniped-concierge-api
impersonationLoadBalancerService: pinniped-concierge-impersonation-proxy-load-balancer

[five lines unchanged)]

labels: {"app": "pinniped-concierge"}
kubeCertAgent:
namePrefix: pinniped-concierge-kube-cert-agent-
image: projects.registry.vmware.com/pinniped/pinniped-server:latest



metadata.name
± value change
- pinniped-concierge-config-9bfbmfgt2f
+ pinniped-concierge-config-296567ccmt

29 changes: 29 additions & 0 deletions assets/kubernetes/rename/from.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: v1
data:
pinniped.yaml: |
discovery:
url: null
api:
servingCertificate:
durationSeconds: 2592000
renewBeforeSeconds: 2160000
apiGroupSuffix: pinniped.dev
# aggregatedAPIServerPort may be set here, although other YAML references to the default port (10250) may also need to be updated
# impersonationProxyServerPort may be set here, although other YAML references to the default port (8444) may also need to be updated
names:
servingCertificateSecret: pinniped-concierge-api-tls-serving-certificate
credentialIssuer: pinniped-concierge-config
apiService: pinniped-concierge-api
impersonationLoadBalancerService: pinniped-concierge-impersonation-proxy-load-balancer
impersonationClusterIPService: pinniped-concierge-impersonation-proxy-cluster-ip
impersonationTLSCertificateSecret: pinniped-concierge-impersonation-proxy-tls-serving-certificate
impersonationCACertificateSecret: pinniped-concierge-impersonation-proxy-ca-certificate
impersonationSignerSecret: pinniped-concierge-impersonation-proxy-signer-ca-certificate
agentServiceAccount: pinniped-concierge-kube-cert-agent
labels: {"app": "pinniped-concierge"}
kubeCertAgent:
namePrefix: pinniped-concierge-kube-cert-agent-
image: projects.registry.vmware.com/pinniped/pinniped-server:latest
kind: ConfigMap
metadata:
name: pinniped-concierge-config-9bfbmfgt2f
5 changes: 5 additions & 0 deletions assets/kubernetes/rename/from/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Source: pinniped-concierge/templates/configmap-pinniped-concierge-config.yaml
configMapGenerator:
- name: pinniped-concierge-config
files:
- pinniped.yaml
23 changes: 23 additions & 0 deletions assets/kubernetes/rename/from/pinniped.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
discovery:
url: null
api:
servingCertificate:
durationSeconds: 2592000
renewBeforeSeconds: 2160000
apiGroupSuffix: pinniped.dev
# aggregatedAPIServerPort may be set here, although other YAML references to the default port (10250) may also need to be updated
# impersonationProxyServerPort may be set here, although other YAML references to the default port (8444) may also need to be updated
names:
servingCertificateSecret: pinniped-concierge-api-tls-serving-certificate
credentialIssuer: pinniped-concierge-config
apiService: pinniped-concierge-api
impersonationLoadBalancerService: pinniped-concierge-impersonation-proxy-load-balancer
impersonationClusterIPService: pinniped-concierge-impersonation-proxy-cluster-ip
impersonationTLSCertificateSecret: pinniped-concierge-impersonation-proxy-tls-serving-certificate
impersonationCACertificateSecret: pinniped-concierge-impersonation-proxy-ca-certificate
impersonationSignerSecret: pinniped-concierge-impersonation-proxy-signer-ca-certificate
agentServiceAccount: pinniped-concierge-kube-cert-agent
labels: {"app": "pinniped-concierge"}
kubeCertAgent:
namePrefix: pinniped-concierge-kube-cert-agent-
image: projects.registry.vmware.com/pinniped/pinniped-server:latest
30 changes: 30 additions & 0 deletions assets/kubernetes/rename/to.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: v1
data:
pinniped.yaml: |
discovery:
url: null
api:
servingCertificate:
durationSeconds: 2592000
renewBeforeSeconds: 2160000
apiGroupSuffix: pinniped.dev
# aggregatedAPIServerPort may be set here, although other YAML references to the default port (10250) may also need to be updated
# impersonationProxyServerPort may be set here, although other YAML references to the default port (8444) may also need to be updated
names:
# Example comment
servingCertificateSecret: pinniped-concierge-api-tls-serving-certificate
credentialIssuer: pinniped-concierge-config
apiService: pinniped-concierge-api
impersonationLoadBalancerService: pinniped-concierge-impersonation-proxy-load-balancer
impersonationClusterIPService: pinniped-concierge-impersonation-proxy-cluster-ip
impersonationTLSCertificateSecret: pinniped-concierge-impersonation-proxy-tls-serving-certificate
impersonationCACertificateSecret: pinniped-concierge-impersonation-proxy-ca-certificate
impersonationSignerSecret: pinniped-concierge-impersonation-proxy-signer-ca-certificate
agentServiceAccount: pinniped-concierge-kube-cert-agent
labels: {"app": "pinniped-concierge"}
kubeCertAgent:
namePrefix: pinniped-concierge-kube-cert-agent-
image: projects.registry.vmware.com/pinniped/pinniped-server:latest
kind: ConfigMap
metadata:
name: pinniped-concierge-config-296567ccmt
5 changes: 5 additions & 0 deletions assets/kubernetes/rename/to/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Source: pinniped-concierge/templates/configmap-pinniped-concierge-config.yaml
configMapGenerator:
- name: pinniped-concierge-config
files:
- pinniped.yaml
24 changes: 24 additions & 0 deletions assets/kubernetes/rename/to/pinniped.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
discovery:
url: null
api:
servingCertificate:
durationSeconds: 2592000
renewBeforeSeconds: 2160000
apiGroupSuffix: pinniped.dev
# aggregatedAPIServerPort may be set here, although other YAML references to the default port (10250) may also need to be updated
# impersonationProxyServerPort may be set here, although other YAML references to the default port (8444) may also need to be updated
names:
# Example comment
servingCertificateSecret: pinniped-concierge-api-tls-serving-certificate
credentialIssuer: pinniped-concierge-config
apiService: pinniped-concierge-api
impersonationLoadBalancerService: pinniped-concierge-impersonation-proxy-load-balancer
impersonationClusterIPService: pinniped-concierge-impersonation-proxy-cluster-ip
impersonationTLSCertificateSecret: pinniped-concierge-impersonation-proxy-tls-serving-certificate
impersonationCACertificateSecret: pinniped-concierge-impersonation-proxy-ca-certificate
impersonationSignerSecret: pinniped-concierge-impersonation-proxy-signer-ca-certificate
agentServiceAccount: pinniped-concierge-kube-cert-agent
labels: {"app": "pinniped-concierge"}
kubeCertAgent:
namePrefix: pinniped-concierge-kube-cert-agent-
image: projects.registry.vmware.com/pinniped/pinniped-server:latest
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/homeport/dyff

go 1.20
go 1.22.0

toolchain go1.23.2

require (
github.com/davecgh/go-spew v1.1.1
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
Expand All @@ -26,6 +27,7 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k=
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
Expand All @@ -44,12 +46,15 @@ github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN
github.com/mitchellh/hashstructure v1.1.0 h1:P6P1hdjqAAknpY/M1CGipelZgp+4y9ja9kmUZPXP+H0=
github.com/mitchellh/hashstructure v1.1.0/go.mod h1:xUDAozZz0Wmdiufv0uyhnHkUTN6/6d8ulp4AwfLKrmA=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo=
github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI=
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand All @@ -62,6 +67,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/texttheater/golang-levenshtein v1.0.1 h1:+cRNoVrfiwufQPhoMzB6N0Yf/Mqajr6t1lOv8GyGE2U=
github.com/texttheater/golang-levenshtein v1.0.1/go.mod h1:PYAKrbF5sAiq9wd+H82hs7gNaen0CplQ9uvm6+enD/8=
github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74 h1:JwtAtbp7r/7QSyGz8mKUbYJBg2+6Cd7OjM8o/GNOcVo=
Expand All @@ -82,10 +88,12 @@ golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE=
golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
Expand Down
2 changes: 2 additions & 0 deletions internal/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ func applyReportOptionsFlags(cmd *cobra.Command) {
cmd.Flags().BoolVarP(&reportOptions.noTableStyle, "no-table-style", "l", defaults.noTableStyle, "do not place blocks next to each other, always use one row per text block")
cmd.Flags().BoolVarP(&reportOptions.doNotInspectCerts, "no-cert-inspection", "x", defaults.doNotInspectCerts, "disable x509 certificate inspection, compare as raw text")
cmd.Flags().BoolVarP(&reportOptions.useGoPatchPaths, "use-go-patch-style", "g", defaults.useGoPatchPaths, "use Go-Patch style paths in outputs")
cmd.Flags().Float64VarP(&reportOptions.minorChangeThreshold, "minor-change-threshold", "", defaults.minorChangeThreshold, "minor change threshold")
cmd.Flags().IntVarP(&reportOptions.multilineContextLines, "multi-line-context-lines", "", defaults.multilineContextLines, "multi-line context lines")

// Deprecated
cmd.Flags().BoolVar(&reportOptions.exitWithCode, "set-exit-status", defaults.exitWithCode, "set program exit code, with 0 meaning no difference, 1 for differences detected, and 255 for program error")
Expand Down
Loading