UNCLASSIFIED

Commit 9faa2bfe authored by Jason van Brackel's avatar Jason van Brackel
Browse files

feat: Add CI/CD settings to Project

parent 19224546
...@@ -68,18 +68,11 @@ const ManifestImageVariableName = "MANIFEST_IMAGE" ...@@ -68,18 +68,11 @@ const ManifestImageVariableName = "MANIFEST_IMAGE"
const annotationKeyID = "ID" const annotationKeyID = "ID"
// Setup General Pipelines // 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 // Set CI/CD Configuration file to products/{group}/{project-path}-ci.yml@platform-one/devops/pipeline-products
// Setup Artifacts // 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. // 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) { 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 ...@@ -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.Log.Error(err, errorUpdatingGitlabProject)
_ = r.updateStatus(ctx, project, errorUpdatingGitlabProject) _ = r.updateStatus(ctx, project, errorUpdatingGitlabProject)
return ctrl.Result{Requeue: true}, err return ctrl.Result{Requeue: true}, err
...@@ -213,9 +206,16 @@ func (r *ProjectReconciler) getGitlabProject(id int) (*gitlab.Project, error) { ...@@ -213,9 +206,16 @@ func (r *ProjectReconciler) getGitlabProject(id int) (*gitlab.Project, error) {
func (r *ProjectReconciler) createGitlabProject(project *v1alpha1.Project) (*gitlab.Project, error) { func (r *ProjectReconciler) createGitlabProject(project *v1alpha1.Project) (*gitlab.Project, error) {
var gitLabProject *gitlab.Project var gitLabProject *gitlab.Project
var err error var err error
autoCancelPendingPipelines := "enabled"
ciForwardDeploymentEnabled := true
publicBuilds := true
createProjectOptions := gitlab.CreateProjectOptions{ createProjectOptions := gitlab.CreateProjectOptions{
Name: &project.Spec.Name, Name: &project.Spec.Name,
Path: &project.Spec.FullPath, Path: &project.Spec.FullPath,
AutoCancelPendingPipelines: &autoCancelPendingPipelines,
CIForwardDeploymentEnabled: &ciForwardDeploymentEnabled,
PublicBuilds: &publicBuilds,
} }
if gitLabProject, _, err = r.gitlabClient.AddProject(createProjectOptions); err != nil { if gitLabProject, _, err = r.gitlabClient.AddProject(createProjectOptions); err != nil {
return nil, err return nil, err
...@@ -224,12 +224,14 @@ func (r *ProjectReconciler) createGitlabProject(project *v1alpha1.Project) (*git ...@@ -224,12 +224,14 @@ func (r *ProjectReconciler) createGitlabProject(project *v1alpha1.Project) (*git
return gitLabProject, nil 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 gitLabProject *gitlab.Project
var err error var err error
if gitLabProject, _, err = r.gitlabClient.UpdateProject(id, gitlab.EditProjectOptions{ if gitLabProject, _, err = r.gitlabClient.UpdateProject(id, gitlab.EditProjectOptions{
Name: &project.Spec.Name, Name: &project.Spec.Name,
Path: &project.Spec.FullPath, Path: &project.Spec.FullPath,
CIForwardDeploymentEnabled: &gitlabProject.CIForwardDeploymentEnabled,
PublicBuilds: &gitlabProject.PublicBuilds,
}); err != nil { }); err != nil {
return nil, err return nil, err
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment