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
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@

rolloutManagerApi "github.com/argoproj-labs/argo-rollouts-manager/api/v1alpha1"
rolloutManagerProvisioner "github.com/argoproj-labs/argo-rollouts-manager/controllers"
argov1alpha1api "github.com/argoproj-labs/argocd-operator/api/v1alpha1"

Check failure on line 35 in cmd/main.go

View workflow job for this annotation

GitHub Actions / Check for changes from make bundle

github.com/argoproj-labs/argocd-operator@v0.17.0-rc1.0.20260127035221-4f29ed709c5e: replacement directory ./argocd-operator does not exist
argov1beta1api "github.com/argoproj-labs/argocd-operator/api/v1beta1"

Check failure on line 36 in cmd/main.go

View workflow job for this annotation

GitHub Actions / Check for changes from make bundle

github.com/argoproj-labs/argocd-operator@v0.17.0-rc1.0.20260127035221-4f29ed709c5e: replacement directory ./argocd-operator does not exist
argocdcommon "github.com/argoproj-labs/argocd-operator/common"

Check failure on line 37 in cmd/main.go

View workflow job for this annotation

GitHub Actions / Check for changes from make bundle

github.com/argoproj-labs/argocd-operator@v0.17.0-rc1.0.20260127035221-4f29ed709c5e: replacement directory ./argocd-operator does not exist
argocdprovisioner "github.com/argoproj-labs/argocd-operator/controllers/argocd"

Check failure on line 38 in cmd/main.go

View workflow job for this annotation

GitHub Actions / Check for changes from make bundle

github.com/argoproj-labs/argocd-operator@v0.17.0-rc1.0.20260127035221-4f29ed709c5e: replacement directory ./argocd-operator does not exist
"github.com/argoproj-labs/argocd-operator/controllers/argoutil"

Check failure on line 39 in cmd/main.go

View workflow job for this annotation

GitHub Actions / Check for changes from make bundle

github.com/argoproj-labs/argocd-operator@v0.17.0-rc1.0.20260127035221-4f29ed709c5e: replacement directory ./argocd-operator does not exist
notificationsprovisioner "github.com/argoproj-labs/argocd-operator/controllers/notificationsconfiguration"

Check failure on line 40 in cmd/main.go

View workflow job for this annotation

GitHub Actions / Check for changes from make bundle

github.com/argoproj-labs/argocd-operator@v0.17.0-rc1.0.20260127035221-4f29ed709c5e: replacement directory ./argocd-operator does not exist
"github.com/argoproj-labs/argocd-operator/pkg/cacheutils"

Check failure on line 41 in cmd/main.go

View workflow job for this annotation

GitHub Actions / Check for changes from make bundle

github.com/argoproj-labs/argocd-operator@v0.17.0-rc1.0.20260127035221-4f29ed709c5e: replacement directory ./argocd-operator does not exist
cw "github.com/argoproj-labs/argocd-operator/pkg/clientwrapper"

Check failure on line 42 in cmd/main.go

View workflow job for this annotation

GitHub Actions / Check for changes from make bundle

