Skip to content

Commit

Permalink
Merge pull request #225 from uselagoon/deployertoken-injection
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon authored Sep 1, 2023
2 parents 04c8d4b + b011227 commit ea3f153
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 14 deletions.
18 changes: 10 additions & 8 deletions apis/lagoon/v1beta1/lagoontask_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,16 @@ type LagoonTaskSpec struct {

// LagoonTaskInfo defines what a task can use to communicate with Lagoon via SSH/API.
type LagoonTaskInfo struct {
ID string `json:"id"` // should be int, but the api sends it as a string :\
Name string `json:"name,omitempty"`
TaskName string `json:"taskName,omitempty"`
Service string `json:"service,omitempty"`
Command string `json:"command,omitempty"`
SSHHost string `json:"sshHost,omitempty"`
SSHPort string `json:"sshPort,omitempty"`
APIHost string `json:"apiHost,omitempty"`
ID string `json:"id"` // should be int, but the api sends it as a string :\
Name string `json:"name,omitempty"`
TaskName string `json:"taskName,omitempty"`
Service string `json:"service,omitempty"`
Command string `json:"command,omitempty"`
SSHHost string `json:"sshHost,omitempty"`
SSHPort string `json:"sshPort,omitempty"`
APIHost string `json:"apiHost,omitempty"`
DeployTokenInjection bool `json:"deployTokenInjection,omitempty"`
ProjectKeyInjection bool `json:"projectKeyInjection,omitempty"`
}

// LagoonAdvancedTaskInfo defines what an advanced task can use for the creation of the pod.
Expand Down
16 changes: 16 additions & 0 deletions config/crd/bases/crd.lagoon.sh_lagoonbuilds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,14 @@ spec:
type: string
command:
type: string
deployTokenInjection:
type: boolean
id:
type: string
name:
type: string
projectKeyInjection:
type: boolean
service:
type: string
sshHost:
Expand Down Expand Up @@ -357,10 +361,14 @@ spec:
type: string
command:
type: string
deployTokenInjection:
type: boolean
id:
type: string
name:
type: string
projectKeyInjection:
type: boolean
service:
type: string
sshHost:
Expand Down Expand Up @@ -448,10 +456,14 @@ spec:
type: string
command:
type: string
deployTokenInjection:
type: boolean
id:
type: string
name:
type: string
projectKeyInjection:
type: boolean
service:
type: string
sshHost:
Expand Down Expand Up @@ -541,10 +553,14 @@ spec:
type: string
command:
type: string
deployTokenInjection:
type: boolean
id:
type: string
name:
type: string
projectKeyInjection:
type: boolean
service:
type: string
sshHost:
Expand Down
20 changes: 20 additions & 0 deletions config/crd/bases/crd.lagoon.sh_lagoontasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,14 @@ spec:
type: string
command:
type: string
deployTokenInjection:
type: boolean
id:
type: string
name:
type: string
projectKeyInjection:
type: boolean
service:
type: string
sshHost:
Expand Down Expand Up @@ -250,10 +254,14 @@ spec:
type: string
command:
type: string
deployTokenInjection:
type: boolean
id:
type: string
name:
type: string
projectKeyInjection:
type: boolean
service:
type: string
sshHost:
Expand Down Expand Up @@ -339,10 +347,14 @@ spec:
type: string
command:
type: string
deployTokenInjection:
type: boolean
id:
type: string
name:
type: string
projectKeyInjection:
type: boolean
service:
type: string
sshHost:
Expand Down Expand Up @@ -430,10 +442,14 @@ spec:
type: string
command:
type: string
deployTokenInjection:
type: boolean
id:
type: string
name:
type: string
projectKeyInjection:
type: boolean
service:
type: string
sshHost:
Expand Down Expand Up @@ -523,10 +539,14 @@ spec:
type: string
command:
type: string
deployTokenInjection:
type: boolean
id:
type: string
name:
type: string
projectKeyInjection:
type: boolean
service:
type: string
sshHost:
Expand Down
8 changes: 4 additions & 4 deletions internal/messenger/tasks_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ func (m *Messenger) ActiveStandbySwitch(namespace string, jobSpec *lagoonv1beta1

// AdvancedTask handles running the ingress migrations.
func (m *Messenger) AdvancedTask(namespace string, jobSpec *lagoonv1beta1.LagoonTaskSpec) error {
if m.AdvancedTaskSSHKeyInjection {
jobSpec.AdvancedTask.SSHKey = true
if jobSpec.Task.DeployTokenInjection {
jobSpec.AdvancedTask.DeployerToken = jobSpec.Task.DeployTokenInjection
}
if m.AdvancedTaskDeployTokenInjection {
jobSpec.AdvancedTask.DeployerToken = true
if jobSpec.Task.ProjectKeyInjection {
jobSpec.AdvancedTask.SSHKey = jobSpec.Task.ProjectKeyInjection
}
return m.createAdvancedTask(namespace, jobSpec, nil)
}
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,11 @@ func main() {
flag.BoolVar(&tlsSkipVerify, "skip-tls-verify", false, "Flag to skip tls verification for http clients (harbor).")

// default the sshkey injection to true for now, eventually Lagoon should handle this for tasks that require it
// these are deprecated now and do nothing as the values are sourced from the lagoon task now
flag.BoolVar(&advancedTaskSSHKeyInjection, "advanced-task-sshkey-injection", true,
"Flag to specify injecting the sshkey for the environment into any advanced tasks.")
"DEPRECATED: Flag to specify injecting the sshkey for the environment into any advanced tasks.")
flag.BoolVar(&advancedTaskDeployToken, "advanced-task-deploytoken-injection", false,
"Flag to specify injecting the deploy token for the environment into any advanced tasks.")
"DEPRECATED: Flag to specify injecting the deploy token for the environment into any advanced tasks.")

flag.BoolVar(&cleanupHarborRepositoryOnDelete, "cleanup-harbor-repository-on-delete", false,
"Flag to specify if when deleting an environment, the associated harbor repository/images should be removed too.")
Expand Down

0 comments on commit ea3f153

Please sign in to comment.