Skip to content

Commit

Permalink
Extract depresolver interface
Browse files Browse the repository at this point in the history
close #908

- extracting interface GslbResolver
- GslbResolver Mock
- refactor Reconciler

Signed-off-by: kuritka <kuritka@gmail.com>
  • Loading branch information
kuritka committed Jun 21, 2022
1 parent 04644df commit fbcb89b
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ mocks:
mockgen -source=controllers/providers/assistant/assistant.go -destination=controllers/providers/assistant/assistant_mock.go -package=assistant
mockgen -source=controllers/providers/dns/dns.go -destination=controllers/providers/dns/dns_mock.go -package=dns
mockgen -source=controllers/providers/dns/infoblox-client.go -destination=controllers/providers/dns/infoblox-client_mock.go -package=dns
mockgen -source=controllers/depresolver/resolver.go -destination=controllers/depresolver/resolver_mock.go -package=depresolver
mockgen -destination=controllers/providers/dns/infoblox-connection_mock.go -package=dns github.com/infobloxopen/infoblox-go-client IBConnector
$(call golic)

Expand Down
36 changes: 36 additions & 0 deletions controllers/depresolver/resolver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package depresolver

/*
Copyright 2022 The k8gb Contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
*/

import (
"context"

k8gbv1beta1 "github.com/k8gb-io/k8gb/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

type GslbResolver interface {
// ResolveOperatorConfig executes once. It reads operator's configuration
// from environment variables into &Config and validates
ResolveOperatorConfig() (*Config, error)

// ResolveGslbSpec fills Gslb by spec values. It executes always, when gslb is initialised.
// If spec value is not defined, it will use the default value. Function returns error if input is invalid.
ResolveGslbSpec(ctx context.Context, gslb *k8gbv1beta1.Gslb, client client.Client) error
}
84 changes: 84 additions & 0 deletions controllers/depresolver/resolver_mock.go

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

2 changes: 1 addition & 1 deletion controllers/gslb_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type GslbReconciler struct {
client.Client
Scheme *runtime.Scheme
Config *depresolver.Config
DepResolver *depresolver.DependencyResolver
DepResolver depresolver.GslbResolver
DNSProvider dns.Provider
}

Expand Down

0 comments on commit fbcb89b

Please sign in to comment.