github.com/argoproj-labs/argocd-operator@v0.17.0-rc1.0.20260127035221-4f29ed709c5e: replacement directory ./argocd-operator does not exist
appsv1 "github.com/openshift/api/apps/v1"
configv1 "github.com/openshift/api/config/v1"
console "github.com/openshift/api/console/v1"
Expand Down Expand Up @@ -221,6 +221,7 @@
if err = (&controllers.ReconcileGitopsService{
Client: client,
Scheme: mgr.GetScheme(),
Config: mgr.GetConfig(),
DisableDefaultInstall: strings.ToLower(os.Getenv(common.DisableDefaultInstallEnvVar)) == "true",
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "GitopsService")
Expand Down Expand Up @@ -260,6 +261,7 @@
if err = (&argocdprovisioner.ReconcileArgoCD{
Client: client,
Scheme: mgr.GetScheme(),
Config: mgr.GetConfig(),
LabelSelector: labelSelectorFlag,
K8sClient: k8sClient,
LocalUsers: &argocdprovisioner.LocalUsersInfo{
Expand Down
9 changes: 6 additions & 3 deletions controllers/argocd/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ func getArgoDexSpec() *argoapp.ArgoCDDexSpec {
}
}

func getArgoSSOSpec() *argoapp.ArgoCDSSOSpec {
func getArgoSSOSpec(oAuthEnabled bool) *argoapp.ArgoCDSSOSpec {
if !oAuthEnabled {
return nil
}
return &argoapp.ArgoCDSSOSpec{
Provider: argoapp.SSOProviderTypeDex,
Dex: getArgoDexSpec(),
Expand Down Expand Up @@ -180,7 +183,7 @@ func getDefaultRBAC() argoapp.ArgoCDRBACSpec {

// NewCR returns an ArgoCD reference optimized for use in OpenShift
// with comprehensive default resource exclusions
func NewCR(name, ns string) (*argoapp.ArgoCD, error) {
func NewCR(name, ns string, oAuthEnabled bool) (*argoapp.ArgoCD, error) {
b, err := yaml.Marshal([]resource{
{
APIGroups: []string{"", "discovery.k8s.io"},
Expand Down Expand Up @@ -239,7 +242,7 @@ func NewCR(name, ns string) (*argoapp.ArgoCD, error) {
Spec: argoapp.ArgoCDSpec{
ApplicationSet: getArgoApplicationSetSpec(),
Controller: getArgoControllerSpec(),
SSO: getArgoSSOSpec(),
SSO: getArgoSSOSpec(oAuthEnabled),
Grafana: getArgoGrafanaSpec(),
HA: getArgoHASpec(),
Redis: getArgoRedisSpec(),
Expand Down
4 changes: 2 additions & 2 deletions controllers/argocd/argocd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

func TestArgoCD(t *testing.T) {
testArgoCD, _ := NewCR("openshift-gitops", "openshift-gitops")
testArgoCD, _ := NewCR("openshift-gitops", "openshift-gitops", false)

testApplicationSetResources := &v1.ResourceRequirements{
Requests: v1.ResourceList{
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestArgoCD(t *testing.T) {
}

func TestDexConfiguration(t *testing.T) {
testArgoCD, _ := NewCR("openshift-gitops", "openshift-gitops")
testArgoCD, _ := NewCR("openshift-gitops", "openshift-gitops", false)

// Verify Dex OpenShift Configuration
assert.Equal(t, testArgoCD.Spec.SSO.Dex.OpenShiftOAuth, true)
Expand Down
47 changes: 40 additions & 7 deletions controllers/gitopsservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ import (
"reflect"
"strings"

apierrors "k8s.io/apimachinery/pkg/api/errors"

argoapp "github.com/argoproj-labs/argocd-operator/api/v1beta1"
argocommon "github.com/argoproj-labs/argocd-operator/common"
argocdcontroller "github.com/argoproj-labs/argocd-operator/controllers/argocd"
argocdutil "github.com/argoproj-labs/argocd-operator/controllers/argoutil"
"github.com/argoproj/argo-cd/v3/pkg/client/clientset/versioned/scheme"
"github.com/go-logr/logr"
version "github.com/hashicorp/go-version"
routev1 "github.com/openshift/api/route/v1"
Expand All @@ -43,8 +46,10 @@ import (
resourcev1 "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -132,6 +137,7 @@ type ReconcileGitopsService struct {

// disableDefaultInstall, if true, will ensure that the default ArgoCD instance is not instantiated in the openshift-gitops namespace.
DisableDefaultInstall bool
Config *rest.Config
}

//+kubebuilder:rbac:groups=pipelines.openshift.io,resources=gitopsservices,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -210,7 +216,7 @@ type ReconcileGitopsService struct {
func (r *ReconcileGitopsService) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
reqLogger := logs.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name)
reqLogger.Info("Reconciling GitopsService")

oAuthEnabled, _ := oAuthEndpointReachable(r.Config)
// Fetch the GitopsService instance
instance := &pipelinesv1alpha1.GitopsService{}
err := r.Client.Get(ctx, types.NamespacedName{Name: serviceName}, instance)
Expand Down Expand Up @@ -260,13 +266,13 @@ func (r *ReconcileGitopsService) Reconcile(ctx context.Context, request reconcil

if !r.DisableDefaultInstall {
// Create/reconcile the default Argo CD instance, unless default install is disabled
if result, err := r.reconcileDefaultArgoCDInstance(instance, reqLogger); err != nil {
if result, err := r.reconcileDefaultArgoCDInstance(instance, reqLogger, oAuthEnabled); err != nil {
return result, fmt.Errorf("unable to reconcile default Argo CD instance: %v", err)
}
} else {
// If installation of default Argo CD instance is disabled, make sure it doesn't exist,
// deleting it if necessary
if err := r.ensureDefaultArgoCDInstanceDoesntExist(); err != nil {
if err := r.ensureDefaultArgoCDInstanceDoesntExist(oAuthEnabled); err != nil {
return reconcile.Result{}, fmt.Errorf("unable to ensure non-existence of default Argo CD instance: %v", err)
}
}
Expand Down Expand Up @@ -311,9 +317,36 @@ func (r *ReconcileGitopsService) Reconcile(ctx context.Context, request reconcil
}
}

func (r *ReconcileGitopsService) ensureDefaultArgoCDInstanceDoesntExist() error {
func oAuthEndpointReachable(cfg *rest.Config) (bool, error) {
if cfg == nil {
return false, fmt.Errorf("rest.Config is nil")
}

restCfg := rest.CopyConfig(cfg)
restCfg.APIPath = "/"
restCfg.GroupVersion = &schema.GroupVersion{}
restCfg.NegotiatedSerializer = scheme.Codecs.WithoutConversion()

client, err := rest.UnversionedRESTClientFor(restCfg)
if err != nil {
return false, err
}

raw, err := client.Get().AbsPath("/.well-known/oauth-authorization-server").Do(context.TODO()).Raw()

if err != nil {
if apierrors.IsNotFound(err) {
return false, fmt.Errorf("OAuth endpoint not found at /.well-known/oauth-authorization-server")
}
return false, err
}

return len(raw) > 0, nil
}

func (r *ReconcileGitopsService) ensureDefaultArgoCDInstanceDoesntExist(oAuthEnabled bool) error {

defaultArgoCDInstance, err := argocd.NewCR(common.ArgoCDInstanceName, serviceNamespace)
defaultArgoCDInstance, err := argocd.NewCR(common.ArgoCDInstanceName, serviceNamespace, oAuthEnabled)
if err != nil {
return err
}
Expand Down Expand Up @@ -347,9 +380,9 @@ func (r *ReconcileGitopsService) ensureDefaultArgoCDInstanceDoesntExist() error
return nil
}

func (r *ReconcileGitopsService) reconcileDefaultArgoCDInstance(instance *pipelinesv1alpha1.GitopsService, reqLogger logr.Logger) (reconcile.Result, error) {
func (r *ReconcileGitopsService) reconcileDefaultArgoCDInstance(instance *pipelinesv1alpha1.GitopsService, reqLogger logr.Logger, oAuthEnabled bool) (reconcile.Result, error) {

defaultArgoCDInstance, err := argocd.NewCR(common.ArgoCDInstanceName, serviceNamespace)
defaultArgoCDInstance, err := argocd.NewCR(common.ArgoCDInstanceName, serviceNamespace, oAuthEnabled)
if err != nil {
return reconcile.Result{}, err
}
Expand Down
85 changes: 45 additions & 40 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
module github.com/redhat-developer/gitops-operator

go 1.25.0
go 1.25.5

replace github.com/argoproj-labs/argocd-operator => ./argocd-operator

require (
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251105123110-0c547c7a7765
github.com/argoproj-labs/argocd-operator v0.17.0-rc1.0.20260203113103-c057992e286f
github.com/argoproj/argo-cd/v3 v3.2.3
github.com/argoproj-labs/argocd-operator v0.17.0-rc1.0.20260127035221-4f29ed709c5e
github.com/argoproj/argo-cd/v3 v3.3.0
github.com/argoproj/gitops-engine v0.7.1-0.20251217140045-5baed5604d2d
github.com/go-logr/logr v1.4.3
github.com/google/go-cmp v0.7.0
github.com/google/uuid v1.6.1-0.20241114170450-2d3c2a9cc518
github.com/hashicorp/go-version v1.7.0
github.com/onsi/ginkgo/v2 v2.25.3
github.com/onsi/gomega v1.39.0
github.com/onsi/ginkgo/v2 v2.28.1
github.com/onsi/gomega v1.39.1
github.com/openshift/api v0.0.0-20240906151052-5d963dce87aa
github.com/operator-framework/api v0.17.5
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.73.2
github.com/stretchr/testify v1.11.1
go.uber.org/zap v1.27.1
golang.org/x/mod v0.31.0
golang.org/x/mod v0.32.0
gopkg.in/yaml.v3 v3.0.1
gotest.tools v2.2.0+incompatible
k8s.io/api v0.34.0
k8s.io/apiextensions-apiserver v0.34.0
k8s.io/apimachinery v0.34.0
k8s.io/client-go v0.34.0
k8s.io/api v0.34.1
k8s.io/apiextensions-apiserver v0.34.1
k8s.io/apimachinery v0.34.1
k8s.io/client-go v0.34.1
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
sigs.k8s.io/controller-runtime v0.21.0
sigs.k8s.io/controller-runtime v0.22.3
sigs.k8s.io/yaml v1.6.0
)

require (
cloud.google.com/go/compute/metadata v0.7.0 // indirect
cloud.google.com/go/compute/metadata v0.9.0 // indirect
cyphar.com/go-pathrs v0.2.1 // indirect
dario.cat/mergo v1.0.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.11.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
Expand All @@ -46,16 +49,18 @@ require (
github.com/argoproj/pkg/v2 v2.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect
github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect
github.com/bombsimon/logrusr/v4 v4.1.0 // indirect
github.com/bradleyfalzon/ghinstallation/v2 v2.17.0 // indirect
github.com/casbin/casbin/v2 v2.123.0 // indirect
github.com/casbin/casbin/v2 v2.135.0 // indirect
github.com/casbin/govaluate v1.10.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cert-manager/cert-manager v1.15.4 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chai2010/gettext-go v1.0.3 // indirect
github.com/chainguard-dev/git-urls v1.0.2 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/distribution/reference v0.6.0 // indirect
Expand All @@ -72,9 +77,10 @@ require (
github.com/go-git/go-billy/v5 v5.6.2 // indirect
github.com/go-git/go-git/v5 v5.16.2 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.21.1 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/jsonpointer v0.22.1 // indirect
github.com/go-openapi/jsonreference v0.21.3 // indirect
github.com/go-openapi/swag v0.23.1 // indirect
github.com/go-openapi/swag/jsonname v0.25.1 // indirect
github.com/go-redis/cache/v9 v9.0.0 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gobwas/glob v0.2.3 // indirect
Expand All @@ -87,7 +93,7 @@ require (
github.com/google/go-github/v69 v69.2.0 // indirect
github.com/google/go-github/v75 v75.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down Expand Up @@ -124,11 +130,11 @@ require (
github.com/redis/go-redis/v9 v9.8.0 // indirect
github.com/robfig/cron/v3 v3.0.2-0.20210106135023-bc59245fe10e // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/sergi/go-diff v1.4.0 // indirect
github.com/sethvargo/go-password v0.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sirupsen/logrus v1.9.4 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/spf13/cobra v1.10.1 // indirect
github.com/spf13/cobra v1.10.2 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/vmihailenco/go-tinylfu v0.2.2 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
Expand All @@ -138,30 +144,29 @@ require (
github.com/xlab/treeprint v1.2.0 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.46.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.31.0 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/net v0.49.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/term v0.38.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/time v0.13.0 // indirect
golang.org/x/tools v0.39.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/term v0.39.0 // indirect
golang.org/x/text v0.33.0 // indirect
golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.41.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect
google.golang.org/grpc v1.76.0 // indirect
google.golang.org/protobuf v1.36.9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect
google.golang.org/grpc v1.77.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/apiserver v0.34.0 // indirect
k8s.io/apiserver v0.34.1 // indirect
k8s.io/cli-runtime v0.34.0 // indirect
k8s.io/component-base v0.34.0 // indirect
k8s.io/component-base v0.34.1 // indirect
k8s.io/component-helpers v0.34.0 // indirect
k8s.io/controller-manager v0.34.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
Expand All @@ -172,8 +177,8 @@ require (
oras.land/oras-go/v2 v2.6.0 // indirect
sigs.k8s.io/gateway-api v1.1.0 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/kustomize/api v0.20.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.20.1 // indirect
sigs.k8s.io/kustomize/api v0.21.0 // indirect
sigs.k8s.io/kustomize/kyaml v0.21.0 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.1-0.20251003215857-446d8398e19c // indirect
)
Expand Down
Loading
Loading