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

Update controller-runtime to v0.16.3 and remove argo-rollout dependency #53

Merged
merged 5 commits into from
May 8, 2024
Merged
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
5 changes: 2 additions & 3 deletions controllers/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

rolloutsmanagerv1alpha1 "github.com/argoproj-labs/argo-rollouts-manager/api/v1alpha1"
"github.com/argoproj/argo-rollouts/utils/plugin/types"
"gopkg.in/yaml.v2"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -31,7 +30,7 @@ func (r *RolloutManagerReconciler) reconcileConfigMap(ctx context.Context, cr *r
},
},
}
trafficRouterPlugins := []types.PluginItem{
trafficRouterPlugins := []pluginItem{
{
Name: OpenShiftRolloutPluginName,
Location: r.OpenShiftRoutePluginLocation,
Expand All @@ -56,7 +55,7 @@ func (r *RolloutManagerReconciler) reconcileConfigMap(ctx context.Context, cr *r
return fmt.Errorf("failed to get the serviceAccount associated with %s: %w", desiredConfigMap.Name, err)
}

var actualTrafficRouterPlugins []types.PluginItem
var actualTrafficRouterPlugins []pluginItem
if err = yaml.Unmarshal([]byte(actualConfigMap.Data[TrafficRouterPluginConfigMapKey]), &actualTrafficRouterPlugins); err != nil {
return fmt.Errorf("failed to unmarshal traffic router plugins from ConfigMap: %s", err)
}
Expand Down
3 changes: 1 addition & 2 deletions controllers/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"

"github.com/argoproj-labs/argo-rollouts-manager/api/v1alpha1"
"github.com/argoproj/argo-rollouts/utils/plugin/types"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -77,7 +76,7 @@ var _ = Describe("ConfigMap Test", func() {
Expect(fetchedConfigMap.Data[TrafficRouterPluginConfigMapKey]).ToNot(ContainSubstring("test/plugin"))

By("adding a new trafficRouter plugin to test the update plugin logic")
trafficRouterPlugins := []types.PluginItem{
trafficRouterPlugins := []pluginItem{
{
Name: "test/plugin",
Location: "https://test-path",
Expand Down
4 changes: 1 addition & 3 deletions controllers/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -250,9 +249,8 @@ var _ = Describe("Resource creation and cleanup tests", func() {
Namespace: a.Namespace,
},
}
resources := []runtime.Object{a}

r := makeTestReconciler(resources...)
r := makeTestReconciler(a)
err := createNamespace(r, a.Namespace)
Expect(err).ToNot(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion controllers/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var _ = Describe("RolloutManager Test", func() {
deploy.Status.ReadyReplicas = 1
deploy.Spec.Replicas = &requiredReplicas

Expect(r.Client.Update(ctx, deploy)).To(Succeed())
Expect(r.Client.Status().Update(ctx, deploy)).To(Succeed())
Expect(r.reconcileStatus(ctx, a)).To(Succeed())

Expect(a.Status.RolloutController).To(Equal(rolloutsmanagerv1alpha1.PhaseAvailable))
Expand Down
8 changes: 8 additions & 0 deletions controllers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ const (
UnsupportedRolloutManagerNamespaceScoped = "when Subscription has environment variable NAMESPACE_SCOPED_ARGO_ROLLOUTS set to False, there may not exist any namespace-scoped RolloutManagers: only a single cluster-scoped RolloutManager is supported"
)

// pluginItem is a clone of PluginItem from "github.com/argoproj/argo-rollouts/utils/plugin/types"
// We clone it here, to avoid a dependency on argo-rollouts.
type pluginItem struct {
Name string `json:"name" yaml:"name"`
Location string `json:"location" yaml:"location"`
Sha256 string `json:"sha256" yaml:"sha256"`
}

func setRolloutsLabels(obj *metav1.ObjectMeta) {
obj.Labels = map[string]string{}
obj.Labels["app.kubernetes.io/name"] = DefaultArgoRolloutsResourceName
Expand Down
10 changes: 5 additions & 5 deletions controllers/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -32,7 +31,6 @@ var _ = Describe("checkForExistingRolloutManager tests", func() {

ctx = context.Background()
log = logger.FromContext(ctx)
k8sClient = fake.NewClientBuilder().WithScheme(s).Build()

rolloutsManager = rolloutsmanagerv1alpha1.RolloutManager{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -43,6 +41,7 @@ var _ = Describe("checkForExistingRolloutManager tests", func() {
NamespaceScoped: false,
},
}
k8sClient = fake.NewClientBuilder().WithScheme(s).WithStatusSubresource(&rolloutsManager).Build()
})

When("A single cluster-scoped RolloutsManager is created.", func() {
Expand Down Expand Up @@ -185,7 +184,6 @@ var _ = Describe("validateRolloutsScope tests", func() {

ctx = context.Background()
log = logger.FromContext(ctx)
k8sClient = fake.NewClientBuilder().WithScheme(s).Build()

rolloutsManager = rolloutsmanagerv1alpha1.RolloutManager{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -196,6 +194,7 @@ var _ = Describe("validateRolloutsScope tests", func() {
NamespaceScoped: false,
},
}
k8sClient = fake.NewClientBuilder().WithScheme(s).WithStatusSubresource(&rolloutsManager).Build()
})

When("NAMESPACE_SCOPED_ARGO_ROLLOUTS environment variable is set to True.", func() {
Expand Down Expand Up @@ -273,13 +272,14 @@ func makeTestRolloutManager(opts ...rolloutManagerOpt) *rolloutsmanagerv1alpha1.
return a
}

func makeTestReconciler(objs ...runtime.Object) *RolloutManagerReconciler {
func makeTestReconciler(obj ...client.Object) *RolloutManagerReconciler {
s := scheme.Scheme

err := rolloutsmanagerv1alpha1.AddToScheme(s)
Expect(err).ToNot(HaveOccurred())

cl := fake.NewClientBuilder().WithScheme(s).WithRuntimeObjects(objs...).Build()
cl := fake.NewClientBuilder().WithScheme(s).WithStatusSubresource(obj...).WithObjects(obj...).Build()

return &RolloutManagerReconciler{
Client: cl,
Scheme: s,
Expand Down
47 changes: 23 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ module github.com/argoproj-labs/argo-rollouts-manager
go 1.21

require (
github.com/argoproj/argo-rollouts v1.6.6
github.com/go-logr/logr v1.2.4
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.10
go.uber.org/zap v1.24.0
go.uber.org/zap v1.25.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.26.0
k8s.io/apimachinery v0.26.0
k8s.io/client-go v0.26.0
sigs.k8s.io/controller-runtime v0.14.1
k8s.io/api v0.28.3
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
sigs.k8s.io/controller-runtime v0.16.3
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -46,31 +46,30 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.3 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.0 // indirect
k8s.io/component-base v0.26.0 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/apiextensions-apiserver v0.28.3 // indirect
k8s.io/component-base v0.28.3 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading
Loading