From c1f9cc95a6ebf7529952d51752870d96e143e27a Mon Sep 17 00:00:00 2001 From: Sergey Smolnikov Date: Tue, 16 Jan 2024 16:16:07 +0100 Subject: [PATCH] Added commit-id to deploying component, deploy component list to the pipeline job --- api/deployments/models/component_builder.go | 1 + api/deployments/models/component_deployment.go | 5 +++++ api/jobs/models/job.go | 15 +++++++++++++-- go.mod | 3 ++- go.sum | 4 ++++ swaggerui/html/swagger.json | 13 +++++++++++++ 6 files changed, 38 insertions(+), 3 deletions(-) diff --git a/api/deployments/models/component_builder.go b/api/deployments/models/component_builder.go index b44f887d..ce844a2b 100644 --- a/api/deployments/models/component_builder.go +++ b/api/deployments/models/component_builder.go @@ -231,6 +231,7 @@ func (b *componentBuilder) BuildComponent() (*Component, error) { Notifications: b.notifications, ExternalDNS: b.externalDNS, HorizontalScalingSummary: b.hpa, + CommitID: variables[defaults.RadixCommitHashEnvironmentVariable], }, b.buildError() } diff --git a/api/deployments/models/component_deployment.go b/api/deployments/models/component_deployment.go index 948aea4e..7599179d 100644 --- a/api/deployments/models/component_deployment.go +++ b/api/deployments/models/component_deployment.go @@ -103,6 +103,11 @@ type Component struct { // required: false ExternalDNS []ExternalDNS `json:"externalDNS,omitempty"` + // Commit ID for the component. In can be different from the Commit ID, defined for entire deployment + // + // required: false + CommitID string `json:",inline"` + AuxiliaryResource `json:",inline"` } diff --git a/api/jobs/models/job.go b/api/jobs/models/job.go index 7a04f51b..62b4f61d 100644 --- a/api/jobs/models/job.go +++ b/api/jobs/models/job.go @@ -123,6 +123,12 @@ type Job struct { // items: // "$ref": "#/definitions/ComponentSummary" Components []*deploymentModels.ComponentSummary `json:"components,omitempty"` + + // ComponentsToDeploy List of components to deploy + // OPTIONAL If specified, only these components are deployed + // + // example: component1,component2 + ComponentsToDeploy []string `json:"componentsToDeploy,omitempty"` } // GetJobFromRadixJob Gets job from a radix job @@ -161,6 +167,7 @@ func GetJobFromRadixJob(job *radixv1.RadixJob, jobDeployments []*deploymentModel case radixv1.Deploy: jobModel.ImageTagNames = job.Spec.Deploy.ImageTagNames jobModel.CommitID = job.Spec.Deploy.CommitID + jobModel.ComponentsToDeploy = job.Spec.Deploy.Components case radixv1.Promote: jobModel.PromotedFromDeployment = job.Spec.Promote.DeploymentName jobModel.PromotedFromEnvironment = job.Spec.Promote.FromEnvironment @@ -181,8 +188,12 @@ func GetJobStepsFromRadixJob(job *radixv1.RadixJob) []Step { PodName: jobStep.PodName, Components: jobStep.Components, } - if jobStep.Started != nil {step.Started = &jobStep.Started.Time} - if jobStep.Ended != nil {step.Ended = &jobStep.Ended.Time} + if jobStep.Started != nil { + step.Started = &jobStep.Started.Time + } + if jobStep.Ended != nil { + step.Ended = &jobStep.Ended.Time + } steps = append(steps, step) } diff --git a/go.mod b/go.mod index 39052d30..97116257 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/equinor/radix-common v1.8.0 github.com/equinor/radix-job-scheduler v1.8.5 - github.com/equinor/radix-operator v1.49.0 + github.com/equinor/radix-operator v1.49.1-0.20240116123121-b7148c5ca4dd github.com/evanphx/json-patch/v5 v5.7.0 github.com/go-swagger/go-swagger v0.30.5 github.com/golang-jwt/jwt/v4 v4.5.0 @@ -83,6 +83,7 @@ require ( github.com/prometheus/common v0.45.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/prometheus/statsd_exporter v0.22.7 // indirect + github.com/rakyll/statik v0.1.7 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect diff --git a/go.sum b/go.sum index 16b2a634..f3ee86bf 100644 --- a/go.sum +++ b/go.sum @@ -87,6 +87,8 @@ github.com/equinor/radix-job-scheduler v1.8.5 h1:ahw6FkFpPV167B1/w7/aQKpVMmU5Vc7 github.com/equinor/radix-job-scheduler v1.8.5/go.mod h1:rNIQU1eCInLV8Yl+5SRITOUU52QwYioYrIGQcsDc3kg= github.com/equinor/radix-operator v1.49.0 h1:yNdb0zocBw7GdWybAGUm2lWmk6I+xeeCjvrN8xjVTyA= github.com/equinor/radix-operator v1.49.0/go.mod h1:i8A6V/g1OM+Zk2lAASZaoX+lHdJIZYYZHA586SHB2p8= +github.com/equinor/radix-operator v1.49.1-0.20240116123121-b7148c5ca4dd h1:0WsH5+0vu9k1AFV8Whux2VrtawqjA1tKWseEo1D7siQ= +github.com/equinor/radix-operator v1.49.1-0.20240116123121-b7148c5ca4dd/go.mod h1:i8A6V/g1OM+Zk2lAASZaoX+lHdJIZYYZHA586SHB2p8= github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.7.0 h1:nJqP7uwL84RJInrohHfW0Fx3awjbm8qZeFv0nW9SYGc= @@ -332,6 +334,8 @@ github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/prometheus/statsd_exporter v0.22.7 h1:7Pji/i2GuhK6Lu7DHrtTkFmNBCudCPT1pX2CziuyQR0= github.com/prometheus/statsd_exporter v0.22.7/go.mod h1:N/TevpjkIh9ccs6nuzY3jQn9dFqnUakOjnEuMPJJJnI= +github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= +github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= diff --git a/swaggerui/html/swagger.json b/swaggerui/html/swagger.json index 6cfc396f..9b5da71c 100644 --- a/swaggerui/html/swagger.json +++ b/swaggerui/html/swagger.json @@ -5495,6 +5495,10 @@ "image" ], "properties": { + "CommitID": { + "description": "Commit ID for the component. In can be different from the Commit ID, defined for entire deployment", + "type": "string" + }, "externalDNS": { "description": "Array of external DNS configurations", "type": "array", @@ -6280,6 +6284,15 @@ }, "x-go-name": "Components" }, + "componentsToDeploy": { + "description": "ComponentsToDeploy List of components to deploy\nOPTIONAL If specified, only these components are deployed", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "ComponentsToDeploy", + "example": "component1,component2" + }, "created": { "description": "Created timestamp", "type": "string",