UNCLASSIFIED
Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Platform One
P
Party Bus
Valkyrie
valkyrie-api
Commits
9faa2bfe
Commit
9faa2bfe
authored
Jul 16, 2021
by
Jason van Brackel
Browse files
feat: Add CI/CD settings to Project
parent
19224546
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
controllers/gitlab/project_controller.go
controllers/gitlab/project_controller.go
+14
-12
No files found.
controllers/gitlab/project_controller.go
View file @
9faa2bfe
...
...
@@ -68,18 +68,11 @@ const ManifestImageVariableName = "MANIFEST_IMAGE"
const
annotationKeyID
=
"ID"
// Setup General Pipelines
// Enable Public Pipelines
// Enable Auto-cancel redundant pipelines
// Enable skip outdated deployment jobs
// Set CI/CD Configuration file to products/{group}/{project-path}-ci.yml@platform-one/devops/pipeline-products
// Setup Artifacts
// Enable keep artifacts from most recent successful jobs
// TODO Setup Variables (Group Controller & Group Object needs updated here)
// KUSTOMIZE_PRODUCTION_PATH
// KUSTOMIZE_STAGING_PATH
// MAINIFEST_REPO_PATH
// Reconcile is the main reconciliation loop that will create/edit/delete Gitlab Projects.
func
(
r
*
ProjectReconciler
)
Reconcile
(
ctx
context
.
Context
,
req
ctrl
.
Request
)
(
ctrl
.
Result
,
error
)
{
...
...
@@ -135,7 +128,7 @@ func (r *ProjectReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
}
}
if
gitlabProject
,
err
=
r
.
updateGitlabProject
(
id
,
project
);
err
!=
nil
{
if
gitlabProject
,
err
=
r
.
updateGitlabProject
(
id
,
project
,
gitlabProject
);
err
!=
nil
{
r
.
Log
.
Error
(
err
,
errorUpdatingGitlabProject
)
_
=
r
.
updateStatus
(
ctx
,
project
,
errorUpdatingGitlabProject
)
return
ctrl
.
Result
{
Requeue
:
true
},
err
...
...
@@ -213,9 +206,16 @@ func (r *ProjectReconciler) getGitlabProject(id int) (*gitlab.Project, error) {
func
(
r
*
ProjectReconciler
)
createGitlabProject
(
project
*
v1alpha1
.
Project
)
(
*
gitlab
.
Project
,
error
)
{
var
gitLabProject
*
gitlab
.
Project
var
err
error
autoCancelPendingPipelines
:=
"enabled"
ciForwardDeploymentEnabled
:=
true
publicBuilds
:=
true
createProjectOptions
:=
gitlab
.
CreateProjectOptions
{
Name
:
&
project
.
Spec
.
Name
,
Path
:
&
project
.
Spec
.
FullPath
,
Name
:
&
project
.
Spec
.
Name
,
Path
:
&
project
.
Spec
.
FullPath
,
AutoCancelPendingPipelines
:
&
autoCancelPendingPipelines
,
CIForwardDeploymentEnabled
:
&
ciForwardDeploymentEnabled
,
PublicBuilds
:
&
publicBuilds
,
}
if
gitLabProject
,
_
,
err
=
r
.
gitlabClient
.
AddProject
(
createProjectOptions
);
err
!=
nil
{
return
nil
,
err
...
...
@@ -224,12 +224,14 @@ func (r *ProjectReconciler) createGitlabProject(project *v1alpha1.Project) (*git
return
gitLabProject
,
nil
}
func
(
r
*
ProjectReconciler
)
updateGitlabProject
(
id
int
,
project
*
v1alpha1
.
Project
)
(
*
gitlab
.
Project
,
error
)
{
func
(
r
*
ProjectReconciler
)
updateGitlabProject
(
id
int
,
project
*
v1alpha1
.
Project
,
gitlabProject
*
gitlab
.
Project
)
(
*
gitlab
.
Project
,
error
)
{
var
gitLabProject
*
gitlab
.
Project
var
err
error
if
gitLabProject
,
_
,
err
=
r
.
gitlabClient
.
UpdateProject
(
id
,
gitlab
.
EditProjectOptions
{
Name
:
&
project
.
Spec
.
Name
,
Path
:
&
project
.
Spec
.
FullPath
,
CIForwardDeploymentEnabled
:
&
gitlabProject
.
CIForwardDeploymentEnabled
,
PublicBuilds
:
&
gitlabProject
.
PublicBuilds
,
});
err
!=
nil
{
return
nil
,
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment