Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-pages-site-operator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
paas-tools
operators
gitlab-pages-site-operator
Commits
cd65891b
Commit
cd65891b
authored
3 months ago
by
Chrysoula Dikonimaki
Browse files
Options
Downloads
Patches
Plain Diff
check that ClientCredentialsSecret is set in appreg and validate secret
parent
411ac25e
No related branches found
No related tags found
1 merge request
!21
Update reconcile loop to check Secret instead of provisionStatus on ApplicationRegistration
Checking pipeline status
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
controllers/operator_methods.go
+10
-2
10 additions, 2 deletions
controllers/operator_methods.go
with
10 additions
and
2 deletions
controllers/operator_methods.go
+
10
−
2
View file @
cd65891b
...
@@ -3,7 +3,6 @@ package controllers
...
@@ -3,7 +3,6 @@ package controllers
import
(
import
(
"context"
"context"
"fmt"
"fmt"
"reflect"
routev1
"github.com/openshift/api/route/v1"
routev1
"github.com/openshift/api/route/v1"
authzalpha1
"gitlab.cern.ch/paas-tools/operators/authz-operator/api/v1alpha1"
authzalpha1
"gitlab.cern.ch/paas-tools/operators/authz-operator/api/v1alpha1"
...
@@ -39,7 +38,7 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag
...
@@ -39,7 +38,7 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag
// Ensure we have a valid ApplicationRegistration registration, this only happens when we have exactly one ApplicationRegistration
// Ensure we have a valid ApplicationRegistration registration, this only happens when we have exactly one ApplicationRegistration
// with a status set by the authz-operator and this status says provisioning succeeded
// with a status set by the authz-operator and this status says provisioning succeeded
if
!
reflect
.
DeepEqual
(
appReg
.
Status
,
authzalpha1
.
ApplicationRegistrationStatus
{})
&&
appReg
.
Status
.
ClientCredentialsSecret
!
=
"
oidc-client-secret
"
{
if
appReg
.
Status
.
ClientCredentialsSecret
=
=
""
{
meta
.
SetStatusCondition
(
&
gitlabPagesSite
.
Status
.
Conditions
,
metav1
.
Condition
{
meta
.
SetStatusCondition
(
&
gitlabPagesSite
.
Status
.
Conditions
,
metav1
.
Condition
{
Type
:
webservicescernchv1alpha1
.
ConditionTypeGitlabPagesSiteCreated
,
Type
:
webservicescernchv1alpha1
.
ConditionTypeGitlabPagesSiteCreated
,
Status
:
metav1
.
ConditionFalse
,
Status
:
metav1
.
ConditionFalse
,
...
@@ -56,6 +55,7 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag
...
@@ -56,6 +55,7 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag
return
nil
,
err
return
nil
,
err
}
}
// Retrieve OIDC secret
oidcSecret
:=
&
v1
.
Secret
{}
oidcSecret
:=
&
v1
.
Secret
{}
namespacedName
:=
types
.
NamespacedName
{
namespacedName
:=
types
.
NamespacedName
{
Name
:
appReg
.
Status
.
ClientCredentialsSecret
,
Name
:
appReg
.
Status
.
ClientCredentialsSecret
,
...
@@ -67,6 +67,14 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag
...
@@ -67,6 +67,14 @@ func (r *GitlabPagesSiteReconciler) getOidcSecret(ctx context.Context, gitlabPag
return
nil
,
err
return
nil
,
err
}
}
// Validate that the secret contains the required data
requiredFields
:=
[]
string
{
"clientID"
,
"clientSecret"
,
"issuerURL"
}
for
_
,
field
:=
range
requiredFields
{
if
value
,
exists
:=
oidcSecret
.
Data
[
field
];
!
exists
||
len
(
value
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"secret '%s' in namespace '%s' is missing required field or has empty value: %s"
,
appReg
.
Status
.
ClientCredentialsSecret
,
gitlabPagesSite
.
Namespace
,
field
)
}
}
return
oidcSecret
,
nil
return
oidcSecret
,
nil
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment