Skip to content

Commit

Permalink
Merge pull request #7211 from oscr/k8s_v125
Browse files Browse the repository at this point in the history
🌱 Bump controller-runtime to use new Kubernetes Go libraries
  • Loading branch information
k8s-ci-robot authored Sep 12, 2022
2 parents 59afdb6 + 9e55898 commit eb5ae53
Show file tree
Hide file tree
Showing 43 changed files with 534 additions and 1,390 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ linters-settings:
alias: apierrors
- pkg: k8s.io/apimachinery/pkg/util/errors
alias: kerrors
- pkg: k8s.io/component-base/logs/api/v1
alias: logsv1
# Controller Runtime
- pkg: sigs.k8s.io/controller-runtime
alias: ctrl
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ SETUP_ENVTEST_BIN := setup-envtest
SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER))
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest

CONTROLLER_GEN_VER := v0.9.1
CONTROLLER_GEN_VER := v0.9.2
CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER))
CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen
Expand Down

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,11 @@ type fakeClient struct {
deleteError error
}

func (fc *fakeClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error {
func (fc *fakeClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error {
if fc.getError != nil {
return fc.getError
}
return fc.Client.Get(ctx, key, obj)
return fc.Client.Get(ctx, key, obj, opts...)
}

func (fc *fakeClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error {
Expand Down
5 changes: 3 additions & 2 deletions bootstrap/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"k8s.io/client-go/tools/leaderelection/resourcelock"
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
logsv1 "k8s.io/component-base/logs/api/v1"
_ "k8s.io/component-base/logs/json/register"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -90,7 +91,7 @@ var (
// InitFlags initializes this manager's flags.
func InitFlags(fs *pflag.FlagSet) {
logs.AddFlags(fs, logs.SkipLoggingConfigurationFlags())
logOptions.AddFlags(fs)
logsv1.AddFlags(logOptions, fs)

fs.StringVar(&metricsBindAddr, "metrics-bind-addr", "localhost:8080",
"The address the metric endpoint binds to.")
Expand Down Expand Up @@ -145,7 +146,7 @@ func main() {
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()

if err := logOptions.ValidateAndApply(nil); err != nil {
if err := logsv1.ValidateAndApply(logOptions, nil); err != nil {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/clusterctl/client/cluster/internal/dryrun/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ func NewClient(apiReader client.Reader, objs []client.Object) *Client {
// Get retrieves an object for the given object key from the internal object tracker.
// If the object does not exist in the internal object tracker it tries to fetch the object
// from the Kubernetes Cluster using the apiReader client (if apiReader is not nil).
func (c *Client) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error {
if err := c.fakeClient.Get(ctx, key, obj); err != nil {
func (c *Client) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error {
if err := c.fakeClient.Get(ctx, key, obj, opts...); err != nil {
// If the object is not found by the fake client, get the object
// using the apiReader.
if apierrors.IsNotFound(err) && c.apiReader != nil {
return c.apiReader.Get(ctx, key, obj)
return c.apiReader.Get(ctx, key, obj, opts...)
}
return err
}
Expand Down

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

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

2 changes: 1 addition & 1 deletion cmd/clusterctl/config/manifest/clusterctl-api.yaml

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

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

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

2 changes: 1 addition & 1 deletion config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

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

2 changes: 1 addition & 1 deletion config/crd/bases/cluster.x-k8s.io_clusters.yaml

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

2 changes: 1 addition & 1 deletion config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml

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

2 changes: 1 addition & 1 deletion config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml

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

50 changes: 25 additions & 25 deletions config/crd/bases/cluster.x-k8s.io_machinepools.yaml

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

2 changes: 1 addition & 1 deletion config/crd/bases/cluster.x-k8s.io_machines.yaml

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

2 changes: 1 addition & 1 deletion config/crd/bases/cluster.x-k8s.io_machinesets.yaml

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

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

2 changes: 1 addition & 1 deletion config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml

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

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

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

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

4 changes: 2 additions & 2 deletions controlplane/kubeadm/internal/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func (e *RemoteClusterConnectionError) Error() string { return e.Name + ": " + e
func (e *RemoteClusterConnectionError) Unwrap() error { return e.Err }

// Get implements client.Reader.
func (m *Management) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error {
return m.Client.Get(ctx, key, obj)
func (m *Management) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error {
return m.Client.Get(ctx, key, obj, opts...)
}

// List implements client.Reader.
Expand Down
2 changes: 1 addition & 1 deletion controlplane/kubeadm/internal/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ type fakeClient struct {
listErr error
}

func (f *fakeClient) Get(_ context.Context, key client.ObjectKey, obj client.Object) error {
func (f *fakeClient) Get(_ context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error {
f.getCalled = true
if f.getErr != nil {
return f.getErr
Expand Down
4 changes: 2 additions & 2 deletions controlplane/kubeadm/internal/controllers/fakes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ type fakeManagementCluster struct {
Reader client.Reader
}

func (f *fakeManagementCluster) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error {
return f.Reader.Get(ctx, key, obj)
func (f *fakeManagementCluster) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error {
return f.Reader.Get(ctx, key, obj, opts...)
}

func (f *fakeManagementCluster) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error {
Expand Down
Loading

0 comments on commit eb5ae53

Please sign in to comment.