diff --git a/apis/lagoon/v1beta2/lagoontask_types.go b/apis/lagoon/v1beta2/lagoontask_types.go index cc1d18a2..7ed56687 100644 --- a/apis/lagoon/v1beta2/lagoontask_types.go +++ b/apis/lagoon/v1beta2/lagoontask_types.go @@ -130,7 +130,7 @@ type LagoonMiscBackupInfo struct { // LagoonTaskProject defines the lagoon project information. type LagoonTaskProject struct { - ID string `json:"id"` // should be int, but the api sends it as a string :\ + ID *uint `json:"id,omitempty"` Name string `json:"name"` NamespacePattern string `json:"namespacePattern,omitempty"` Variables LagoonVariables `json:"variables,omitempty"` @@ -139,7 +139,7 @@ type LagoonTaskProject struct { // LagoonTaskEnvironment defines the lagoon environment information. type LagoonTaskEnvironment struct { - ID string `json:"id"` // should be int, but the api sends it as a string :\ + ID *uint `json:"id,omitempty"` Name string `json:"name"` Project string `json:"project"` // should be int, but the api sends it as a string :\ EnvironmentType string `json:"environmentType"` diff --git a/apis/lagoon/v1beta2/zz_generated.deepcopy.go b/apis/lagoon/v1beta2/zz_generated.deepcopy.go index 54401dc6..b8802ec1 100644 --- a/apis/lagoon/v1beta2/zz_generated.deepcopy.go +++ b/apis/lagoon/v1beta2/zz_generated.deepcopy.go @@ -278,6 +278,11 @@ func (in *LagoonTaskConditions) DeepCopy() *LagoonTaskConditions { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LagoonTaskEnvironment) DeepCopyInto(out *LagoonTaskEnvironment) { *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(uint) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LagoonTaskEnvironment. @@ -325,6 +330,11 @@ func (in *LagoonTaskList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LagoonTaskProject) DeepCopyInto(out *LagoonTaskProject) { *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(uint) + **out = **in + } in.Variables.DeepCopyInto(&out.Variables) if in.Organization != nil { in, out := &in.Organization, &out.Organization @@ -348,7 +358,7 @@ func (in *LagoonTaskSpec) DeepCopyInto(out *LagoonTaskSpec) { *out = *in out.Task = in.Task in.Project.DeepCopyInto(&out.Project) - out.Environment = in.Environment + in.Environment.DeepCopyInto(&out.Environment) if in.Misc != nil { in, out := &in.Misc, &out.Misc *out = new(LagoonMiscInfo) diff --git a/config/crd/bases/crd.lagoon.sh_lagoontasks.yaml b/config/crd/bases/crd.lagoon.sh_lagoontasks.yaml index 5be4d4aa..bdb06319 100644 --- a/config/crd/bases/crd.lagoon.sh_lagoontasks.yaml +++ b/config/crd/bases/crd.lagoon.sh_lagoontasks.yaml @@ -703,14 +703,13 @@ spec: environmentType: type: string id: - type: string + type: integer name: type: string project: type: string required: - environmentType - - id - name - project type: object @@ -751,7 +750,7 @@ spec: description: LagoonTaskProject defines the lagoon project information. properties: id: - type: string + type: integer name: type: string namespacePattern: @@ -775,7 +774,6 @@ spec: type: string type: object required: - - id - name type: object task: diff --git a/controllers/v1beta2/build_helpers.go b/controllers/v1beta2/build_helpers.go index 1d07dc85..7ea4d7ee 100644 --- a/controllers/v1beta2/build_helpers.go +++ b/controllers/v1beta2/build_helpers.go @@ -463,6 +463,18 @@ func (r *LagoonBuildReconciler) processBuild(ctx context.Context, opLog logr.Log Value: helpers.GetAPIValues(r.LagoonAPIConfiguration, "LAGOON_CONFIG_SSH_PORT"), }, } + if lagoonBuild.Spec.Project.EnvironmentID != nil { + podEnvs = append(podEnvs, corev1.EnvVar{ + Name: "ENVIRONMENT_ID", + Value: strconv.Itoa(int(*lagoonBuild.Spec.Project.EnvironmentID)), + }) + } + if lagoonBuild.Spec.Project.ID != nil { + podEnvs = append(podEnvs, corev1.EnvVar{ + Name: "PROJECT_ID", + Value: strconv.Itoa(int(*lagoonBuild.Spec.Project.ID)), + }) + } // add proxy variables to builds if they are defined if r.ProxyConfig.HTTPProxy != "" { podEnvs = append(podEnvs, corev1.EnvVar{ diff --git a/controllers/v1beta2/podmonitor_taskhandlers.go b/controllers/v1beta2/podmonitor_taskhandlers.go index dc6aaebc..45b75027 100644 --- a/controllers/v1beta2/podmonitor_taskhandlers.go +++ b/controllers/v1beta2/podmonitor_taskhandlers.go @@ -181,8 +181,8 @@ func (r *LagoonMonitorReconciler) updateLagoonTask(opLog logr.Logger, Task: &lagoonTask.Spec.Task, Environment: lagoonTask.Spec.Environment.Name, Project: lagoonTask.Spec.Project.Name, - EnvironmentID: helpers.StringToUintPtr(lagoonTask.Spec.Environment.ID), - ProjectID: helpers.StringToUintPtr(lagoonTask.Spec.Project.ID), + EnvironmentID: lagoonTask.Spec.Environment.ID, + ProjectID: lagoonTask.Spec.Project.ID, JobName: lagoonTask.ObjectMeta.Name, JobStatus: condition, RemoteID: string(jobPod.ObjectMeta.UID), @@ -237,8 +237,8 @@ func (r *LagoonMonitorReconciler) taskStatusLogsToLagoonLogs(opLog logr.Logger, Task: &lagoonTask.Spec.Task, ProjectName: lagoonTask.Spec.Project.Name, Environment: lagoonTask.Spec.Environment.Name, - EnvironmentID: helpers.StringToUintPtr(lagoonTask.Spec.Environment.ID), - ProjectID: helpers.StringToUintPtr(lagoonTask.Spec.Project.ID), + EnvironmentID: lagoonTask.Spec.Environment.ID, + ProjectID: lagoonTask.Spec.Project.ID, JobName: lagoonTask.ObjectMeta.Name, JobStatus: condition, RemoteID: string(jobPod.ObjectMeta.UID), diff --git a/controllers/v1beta2/task_controller.go b/controllers/v1beta2/task_controller.go index 429a63b7..cd138fff 100644 --- a/controllers/v1beta2/task_controller.go +++ b/controllers/v1beta2/task_controller.go @@ -182,6 +182,18 @@ func (r *LagoonTaskReconciler) getTaskPodDeployment(ctx context.Context, lagoonT Name: "TASK_DATA_ID", Value: lagoonTask.Spec.Task.ID, }) + if lagoonTask.Spec.Project.ID != nil { + dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ + Name: "LAGOON_PROJECT_ID", + Value: strconv.Itoa(int(*lagoonTask.Spec.Project.ID)), + }) + } + if lagoonTask.Spec.Environment.ID != nil { + dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{ + Name: "LAGOON_ENVIRONMENT_ID", + Value: strconv.Itoa(int(*lagoonTask.Spec.Environment.ID)), + }) + } // add proxy variables to builds if they are defined if r.ProxyConfig.HTTPProxy != "" { dep.Spec.Template.Spec.Containers[idx].Env = append(dep.Spec.Template.Spec.Containers[idx].Env, corev1.EnvVar{