Skip to content

Commit

Permalink
added function to build k8s driver option
Browse files Browse the repository at this point in the history
  • Loading branch information
ayu-devtron committed Oct 29, 2024
1 parent 3f39878 commit 044a2f0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkg/pipeline/CiService.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,21 +384,29 @@ func (impl *CiServiceImpl) setBuildxK8sDriverData(workflowRequest *types.Workflo
ciBuildConfig := workflowRequest.CiBuildConfig
if ciBuildConfig != nil {
if dockerBuildConfig := ciBuildConfig.DockerBuildConfig; dockerBuildConfig != nil {
buildxK8sDriverOptions := make([]map[string]string, 0)
err := json.Unmarshal([]byte(impl.config.BuildxK8sDriverOptions), &buildxK8sDriverOptions)
k8sDriverOptions, err := impl.getK8sDriverOptions()
if err != nil {
errMsg := "error in parsing BUILDX_K8S_DRIVER_OPTIONS from the devtron-cm, "
err = errors.New(errMsg + "error : " + err.Error())
impl.Logger.Errorw(errMsg, "err", err)
return err
} else {
dockerBuildConfig.BuildxK8sDriverOptions = buildxK8sDriverOptions
}
dockerBuildConfig.BuildxK8sDriverOptions = k8sDriverOptions

}
}
return nil
}

func (impl *CiServiceImpl) getK8sDriverOptions() ([]map[string]string, error) {
buildxK8sDriverOptions := make([]map[string]string, 0)
err := json.Unmarshal([]byte(impl.config.BuildxK8sDriverOptions), &buildxK8sDriverOptions)
if err != nil {
return nil, err
} else {
return buildxK8sDriverOptions, nil
}
}

func (impl *CiServiceImpl) getEnvironmentForJob(pipeline *pipelineConfig.CiPipeline, trigger types.Trigger) (*repository1.Environment, bool, error) {
app, err := impl.appRepository.FindById(pipeline.AppId)
if err != nil {
Expand Down

0 comments on commit 044a2f0

Please sign in to comment.