Skip to content

Commit

Permalink
Added overrideUseBuildCache (#661)
Browse files Browse the repository at this point in the history
* Added overrideUseBuildCache

* Added unit test

* Updated swagger

* Updated refs
  • Loading branch information
satr committed Aug 26, 2024
1 parent 4482622 commit fb4ab9e
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 21 deletions.
20 changes: 13 additions & 7 deletions api/applications/models/pipeline_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,24 @@ type PipelineParametersBuild struct {
//
// example: master-latest
ImageTag string `json:"imageTag,omitempty"`

// OverrideUseBuildCache override default or configured build cache option
//
// required: false
OverrideUseBuildCache *bool `json:"overrideUseBuildCache,omitempty"`
}

// MapPipelineParametersBuildToJobParameter maps to JobParameter
func (buildParam PipelineParametersBuild) MapPipelineParametersBuildToJobParameter() *jobModels.JobParameters {
return &jobModels.JobParameters{
Branch: buildParam.Branch,
CommitID: buildParam.CommitID,
PushImage: buildParam.PushImageToContainerRegistry(),
TriggeredBy: buildParam.TriggeredBy,
ImageRepository: buildParam.ImageRepository,
ImageName: buildParam.ImageName,
ImageTag: buildParam.ImageTag,
Branch: buildParam.Branch,
CommitID: buildParam.CommitID,
PushImage: buildParam.PushImageToContainerRegistry(),
TriggeredBy: buildParam.TriggeredBy,
ImageRepository: buildParam.ImageRepository,
ImageName: buildParam.ImageName,
ImageTag: buildParam.ImageTag,
OverrideUseBuildCache: buildParam.OverrideUseBuildCache,
}
}

Expand Down
13 changes: 8 additions & 5 deletions api/jobs/job_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"testing"

"github.com/equinor/radix-common/utils/pointers"
kedav2 "github.com/kedacore/keda/v2/pkg/generated/clientset/versioned"
kedafake "github.com/kedacore/keda/v2/pkg/generated/clientset/versioned/fake"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -70,10 +71,11 @@ func TestGetApplicationJob(t *testing.T) {
require.NoError(t, err)

jobParameters := &jobmodels.JobParameters{
Branch: anyBranch,
CommitID: anyPushCommitID,
PushImage: true,
TriggeredBy: anyUser,
Branch: anyBranch,
CommitID: anyPushCommitID,
PushImage: true,
TriggeredBy: anyUser,
OverrideUseBuildCache: pointers.Ptr(true),
}

accounts := models.NewAccounts(client, radixclient, kedaClient, secretproviderclient, nil, certClient, client, radixclient, kedaClient, secretproviderclient, nil, certClient, "", radixmodels.Impersonation{})
Expand Down Expand Up @@ -119,7 +121,8 @@ func TestGetApplicationJob(t *testing.T) {
assert.Equal(t, anyPushCommitID, job.CommitID)
assert.Equal(t, anyUser, job.TriggeredBy)
assert.Equal(t, string(anyPipeline.Type), job.Pipeline)

assert.NotNil(t, jobSummary.OverrideUseBuildCache)
assert.True(t, *jobSummary.OverrideUseBuildCache)
}

func TestGetApplicationJob_RadixJobSpecExists(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions api/jobs/models/job_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ type JobParameters struct {
//
// required: false
ComponentsToDeploy []string `json:"componentsToDeploy"`

// OverrideUseBuildCache override default or configured build cache option
//
// required: false
OverrideUseBuildCache *bool `json:"overrideUseBuildCache,omitempty"`
}

// GetPushImageTag Represents boolean as 1 or 0
Expand Down
6 changes: 6 additions & 0 deletions api/jobs/models/job_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ type JobSummary struct {
//
// required: false
PromotedToEnvironment string `json:"promotedToEnvironment,omitempty"`

// OverrideUseBuildCache override default or configured build cache option
//
// required: false
OverrideUseBuildCache *bool `json:"overrideUseBuildCache,omitempty"`
}

// GetSummaryFromRadixJob Used to get job summary from a radix job
Expand Down Expand Up @@ -124,6 +129,7 @@ func GetSummaryFromRadixJob(job *radixv1.RadixJob) *JobSummary {
case radixv1.Build, radixv1.BuildDeploy:
pipelineJob.Branch = job.Spec.Build.Branch
pipelineJob.CommitID = job.Spec.Build.CommitID
pipelineJob.OverrideUseBuildCache = job.Spec.Build.OverrideUseBuildCache
case radixv1.Deploy:
pipelineJob.ImageTagNames = job.Spec.Deploy.ImageTagNames
pipelineJob.CommitID = job.Spec.Deploy.CommitID
Expand Down
9 changes: 5 additions & 4 deletions api/jobs/start_job_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ func (jh JobHandler) buildPipelineJob(ctx context.Context, appName, cloneURL, ra
switch pipeline.Type {
case v1.BuildDeploy, v1.Build:
buildSpec = v1.RadixBuildSpec{
ImageTag: imageTag,
Branch: jobSpec.Branch,
CommitID: jobSpec.CommitID,
PushImage: jobSpec.PushImage,
ImageTag: imageTag,
Branch: jobSpec.Branch,
CommitID: jobSpec.CommitID,
PushImage: jobSpec.PushImage,
OverrideUseBuildCache: jobSpec.OverrideUseBuildCache,
}
case v1.Promote:
promoteSpec = v1.RadixPromoteSpec{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/cert-manager/cert-manager v1.15.0
github.com/equinor/radix-common v1.9.3
github.com/equinor/radix-job-scheduler v1.10.2
github.com/equinor/radix-operator v1.57.16
github.com/equinor/radix-operator v1.57.18
github.com/evanphx/json-patch/v5 v5.9.0
github.com/felixge/httpsnoop v1.0.4
github.com/golang-jwt/jwt/v5 v5.2.1
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ github.com/equinor/radix-common v1.9.3 h1:dLKFzYy8/XyEG9Zygi0rMWIYGCddai/ILwUqjB
github.com/equinor/radix-common v1.9.3/go.mod h1:+g0Wj0D40zz29DjNkYKVmCVeYy4OsFWKI7Qi9rA6kpY=
github.com/equinor/radix-job-scheduler v1.10.2 h1:Ea/gmSQjVdomC3XzkqJdR1TGQ9Bvq8ZJOKUfwYY3Ask=
github.com/equinor/radix-job-scheduler v1.10.2/go.mod h1:cnVXZ09D0rAPTZrcgWynL/txMQnpYmPSPyzfKfTYlec=
github.com/equinor/radix-operator v1.57.8 h1:fvXky2aZmKcre2X54R9hL5sl9gK19RGfFY9Q2Gn3IQg=
github.com/equinor/radix-operator v1.57.8/go.mod h1:zCdAiP/wxyvlUO4qGoJuLW3O+ZSt9kTyHMnjmsR3fCU=
github.com/equinor/radix-operator v1.57.16 h1:kDuPbKrb/r3Iu6BtCoq50IETspvynl55X+RGug9CSqw=
github.com/equinor/radix-operator v1.57.16/go.mod h1:zCdAiP/wxyvlUO4qGoJuLW3O+ZSt9kTyHMnjmsR3fCU=
github.com/equinor/radix-operator v1.57.18 h1:+zPaeZKfErjXE9O2+EjtUenrKw2nabq3e0y5VBjlwHA=
github.com/equinor/radix-operator v1.57.18/go.mod h1:zCdAiP/wxyvlUO4qGoJuLW3O+ZSt9kTyHMnjmsR3fCU=
github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls=
github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg=
Expand Down
10 changes: 10 additions & 0 deletions swaggerui/html/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6668,6 +6668,11 @@
"x-go-name": "Name",
"example": "radix-pipeline-20181029135644-algpv-6hznh"
},
"overrideUseBuildCache": {
"description": "OverrideUseBuildCache override default or configured build cache option",
"type": "boolean",
"x-go-name": "OverrideUseBuildCache"
},
"pipeline": {
"description": "Name of the pipeline",
"type": "string",
Expand Down Expand Up @@ -6824,6 +6829,11 @@
"x-go-name": "ImageTag",
"example": "master-latest"
},
"overrideUseBuildCache": {
"description": "OverrideUseBuildCache override default or configured build cache option",
"type": "boolean",
"x-go-name": "OverrideUseBuildCache"
},
"pushImage": {
"description": "PushImage should image be pushed to container registry. Defaults pushing",
"type": "string",
Expand Down

0 comments on commit fb4ab9e

Please sign in to comment.