Skip to content

Commit

Permalink
Deploy only specific component (#587)
Browse files Browse the repository at this point in the history
* In the deploy pipeline added argument components

* Added commit-id to deploying component, deploy component list to the pipeline job

* Corrected properties

* Renamed components property, set it as array

* Added swagger.json

* Fixed CommitID

* Fixed CommitID

* Fixed go.mod
  • Loading branch information
satr committed Jan 22, 2024
1 parent cb05c7d commit 3ff031e
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 14 deletions.
21 changes: 15 additions & 6 deletions api/applications/models/pipeline_parameters.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package models

import jobModels "github.com/equinor/radix-api/api/jobs/models"
import (
jobModels "github.com/equinor/radix-api/api/jobs/models"
)

// PipelineParametersPromote identify deployment to promote and a target environment
// swagger:model PipelineParametersPromote
Expand Down Expand Up @@ -121,15 +123,22 @@ type PipelineParametersDeploy struct {
// OPTIONAL for information only
//
// example: 4faca8595c5283a9d0f17a623b9255a0d9866a2e
CommitID string `json:"commitID"`
CommitID string `json:"commitID,omitempty"`

// ComponentsToDeploy List of components to deploy
// OPTIONAL If specified, only these components are deployed
//
// required: false
ComponentsToDeploy []string `json:"componentsToDeploy"`
}

// MapPipelineParametersDeployToJobParameter maps to JobParameter
func (deployParam PipelineParametersDeploy) MapPipelineParametersDeployToJobParameter() *jobModels.JobParameters {
return &jobModels.JobParameters{
ToEnvironment: deployParam.ToEnvironment,
TriggeredBy: deployParam.TriggeredBy,
ImageTagNames: deployParam.ImageTagNames,
CommitID: deployParam.CommitID,
ToEnvironment: deployParam.ToEnvironment,
TriggeredBy: deployParam.TriggeredBy,
ImageTagNames: deployParam.ImageTagNames,
CommitID: deployParam.CommitID,
ComponentsToDeploy: deployParam.ComponentsToDeploy,
}
}
1 change: 1 addition & 0 deletions api/deployments/models/component_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
5 changes: 5 additions & 0 deletions api/deployments/models/component_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ type Component struct {
// required: false
ExternalDNS []ExternalDNS `json:"externalDNS,omitempty"`

// Commit ID for the component. It can be different from the Commit ID, specified in deployment label
//
// required: false
CommitID string `json:"commitID,omitempty"`

AuxiliaryResource `json:",inline"`
}

Expand Down
15 changes: 13 additions & 2 deletions api/jobs/models/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
// required: false
ComponentsToDeploy []string `json:"componentsToDeploy,omitempty"`
}

// GetJobFromRadixJob Gets job from a radix job
Expand Down Expand Up @@ -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.ComponentsToDeploy
case radixv1.Promote:
jobModel.PromotedFromDeployment = job.Spec.Promote.DeploymentName
jobModel.PromotedFromEnvironment = job.Spec.Promote.FromEnvironment
Expand All @@ -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)
}
Expand Down
6 changes: 6 additions & 0 deletions api/jobs/models/job_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ type JobParameters struct {
//
// example: component1=tag1,component2=tag2
ImageTagNames map[string]string

// ComponentsToDeploy List of components to deploy
// OPTIONAL If specified, only these components are deployed
//
// required: false
ComponentsToDeploy []string `json:"componentsToDeploy"`
}

// GetPushImageTag Represents boolean as 1 or 0
Expand Down
7 changes: 4 additions & 3 deletions api/jobs/start_job_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ func (jh JobHandler) buildPipelineJob(appName, cloneURL, radixConfigFullName str
}
case v1.Deploy:
deploySpec = v1.RadixDeploySpec{
ToEnvironment: jobSpec.ToEnvironment,
ImageTagNames: jobSpec.ImageTagNames,
CommitID: jobSpec.CommitID,
ToEnvironment: jobSpec.ToEnvironment,
ImageTagNames: jobSpec.ImageTagNames,
CommitID: jobSpec.CommitID,
ComponentsToDeploy: jobSpec.ComponentsToDeploy,
}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ github.com/equinor/radix-common v1.8.0 h1:4mMu36mvJi2QSPEiKOUUJG/Z5EUrPkf0/lRO1q
github.com/equinor/radix-common v1.8.0/go.mod h1:8wGBEAa6auVB3yQ5pImahQzrL3w1ZYTu6N7EXLpJKUk=
github.com/equinor/radix-job-scheduler v1.8.5 h1:ahw6FkFpPV167B1/w7/aQKpVMmU5Vc7UBO8411ZtYck=
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 h1:X3MVpNGT6iyIO09nl82V6hjgwCvwsXPBkplKiLFQe0E=
github.com/equinor/radix-operator v1.49.1/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=
Expand Down
21 changes: 21 additions & 0 deletions swaggerui/html/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5495,6 +5495,11 @@
"image"
],
"properties": {
"commitID": {
"description": "Commit ID for the component. It can be different from the Commit ID, specified in deployment label",
"type": "string",
"x-go-name": "CommitID"
},
"externalDNS": {
"description": "Array of external DNS configurations",
"type": "array",
Expand Down Expand Up @@ -6280,6 +6285,14 @@
},
"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"
},
"created": {
"description": "Created timestamp",
"type": "string",
Expand Down Expand Up @@ -6618,6 +6631,14 @@
"x-go-name": "CommitID",
"example": "4faca8595c5283a9d0f17a623b9255a0d9866a2e"
},
"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"
},
"imageTagNames": {
"description": "Image tags names for components",
"type": "object",
Expand Down

0 comments on commit 3ff031e

Please sign in to comment.