Skip to content
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.

Commit

Permalink
Fix dockerconfigjson secret namespace and name swap issue. Move sourc…
Browse files Browse the repository at this point in the history
…es to func in main driver. (#17)
  • Loading branch information
wtam2018 authored and chetan-rns committed Feb 25, 2020
1 parent eee2b6b commit e8c5d65
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions pkg/pipelines/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ func Bootstrap(o *BootstrapOptions) error {
}

// Create Pipelines
outputs = append(outputs, createDevCIPipeline(meta.NamespacedName(namespaces["cicd"], "dev-ci-pipeline")))
outputs = append(outputs, createStageCIPipeline(meta.NamespacedName(namespaces["cicd"], "stage-ci-pipeline"), namespaces["stage"]))
outputs = append(outputs, createDevCDPipeline(meta.NamespacedName(namespaces["cicd"], "dev-cd-pipeline"), o.DeploymentPath, namespaces["dev"]))
outputs = append(outputs, createStageCDPipeline(meta.NamespacedName(namespaces["cicd"], "stage-cd-pipeline"), namespaces["stage"]))
outputs = append(outputs, createPipelines(namespaces, o.DeploymentPath))

// Create Event Listener
eventListener := eventlisteners.Generate(o.GitRepo, namespaces["cicd"])
Expand All @@ -117,15 +114,35 @@ func Bootstrap(o *BootstrapOptions) error {
outputs = append(outputs, sa)
role := createRole(meta.NamespacedName(namespaces["cicd"], roleName), rules)
outputs = append(outputs, role)
outputs = append(outputs, createRoleBinding(meta.NamespacedName(namespaces["cicd"], roleBindingName), sa, role.Kind, role.Name))
outputs = append(outputs, createRoleBinding(meta.NamespacedName("", "edit-clusterrole-binding"), sa, "ClusterRole", "edit"))

outputs = append(outputs, createRoleBinding(meta.NamespacedName(namespaces["cicd"], devRoleBindingName), sa, "ClusterRole", "edit"))
outputs = append(outputs, createRoleBinding(meta.NamespacedName(namespaces["cicd"], stageRoleBindingName), sa, "ClusterRole", "edit"))
outputs = append(outputs, createRoleBindings(namespaces))

return marshalOutputs(os.Stdout, outputs)
}

func createRoleBindings(ns map[string]string) []interface{} {
out := make([]interface{}, 0)
sa := createServiceAccount(meta.NamespacedName(ns["cicd"], saName), dockerSecretName)
out = append(out, sa)
role := createRole(meta.NamespacedName(ns["cicd"], roleName), rules)
out = append(out, role)
out = append(out, createRoleBinding(meta.NamespacedName(roleBindingName, ns["cicd"]), sa, role.Kind, role.Name))
out = append(out, createRoleBinding(meta.NamespacedName("edit-clusterrole-binding", ""), sa, "ClusterRole", "edit"))
return out
}

func createPipelines(ns map[string]string, deploymentPath string) []interface{} {
out := make([]interface{}, 0)
out = append(out, createDevCIPipeline(meta.NamespacedName(ns["cicd"], "dev-ci-pipeline")))
out = append(out, createStageCIPipeline(meta.NamespacedName(ns["cicd"], "stage-ci-pipeline"), ns["stage"]))
out = append(out, createDevCDPipeline(meta.NamespacedName(ns["cicd"], "dev-cd-pipeline"), deploymentPath, ns["dev"]))
out = append(out, createStageCDPipeline(meta.NamespacedName(ns["cicd"], "stage-cd-pipeline"), ns["stage"]))
return out

}

// createDockerSecret creates Docker secret
func createDockerSecret(quayIOAuthFilename, ns string) (*corev1.Secret, error) {

Expand Down

0 comments on commit e8c5d65

Please sign in to comment.