diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 99b80021af..cf9b0d5f27 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -1,4 +1,4 @@ -// +build !ignore_autogenerated +//go:build !ignore_autogenerated /* Copyright 2021. diff --git a/go.mod b/go.mod index aa00c35b34..af49777704 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/Masterminds/sprig/v3 v3.2.2 github.com/blang/semver v3.5.1+incompatible github.com/cenkalti/backoff v2.2.1+incompatible + github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/coreos/go-systemd/v22 v22.0.0 github.com/fsnotify/fsnotify v1.4.9 github.com/go-logr/logr v0.4.0 // indirect diff --git a/go.sum b/go.sum index 821f0ce86c..7e20e9f081 100644 --- a/go.sum +++ b/go.sum @@ -133,6 +133,8 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= diff --git a/hack/tools.go b/hack/tools.go index 7a21725cf1..d1427a6788 100644 --- a/hack/tools.go +++ b/hack/tools.go @@ -1,4 +1,4 @@ -// +build tools +//go:build tools // This package imports things required by build scripts, to force `go mod` to see them as dependencies package tools diff --git a/vendor/github.com/cespare/xxhash/v2/.travis.yml b/vendor/github.com/cespare/xxhash/v2/.travis.yml deleted file mode 100644 index c516ea88da..0000000000 --- a/vendor/github.com/cespare/xxhash/v2/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go -go: - - "1.x" - - master -env: - - TAGS="" - - TAGS="-tags purego" -script: go test $TAGS -v ./... diff --git a/vendor/github.com/cespare/xxhash/v2/README.md b/vendor/github.com/cespare/xxhash/v2/README.md index 2fd8693c21..792b4a60b3 100644 --- a/vendor/github.com/cespare/xxhash/v2/README.md +++ b/vendor/github.com/cespare/xxhash/v2/README.md @@ -1,7 +1,7 @@ # xxhash -[![GoDoc](https://godoc.org/github.com/cespare/xxhash?status.svg)](https://godoc.org/github.com/cespare/xxhash) -[![Build Status](https://travis-ci.org/cespare/xxhash.svg?branch=master)](https://travis-ci.org/cespare/xxhash) +[![Go Reference](https://pkg.go.dev/badge/github.com/cespare/xxhash/v2.svg)](https://pkg.go.dev/github.com/cespare/xxhash/v2) +[![Test](https://github.com/cespare/xxhash/actions/workflows/test.yml/badge.svg)](https://github.com/cespare/xxhash/actions/workflows/test.yml) xxhash is a Go implementation of the 64-bit [xxHash](http://cyan4973.github.io/xxHash/) algorithm, XXH64. This is a @@ -64,4 +64,6 @@ $ go test -benchtime 10s -bench '/xxhash,direct,bytes' - [InfluxDB](https://github.com/influxdata/influxdb) - [Prometheus](https://github.com/prometheus/prometheus) +- [VictoriaMetrics](https://github.com/VictoriaMetrics/VictoriaMetrics) - [FreeCache](https://github.com/coocood/freecache) +- [FastCache](https://github.com/VictoriaMetrics/fastcache) diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash.go b/vendor/github.com/cespare/xxhash/v2/xxhash.go index db0b35fbe3..15c835d541 100644 --- a/vendor/github.com/cespare/xxhash/v2/xxhash.go +++ b/vendor/github.com/cespare/xxhash/v2/xxhash.go @@ -193,7 +193,6 @@ func (d *Digest) UnmarshalBinary(b []byte) error { b, d.v4 = consumeUint64(b) b, d.total = consumeUint64(b) copy(d.mem[:], b) - b = b[len(d.mem):] d.n = int(d.total % uint64(len(d.mem))) return nil } diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s b/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s index d580e32aed..be8db5bf79 100644 --- a/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s +++ b/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s @@ -6,7 +6,7 @@ // Register allocation: // AX h -// CX pointer to advance through b +// SI pointer to advance through b // DX n // BX loop end // R8 v1, k1 @@ -16,39 +16,39 @@ // R12 tmp // R13 prime1v // R14 prime2v -// R15 prime4v +// DI prime4v -// round reads from and advances the buffer pointer in CX. +// round reads from and advances the buffer pointer in SI. // It assumes that R13 has prime1v and R14 has prime2v. #define round(r) \ - MOVQ (CX), R12 \ - ADDQ $8, CX \ + MOVQ (SI), R12 \ + ADDQ $8, SI \ IMULQ R14, R12 \ ADDQ R12, r \ ROLQ $31, r \ IMULQ R13, r // mergeRound applies a merge round on the two registers acc and val. -// It assumes that R13 has prime1v, R14 has prime2v, and R15 has prime4v. +// It assumes that R13 has prime1v, R14 has prime2v, and DI has prime4v. #define mergeRound(acc, val) \ IMULQ R14, val \ ROLQ $31, val \ IMULQ R13, val \ XORQ val, acc \ IMULQ R13, acc \ - ADDQ R15, acc + ADDQ DI, acc // func Sum64(b []byte) uint64 TEXT ·Sum64(SB), NOSPLIT, $0-32 // Load fixed primes. MOVQ ·prime1v(SB), R13 MOVQ ·prime2v(SB), R14 - MOVQ ·prime4v(SB), R15 + MOVQ ·prime4v(SB), DI // Load slice. - MOVQ b_base+0(FP), CX + MOVQ b_base+0(FP), SI MOVQ b_len+8(FP), DX - LEAQ (CX)(DX*1), BX + LEAQ (SI)(DX*1), BX // The first loop limit will be len(b)-32. SUBQ $32, BX @@ -65,14 +65,14 @@ TEXT ·Sum64(SB), NOSPLIT, $0-32 XORQ R11, R11 SUBQ R13, R11 - // Loop until CX > BX. + // Loop until SI > BX. blockLoop: round(R8) round(R9) round(R10) round(R11) - CMPQ CX, BX + CMPQ SI, BX JLE blockLoop MOVQ R8, AX @@ -100,16 +100,16 @@ noBlocks: afterBlocks: ADDQ DX, AX - // Right now BX has len(b)-32, and we want to loop until CX > len(b)-8. + // Right now BX has len(b)-32, and we want to loop until SI > len(b)-8. ADDQ $24, BX - CMPQ CX, BX + CMPQ SI, BX JG fourByte wordLoop: // Calculate k1. - MOVQ (CX), R8 - ADDQ $8, CX + MOVQ (SI), R8 + ADDQ $8, SI IMULQ R14, R8 ROLQ $31, R8 IMULQ R13, R8 @@ -117,18 +117,18 @@ wordLoop: XORQ R8, AX ROLQ $27, AX IMULQ R13, AX - ADDQ R15, AX + ADDQ DI, AX - CMPQ CX, BX + CMPQ SI, BX JLE wordLoop fourByte: ADDQ $4, BX - CMPQ CX, BX + CMPQ SI, BX JG singles - MOVL (CX), R8 - ADDQ $4, CX + MOVL (SI), R8 + ADDQ $4, SI IMULQ R13, R8 XORQ R8, AX @@ -138,19 +138,19 @@ fourByte: singles: ADDQ $4, BX - CMPQ CX, BX + CMPQ SI, BX JGE finalize singlesLoop: - MOVBQZX (CX), R12 - ADDQ $1, CX + MOVBQZX (SI), R12 + ADDQ $1, SI IMULQ ·prime5v(SB), R12 XORQ R12, AX ROLQ $11, AX IMULQ R13, AX - CMPQ CX, BX + CMPQ SI, BX JL singlesLoop finalize: @@ -179,9 +179,9 @@ TEXT ·writeBlocks(SB), NOSPLIT, $0-40 MOVQ ·prime2v(SB), R14 // Load slice. - MOVQ b_base+8(FP), CX + MOVQ b_base+8(FP), SI MOVQ b_len+16(FP), DX - LEAQ (CX)(DX*1), BX + LEAQ (SI)(DX*1), BX SUBQ $32, BX // Load vN from d. @@ -199,7 +199,7 @@ blockLoop: round(R10) round(R11) - CMPQ CX, BX + CMPQ SI, BX JLE blockLoop // Copy vN back to d. @@ -208,8 +208,8 @@ blockLoop: MOVQ R10, 16(AX) MOVQ R11, 24(AX) - // The number of bytes written is CX minus the old base pointer. - SUBQ b_base+8(FP), CX - MOVQ CX, ret+32(FP) + // The number of bytes written is SI minus the old base pointer. + SUBQ b_base+8(FP), SI + MOVQ SI, ret+32(FP) RET diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go b/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go index 53bf76efbc..376e0ca2e4 100644 --- a/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go +++ b/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go @@ -6,41 +6,52 @@ package xxhash import ( - "reflect" "unsafe" ) -// Notes: +// In the future it's possible that compiler optimizations will make these +// XxxString functions unnecessary by realizing that calls such as +// Sum64([]byte(s)) don't need to copy s. See https://golang.org/issue/2205. +// If that happens, even if we keep these functions they can be replaced with +// the trivial safe code. + +// NOTE: The usual way of doing an unsafe string-to-[]byte conversion is: // -// See https://groups.google.com/d/msg/golang-nuts/dcjzJy-bSpw/tcZYBzQqAQAJ -// for some discussion about these unsafe conversions. +// var b []byte +// bh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) +// bh.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data +// bh.Len = len(s) +// bh.Cap = len(s) // -// In the future it's possible that compiler optimizations will make these -// unsafe operations unnecessary: https://golang.org/issue/2205. +// Unfortunately, as of Go 1.15.3 the inliner's cost model assigns a high enough +// weight to this sequence of expressions that any function that uses it will +// not be inlined. Instead, the functions below use a different unsafe +// conversion designed to minimize the inliner weight and allow both to be +// inlined. There is also a test (TestInlining) which verifies that these are +// inlined. // -// Both of these wrapper functions still incur function call overhead since they -// will not be inlined. We could write Go/asm copies of Sum64 and Digest.Write -// for strings to squeeze out a bit more speed. Mid-stack inlining should -// eventually fix this. +// See https://github.com/golang/go/issues/42739 for discussion. // Sum64String computes the 64-bit xxHash digest of s. // It may be faster than Sum64([]byte(s)) by avoiding a copy. func Sum64String(s string) uint64 { - var b []byte - bh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) - bh.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data - bh.Len = len(s) - bh.Cap = len(s) + b := *(*[]byte)(unsafe.Pointer(&sliceHeader{s, len(s)})) return Sum64(b) } // WriteString adds more data to d. It always returns len(s), nil. // It may be faster than Write([]byte(s)) by avoiding a copy. func (d *Digest) WriteString(s string) (n int, err error) { - var b []byte - bh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) - bh.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data - bh.Len = len(s) - bh.Cap = len(s) - return d.Write(b) + d.Write(*(*[]byte)(unsafe.Pointer(&sliceHeader{s, len(s)}))) + // d.Write always returns len(s), nil. + // Ignoring the return output and returning these fixed values buys a + // savings of 6 in the inliner's cost model. + return len(s), nil +} + +// sliceHeader is similar to reflect.SliceHeader, but it assumes that the layout +// of the first two words is the same as the layout of a string. +type sliceHeader struct { + s string + cap int } diff --git a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/apiext.go b/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/apiext.go deleted file mode 100644 index 32e4043f62..0000000000 --- a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/apiext.go +++ /dev/null @@ -1,18 +0,0 @@ -package resourcemerge - -import ( - apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apimachinery/pkg/api/equality" -) - -// EnsureCustomResourceDefinition ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func EnsureCustomResourceDefinition(modified *bool, existing *apiextv1beta1.CustomResourceDefinition, required apiextv1beta1.CustomResourceDefinition) { - EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - - // we stomp everything - if !equality.Semantic.DeepEqual(existing.Spec, required.Spec) { - *modified = true - existing.Spec = required.Spec - } -} diff --git a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/apps.go b/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/apps.go deleted file mode 100644 index 16b2dd5ae8..0000000000 --- a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/apps.go +++ /dev/null @@ -1,40 +0,0 @@ -package resourcemerge - -import ( - appsv1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/api/equality" -) - -// EnsureDeployment ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func EnsureDeployment(modified *bool, existing *appsv1.Deployment, required appsv1.Deployment) { - EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - - if existing.Spec.Selector == nil { - *modified = true - existing.Spec.Selector = required.Spec.Selector - } - if !equality.Semantic.DeepEqual(existing.Spec.Selector, required.Spec.Selector) { - *modified = true - existing.Spec.Selector = required.Spec.Selector - } - - ensurePodTemplateSpec(modified, &existing.Spec.Template, required.Spec.Template) -} - -// EnsureDaemonSet ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func EnsureDaemonSet(modified *bool, existing *appsv1.DaemonSet, required appsv1.DaemonSet) { - EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - - if existing.Spec.Selector == nil { - *modified = true - existing.Spec.Selector = required.Spec.Selector - } - if !equality.Semantic.DeepEqual(existing.Spec.Selector, required.Spec.Selector) { - *modified = true - existing.Spec.Selector = required.Spec.Selector - } - - ensurePodTemplateSpec(modified, &existing.Spec.Template, required.Spec.Template) -} diff --git a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/core.go b/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/core.go deleted file mode 100644 index 713302a44e..0000000000 --- a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/core.go +++ /dev/null @@ -1,497 +0,0 @@ -package resourcemerge - -import ( - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/equality" -) - -// EnsureConfigMap ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func EnsureConfigMap(modified *bool, existing *corev1.ConfigMap, required corev1.ConfigMap) { - EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - - mergeMap(modified, &existing.Data, required.Data) -} - -// ensurePodTemplateSpec ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func ensurePodTemplateSpec(modified *bool, existing *corev1.PodTemplateSpec, required corev1.PodTemplateSpec) { - EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - - ensurePodSpec(modified, &existing.Spec, required.Spec) -} - -func ensurePodSpec(modified *bool, existing *corev1.PodSpec, required corev1.PodSpec) { - // any container we specify, we require. - for _, required := range required.InitContainers { - var existingCurr *corev1.Container - for j, curr := range existing.InitContainers { - if curr.Name == required.Name { - existingCurr = &existing.InitContainers[j] - break - } - } - if existingCurr == nil { - *modified = true - existing.Containers = append(existing.InitContainers, corev1.Container{}) - existingCurr = &existing.InitContainers[len(existing.InitContainers)-1] - } - ensureContainer(modified, existingCurr, required) - } - - for _, required := range required.Containers { - var existingCurr *corev1.Container - for j, curr := range existing.Containers { - if curr.Name == required.Name { - existingCurr = &existing.Containers[j] - break - } - } - if existingCurr == nil { - *modified = true - existing.Containers = append(existing.Containers, corev1.Container{}) - existingCurr = &existing.Containers[len(existing.Containers)-1] - } - ensureContainer(modified, existingCurr, required) - } - - // any volume we specify, we require. - for _, required := range required.Volumes { - var existingCurr *corev1.Volume - for j, curr := range existing.Volumes { - if curr.Name == required.Name { - existingCurr = &existing.Volumes[j] - break - } - } - if existingCurr == nil { - *modified = true - existing.Volumes = append(existing.Volumes, corev1.Volume{}) - existingCurr = &existing.Volumes[len(existing.Volumes)-1] - } - ensureVolume(modified, existingCurr, required) - } - - if len(required.RestartPolicy) > 0 { - if existing.RestartPolicy != required.RestartPolicy { - *modified = true - existing.RestartPolicy = required.RestartPolicy - } - } - - setStringIfSet(modified, &existing.ServiceAccountName, required.ServiceAccountName) - setBool(modified, &existing.HostNetwork, required.HostNetwork) - mergeMap(modified, &existing.NodeSelector, required.NodeSelector) - ensurePodSecurityContextPtr(modified, &existing.SecurityContext, required.SecurityContext) - ensureAffinityPtr(modified, &existing.Affinity, required.Affinity) - ensureTolerations(modified, &existing.Tolerations, required.Tolerations) - setStringIfSet(modified, &existing.PriorityClassName, required.PriorityClassName) - setInt32Ptr(modified, &existing.Priority, required.Priority) -} - -func ensureContainer(modified *bool, existing *corev1.Container, required corev1.Container) { - setStringIfSet(modified, &existing.Name, required.Name) - setStringIfSet(modified, &existing.Image, required.Image) - - // if you want modify the launch, you need to modify it in the config, not in the launch args - setStringSliceIfSet(modified, &existing.Command, required.Command) - setStringSliceIfSet(modified, &existing.Args, required.Args) - - setStringIfSet(modified, &existing.WorkingDir, required.WorkingDir) - - // also sync the env vars here, added to handle proxy - for _, required := range required.Env { - var existingCurr *corev1.EnvVar - for j, curr := range existing.Env { - if curr.Name == required.Name { - existingCurr = &existing.Env[j] - break - } - } - if existingCurr == nil { - *modified = true - existing.Env = append(existing.Env, corev1.EnvVar{}) - existingCurr = &existing.Env[len(existing.Env)-1] - } - ensureEnvVar(modified, existingCurr, required) - } - - // any port we specify, we require - for _, required := range required.Ports { - var existingCurr *corev1.ContainerPort - for j, curr := range existing.Ports { - if curr.Name == required.Name { - existingCurr = &existing.Ports[j] - break - } - } - if existingCurr == nil { - *modified = true - existing.Ports = append(existing.Ports, corev1.ContainerPort{}) - existingCurr = &existing.Ports[len(existing.Ports)-1] - } - ensureContainerPort(modified, existingCurr, required) - } - - // any volume mount we specify, we require - for _, required := range required.VolumeMounts { - var existingCurr *corev1.VolumeMount - for j, curr := range existing.VolumeMounts { - if curr.Name == required.Name { - existingCurr = &existing.VolumeMounts[j] - break - } - } - if existingCurr == nil { - *modified = true - existing.VolumeMounts = append(existing.VolumeMounts, corev1.VolumeMount{}) - existingCurr = &existing.VolumeMounts[len(existing.VolumeMounts)-1] - } - ensureVolumeMount(modified, existingCurr, required) - } - - if required.LivenessProbe != nil { - ensureProbePtr(modified, &existing.LivenessProbe, required.LivenessProbe) - } - if required.ReadinessProbe != nil { - ensureProbePtr(modified, &existing.ReadinessProbe, required.ReadinessProbe) - } - - // our security context should always win - ensureSecurityContextPtr(modified, &existing.SecurityContext, required.SecurityContext) -} - -func ensureProbePtr(modified *bool, existing **corev1.Probe, required *corev1.Probe) { - // if we have no required, then we don't care what someone else has set - if required == nil { - return - } - if *existing == nil { - *modified = true - *existing = required - return - } - ensureProbe(modified, *existing, *required) -} - -func ensureProbe(modified *bool, existing *corev1.Probe, required corev1.Probe) { - setInt32(modified, &existing.InitialDelaySeconds, required.InitialDelaySeconds) - - ensureProbeHandler(modified, &existing.Handler, required.Handler) -} - -func ensureProbeHandler(modified *bool, existing *corev1.Handler, required corev1.Handler) { - if !equality.Semantic.DeepEqual(required, *existing) { - *modified = true - *existing = required - } -} - -func ensureContainerPort(modified *bool, existing *corev1.ContainerPort, required corev1.ContainerPort) { - if !equality.Semantic.DeepEqual(required, *existing) { - *modified = true - *existing = required - } -} - -func ensureEnvVar(modified *bool, existing *corev1.EnvVar, required corev1.EnvVar) { - if !equality.Semantic.DeepEqual(required, *existing) { - *modified = true - *existing = required - } -} - -func ensureVolumeMount(modified *bool, existing *corev1.VolumeMount, required corev1.VolumeMount) { - if !equality.Semantic.DeepEqual(required, *existing) { - *modified = true - *existing = required - } -} - -func ensureVolume(modified *bool, existing *corev1.Volume, required corev1.Volume) { - if !equality.Semantic.DeepEqual(required, *existing) { - *modified = true - *existing = required - } -} - -func ensureSecurityContextPtr(modified *bool, existing **corev1.SecurityContext, required *corev1.SecurityContext) { - // if we have no required, then we don't care what someone else has set - if required == nil { - return - } - - if *existing == nil { - *modified = true - *existing = required - return - } - ensureSecurityContext(modified, *existing, *required) -} - -func ensureSecurityContext(modified *bool, existing *corev1.SecurityContext, required corev1.SecurityContext) { - ensureCapabilitiesPtr(modified, &existing.Capabilities, required.Capabilities) - ensureSELinuxOptionsPtr(modified, &existing.SELinuxOptions, required.SELinuxOptions) - setBoolPtr(modified, &existing.Privileged, required.Privileged) - setInt64Ptr(modified, &existing.RunAsUser, required.RunAsUser) - setBoolPtr(modified, &existing.RunAsNonRoot, required.RunAsNonRoot) - setBoolPtr(modified, &existing.ReadOnlyRootFilesystem, required.ReadOnlyRootFilesystem) - setBoolPtr(modified, &existing.AllowPrivilegeEscalation, required.AllowPrivilegeEscalation) -} - -func ensureCapabilitiesPtr(modified *bool, existing **corev1.Capabilities, required *corev1.Capabilities) { - // if we have no required, then we don't care what someone else has set - if required == nil { - return - } - - if *existing == nil { - *modified = true - *existing = required - return - } - ensureCapabilities(modified, *existing, *required) -} - -func ensureCapabilities(modified *bool, existing *corev1.Capabilities, required corev1.Capabilities) { - // any Add we specify, we require. - for _, required := range required.Add { - found := false - for _, curr := range existing.Add { - if equality.Semantic.DeepEqual(curr, required) { - found = true - break - } - } - if !found { - *modified = true - existing.Add = append(existing.Add, required) - } - } - - // any Drop we specify, we require. - for _, required := range required.Drop { - found := false - for _, curr := range existing.Drop { - if equality.Semantic.DeepEqual(curr, required) { - found = true - break - } - } - if !found { - *modified = true - existing.Drop = append(existing.Drop, required) - } - } -} - -func setStringSliceIfSet(modified *bool, existing *[]string, required []string) { - if required == nil { - return - } - if !equality.Semantic.DeepEqual(required, *existing) { - *existing = required - *modified = true - } -} - -func mergeStringSlice(modified *bool, existing *[]string, required []string) { - for _, required := range required { - found := false - for _, curr := range *existing { - if required == curr { - found = true - break - } - } - if !found { - *modified = true - *existing = append(*existing, required) - } - } -} - -func ensureTolerations(modified *bool, existing *[]corev1.Toleration, required []corev1.Toleration) { - for ridx := range required { - found := false - for eidx := range *existing { - if required[ridx].Key == (*existing)[eidx].Key { - found = true - if !equality.Semantic.DeepEqual((*existing)[eidx], required[ridx]) { - *modified = true - (*existing)[eidx] = required[ridx] - } - break - } - } - if !found { - *modified = true - *existing = append(*existing, required[ridx]) - } - } -} - -func ensureAffinityPtr(modified *bool, existing **corev1.Affinity, required *corev1.Affinity) { - // if we have no required, then we don't care what someone else has set - if required == nil { - return - } - - if *existing == nil { - *modified = true - *existing = required - return - } - ensureAffinity(modified, *existing, *required) -} - -func ensureAffinity(modified *bool, existing *corev1.Affinity, required corev1.Affinity) { - if !equality.Semantic.DeepEqual(existing.NodeAffinity, required.NodeAffinity) { - *modified = true - (*existing).NodeAffinity = required.NodeAffinity - } - if !equality.Semantic.DeepEqual(existing.PodAffinity, required.PodAffinity) { - *modified = true - (*existing).PodAffinity = required.PodAffinity - } - if !equality.Semantic.DeepEqual(existing.PodAntiAffinity, required.PodAntiAffinity) { - *modified = true - (*existing).PodAntiAffinity = required.PodAntiAffinity - } -} - -func ensurePodSecurityContextPtr(modified *bool, existing **corev1.PodSecurityContext, required *corev1.PodSecurityContext) { - // if we have no required, then we don't care what someone else has set - if required == nil { - return - } - - if *existing == nil { - *modified = true - *existing = required - return - } - ensurePodSecurityContext(modified, *existing, *required) -} - -func ensurePodSecurityContext(modified *bool, existing *corev1.PodSecurityContext, required corev1.PodSecurityContext) { - ensureSELinuxOptionsPtr(modified, &existing.SELinuxOptions, required.SELinuxOptions) - setInt64Ptr(modified, &existing.RunAsUser, required.RunAsUser) - setInt64Ptr(modified, &existing.RunAsGroup, required.RunAsGroup) - setBoolPtr(modified, &existing.RunAsNonRoot, required.RunAsNonRoot) - - // any SupplementalGroups we specify, we require. - for _, required := range required.SupplementalGroups { - found := false - for _, curr := range existing.SupplementalGroups { - if curr == required { - found = true - break - } - } - if !found { - *modified = true - existing.SupplementalGroups = append(existing.SupplementalGroups, required) - } - } - - setInt64Ptr(modified, &existing.FSGroup, required.FSGroup) - - // any SupplementalGroups we specify, we require. - for _, required := range required.Sysctls { - found := false - for j, curr := range existing.Sysctls { - if curr.Name == required.Name { - found = true - if curr.Value != required.Value { - *modified = true - existing.Sysctls[j] = required - } - break - } - } - if !found { - *modified = true - existing.Sysctls = append(existing.Sysctls, required) - } - } -} - -func ensureSELinuxOptionsPtr(modified *bool, existing **corev1.SELinuxOptions, required *corev1.SELinuxOptions) { - // if we have no required, then we don't care what someone else has set - if required == nil { - return - } - - if *existing == nil { - *modified = true - *existing = required - return - } - ensureSELinuxOptions(modified, *existing, *required) -} - -func ensureSELinuxOptions(modified *bool, existing *corev1.SELinuxOptions, required corev1.SELinuxOptions) { - setStringIfSet(modified, &existing.User, required.User) - setStringIfSet(modified, &existing.Role, required.Role) - setStringIfSet(modified, &existing.Type, required.Type) - setStringIfSet(modified, &existing.Level, required.Level) -} - -func setBool(modified *bool, existing *bool, required bool) { - if required != *existing { - *existing = required - *modified = true - } -} - -func setBoolPtr(modified *bool, existing **bool, required *bool) { - // if we have no required, then we don't care what someone else has set - if required == nil { - return - } - - if *existing == nil { - *modified = true - *existing = required - return - } - setBool(modified, *existing, *required) -} - -func setInt32(modified *bool, existing *int32, required int32) { - if required != *existing { - *existing = required - *modified = true - } -} - -func setInt32Ptr(modified *bool, existing **int32, required *int32) { - if *existing == nil || (required == nil && *existing != nil) { - *modified = true - *existing = required - return - } - setInt32(modified, *existing, *required) -} - -func setInt64(modified *bool, existing *int64, required int64) { - if required != *existing { - *existing = required - *modified = true - } -} - -func setInt64Ptr(modified *bool, existing **int64, required *int64) { - // if we have no required, then we don't care what someone else has set - if required == nil { - return - } - - if *existing == nil { - *modified = true - *existing = required - return - } - setInt64(modified, *existing, *required) -} diff --git a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/machineconfig.go b/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/machineconfig.go deleted file mode 100644 index ccce3212c7..0000000000 --- a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/machineconfig.go +++ /dev/null @@ -1,109 +0,0 @@ -package resourcemerge - -import ( - mcfgv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1" - "k8s.io/apimachinery/pkg/api/equality" -) - -// EnsureMachineConfig ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func EnsureMachineConfig(modified *bool, existing *mcfgv1.MachineConfig, required mcfgv1.MachineConfig) { - EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - ensureMachineConfigSpec(modified, &existing.Spec, required.Spec) -} - -// EnsureControllerConfig ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func EnsureControllerConfig(modified *bool, existing *mcfgv1.ControllerConfig, required mcfgv1.ControllerConfig) { - EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - ensureControllerConfigSpec(modified, &existing.Spec, required.Spec) -} - -// EnsureMachineConfigPool ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func EnsureMachineConfigPool(modified *bool, existing *mcfgv1.MachineConfigPool, required mcfgv1.MachineConfigPool) { - EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - - if existing.Spec.MachineConfigSelector == nil { - *modified = true - existing.Spec.MachineConfigSelector = required.Spec.MachineConfigSelector - } - if !equality.Semantic.DeepEqual(existing.Spec.MachineConfigSelector, required.Spec.MachineConfigSelector) { - *modified = true - existing.Spec.MachineConfigSelector = required.Spec.MachineConfigSelector - } - - if existing.Spec.NodeSelector == nil { - *modified = true - existing.Spec.NodeSelector = required.Spec.NodeSelector - } - if !equality.Semantic.DeepEqual(existing.Spec.NodeSelector, required.Spec.NodeSelector) { - *modified = true - existing.Spec.NodeSelector = required.Spec.NodeSelector - } -} - -func ensureMachineConfigSpec(modified *bool, existing *mcfgv1.MachineConfigSpec, required mcfgv1.MachineConfigSpec) { - setStringIfSet(modified, &existing.OSImageURL, required.OSImageURL) - setStringIfSet(modified, &existing.KernelType, required.KernelType) - - if !equality.Semantic.DeepEqual(existing.KernelArguments, required.KernelArguments) { - *modified = true - (*existing).KernelArguments = required.KernelArguments - } - if !equality.Semantic.DeepEqual(existing.Config, required.Config) { - *modified = true - (*existing).Config = required.Config - } - if existing.FIPS != required.FIPS { - *modified = true - (*existing).FIPS = required.FIPS - } - if !equality.Semantic.DeepEqual(existing.Extensions, required.Extensions) { - *modified = true - (*existing).Extensions = required.Extensions - } -} - -func ensureControllerConfigSpec(modified *bool, existing *mcfgv1.ControllerConfigSpec, required mcfgv1.ControllerConfigSpec) { - setStringIfSet(modified, &existing.ClusterDNSIP, required.ClusterDNSIP) - setStringIfSet(modified, &existing.CloudProviderConfig, required.CloudProviderConfig) - setStringIfSet(modified, &existing.Platform, required.Platform) - setStringIfSet(modified, &existing.EtcdDiscoveryDomain, required.EtcdDiscoveryDomain) - setStringIfSet(modified, &existing.OSImageURL, required.OSImageURL) - setStringIfSet(modified, &existing.NetworkType, required.NetworkType) - - setBytesIfSet(modified, &existing.AdditionalTrustBundle, required.AdditionalTrustBundle) - setBytesIfSet(modified, &existing.RootCAData, required.RootCAData) - setBytesIfSet(modified, &existing.KubeAPIServerServingCAData, required.KubeAPIServerServingCAData) - setBytesIfSet(modified, &existing.CloudProviderCAData, required.CloudProviderCAData) - - if required.Infra != nil && !equality.Semantic.DeepEqual(existing.Infra, required.Infra) { - *modified = true - existing.Infra = required.Infra - } - - if existing.Infra.Status.PlatformStatus != nil && required.Infra.Status.PlatformStatus != nil { - if !equality.Semantic.DeepEqual(existing.Infra.Status.PlatformStatus.Type, required.Infra.Status.PlatformStatus.Type) { - *modified = true - existing.Infra.Status.PlatformStatus.Type = required.Infra.Status.PlatformStatus.Type - } - } - - if !equality.Semantic.DeepEqual(existing.Proxy, required.Proxy) { - *modified = true - existing.Proxy = required.Proxy - } - - if required.PullSecret != nil && !equality.Semantic.DeepEqual(existing.PullSecret, required.PullSecret) { - existing.PullSecret = required.PullSecret - *modified = true - } - - if existing.DNS != nil && required.DNS != nil && !equality.Semantic.DeepEqual(existing.DNS, required.DNS) { - *modified = true - existing.DNS = required.DNS - } - - mergeMap(modified, &existing.Images, required.Images) -} diff --git a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/meta.go b/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/meta.go deleted file mode 100644 index cd5422892f..0000000000 --- a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/meta.go +++ /dev/null @@ -1,73 +0,0 @@ -package resourcemerge - -import ( - "k8s.io/apimachinery/pkg/api/equality" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EnsureObjectMeta ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func EnsureObjectMeta(modified *bool, existing *metav1.ObjectMeta, required metav1.ObjectMeta) { - setStringIfSet(modified, &existing.Namespace, required.Namespace) - setStringIfSet(modified, &existing.Name, required.Name) - mergeMap(modified, &existing.Labels, required.Labels) - mergeMap(modified, &existing.Annotations, required.Annotations) - mergeOwnerRefs(modified, &existing.OwnerReferences, required.OwnerReferences) -} - -func setStringIfSet(modified *bool, existing *string, required string) { - if len(required) == 0 { - return - } - if required != *existing { - *existing = required - *modified = true - } -} - -func setBytesIfSet(modified *bool, existing *[]byte, required []byte) { - if len(required) == 0 { - return - } - if string(required) != string(*existing) { - *existing = required - *modified = true - } -} - -func mergeMap(modified *bool, existing *map[string]string, required map[string]string) { - if *existing == nil { - *existing = map[string]string{} - } - for k, v := range required { - if existingV, ok := (*existing)[k]; !ok || v != existingV { - *modified = true - (*existing)[k] = v - } - } -} - -func mergeOwnerRefs(modified *bool, existing *[]metav1.OwnerReference, required []metav1.OwnerReference) { - for ridx := range required { - found := false - for eidx := range *existing { - if required[ridx].UID == (*existing)[eidx].UID { - found = true - if !equality.Semantic.DeepEqual((*existing)[eidx], required[ridx]) { - *modified = true - (*existing)[eidx] = required[ridx] - } - break - } - } - if !found { - *modified = true - *existing = append(*existing, required[ridx]) - } - } -} - -// BoolPtr returns ptr to bool. -func BoolPtr(val bool) *bool { - return &val -} diff --git a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/rbac.go b/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/rbac.go deleted file mode 100644 index 04036e90f1..0000000000 --- a/vendor/github.com/openshift/machine-config-operator/lib/resourcemerge/rbac.go +++ /dev/null @@ -1,44 +0,0 @@ -package resourcemerge - -import ( - rbacv1 "k8s.io/api/rbac/v1" - "k8s.io/apimachinery/pkg/api/equality" -) - -// EnsureClusterRoleBinding ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func EnsureClusterRoleBinding(modified *bool, existing *rbacv1.ClusterRoleBinding, required rbacv1.ClusterRoleBinding) { - EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - if !equality.Semantic.DeepEqual(existing.Subjects, required.Subjects) { - *modified = true - existing.Subjects = required.Subjects - } - if !equality.Semantic.DeepEqual(existing.RoleRef, required.RoleRef) { - *modified = true - existing.RoleRef = required.RoleRef - } -} - -// EnsureRoleBinding ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func EnsureRoleBinding(modified *bool, existing *rbacv1.RoleBinding, required rbacv1.RoleBinding) { - EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - if !equality.Semantic.DeepEqual(existing.Subjects, required.Subjects) { - *modified = true - existing.Subjects = required.Subjects - } - if !equality.Semantic.DeepEqual(existing.RoleRef, required.RoleRef) { - *modified = true - existing.RoleRef = required.RoleRef - } -} - -// EnsureClusterRole ensures that the existing matches the required. -// modified is set to true when existing had to be updated with required. -func EnsureClusterRole(modified *bool, existing *rbacv1.ClusterRole, required rbacv1.ClusterRole) { - EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - if !equality.Semantic.DeepEqual(existing.Rules, required.Rules) { - *modified = true - existing.Rules = required.Rules - } -} diff --git a/vendor/modules.txt b/vendor/modules.txt index f9a176d503..2a9e6452ec 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -42,7 +42,8 @@ github.com/blang/semver # github.com/cenkalti/backoff v2.2.1+incompatible ## explicit github.com/cenkalti/backoff -# github.com/cespare/xxhash/v2 v2.1.1 +# github.com/cespare/xxhash/v2 v2.1.2 +## explicit github.com/cespare/xxhash/v2 # github.com/clarketm/json v1.14.1 github.com/clarketm/json @@ -293,7 +294,6 @@ github.com/openshift/client-go/operator/listers/operator/v1alpha1 # github.com/openshift/machine-config-operator v0.0.1-0.20201023110058-6c8bd9b2915c ## explicit github.com/openshift/machine-config-operator/internal/clients -github.com/openshift/machine-config-operator/lib/resourcemerge github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1 github.com/openshift/machine-config-operator/pkg/controller/common github.com/openshift/machine-config-operator/pkg/daemon/constants