Skip to content

Commit 2e32e12

Browse files
committed
use workload identity
Signed-off-by: Somtochi Onyekwere <[email protected]>
1 parent 50b261c commit 2e32e12

File tree

9 files changed

+176
-36
lines changed

9 files changed

+176
-36
lines changed

go.mod

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ replace golang.org/x/text => golang.org/x/text v0.4.0
3333
require (
3434
cloud.google.com/go/compute v1.10.0 // indirect
3535
github.com/Azure/azure-sdk-for-go v67.0.0+incompatible // indirect
36-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 // indirect
37-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 // indirect
36+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.5.0-beta.1 // indirect
37+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0-beta.4 // indirect
3838
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect
3939
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
4040
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
@@ -45,7 +45,7 @@ require (
4545
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
4646
github.com/Azure/go-autorest/logger v0.2.1 // indirect
4747
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
48-
github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 // indirect
48+
github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect
4949
github.com/MakeNowJust/heredoc v1.0.0 // indirect
5050
github.com/aws/aws-sdk-go-v2 v1.17.5 // indirect
5151
github.com/aws/aws-sdk-go-v2/config v1.18.15 // indirect
@@ -89,7 +89,7 @@ require (
8989
github.com/go-openapi/jsonreference v0.20.0 // indirect
9090
github.com/go-openapi/swag v0.22.3 // indirect
9191
github.com/gogo/protobuf v1.3.2 // indirect
92-
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
92+
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
9393
github.com/golang/glog v1.0.0 // indirect
9494
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
9595
github.com/golang/protobuf v1.5.2 // indirect
@@ -171,3 +171,5 @@ require (
171171
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
172172
sigs.k8s.io/yaml v1.3.0 // indirect
173173
)
174+
175+
replace github.com/fluxcd/pkg/oci => github.com/weisdd/fluxcd-pkg/oci v0.0.0-20230216100018-1186e0dede79

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1
3737
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1/go.mod h1:VzwV+t+dZ9j/H867F1M2ziD+yLHtB46oM35FxxMJ4d0=
3838
github.com/Azure/azure-sdk-for-go v67.0.0+incompatible h1:SVBwznSETB0Sipd0uyGJr7khLhJOFRUEUb+0JgkCvDo=
3939
github.com/Azure/azure-sdk-for-go v67.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
40-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY=
41-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M=
42-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 h1:T8quHYlUGyb/oqtSTwqlCr1ilJHrDv+ZtpSfo+hm1BU=
43-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1/go.mod h1:gLa1CL2RNE4s7M3yopJ/p0iq5DdY6Yv5ZUt9MTRZOQM=
40+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.5.0-beta.1 h1:yLM4ZIC+NRvzwFGpXjUbf5FhPBVxJgmYXkjePgNAx64=
41+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.5.0-beta.1/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M=
42+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0-beta.4 h1:jpSh2461XzXBEw1MJwvVRJwZS0CAgqS0h6jBdoIFtLk=
43+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0-beta.4/go.mod h1:oWa/ZXP08smIi12UyWVbVikBxoZHZCyxijZamTK1i8Q=
4444
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 h1:+5VZ72z0Qan5Bog5C+ZkgSqUbeVUd9wgtHOrIKuc5b8=
4545
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
4646
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
@@ -67,8 +67,8 @@ github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+Z
6767
github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8=
6868
github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo=
6969
github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
70-
github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 h1:oPdPEZFSbl7oSPEAIPMPBMUmiL+mqgzBJwM/9qYcwNg=
71-
github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1/go.mod h1:4qFor3D/HDsvBME35Xy9rwW9DecL+M2sNw1ybjPtwA0=
70+
github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU=
71+
github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o=
7272
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
7373
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
7474
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
@@ -210,8 +210,6 @@ github.com/fluxcd/pkg/apis/event v0.4.1 h1:63wP8NM/uA4680F4Ft8q8/0rJivX90i7FmMkR
210210
github.com/fluxcd/pkg/apis/event v0.4.1/go.mod h1:LHT1ZsbMrcHwCHQCaFtQviQBZwhMOAbTUPK6+KgBkFo=
211211
github.com/fluxcd/pkg/apis/meta v0.19.1 h1:fCI5CnTXpAqr67UlaI9q0H+OztMKB5kDTr6xV6vlAo0=
212212
github.com/fluxcd/pkg/apis/meta v0.19.1/go.mod h1:ZPPMYrPnWwPQYNEGM/Uc0N4SurUPS3xNI3IIpCQEfuM=
213-
github.com/fluxcd/pkg/oci v0.21.1 h1:9kn19wkabE2xB77NRlOtMJlSYhZmUjdloZCzlHdAS6s=
214-
github.com/fluxcd/pkg/oci v0.21.1/go.mod h1:9E2DBlQII7YmeWt2ieTh38wwkiBqx3yg5NEJ51uefaA=
215213
github.com/fluxcd/pkg/runtime v0.31.0 h1:addyXaANHl/A68bEjCbiR4HzcFKgfXv1eaG7B7ZHxOo=
216214
github.com/fluxcd/pkg/runtime v0.31.0/go.mod h1:toGOOubMo4ZC1aWhB8C3drdTglr1/A1dETeNwjiIv0g=
217215
github.com/fluxcd/pkg/version v0.2.1 h1:RRH7+6qiWHdTvRNwpoBmilnubJ2C4FZYGgy5wTDVKVc=
@@ -256,8 +254,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
256254
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
257255
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
258256
github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
259-
github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs=
260-
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
257+
github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
258+
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
261259
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
262260
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
263261
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
@@ -525,6 +523,8 @@ github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljT
525523
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
526524
github.com/vbatts/tar-split v0.11.2 h1:Via6XqJr0hceW4wff3QRzD5gAk/tatMw/4ZA7cTlIME=
527525
github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI=
526+
github.com/weisdd/fluxcd-pkg/oci v0.0.0-20230216100018-1186e0dede79 h1:4BWUOxxtn2LhWKGBPrm+yJEL3EofGv6QAb4Z+FO3Mco=
527+
github.com/weisdd/fluxcd-pkg/oci v0.0.0-20230216100018-1186e0dede79/go.mod h1:GXQ3mmh3DX7RsEt2btj1x+XEu2s/OC0HHlQ/OnVre2U=
528528
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
529529
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
530530
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=

tests/integration/aws_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,9 @@ func pushFluxTestImagesECR(ctx context.Context, localImgs map[string]string, out
6969
remoteImage := repo + ":test"
7070
return tftestenv.PushTestAppImagesECR(ctx, localImgs, remoteImage)
7171
}
72+
73+
// getKustomizePatchesAWS return the patches that should be added to the kustomization.yaml
74+
// before deploying Flux. It returns an empty array since no patches are needed
75+
func getKustomizePatchesAWS(output map[string]*tfjson.StateOutput) []string {
76+
return nil
77+
}

tests/integration/azure_test.go

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ func registryLoginACR(ctx context.Context, output map[string]*tfjson.StateOutput
4343
testRepos := map[string]string{}
4444

4545
registryURL := output["acr_registry_url"].Value.(string)
46+
fluxRegistryURL := output["flux_acr_registry_url"].Value.(string)
47+
if err := tftestenv.RegistryLoginACR(ctx, fluxRegistryURL); err != nil {
48+
return nil, err
49+
}
50+
4651
if err := tftestenv.RegistryLoginACR(ctx, registryURL); err != nil {
4752
return nil, err
4853
}
@@ -56,6 +61,40 @@ func registryLoginACR(ctx context.Context, output map[string]*tfjson.StateOutput
5661
// logged in and is capable of pushing the test images.
5762
func pushFluxTestImagesACR(ctx context.Context, localImgs map[string]string, output map[string]*tfjson.StateOutput) (map[string]string, error) {
5863
// Get the registry name and construct the image names accordingly.
59-
registryURL := output["acr_registry_url"].Value.(string)
64+
registryURL := output["flux_acr_registry_url"].Value.(string)
6065
return tftestenv.PushTestAppImagesACR(ctx, localImgs, registryURL)
6166
}
67+
68+
// getKustomizePatchesAzure return the patches that should be added to the kustomization.yaml
69+
// before deploying Flux. It returns two patches, one to annotate the image-reflector-controller
70+
// service account and the other for the image-reflector-controller deployment. These are needed
71+
// for workload identity to work properly on Azure
72+
func getKustomizePatchesAzure(output map[string]*tfjson.StateOutput) []string {
73+
appClientId := output["spn_id"].Value.(string)
74+
saAnnotation := `
75+
apiVersion: v1
76+
kind: ServiceAccount
77+
metadata:
78+
name: image-reflector-controller
79+
namespace: flux-system
80+
annotations:
81+
azure.workload.identity/client-id: "%s"
82+
labels:
83+
azure.workload.identity/use: "true"
84+
`
85+
saPatch := fmt.Sprintf(saAnnotation, appClientId)
86+
deployPatch := `apiVersion: apps/v1
87+
kind: Deployment
88+
metadata:
89+
name: image-reflector-controller
90+
namespace: flux-system
91+
labels:
92+
azure.workload.identity/use: "true"
93+
spec:
94+
template:
95+
metadata:
96+
labels:
97+
azure.workload.identity/use: "true"
98+
`
99+
return []string{deployPatch, saPatch}
100+
}

tests/integration/gcp_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,9 @@ func pushFluxTestImagesGCR(ctx context.Context, localImgs map[string]string, out
6969
repositoryID := output["gcp_artifact_repository"].Value.(string)
7070
return tftestenv.PushTestAppImagesGCR(ctx, localImgs, project, region, repositoryID)
7171
}
72+
73+
// getKustomizePatchesGCP return the patches that should be added to the kustomization.yaml
74+
// before deploying Flux. It returns an empty array since no patches are needed
75+
func getKustomizePatchesGCP(output map[string]*tfjson.StateOutput) []string {
76+
return nil
77+
}

tests/integration/suite_test.go

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ type registryLoginFunc func(ctx context.Context, output map[string]*tfjson.State
9898
// pushed to a corresponding registry repository for the image.
9999
type pushTestImages func(ctx context.Context, localImgs map[string]string, output map[string]*tfjson.StateOutput) (map[string]string, error)
100100

101+
// getKustomizePatches is used to return provider specific kustomize patches
102+
// that would be added to the kustomization.yaml before Flux is deployed. It takes
103+
// in a terraform state output as some value might be needed for
104+
// creating the patch,
105+
type getKustomizePatches func(output map[string]*tfjson.StateOutput) []string
106+
101107
// ProviderConfig is the test configuration of a supported cloud provider to run
102108
// the tests against.
103109
type ProviderConfig struct {
@@ -110,6 +116,8 @@ type ProviderConfig struct {
110116
createKubeconfig tftestenv.CreateKubeconfig
111117
// pushFluxTestImages is used to push flux test images to a remote registry.
112118
pushFluxTestImages pushTestImages
119+
// getKustomizePatches is used to get provider specific kustomize patches
120+
getKustomizePatches getKustomizePatches
113121
}
114122

115123
func init() {
@@ -198,8 +206,10 @@ func TestMain(m *testing.M) {
198206
panic(fmt.Sprintf("Failed to create and push images: %v", err))
199207
}
200208

209+
patches := providerCfg.getKustomizePatches(output)
210+
201211
// Update flux install manifests with the pushed test images.
202-
if err := updateAndBuildFluxInstallManifests(ctx, pushedImages); err != nil {
212+
if err := updateAndBuildFluxInstallManifests(ctx, pushedImages, patches); err != nil {
203213
panic(fmt.Sprintf("Failed to update and build flux install manifests: %v", err))
204214
}
205215

@@ -224,24 +234,27 @@ func getProviderConfig(provider string) *ProviderConfig {
224234
switch provider {
225235
case "aws":
226236
return &ProviderConfig{
227-
terraformPath: terraformPathAWS,
228-
registryLogin: registryLoginECR,
229-
pushFluxTestImages: pushFluxTestImagesECR,
230-
createKubeconfig: createKubeconfigEKS,
237+
terraformPath: terraformPathAWS,
238+
registryLogin: registryLoginECR,
239+
pushFluxTestImages: pushFluxTestImagesECR,
240+
createKubeconfig: createKubeconfigEKS,
241+
getKustomizePatches: getKustomizePatchesAWS,
231242
}
232243
case "azure":
233244
return &ProviderConfig{
234-
terraformPath: terraformPathAzure,
235-
registryLogin: registryLoginACR,
236-
pushFluxTestImages: pushFluxTestImagesACR,
237-
createKubeconfig: createKubeConfigAKS,
245+
terraformPath: terraformPathAzure,
246+
registryLogin: registryLoginACR,
247+
pushFluxTestImages: pushFluxTestImagesACR,
248+
createKubeconfig: createKubeConfigAKS,
249+
getKustomizePatches: getKustomizePatchesAzure,
238250
}
239251
case "gcp":
240252
return &ProviderConfig{
241-
terraformPath: terraformPathGCP,
242-
registryLogin: registryLoginGCR,
243-
pushFluxTestImages: pushFluxTestImagesGCR,
244-
createKubeconfig: createKubeconfigGKE,
253+
terraformPath: terraformPathGCP,
254+
registryLogin: registryLoginGCR,
255+
pushFluxTestImages: pushFluxTestImagesGCR,
256+
createKubeconfig: createKubeconfigGKE,
257+
getKustomizePatches: getKustomizePatchesGCP,
245258
}
246259
}
247260
return nil

tests/integration/terraform/azure/main.tf

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,73 @@ locals {
1313
}
1414

1515
module "aks" {
16-
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/azure/aks"
16+
source = "git::https://github.com/somtochiama/test-infra.git//tf-modules/azure/aks?ref=az-workload"
1717

1818
name = local.name
1919
location = var.azure_location
2020
}
2121

2222
module "acr" {
23-
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/azure/acr"
23+
source = "git::https://github.com/somtochiama/test-infra.git//tf-modules/azure/acr?ref=az-workload"
2424

2525
name = local.name
2626
location = var.azure_location
27-
aks_principal_id = module.aks.principal_id
2827
resource_group = module.aks.resource_group
28+
}
29+
30+
module "acr_flux" {
31+
source = "git::https://github.com/somtochiama/test-infra.git//tf-modules/azure/acr?ref=az-workload"
32+
33+
name = "manager${random_pet.suffix.id}"
34+
location = var.azure_location
35+
resource_group = module.aks.resource_group
36+
aks_principal_id = [module.aks.principal_id]
2937

3038
depends_on = [module.aks]
3139
}
40+
41+
resource "azuread_application" "flux" {
42+
display_name = "acr-sp"
43+
44+
required_resource_access {
45+
resource_app_id = "00000003-0000-0000-c000-000000000000"
46+
47+
resource_access {
48+
id = "df021288-bdef-4463-88db-98f22de89214"
49+
type = "Role"
50+
}
51+
}
52+
53+
required_resource_access {
54+
resource_app_id = "00000002-0000-0000-c000-000000000000"
55+
56+
resource_access {
57+
id = "1cda74f2-2616-4834-b122-5cb1b07f8a59"
58+
type = "Role"
59+
}
60+
resource_access {
61+
id = "78c8a3c8-a07e-4b9e-af1b-b5ccab50a175"
62+
type = "Role"
63+
}
64+
}
65+
}
66+
67+
resource "azuread_service_principal" "flux" {
68+
application_id = azuread_application.flux.application_id
69+
}
70+
71+
resource "azurerm_role_assignment" "acr" {
72+
scope = module.acr.registry_id
73+
role_definition_name = "AcrPull"
74+
principal_id = azuread_service_principal.flux.object_id
75+
}
76+
77+
78+
resource "azuread_application_federated_identity_credential" "example" {
79+
application_object_id = azuread_application.flux.object_id
80+
display_name = "image-reflector-sa"
81+
description = "Kubernetes service account federated credential"
82+
audiences = ["api://AzureADTokenExchange"]
83+
issuer = module.aks.cluster_oidc_url
84+
subject = "system:serviceaccount:flux-system:image-reflector-controller"
85+
}

tests/integration/terraform/azure/outputs.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ output "acr_registry_url" {
1010
output "acr_registry_id" {
1111
value = module.acr.registry_id
1212
}
13+
14+
output "flux_acr_registry_url" {
15+
value = module.acr_flux.registry_url
16+
}
17+
18+
output "flux_acr_registry_id" {
19+
value = module.acr_flux.registry_id
20+
}
21+
22+
output "spn_id" {
23+
value = azuread_application.flux.application_id
24+
}

tests/integration/utils.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@ package integration
1919
import (
2020
"context"
2121
"fmt"
22-
"log"
22+
"github.com/fluxcd/test-infra/tftestenv"
2323
"path"
2424
"strings"
25-
26-
"github.com/fluxcd/test-infra/tftestenv"
2725
)
2826

2927
// updateAndBuildFluxInstallManifests assumes that ./build/flux/ already exists
3028
// with downloaded install.yaml and copied kustomization.yaml. It updates the
3129
// kustomization.yaml with new test images and builds a new install manifest
3230
// at ./build/flux.yaml.
33-
func updateAndBuildFluxInstallManifests(ctx context.Context, images map[string]string) error {
31+
func updateAndBuildFluxInstallManifests(ctx context.Context, images map[string]string, patches []string) error {
3432
// Construct kustomize set image arguments.
3533
setImgArgs := []string{}
3634
for name, img := range images {
@@ -40,7 +38,17 @@ func updateAndBuildFluxInstallManifests(ctx context.Context, images map[string]s
4038
arg := fmt.Sprintf("%s=%s", imageName, img)
4139
setImgArgs = append(setImgArgs, arg)
4240
}
43-
log.Println("setting images:", setImgArgs)
41+
42+
for _, patch := range patches {
43+
// add patches to kustomization.
44+
err := tftestenv.RunCommand(ctx, "./build/flux",
45+
fmt.Sprintf("kustomize edit add patch --patch '%s'", patch),
46+
tftestenv.RunCommandOptions{},
47+
)
48+
if err != nil {
49+
return err
50+
}
51+
}
4452

4553
// Update all the images in kustomization.
4654
err := tftestenv.RunCommand(ctx, "./build/flux",

0 commit comments

Comments
 (0)