Skip to content

Commit a2f28d5

Browse files
authored
Feat flux cd k2 crud (#6662)
* cd pipeline crud * cd pipeline cryd * async flow handling * dep fix * fix condition
1 parent 9ed0126 commit a2f28d5

File tree

16 files changed

+190
-93
lines changed

16 files changed

+190
-93
lines changed

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ require (
279279
require (
280280
github.com/docker/distribution v2.8.2+incompatible
281281
github.com/fluxcd/helm-controller/api v1.3.0
282+
github.com/fluxcd/pkg/apis/meta v1.12.0
282283
github.com/fluxcd/source-controller/api v1.6.0
283284
sigs.k8s.io/controller-runtime v0.21.0
284285
)
@@ -309,7 +310,6 @@ require (
309310
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
310311
github.com/fluxcd/pkg/apis/acl v0.7.0 // indirect
311312
github.com/fluxcd/pkg/apis/kustomize v1.10.0 // indirect
312-
github.com/fluxcd/pkg/apis/meta v1.12.0 // indirect
313313
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
314314
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
315315
sigs.k8s.io/randfill v1.0.0 // indirect
@@ -347,5 +347,7 @@ replace (
347347
k8s.io/mount-utils => k8s.io/mount-utils v0.29.7
348348
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.29.7
349349
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.29.7
350+
k8s.io/utils => k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e
351+
sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.20.0
350352
sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.17.3
351353
)

go.sum

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,6 @@ github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2C
949949
github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpxhq9o2S/CELCSUxEWWAuoCUcVCQWv7G2OCk=
950950
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
951951
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
952-
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
953952
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
954953
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
955954
github.com/go-logr/logr v1.0.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
@@ -1389,8 +1388,8 @@ github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3Ro
13891388
github.com/onsi/ginkgo/v2 v2.9.7/go.mod h1:cxrmXWykAwTwhQsJOPfdIDiJ+l2RYq7U8hFU+M/1uw0=
13901389
github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM=
13911390
github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o=
1392-
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
1393-
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
1391+
github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
1392+
github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
13941393
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
13951394
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
13961395
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
@@ -1411,8 +1410,8 @@ github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRah
14111410
github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ=
14121411
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
14131412
github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
1414-
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
1415-
github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
1413+
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
1414+
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
14161415
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
14171416
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
14181417
github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI=
@@ -1500,7 +1499,6 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
15001499
github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY=
15011500
github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M=
15021501
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
1503-
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
15041502
github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
15051503
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
15061504
github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
@@ -2484,7 +2482,6 @@ k8s.io/component-helpers v0.29.7/go.mod h1:fBB9g4OrGCxo2+px6+kU4BPQ56WnBbL8n2NY6
24842482
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
24852483
k8s.io/helm v2.12.3+incompatible h1:wo1cdYjOnr5Z+LFuhtwIJaeQnec6D4gcg2H5UAKzY6w=
24862484
k8s.io/helm v2.12.3+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
2487-
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
24882485
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
24892486
k8s.io/klog/v2 v2.5.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec=
24902487
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
@@ -2502,8 +2499,6 @@ k8s.io/kubernetes v1.29.10 h1:vlze77k0CbdevTbgliyxpSjfI3bvOUhPEJVSJAEUl5Q=
25022499
k8s.io/kubernetes v1.29.10/go.mod h1:L6/pfKQZ6Tv2O8gyT4OxhGZp+nNsjV54xtNodRoup9k=
25032500
k8s.io/metrics v0.29.7 h1:/oMPdVL7dt+lF8W6lXTg9gIKz1dDKgVBfDnJwgyJrhk=
25042501
k8s.io/metrics v0.29.7/go.mod h1:5AiYPn1Crd25wtTh7OxHg9Rm2t9THSXJVp3Lb2k7MB8=
2505-
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
2506-
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
25072502
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e h1:KqK5c/ghOm8xkHYhlodbp6i6+r+ChV2vuAuVRdFbLro=
25082503
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
25092504
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
@@ -2548,8 +2543,8 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
25482543
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
25492544
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
25502545
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
2551-
sigs.k8s.io/controller-runtime v0.21.0 h1:CYfjpEuicjUecRk+KAeyYh+ouUBn4llGyDYytIGcJS8=
2552-
sigs.k8s.io/controller-runtime v0.21.0/go.mod h1:OSg14+F65eWqIu4DceX7k/+QRAbTTvxeQSNSOQpukWM=
2546+
sigs.k8s.io/controller-runtime v0.20.0 h1:jjkMo29xEXH+02Md9qaVXfEIaMESSpy3TBWPrsfQkQs=
2547+
sigs.k8s.io/controller-runtime v0.20.0/go.mod h1:BrP3w158MwvB3ZbNpaAcIKkHQ7YGpYnzpoSTZ8E14WU=
25532548
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
25542549
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE=
25552550
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=

pkg/bean/app.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,14 @@ type CDPipelineConfigObject struct {
657657
ReleaseMode string `json:"releaseMode" validate:"omitempty,oneof=link create"`
658658
}
659659

660+
func (cdPipelineConfig *CDPipelineConfigObject) IsFluxDeploymentAppType() bool {
661+
return cdPipelineConfig.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_FLUX
662+
}
663+
664+
func (cdPipelineConfig *CDPipelineConfigObject) IsAcdDeploymentAppType() bool {
665+
return cdPipelineConfig.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_ACD
666+
}
667+
660668
func (cdPipelineConfig *CDPipelineConfigObject) IsLinkedRelease() bool {
661669
return cdPipelineConfig.GetReleaseMode() == util.PIPELINE_RELEASE_MODE_LINK
662670
}
@@ -706,6 +714,11 @@ func (cdPipelineConfig *CDPipelineConfigObject) IsExternalArgoAppLinkRequest() b
706714
cdPipelineConfig.GetReleaseMode() == util.PIPELINE_RELEASE_MODE_LINK
707715
}
708716

717+
func (cdPipelineConfig *CDPipelineConfigObject) IsExternalFluxAppLinkRequest() bool {
718+
return cdPipelineConfig.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_FLUX &&
719+
cdPipelineConfig.GetReleaseMode() == util.PIPELINE_RELEASE_MODE_LINK
720+
}
721+
709722
func (cdPipelineConfig *CDPipelineConfigObject) IsExternalHelmAppLinkRequest() bool {
710723
return cdPipelineConfig.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_HELM &&
711724
cdPipelineConfig.GetReleaseMode() == util.PIPELINE_RELEASE_MODE_LINK

pkg/cluster/environment/bean/bean.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ type ResourceGroupingResponse struct {
6666
const (
6767
PIPELINE_DEPLOYMENT_TYPE_HELM = "helm"
6868
PIPELINE_DEPLOYMENT_TYPE_ACD = "argo_cd"
69+
PIPELINE_DEPLOYMENT_TYPE_FLUX = "flux_cd"
6970
)
7071

7172
type DataSourceMetaData struct {

pkg/deployment/common/adapter/adapter.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,20 @@ func NewAppLevelReleaseConfigFromChart(gitRepoURL, chartLocation string) *bean.R
7373
}}
7474
}
7575

76-
func NewFluxSpecReleaseConfig(namespace, gitRepositoryName, helmReleaseName, gitOpsSecretName string) *bean.ReleaseConfiguration {
76+
func NewFluxSpecReleaseConfig(clusterId int, namespace, gitRepositoryName, helmReleaseName, gitOpsSecretName, ChartLocation, ChartVersion, RevisionTarget, RepoUrl string, ValuesFiles []string) *bean.ReleaseConfiguration {
7777
return &bean.ReleaseConfiguration{
7878
Version: bean.Version,
7979
FluxCDSpec: bean.FluxCDSpec{
80+
ClusterId: clusterId,
8081
Namespace: namespace,
8182
GitRepositoryName: gitRepositoryName,
8283
HelmReleaseName: helmReleaseName,
8384
GitOpsSecretName: gitOpsSecretName,
85+
ChartLocation: ChartLocation,
86+
ChartVersion: ChartVersion,
87+
RevisionTarget: RevisionTarget,
88+
RepoUrl: RepoUrl,
89+
ValuesFiles: ValuesFiles,
8490
}}
8591
}
8692

pkg/deployment/common/bean/bean.go

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type ReleaseConfiguration struct {
2222
}
2323

2424
type FluxCDSpec struct {
25+
ClusterId int `json:"clusterId"`
2526
Namespace string `json:"namespace"`
2627
GitRepositoryName string `json:"gitRepositoryName"`
2728
HelmReleaseName string `json:"helmReleaseName"`
@@ -186,6 +187,10 @@ func (d *DeploymentConfig) IsAcdRelease() bool {
186187
return d.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_ACD
187188
}
188189

190+
func (d *DeploymentConfig) IsFluxRelease() bool {
191+
return d.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_FLUX
192+
}
193+
189194
func (d *DeploymentConfig) IsLinkedRelease() bool {
190195
return d.ReleaseMode == util.PIPELINE_RELEASE_MODE_LINK
191196
}
@@ -224,13 +229,21 @@ func (d *DeploymentConfig) IsPipelineGitOpsRepoConfigured(isAppLevelGitOpsConfig
224229
}
225230

226231
func (d *DeploymentConfig) GetRepoURL() string {
232+
233+
if d.IsFluxRelease() && d.ReleaseConfiguration != nil {
234+
return d.ReleaseConfiguration.FluxCDSpec.RepoUrl
235+
}
236+
227237
if d.ReleaseConfiguration == nil || d.ReleaseConfiguration.ArgoCDSpec.Spec.Source == nil {
228238
return d.RepoURL
229239
}
230240
return d.ReleaseConfiguration.ArgoCDSpec.Spec.Source.RepoURL
231241
}
232242

233243
func (d *DeploymentConfig) GetTargetRevision() string {
244+
if d.IsFluxRelease() && d.ReleaseConfiguration != nil {
245+
return d.ReleaseConfiguration.FluxCDSpec.RevisionTarget
246+
}
234247
if d.ReleaseConfiguration == nil ||
235248
d.ReleaseConfiguration.ArgoCDSpec.Spec.Source == nil ||
236249
len(d.ReleaseConfiguration.ArgoCDSpec.Spec.Source.TargetRevision) == 0 {
@@ -239,7 +252,11 @@ func (d *DeploymentConfig) GetTargetRevision() string {
239252
return d.ReleaseConfiguration.ArgoCDSpec.Spec.Source.TargetRevision
240253
}
241254

242-
func (d *DeploymentConfig) GetValuesFilePath() string {
255+
func (d *DeploymentConfig) GetValuesFilePathForCommit() string {
256+
if d.IsFluxRelease() && d.ReleaseConfiguration != nil {
257+
// We will commit values in last file of array
258+
return d.ReleaseConfiguration.FluxCDSpec.ValuesFiles[len(d.ReleaseConfiguration.FluxCDSpec.ValuesFiles)-1]
259+
}
243260
if d.ReleaseConfiguration == nil || d.ReleaseConfiguration.ArgoCDSpec.Spec.Source == nil {
244261
return ""
245262
}
@@ -252,6 +269,9 @@ func (d *DeploymentConfig) GetValuesFilePath() string {
252269
}
253270

254271
func (d *DeploymentConfig) GetChartLocation() string {
272+
if d.IsFluxRelease() && d.ReleaseConfiguration != nil {
273+
return d.ReleaseConfiguration.FluxCDSpec.ChartLocation
274+
}
255275
if d.ReleaseConfiguration == nil || d.ReleaseConfiguration.ArgoCDSpec.Spec.Source == nil {
256276
return ""
257277
}
@@ -260,6 +280,10 @@ func (d *DeploymentConfig) GetChartLocation() string {
260280

261281
func (d *DeploymentConfig) SetRepoURL(repoURL string) *DeploymentConfig {
262282
d.RepoURL = repoURL // maintain for backward compatibility
283+
if d.IsFluxRelease() && d.ReleaseConfiguration != nil {
284+
d.ReleaseConfiguration.FluxCDSpec.RepoUrl = repoURL
285+
return d
286+
}
263287
if d.ReleaseConfiguration == nil || d.ReleaseConfiguration.ArgoCDSpec.Spec.Source == nil {
264288
return d
265289
}
@@ -268,17 +292,32 @@ func (d *DeploymentConfig) SetRepoURL(repoURL string) *DeploymentConfig {
268292
}
269293

270294
func (d *DeploymentConfig) SetChartLocation(chartLocation string) {
271-
if d.ReleaseConfiguration == nil || d.ReleaseConfiguration.ArgoCDSpec.Spec.Source == nil {
295+
if d.IsFluxRelease() && d.ReleaseConfiguration != nil {
296+
d.ReleaseConfiguration.FluxCDSpec.ChartLocation = chartLocation
297+
return
298+
}
299+
if d.ReleaseConfiguration == nil ||
300+
(d.ReleaseConfiguration.ArgoCDSpec.Spec.Source == nil &&
301+
len(d.ReleaseConfiguration.FluxCDSpec.ChartLocation) == 0) {
272302
return
273303
}
274304
d.ReleaseConfiguration.ArgoCDSpec.Spec.Source.Path = chartLocation
275305
}
276306

277307
func (d *DeploymentConfig) GetRevision() string {
308+
if d.IsFluxRelease() && d.ReleaseConfiguration != nil {
309+
return d.ReleaseConfiguration.FluxCDSpec.RevisionTarget
310+
}
311+
278312
if d.ReleaseConfiguration == nil || d.ReleaseConfiguration.ArgoCDSpec.Spec.Source == nil {
279313
return ""
280314
}
281-
return d.ReleaseConfiguration.ArgoCDSpec.Spec.Source.TargetRevision
315+
if d.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_ACD {
316+
return d.ReleaseConfiguration.ArgoCDSpec.Spec.Source.TargetRevision
317+
} else if d.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_FLUX {
318+
return d.ReleaseConfiguration.FluxCDSpec.RevisionTarget
319+
}
320+
return ""
282321
}
283322

284323
func (d *DeploymentConfig) GetAcdAppName() string {

pkg/deployment/common/deploymentConfigService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func (impl *DeploymentConfigServiceImpl) UpdateChartLocationInDeploymentConfig(a
336336
impl.logger.Errorw("error, GetConfigForDevtronApps", "appId", appId, "envId", envId, "err", err)
337337
return err
338338
}
339-
if config.ReleaseMode == util2.PIPELINE_RELEASE_MODE_CREATE && config.DeploymentAppType == bean4.PIPELINE_DEPLOYMENT_TYPE_ACD {
339+
if config.ReleaseMode == util2.PIPELINE_RELEASE_MODE_CREATE && (config.IsAcdRelease() || config.IsFluxRelease()) {
340340
chartRef, err := impl.chartRefRepository.FindById(chartRefId)
341341
if err != nil {
342342
impl.logger.Errorw("error in chartRefRepository.FindById", "chartRefId", chartRefId, "err", err)

pkg/deployment/providerConfig/DeploymentTypeOverrideService.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func (impl *DeploymentTypeOverrideServiceImpl) ValidateAndOverrideDeploymentAppT
6262
AllowedDeploymentAppTypes := map[string]bool{
6363
util2.PIPELINE_DEPLOYMENT_TYPE_ACD: true,
6464
util2.PIPELINE_DEPLOYMENT_TYPE_HELM: true,
65+
util2.PIPELINE_DEPLOYMENT_TYPE_FLUX: true,
6566
}
6667
for k, v := range deploymentTypeValidationConfig {
6768
// rewriting allowed deployment types based on config provided by user
@@ -72,11 +73,15 @@ func (impl *DeploymentTypeOverrideServiceImpl) ValidateAndOverrideDeploymentAppT
7273
overrideDeploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_ACD
7374
} else if AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_HELM] {
7475
overrideDeploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_HELM
76+
} else if AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_FLUX] {
77+
overrideDeploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_FLUX
7578
}
7679
}
7780
if deploymentType == "" {
7881
if isGitOpsConfigured && AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_ACD] {
7982
overrideDeploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_ACD
83+
} else if isGitOpsConfigured && AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_FLUX] {
84+
overrideDeploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_FLUX
8085
} else if AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_HELM] {
8186
overrideDeploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_HELM
8287
}
@@ -85,7 +90,7 @@ func (impl *DeploymentTypeOverrideServiceImpl) ValidateAndOverrideDeploymentAppT
8590
impl.logger.Errorw("validation error for the given deployment type", "deploymentType", deploymentType, "err", err)
8691
return overrideDeploymentType, err
8792
}
88-
if !isGitOpsConfigured && util2.IsAcdApp(overrideDeploymentType) {
93+
if !isGitOpsConfigured && util2.IsAcdApp(overrideDeploymentType) && util2.IsFluxApp(overrideDeploymentType) {
8994
impl.logger.Errorw("GitOps not configured but selected as a deployment app type")
9095
err = &util2.ApiError{
9196
HttpStatusCode: http.StatusBadRequest,

pkg/deployment/trigger/devtronApps/deployStageHandlerCode.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,13 +800,14 @@ func (impl *HandlerServiceImpl) buildManifestPushTemplate(overrideRequest *bean3
800800
}
801801
}
802802
} else {
803+
803804
manifestPushTemplate.ChartReferenceTemplate = valuesOverrideResponse.EnvOverride.Chart.ReferenceTemplate
804805
manifestPushTemplate.ChartName = valuesOverrideResponse.EnvOverride.Chart.ChartName
805806
manifestPushTemplate.ChartVersion = valuesOverrideResponse.EnvOverride.Chart.ChartVersion
806807
manifestPushTemplate.ChartLocation = valuesOverrideResponse.DeploymentConfig.GetChartLocation()
807808
manifestPushTemplate.RepoUrl = valuesOverrideResponse.DeploymentConfig.GetRepoURL()
808809
manifestPushTemplate.TargetRevision = valuesOverrideResponse.DeploymentConfig.GetTargetRevision()
809-
manifestPushTemplate.ValuesFilePath = valuesOverrideResponse.DeploymentConfig.GetValuesFilePath()
810+
manifestPushTemplate.ValuesFilePath = valuesOverrideResponse.DeploymentConfig.GetValuesFilePathForCommit()
810811
manifestPushTemplate.ReleaseMode = valuesOverrideResponse.DeploymentConfig.ReleaseMode
811812
manifestPushTemplate.IsCustomGitRepository = common.IsCustomGitOpsRepo(valuesOverrideResponse.DeploymentConfig.ConfigType)
812813
manifestPushTemplate.IsArgoSyncSupported = valuesOverrideResponse.DeploymentConfig.IsArgoAppSyncAndRefreshSupported()
@@ -1267,6 +1268,9 @@ func (impl *HandlerServiceImpl) isDevtronAsyncInstallModeEnabled(overrideRequest
12671268
} else if util.IsAcdApp(overrideRequest.DeploymentAppType) {
12681269
return impl.isDevtronAsyncArgoCdInstallModeEnabledForApp(overrideRequest.AppId,
12691270
overrideRequest.EnvId, overrideRequest.ForceSyncDeployment)
1271+
} else if util.IsFluxApp(overrideRequest.DeploymentAppType) {
1272+
// will need sanity and testing around flux cd
1273+
return false, nil
12701274
}
12711275
return false, nil
12721276
}

0 commit comments

Comments
 (0)