mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-23 16:00:46 +00:00
Upgrade the operator to use Operator SDK v1.33.0 (#182)
* Move controller package inside internal directory Based on the go/v4 project structure, the following changed: - Pakcage `controllers` is now named `controller` - Package `controller` now lives inside new `internal` directory * Move main.go in cmd directory Based on the new go/v4 project structure, `main.go` now lives in the `cmd` directory. * Change package import in main.go * Update go mod dependencies Update the dependencies based on the versions obtained by creating a new operator project using `kubebuilder init --domain onepassword.com --plugins=go/v4`. This is based on the migration steps provided to go from go/v3 to go/v4 (https://book.kubebuilder.io/migration/migration_guide_gov3_to_gov4) * Update vendor * Adjust code for breaking changes from pkg update sigs.k8s.io/controller-runtime package had breaking changes from v0.14.5 to v0.16.3. This commit brings the changes needed to achieve the same things using the new functionality avaialble. * Adjust paths to connect yaml files Since `main.go` is now in `cmd` directory, the paths to the files for deploying Connect have to be adjusted based on the new location `main.go` is executed from. * Update files based on new structure and scaffolding These changes are made based on the new project structure and scaffolding obtained when using the new go/v4 project structure. These were done based on the migration steps mentioned when migrating to go/v4 (https://book.kubebuilder.io/migration/migration_guide_gov3_to_gov4). * Update config files These updates are made based on the Kustomize v4 syntax. This is part of the upgrate to go/v4 (https://book.kubebuilder.io/migration/migration_guide_gov3_to_gov4) * Update dependencies and GO version * Update vendor * Update Kubernetes tools versions * Update operator version in Makefile Now the version in the Makefile matches the version of the operator * Update Operator SDK version in version.go * Adjust generated deepcopy It seems that the +build tag is no longer needed based on the latest generated scaffolding, therefore it's removed. * Update copyright year * Bring back missing changes from migration Some customization in Makefile was lost during the migration process. Specifically, the namespace customization for `make deploy` command. Also, we push changes to kustomization.yaml for making the deploy process smoother. * Add RBAC perms for coordination.k8s.io It seems that with the latest changes to Kubernetes and Kustomize, we need to add additional RBAC to the service account used so that it can properly access the `leases` resource. * Optimize Dockerfile Dockerfile had a step for caching dependencies (go mod download). However, this is already done by the vendor directory, which we include. Therefore, this step can be removed to make the image build time faster.
This commit is contained in:
2
vendor/github.com/onsi/gomega/matchers/be_a_directory.go
generated
vendored
2
vendor/github.com/onsi/gomega/matchers/be_a_directory.go
generated
vendored
@@ -52,5 +52,5 @@ func (matcher *BeADirectoryMatcher) FailureMessage(actual interface{}) (message
|
||||
}
|
||||
|
||||
func (matcher *BeADirectoryMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, fmt.Sprintf("not be a directory"))
|
||||
return format.Message(actual, "not be a directory")
|
||||
}
|
||||
|
2
vendor/github.com/onsi/gomega/matchers/be_a_regular_file.go
generated
vendored
2
vendor/github.com/onsi/gomega/matchers/be_a_regular_file.go
generated
vendored
@@ -52,5 +52,5 @@ func (matcher *BeARegularFileMatcher) FailureMessage(actual interface{}) (messag
|
||||
}
|
||||
|
||||
func (matcher *BeARegularFileMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, fmt.Sprintf("not be a regular file"))
|
||||
return format.Message(actual, "not be a regular file")
|
||||
}
|
||||
|
4
vendor/github.com/onsi/gomega/matchers/be_an_existing_file.go
generated
vendored
4
vendor/github.com/onsi/gomega/matchers/be_an_existing_file.go
generated
vendored
@@ -32,9 +32,9 @@ func (matcher *BeAnExistingFileMatcher) Match(actual interface{}) (success bool,
|
||||
}
|
||||
|
||||
func (matcher *BeAnExistingFileMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, fmt.Sprintf("to exist"))
|
||||
return format.Message(actual, "to exist")
|
||||
}
|
||||
|
||||
func (matcher *BeAnExistingFileMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, fmt.Sprintf("not to exist"))
|
||||
return format.Message(actual, "not to exist")
|
||||
}
|
||||
|
13
vendor/github.com/onsi/gomega/matchers/be_false_matcher.go
generated
vendored
13
vendor/github.com/onsi/gomega/matchers/be_false_matcher.go
generated
vendored
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type BeFalseMatcher struct {
|
||||
Reason string
|
||||
}
|
||||
|
||||
func (matcher *BeFalseMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
@@ -20,9 +21,17 @@ func (matcher *BeFalseMatcher) Match(actual interface{}) (success bool, err erro
|
||||
}
|
||||
|
||||
func (matcher *BeFalseMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "to be false")
|
||||
if matcher.Reason == "" {
|
||||
return format.Message(actual, "to be false")
|
||||
} else {
|
||||
return matcher.Reason
|
||||
}
|
||||
}
|
||||
|
||||
func (matcher *BeFalseMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "not to be false")
|
||||
if matcher.Reason == "" {
|
||||
return format.Message(actual, "not to be false")
|
||||
} else {
|
||||
return fmt.Sprintf(`Expected not false but got false\nNegation of "%s" failed`, matcher.Reason)
|
||||
}
|
||||
}
|
||||
|
13
vendor/github.com/onsi/gomega/matchers/be_true_matcher.go
generated
vendored
13
vendor/github.com/onsi/gomega/matchers/be_true_matcher.go
generated
vendored
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type BeTrueMatcher struct {
|
||||
Reason string
|
||||
}
|
||||
|
||||
func (matcher *BeTrueMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
@@ -20,9 +21,17 @@ func (matcher *BeTrueMatcher) Match(actual interface{}) (success bool, err error
|
||||
}
|
||||
|
||||
func (matcher *BeTrueMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "to be true")
|
||||
if matcher.Reason == "" {
|
||||
return format.Message(actual, "to be true")
|
||||
} else {
|
||||
return matcher.Reason
|
||||
}
|
||||
}
|
||||
|
||||
func (matcher *BeTrueMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "not to be true")
|
||||
if matcher.Reason == "" {
|
||||
return format.Message(actual, "not to be true")
|
||||
} else {
|
||||
return fmt.Sprintf(`Expected not true but got true\nNegation of "%s" failed`, matcher.Reason)
|
||||
}
|
||||
}
|
||||
|
29
vendor/github.com/onsi/gomega/matchers/consist_of.go
generated
vendored
29
vendor/github.com/onsi/gomega/matchers/consist_of.go
generated
vendored
@@ -48,11 +48,13 @@ func neighbours(value, matcher interface{}) (bool, error) {
|
||||
|
||||
func equalMatchersToElements(matchers []interface{}) (elements []interface{}) {
|
||||
for _, matcher := range matchers {
|
||||
equalMatcher, ok := matcher.(*EqualMatcher)
|
||||
if ok {
|
||||
matcher = equalMatcher.Expected
|
||||
if equalMatcher, ok := matcher.(*EqualMatcher); ok {
|
||||
elements = append(elements, equalMatcher.Expected)
|
||||
} else if _, ok := matcher.(*BeNilMatcher); ok {
|
||||
elements = append(elements, nil)
|
||||
} else {
|
||||
elements = append(elements, matcher)
|
||||
}
|
||||
elements = append(elements, matcher)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -72,11 +74,13 @@ func flatten(elems []interface{}) []interface{} {
|
||||
|
||||
func matchers(expectedElems []interface{}) (matchers []interface{}) {
|
||||
for _, e := range flatten(expectedElems) {
|
||||
matcher, isMatcher := e.(omegaMatcher)
|
||||
if !isMatcher {
|
||||
matcher = &EqualMatcher{Expected: e}
|
||||
if e == nil {
|
||||
matchers = append(matchers, &BeNilMatcher{})
|
||||
} else if matcher, isMatcher := e.(omegaMatcher); isMatcher {
|
||||
matchers = append(matchers, matcher)
|
||||
} else {
|
||||
matchers = append(matchers, &EqualMatcher{Expected: e})
|
||||
}
|
||||
matchers = append(matchers, matcher)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -89,9 +93,14 @@ func presentable(elems []interface{}) interface{} {
|
||||
}
|
||||
|
||||
sv := reflect.ValueOf(elems)
|
||||
tt := sv.Index(0).Elem().Type()
|
||||
firstEl := sv.Index(0)
|
||||
if firstEl.IsNil() {
|
||||
return elems
|
||||
}
|
||||
tt := firstEl.Elem().Type()
|
||||
for i := 1; i < sv.Len(); i++ {
|
||||
if sv.Index(i).Elem().Type() != tt {
|
||||
el := sv.Index(i)
|
||||
if el.IsNil() || (sv.Index(i).Elem().Type() != tt) {
|
||||
return elems
|
||||
}
|
||||
}
|
||||
|
7
vendor/github.com/onsi/gomega/matchers/have_exact_elements.go
generated
vendored
7
vendor/github.com/onsi/gomega/matchers/have_exact_elements.go
generated
vendored
@@ -44,7 +44,12 @@ func (matcher *HaveExactElementsMatcher) Match(actual interface{}) (success bool
|
||||
|
||||
elemMatcher := matchers[i].(omegaMatcher)
|
||||
match, err := elemMatcher.Match(values[i])
|
||||
if err != nil || !match {
|
||||
if err != nil {
|
||||
matcher.mismatchFailures = append(matcher.mismatchFailures, mismatchFailure{
|
||||
index: i,
|
||||
failure: err.Error(),
|
||||
})
|
||||
} else if !match {
|
||||
matcher.mismatchFailures = append(matcher.mismatchFailures, mismatchFailure{
|
||||
index: i,
|
||||
failure: elemMatcher.FailureMessage(values[i]),
|
||||
|
9
vendor/github.com/onsi/gomega/matchers/have_http_body_matcher.go
generated
vendored
9
vendor/github.com/onsi/gomega/matchers/have_http_body_matcher.go
generated
vendored
@@ -11,8 +11,9 @@ import (
|
||||
)
|
||||
|
||||
type HaveHTTPBodyMatcher struct {
|
||||
Expected interface{}
|
||||
cachedBody []byte
|
||||
Expected interface{}
|
||||
cachedResponse interface{}
|
||||
cachedBody []byte
|
||||
}
|
||||
|
||||
func (matcher *HaveHTTPBodyMatcher) Match(actual interface{}) (bool, error) {
|
||||
@@ -73,7 +74,7 @@ func (matcher *HaveHTTPBodyMatcher) NegatedFailureMessage(actual interface{}) (m
|
||||
// the Reader is closed and it is not readable again in FailureMessage()
|
||||
// or NegatedFailureMessage()
|
||||
func (matcher *HaveHTTPBodyMatcher) body(actual interface{}) ([]byte, error) {
|
||||
if matcher.cachedBody != nil {
|
||||
if matcher.cachedResponse == actual && matcher.cachedBody != nil {
|
||||
return matcher.cachedBody, nil
|
||||
}
|
||||
|
||||
@@ -91,8 +92,10 @@ func (matcher *HaveHTTPBodyMatcher) body(actual interface{}) ([]byte, error) {
|
||||
|
||||
switch a := actual.(type) {
|
||||
case *http.Response:
|
||||
matcher.cachedResponse = a
|
||||
return body(a)
|
||||
case *httptest.ResponseRecorder:
|
||||
matcher.cachedResponse = a
|
||||
return body(a.Result())
|
||||
default:
|
||||
return nil, fmt.Errorf("HaveHTTPBody matcher expects *http.Response or *httptest.ResponseRecorder. Got:\n%s", format.Object(actual, 1))
|
||||
|
25
vendor/github.com/onsi/gomega/matchers/match_error_matcher.go
generated
vendored
25
vendor/github.com/onsi/gomega/matchers/match_error_matcher.go
generated
vendored
@@ -9,10 +9,14 @@ import (
|
||||
)
|
||||
|
||||
type MatchErrorMatcher struct {
|
||||
Expected interface{}
|
||||
Expected any
|
||||
FuncErrDescription []any
|
||||
isFunc bool
|
||||
}
|
||||
|
||||
func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
func (matcher *MatchErrorMatcher) Match(actual any) (success bool, err error) {
|
||||
matcher.isFunc = false
|
||||
|
||||
if isNil(actual) {
|
||||
return false, fmt.Errorf("Expected an error, got nil")
|
||||
}
|
||||
@@ -42,6 +46,17 @@ func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err e
|
||||
return actualErr.Error() == expected, nil
|
||||
}
|
||||
|
||||
v := reflect.ValueOf(expected)
|
||||
t := v.Type()
|
||||
errorInterface := reflect.TypeOf((*error)(nil)).Elem()
|
||||
if t.Kind() == reflect.Func && t.NumIn() == 1 && t.In(0).Implements(errorInterface) && t.NumOut() == 1 && t.Out(0).Kind() == reflect.Bool {
|
||||
if len(matcher.FuncErrDescription) == 0 {
|
||||
return false, fmt.Errorf("MatchError requires an additional description when passed a function")
|
||||
}
|
||||
matcher.isFunc = true
|
||||
return v.Call([]reflect.Value{reflect.ValueOf(actualErr)})[0].Bool(), nil
|
||||
}
|
||||
|
||||
var subMatcher omegaMatcher
|
||||
var hasSubMatcher bool
|
||||
if expected != nil {
|
||||
@@ -57,9 +72,15 @@ func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err e
|
||||
}
|
||||
|
||||
func (matcher *MatchErrorMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
if matcher.isFunc {
|
||||
return format.Message(actual, fmt.Sprintf("to match error function %s", matcher.FuncErrDescription[0]))
|
||||
}
|
||||
return format.Message(actual, "to match error", matcher.Expected)
|
||||
}
|
||||
|
||||
func (matcher *MatchErrorMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
if matcher.isFunc {
|
||||
return format.Message(actual, fmt.Sprintf("not to match error function %s", matcher.FuncErrDescription[0]))
|
||||
}
|
||||
return format.Message(actual, "not to match error", matcher.Expected)
|
||||
}
|
||||
|
Reference in New Issue
Block a user