Skip to content
Open
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
10 changes: 4 additions & 6 deletions controllers/argocd/openshift/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var log = logf.Log.WithName("openshift_controller_argocd")
// argocd.Register(reconcilerHook)
// }

func ReconcilerHook(cr *argoapp.ArgoCD, v interface{}, hint string) error {
func ReconcilerHook(cr *argoapp.ArgoCD, v any, hint string) error {

logv := log.WithValues("ArgoCD Namespace", cr.Namespace, "ArgoCD Name", cr.Name)
switch o := v.(type) {
Expand Down Expand Up @@ -205,7 +205,7 @@ echo "Done!"
}

// BuilderHook updates the Argo CD controller builder to watch for changes to the "admin" ClusterRole
func BuilderHook(_ *argoapp.ArgoCD, v interface{}, _ string) error {
func BuilderHook(_ *argoapp.ArgoCD, v any, _ string) error {
logv := log.WithValues("module", "builder-hook")

bldr, ok := v.(*argocd.BuilderHook)
Expand Down Expand Up @@ -480,10 +480,8 @@ func allowedNamespace(current string, namespaces string) bool {
return true
}

for _, n := range clusterConfigNamespaces {
if n == current {
return true
}
if slices.Contains(clusterConfigNamespaces, current) {
return true
}
}
return false
Expand Down
9 changes: 4 additions & 5 deletions controllers/consoleplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
resourcev1 "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/ptr"

"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -107,7 +106,7 @@ func getPluginPodSpec(crImagePullPolicy corev1.PullPolicy) corev1.PodSpec {
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: pluginServingCertName,
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand All @@ -118,7 +117,7 @@ func getPluginPodSpec(crImagePullPolicy corev1.PullPolicy) corev1.PodSpec {
LocalObjectReference: corev1.LocalObjectReference{
Name: httpdConfigMapName,
},
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand Down Expand Up @@ -232,8 +231,8 @@ func securityContextForPlugin() *corev1.SecurityContext {
"ALL",
},
},
RunAsNonRoot: ptr.To(true),
AllowPrivilegeEscalation: ptr.To(false),
RunAsNonRoot: new(true),
AllowPrivilegeEscalation: new(false),
SeccompProfile: &corev1.SeccompProfile{
Type: corev1.SeccompProfileTypeRuntimeDefault,
},
Expand Down
27 changes: 13 additions & 14 deletions controllers/consoleplugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/utils/ptr"

"sigs.k8s.io/controller-runtime/pkg/client/fake"
)
Expand Down Expand Up @@ -146,7 +145,7 @@ func TestPlugin_reconcileDeployment_changedLabels(t *testing.T) {
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: pluginServingCertName,
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand All @@ -157,7 +156,7 @@ func TestPlugin_reconcileDeployment_changedLabels(t *testing.T) {
LocalObjectReference: corev1.LocalObjectReference{
Name: httpdConfigMapName,
},
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand Down Expand Up @@ -292,7 +291,7 @@ func TestPlugin_reconcileDeployment_changedReplicas(t *testing.T) {
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: pluginServingCertName,
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand All @@ -303,7 +302,7 @@ func TestPlugin_reconcileDeployment_changedReplicas(t *testing.T) {
LocalObjectReference: corev1.LocalObjectReference{
Name: httpdConfigMapName,
},
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand Down Expand Up @@ -433,7 +432,7 @@ func TestPlugin_reconcileDeployment_changedSelector(t *testing.T) {
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: pluginServingCertName,
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand All @@ -444,7 +443,7 @@ func TestPlugin_reconcileDeployment_changedSelector(t *testing.T) {
LocalObjectReference: corev1.LocalObjectReference{
Name: httpdConfigMapName,
},
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand Down Expand Up @@ -573,7 +572,7 @@ func TestPlugin_reconcileDeployment_changedTemplateLabels(t *testing.T) {
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: pluginServingCertName,
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand All @@ -584,7 +583,7 @@ func TestPlugin_reconcileDeployment_changedTemplateLabels(t *testing.T) {
LocalObjectReference: corev1.LocalObjectReference{
Name: httpdConfigMapName,
},
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand Down Expand Up @@ -660,7 +659,7 @@ func TestPlugin_reconcileDeployment_changedContainers(t *testing.T) {
Name: "wrong name",
Image: "wrong image",
SecurityContext: &corev1.SecurityContext{
Privileged: ptr.To(true),
Privileged: new(true),
},
},
}
Expand Down Expand Up @@ -780,7 +779,7 @@ func TestPlugin_reconcileDeployment_changedRestartPolicy(t *testing.T) {
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: pluginServingCertName,
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand All @@ -791,7 +790,7 @@ func TestPlugin_reconcileDeployment_changedRestartPolicy(t *testing.T) {
LocalObjectReference: corev1.LocalObjectReference{
Name: httpdConfigMapName,
},
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand Down Expand Up @@ -920,7 +919,7 @@ func TestPlugin_reconcileDeployment_changedDNSPolicy(t *testing.T) {
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: pluginServingCertName,
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand All @@ -931,7 +930,7 @@ func TestPlugin_reconcileDeployment_changedDNSPolicy(t *testing.T) {
LocalObjectReference: corev1.LocalObjectReference{
Name: httpdConfigMapName,
},
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions controllers/gitopsservice_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,13 @@ func TestReconcile_BackendSecurityContext(t *testing.T) {

securityContext := deployment.Spec.Template.Spec.Containers[0].SecurityContext
want := &corev1.SecurityContext{
AllowPrivilegeEscalation: util.BoolPtr(false),
AllowPrivilegeEscalation: new(false),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{
"ALL",
},
},
RunAsNonRoot: util.BoolPtr(true),
RunAsNonRoot: new(true),
SeccompProfile: &corev1.SeccompProfile{
Type: corev1.SeccompProfileTypeRuntimeDefault,
},
Expand Down
9 changes: 2 additions & 7 deletions controllers/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,6 @@ func caseInsensitiveGetenv(s string) (string, string) {
return "", ""
}

// BoolPtr returns a pointer to val
func BoolPtr(val bool) *bool {
return &val
}

func AddSeccompProfileForOpenShift(client client.Client, podspec *corev1.PodSpec) {

version, _ := GetClusterVersion(client)
Expand All @@ -280,13 +275,13 @@ func AddSeccompProfileForOpenShift(client client.Client, podspec *corev1.PodSpec
}
if podspec.Containers[0].SecurityContext == nil {
podspec.Containers[0].SecurityContext = &corev1.SecurityContext{
AllowPrivilegeEscalation: BoolPtr(false),
AllowPrivilegeEscalation: new(false),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{
"ALL",
},
},
RunAsNonRoot: BoolPtr(true),
RunAsNonRoot: new(true),
SeccompProfile: &corev1.SeccompProfile{
Type: corev1.SeccompProfileTypeRuntimeDefault,
},
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/gitopsservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,8 @@ var _ = Describe("GitOpsServiceController", func() {
continue
}
if namespaces, ok := secret.Data["namespaces"]; ok {
namespaceList := strings.Split(string(namespaces), ",")
for _, ns := range namespaceList {
namespaceList := strings.SplitSeq(string(namespaces), ",")
for ns := range namespaceList {
if strings.TrimSpace(ns) == argocdTargetNamespace {
err := fmt.Errorf("namespace %v still present in cluster secret namespace list", argocdTargetNamespace)
GinkgoT().Log(err.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s"
fixtureUtils "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"

"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -74,7 +73,7 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
Keycloak: &argov1alpha1api.ArgoCDKeycloakSpec{
RootCA: "\"---BEGIN---END---\"",
},
VerifyTLS: ptr.To(false),
VerifyTLS: new(false),
},
ExtraConfig: map[string]string{
"oidc.tls.insecure.skip.verify": "true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -71,7 +70,7 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
},
},
ApplicationSet: &argov1beta1api.ArgoCDApplicationSet{
Enabled: ptr.To(true),
Enabled: new(true),
WebhookServer: argov1beta1api.WebhookServerSpec{
Host: "example.com",
Route: argov1beta1api.ArgoCDRouteSpec{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"

"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -103,21 +102,21 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
{
Name: "ssh-known-hosts", VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
LocalObjectReference: corev1.LocalObjectReference{Name: "argocd-ssh-known-hosts-cm"}},
},
},
{
Name: "tls-certs", VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
LocalObjectReference: corev1.LocalObjectReference{Name: "argocd-tls-certs-cm"}},
},
},
{
Name: "gpg-keys", VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
DefaultMode: ptr.To(int32(420)),
DefaultMode: new(int32(420)),
LocalObjectReference: corev1.LocalObjectReference{
Name: "argocd-gpg-keys-cm",
},
Expand Down
Loading
Loading