Skip to content

Commit 2f8784e

Browse files
authored
fix: add extra identity to the resource lookup reference (#655)
<!-- markdownlint-disable MD041 --> #### What this PR does / why we need it Related to open-component-model/ocm-k8s-toolkit#119 #### Which issue(s) this PR fixes <!-- Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> --------- Signed-off-by: Gergely Brautigam <[email protected]>
1 parent 494a0e7 commit 2f8784e

File tree

14 files changed

+324
-29
lines changed

14 files changed

+324
-29
lines changed

e2e/main_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var (
3939
testRepoName = "ocm-controller-test"
4040
testRepoSignedName = "ocm-controller-signed-test"
4141
testRepoHelmName = "ocm-controller-helm-test"
42+
testRepoSameName = "ocm-controller-same-test"
4243
testHelmChartBasedResource = "testHelmChartResource"
4344
testOCMControllerPath = "testOCMController"
4445
testSignedComponentsPath = "testSignedOCIRegistryComponents"

e2e/same_resource_test.go

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
//go:build e2e
2+
3+
package e2e
4+
5+
import (
6+
"os"
7+
"path/filepath"
8+
"testing"
9+
10+
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2"
11+
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
12+
"github.com/open-component-model/ocm-controller/api/v1alpha1"
13+
"github.com/open-component-model/ocm-e2e-framework/shared"
14+
"sigs.k8s.io/e2e-framework/pkg/features"
15+
16+
"github.com/open-component-model/ocm-e2e-framework/shared/steps/setup"
17+
)
18+
19+
func TestSameResource(t *testing.T) {
20+
management := features.New("Configure Management Repository").
21+
Setup(setup.AddScheme(v1alpha1.AddToScheme)).
22+
Setup(setup.AddScheme(sourcev1.AddToScheme)).
23+
Setup(setup.AddScheme(kustomizev1.AddToScheme)).
24+
Setup(setup.AddGitRepository(testRepoSameName)).
25+
Setup(setup.AddFluxSyncForRepo(testRepoSameName, destinationPrefix, ocmNamespace))
26+
27+
configContent, err := os.ReadFile(filepath.Join("testdata", "testOCMControllerMultipleSameResources", "config.yaml"))
28+
if err != nil {
29+
t.Fatal("failed to read config file: %w", err)
30+
}
31+
32+
manifestContent, err := os.ReadFile(filepath.Join("testdata", "testOCMControllerMultipleSameResources", "manifests.tar"))
33+
if err != nil {
34+
t.Fatal("failed to read config file: %w", err)
35+
}
36+
37+
component := setup.Component{
38+
Component: shared.Component{
39+
Name: "component.name.resources/same",
40+
Version: "v1.0.0",
41+
},
42+
ComponentVersionModifications: []shared.ComponentModification{
43+
shared.BlobResource(shared.Resource{
44+
Name: "same",
45+
Data: string(configContent),
46+
Type: "configdata.ocm.software",
47+
Version: "1.0.0",
48+
ExtraIdentity: map[string]string{
49+
"type": "config",
50+
},
51+
}),
52+
shared.BlobResource(shared.Resource{
53+
Name: "same",
54+
Data: string(manifestContent),
55+
Type: "kustomize.ocm.fluxcd.io",
56+
Version: "1.0.0",
57+
ExtraIdentity: map[string]string{
58+
"type": "manifest",
59+
},
60+
}),
61+
},
62+
}
63+
64+
gitRepositoryName := "ocm-controller-test"
65+
testName := "testOCMControllerMultipleSameResources"
66+
67+
setupComponentFeature := features.New("Setup Component").Setup(setup.AddComponentVersions(component))
68+
componentVersionFeature := features.New("Create Manifests").
69+
Setup(setup.AddFilesToGitRepository(setup.File{
70+
RepoName: gitRepositoryName,
71+
SourceFilepath: filepath.Join(testName, "component_version.yaml"),
72+
DestFilepath: destinationPrefix + testName + "component_version.yaml",
73+
}, setup.File{
74+
RepoName: gitRepositoryName,
75+
SourceFilepath: filepath.Join(testName, "resource1.yaml"),
76+
DestFilepath: destinationPrefix + testName + "resource1.yaml",
77+
}, setup.File{
78+
RepoName: gitRepositoryName,
79+
SourceFilepath: filepath.Join(testName, "resource2.yaml"),
80+
DestFilepath: destinationPrefix + testName + "resource2.yaml",
81+
})).Assess("check that component version component_version.yaml is ready and valid", checkIsComponentVersionReady("same-resource-component", ocmNamespace))
82+
83+
resourceAssertFeatures := features.New("Validate Resources").Setup(checkIsResourceReady("resource-1")).Setup(checkIsResourceReady("resource-2"))
84+
85+
testEnv.Test(t,
86+
setupComponentFeature.Feature(),
87+
management.Feature(),
88+
componentVersionFeature.Feature(),
89+
resourceAssertFeatures.Feature(),
90+
)
91+
}

e2e/suite_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616

1717
var (
1818
testEnv env.Environment
19-
kindClusterName string
2019
ocmNamespace string
2120
registryPort = 5000
2221
gitRepositoryPort = 3000
@@ -32,14 +31,12 @@ func TestMain(m *testing.M) {
3231
path := conf.ResolveKubeConfigFile()
3332
cfg := envconf.NewWithKubeConfig(path)
3433
testEnv = env.NewWithConfig(cfg)
35-
kindClusterName = envconf.RandomName("ocm-ctrl-e2e", 32)
3634
ocmNamespace = "ocm-system"
3735

3836
stopChannelRegistry := make(chan struct{}, 1)
3937
stopChannelGitea := make(chan struct{}, 1)
4038

4139
testEnv.Setup(
42-
//envfuncs.CreateKindCluster(kindClusterName),
4340
envfuncs.CreateNamespace(ocmNamespace),
4441
shared.StartGitServer(ocmNamespace),
4542
shared.InstallFlux("latest"),
@@ -53,7 +50,6 @@ func TestMain(m *testing.M) {
5350
shared.ShutdownPortForward(stopChannelRegistry),
5451
shared.ShutdownPortForward(stopChannelGitea),
5552
envfuncs.DeleteNamespace(ocmNamespace),
56-
//envfuncs.DestroyKindCluster(kindClusterName),
5753
)
5854

5955
os.Exit(testEnv.Run(m))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: delivery.ocm.software/v1alpha1
2+
kind: ComponentVersion
3+
metadata:
4+
name: same-resource-component
5+
namespace: ocm-system
6+
spec:
7+
component: component.name.resources/same
8+
interval: 5s
9+
repository:
10+
url: registry.ocm-system.svc.cluster.local:5000
11+
version:
12+
semver: ">=v1.0.0"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: config.ocm.software/v1alpha1
2+
kind: ConfigData
3+
metadata:
4+
name: ocm-config-pipeline-backend
5+
labels:
6+
env: test
7+
configuration:
8+
defaults:
9+
replicas: 1
10+
cacheAddr: tcp://redis:6379
11+
message: Hello, world!
12+
schema:
13+
type: object
14+
additionalProperties: false
15+
properties:
16+
replicas:
17+
type: integer
18+
cacheAddr:
19+
type: string
20+
message:
21+
type: string
22+
rules:
23+
- value: (( replicas ))
24+
file: manifests/deploy.yaml
25+
path: spec.replicas
26+
- value: (( cacheAddr ))
27+
file: manifests/configmap.yaml
28+
path: data.PODINFO_CACHE_SERVER
29+
- value: (( message ))
30+
file: manifests/configmap.yaml
31+
path: data.PODINFO_UI_MESSAGE
32+
localization:
33+
- resource:
34+
name: image
35+
file: manifests/deploy.yaml
36+
image: spec.template.spec.containers[0].image
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: delivery.ocm.software/v1alpha1
2+
kind: Resource
3+
metadata:
4+
name: resource-1
5+
namespace: ocm-system
6+
spec:
7+
interval: 5s
8+
sourceRef:
9+
kind: ComponentVersion
10+
name: same-resource-component
11+
resourceRef:
12+
name: same
13+
version: 1.0.0
14+
extraIdentity:
15+
type: manifest
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: delivery.ocm.software/v1alpha1
2+
kind: Resource
3+
metadata:
4+
name: resource-2
5+
namespace: ocm-system
6+
spec:
7+
interval: 5s
8+
sourceRef:
9+
kind: ComponentVersion
10+
name: same-resource-component
11+
resourceRef:
12+
name: same
13+
version: 1.0.0
14+
extraIdentity:
15+
type: config

go.mod

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ require (
3636
github.com/mitchellh/hashstructure v1.1.0
3737
github.com/mitchellh/hashstructure/v2 v2.0.2
3838
github.com/onsi/gomega v1.37.0
39-
github.com/open-component-model/ocm-e2e-framework v0.11.0
39+
github.com/open-component-model/ocm-e2e-framework v0.11.1
4040
github.com/open-component-model/pkg/metrics v0.0.0-20240402143848-8961dae2122b
4141
github.com/opencontainers/go-digest v1.0.0
4242
github.com/opencontainers/image-spec v1.1.1
@@ -58,10 +58,10 @@ require (
5858
cloud.google.com/go/auth v0.15.0 // indirect
5959
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
6060
cloud.google.com/go/compute/metadata v0.6.0 // indirect
61-
code.gitea.io/sdk/gitea v0.20.0 // indirect
61+
code.gitea.io/sdk/gitea v0.21.0 // indirect
6262
dario.cat/mergo v1.0.1 // indirect
6363
filippo.io/edwards25519 v1.1.0 // indirect
64-
github.com/42wim/httpsig v1.2.1 // indirect
64+
github.com/42wim/httpsig v1.2.2 // indirect
6565
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
6666
github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider v0.15.2 // indirect
6767
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
@@ -151,6 +151,7 @@ require (
151151
github.com/docker/distribution v2.8.3+incompatible // indirect
152152
github.com/docker/docker v28.0.4+incompatible // indirect
153153
github.com/docker/docker-credential-helpers v0.9.3 // indirect
154+
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
154155
github.com/docker/go-connections v0.5.0 // indirect
155156
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
156157
github.com/docker/go-metrics v0.0.1 // indirect
@@ -173,8 +174,8 @@ require (
173174
github.com/fluxcd/pkg/apis/kustomize v1.10.0 // indirect
174175
github.com/fluxcd/pkg/envsubst v1.4.0 // indirect
175176
github.com/fluxcd/pkg/sourceignore v0.12.0 // indirect
176-
github.com/fluxcd/pkg/ssa v0.45.1 // indirect
177-
github.com/fluxcd/pkg/version v0.6.0 // indirect
177+
github.com/fluxcd/pkg/ssa v0.46.0 // indirect
178+
github.com/fluxcd/pkg/version v0.7.0 // indirect
178179
github.com/fvbommel/sortorder v1.1.0 // indirect
179180
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
180181
github.com/ghodss/yaml v1.0.0 // indirect

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ cloud.google.com/go/kms v1.21.1 h1:r1Auo+jlfJSf8B7mUnVw5K0fI7jWyoUy65bV53VjKyk=
1313
cloud.google.com/go/kms v1.21.1/go.mod h1:s0wCyByc9LjTdCjG88toVs70U9W+cc6RKFc8zAqX7nE=
1414
cloud.google.com/go/longrunning v0.6.5 h1:sD+t8DO8j4HKW4QfouCklg7ZC1qC4uzVZt8iz3uTW+Q=
1515
cloud.google.com/go/longrunning v0.6.5/go.mod h1:Et04XK+0TTLKa5IPYryKf5DkpwImy6TluQ1QTLwlKmY=
16-
code.gitea.io/sdk/gitea v0.20.0 h1:Zm/QDwwZK1awoM4AxdjeAQbxolzx2rIP8dDfmKu+KoU=
17-
code.gitea.io/sdk/gitea v0.20.0/go.mod h1:faouBHC/zyx5wLgjmRKR62ydyvMzwWf3QnU0bH7Cw6U=
16+
code.gitea.io/sdk/gitea v0.21.0 h1:69n6oz6kEVHRo1+APQQyizkhrZrLsTLXey9142pfkD4=
17+
code.gitea.io/sdk/gitea v0.21.0/go.mod h1:tnBjVhuKJCn8ibdyyhvUyxrR1Ca2KHEoTWoukNhXQPA=
1818
cuelabs.dev/go/oci/ociregistry v0.0.0-20241125120445-2c00c104c6e1 h1:mRwydyTyhtRX2wXS3mqYWzR2qlv6KsmoKXmlz5vInjg=
1919
cuelabs.dev/go/oci/ociregistry v0.0.0-20241125120445-2c00c104c6e1/go.mod h1:5A4xfTzHTXfeVJBU6RAUf+QrlfTCW+017q/QiW+sMLg=
2020
cuelang.org/go v0.12.1 h1:5I+zxmXim9MmiN2tqRapIqowQxABv2NKTgbOspud1Eo=
@@ -23,8 +23,8 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
2323
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
2424
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
2525
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
26-
github.com/42wim/httpsig v1.2.1 h1:oLBxptMe9U4ZmSGtkosT8Dlfg31P3VQnAGq6psXv82Y=
27-
github.com/42wim/httpsig v1.2.1/go.mod h1:P/UYo7ytNBFwc+dg35IubuAUIs8zj5zzFIgUCEl55WY=
26+
github.com/42wim/httpsig v1.2.2 h1:ofAYoHUNs/MJOLqQ8hIxeyz2QxOz8qdSVvp3PX/oPgA=
27+
github.com/42wim/httpsig v1.2.2/go.mod h1:P/UYo7ytNBFwc+dg35IubuAUIs8zj5zzFIgUCEl55WY=
2828
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk=
2929
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
3030
github.com/AdamKorcz/go-fuzz-headers-1 v0.0.0-20230919221257-8b5d3ce2d11d h1:zjqpY4C7H15HjRPEenkS4SAn3Jy2eRRjkjZbGR30TOg=
@@ -397,14 +397,14 @@ github.com/fluxcd/pkg/runtime v0.59.0 h1:3OrFkMJB39NcQ2vhhoxqls59sQVSn8U+thhyLbs
397397
github.com/fluxcd/pkg/runtime v0.59.0/go.mod h1:MFbfyNyyoYRgPxpdwC9/dCOkzo7Yxhu/cQ9NKyhvqc0=
398398
github.com/fluxcd/pkg/sourceignore v0.12.0 h1:jCIe6d50rQ3wdXPF0+PhhqN0XrTRIq3upMomPelI8Mw=
399399
github.com/fluxcd/pkg/sourceignore v0.12.0/go.mod h1:dc0zvkuXM5OgL/b3IkrVuwvPjj1zJn4NBUMH45uJ4Y0=
400-
github.com/fluxcd/pkg/ssa v0.45.1 h1:ISl84TJwRP/GuZXrKiR9Tf8JOnG5XFgtjcYoR4XQYf4=
401-
github.com/fluxcd/pkg/ssa v0.45.1/go.mod h1:8Anf7XVZ0zxOve7HXbDaW1s0gfmP95ksJBlKfDYinhQ=
400+
github.com/fluxcd/pkg/ssa v0.46.0 h1:TGomtbA6zTfZrHF0TDn3mIGKH+bbX45zdWSkdYrwS8g=
401+
github.com/fluxcd/pkg/ssa v0.46.0/go.mod h1:qCek0b8tKumh9iNZLmga1mjeXOlZPlZpc6xip/hLMJM=
402402
github.com/fluxcd/pkg/tar v0.12.0 h1:og6F+ivnWNRbNJSq0ukCTVs7YrGIlzjxSVZU+E8NprM=
403403
github.com/fluxcd/pkg/tar v0.12.0/go.mod h1:Ra5Cj++MD5iCy7bZGKJJX3GpOeMPv+ZDkPO9bBwpDeU=
404404
github.com/fluxcd/pkg/testserver v0.11.0 h1:a/kxpFqv7XQxZjwVPP3voooRmSd/3ipLVolK0xUIxXQ=
405405
github.com/fluxcd/pkg/testserver v0.11.0/go.mod h1:E8LAH1jW9uClFjTRN27Y/gCCSrzNVx1/w/0NxKuNcas=
406-
github.com/fluxcd/pkg/version v0.6.0 h1:tYRWpV7RvBOO5ahD525TiDhWXmhnvBM0RAIY1MCRe9s=
407-
github.com/fluxcd/pkg/version v0.6.0/go.mod h1:ZCl5BkIvXmMm3C4q4fz4aMi5LQHvcXNSEaL2puXIZo8=
406+
github.com/fluxcd/pkg/version v0.7.0 h1:jZT5I6WFy1KlM40nHCSqlHmjC1VT1/DfmbAdOkIVVJc=
407+
github.com/fluxcd/pkg/version v0.7.0/go.mod h1:3BjQDJXIZJmeJLXnfa2yG/sNAT1t5oeLAPfnSjOHNuA=
408408
github.com/fluxcd/source-controller/api v1.5.0 h1:caSR+u/r2Vh0jq/0pNR0r1zLxyvgatWuGSV2mxgTB/I=
409409
github.com/fluxcd/source-controller/api v1.5.0/go.mod h1:OZPuHMlLH2E2mnj6Q5DLkWfUOmJ20zA1LIvUVfNsYl8=
410410
github.com/foxcpp/go-mockdns v1.1.0 h1:jI0rD8M0wuYAxL7r/ynTrCQQq0BVqfB99Vgk7DlmewI=
@@ -608,8 +608,8 @@ github.com/hashicorp/golang-lru/arc/v2 v2.0.5 h1:l2zaLDubNhW4XO3LnliVj0GXO3+/CGN
608608
github.com/hashicorp/golang-lru/arc/v2 v2.0.5/go.mod h1:ny6zBSQZi2JxIeYcv7kt2sH2PXJtirBN7RDhRpxPkxU=
609609
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
610610
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
611-
github.com/hashicorp/hcl v1.0.1-vault-5 h1:kI3hhbbyzr4dldA8UdTb7ZlVVlI2DACdCfz31RPDgJM=
612-
github.com/hashicorp/hcl v1.0.1-vault-5/go.mod h1:XYhtn6ijBSAj6n4YqAaf7RBPS4I06AItNorpy+MoQNM=
611+
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
612+
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
613613
github.com/hashicorp/vault-client-go v0.4.3 h1:zG7STGVgn/VK6rnZc0k8PGbfv2x/sJExRKHSUg3ljWc=
614614
github.com/hashicorp/vault-client-go v0.4.3/go.mod h1:4tDw7Uhq5XOxS1fO+oMtotHL7j4sB9cp0T7U6m4FzDY=
615615
github.com/hashicorp/vault/api v1.16.0 h1:nbEYGJiAPGzT9U4oWgaaB0g+Rj8E59QuHKyA5LhwQN4=
@@ -777,8 +777,8 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl
777777
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
778778
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
779779
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
780-
github.com/open-component-model/ocm-e2e-framework v0.11.0 h1:CMTbuKExNv6C+OBw9SeMyTHO9mFykS7iMyCht49Z+Og=
781-
github.com/open-component-model/ocm-e2e-framework v0.11.0/go.mod h1:l+zQDj5NA89vEQlHwCCRqE+KANXxDaDuGSor4vvtw2s=
780+
github.com/open-component-model/ocm-e2e-framework v0.11.1 h1:dXVN/23K/KgJ3QOzzcKj0j+PbbcUADmzv+Pjb2zGHl4=
781+
github.com/open-component-model/ocm-e2e-framework v0.11.1/go.mod h1:kugoRHM8cpgOPyUZssRiareAiztRmtB0hHpnGS65y+c=
782782
github.com/open-component-model/pkg/metrics v0.0.0-20240402143848-8961dae2122b h1:Z95/2zF9f7xeTmtIWNB9oDq9jiQlkRzuOUzMNSeU1qQ=
783783
github.com/open-component-model/pkg/metrics v0.0.0-20240402143848-8961dae2122b/go.mod h1:frQj/b3+bzniEC/qUbSNUYm+pHZbjd6l0ofAsPgmEF0=
784784
github.com/opencontainers/go-digest v1.0.1-0.20220411205349-bde1400a84be h1:f2PlhC9pm5sqpBZFvnAoKj+KzXRzbjFMA+TqXfJdgho=

0 commit comments

Comments
 (0)