Skip to content

feat: rely solely on metadata name #2040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2be2b14
feat: load id and name
j-zimnowoda Apr 3, 2025
9ee40db
Merge remote-tracking branch 'origin/main' into load-ids-from-metadata
j-zimnowoda Apr 3, 2025
08cda49
feat: remove name property from spec in fixtures
j-zimnowoda Apr 3, 2025
79d07e6
feat: remove teamId property from spec in fixtures
j-zimnowoda Apr 3, 2025
1da5efa
feat: remove id property from spec in fixtures
j-zimnowoda Apr 3, 2025
8f83c8b
feat: add name property to spec while loading
j-zimnowoda Apr 3, 2025
1184c55
feat: add name property to spec while loading
j-zimnowoda Apr 3, 2025
e18678d
Merge branch 'main' into APL-612
merll Apr 8, 2025
9919042
Merge remote-tracking branch 'origin/main' into APL-612
j-zimnowoda Apr 8, 2025
daf1b4e
Merge remote-tracking branch 'origin/main' into APL-612
j-zimnowoda Apr 9, 2025
c2077d0
ci: ignore order changes while using dyff
j-zimnowoda Apr 9, 2025
cd4c4c8
feat: load name to spec for arrayItems
j-zimnowoda Apr 9, 2025
4478eb3
feat: log sops errors
j-zimnowoda Apr 9, 2025
2d3188b
feat: remove teamId, name, and id from spec
j-zimnowoda Apr 9, 2025
fd049e1
ci: remove old secret
j-zimnowoda Apr 9, 2025
6d523ab
Merge branch 'main' into APL-612
j-zimnowoda Apr 9, 2025
c92ceb9
feat: use user name instead of user id
j-zimnowoda Apr 9, 2025
deed949
feat: use user name instead of user id
j-zimnowoda Apr 9, 2025
6f754b2
ci: debug bootstrap tests/fixtures
j-zimnowoda Apr 9, 2025
243cb20
ci: bootstrap tests fixtures
j-zimnowoda Apr 9, 2025
b99470e
ci: bootstrap tests fixtures
j-zimnowoda Apr 9, 2025
b1ca83d
Merge remote-tracking branch 'origin/APL-612' into APL-612
j-zimnowoda Apr 9, 2025
ae59a7b
fix: get user name from file name
j-zimnowoda Apr 9, 2025
2478ee3
fix: wring user name
j-zimnowoda Apr 9, 2025
fcb38b8
test: add unit
j-zimnowoda Apr 9, 2025
d13a2f1
fix: rework
j-zimnowoda Apr 11, 2025
258daf0
Merge branch 'main' into APL-612
j-zimnowoda Apr 11, 2025
1f1a081
fix: rework
j-zimnowoda Apr 11, 2025
8a648d8
Merge branch 'APL-612' of https://github.com/linode/apl-core into APL…
j-zimnowoda Apr 11, 2025
f5c8168
ci: fixtures for local dev
j-zimnowoda Apr 11, 2025
33f30fb
fix: rework
j-zimnowoda Apr 11, 2025
bcb6a9a
Merge remote-tracking branch 'origin/main' into APL-612
j-zimnowoda Apr 11, 2025
c7972ec
test: update resource quota
j-zimnowoda Apr 11, 2025
fbb81cd
Merge remote-tracking branch 'origin/main' into APL-612
j-zimnowoda Apr 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions src/common/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@
if (hasCorrespondingDecryptedFile(filePath, files)) return
promises.push(deps.loadFileToSpec(filePath, fileMap, spec))
})

await Promise.all(promises)
}

Expand All @@ -565,18 +564,35 @@
deps = { loadYaml },
): Promise<void> {
const jsonPath = getJsonPath(fileMap, filePath)
const data = await deps.loadYaml(filePath)
if (fileMap.processAs === 'arrayItem') {
const ref: Record<string, any>[] = get(spec, jsonPath)
ref.push(data?.spec)
} else {
const ref: Record<string, any> = get(spec, jsonPath)
// Decrypted secrets may need to be merged with plain text specs
const newRef = merge(cloneDeep(ref), data?.spec)
set(spec, jsonPath, newRef)
const data = (await deps.loadYaml(filePath)) || {}

try {
if (!filePath.includes('secrets.')) {
// data.spec.id = data.metadata.name

if (fileMap.resourceGroup === 'team') {
data.spec.name = data.metadata.name

Check warning on line 574 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
// data.spec.teamId = data.metadata.labels['apl.io/teamId']
}

Check warning on line 576 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 576 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
if (fileMap.resourceGroup === 'users') {
data.spec.id = data.metadata.name

Check warning on line 578 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 579 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 579 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
}

Check warning on line 580 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 580 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
if (fileMap.processAs === 'arrayItem') {
const ref: Record<string, any>[] = get(spec, jsonPath)
ref.push(data?.spec)
} else {
const ref: Record<string, any> = get(spec, jsonPath)
// Decrypted secrets may need to be merged with plain text specs
const newRef = merge(cloneDeep(ref), data?.spec)
set(spec, jsonPath, newRef)
}
} catch (e) {
console.log(filePath)
console.log(fileMap)
throw e
}

Check warning on line 594 in src/common/repo.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

export async function getKmsSettings(envDir: string, deps = { loadToSpec }): Promise<Record<string, any>> {
const kmsFiles = getFileMap('AplKms', envDir)
const spec = {}
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/env/settings/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ metadata:
name: cluster
labels: {}
spec:
name: demo
apiServer: https://1.1.1.1:8443
domainSuffix: dev.linode-apl.net
k8sContext: linode-dev
name: demo
owner: akamai
provider: linode
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/admin/services/hello-admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
spec:
auth: true
domain: hello.team-admin.dev.linode-apl.net
name: hello-admin
ownHost: true
port: 80
type: public
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/admin/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
labels:
apl.io/teamId: admin
spec:
id: admin
managedMonitoring:
alertmanager: true
grafana: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
apl.io/teamId: admin
spec:
chart: crossplane
name: crossplane-custom-namespace
namespace: crossplane
revision: 1.11.2
url: https://charts.crossplane.io/stable
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ metadata:
apl.io/teamId: admin
spec:
chart: crossplane
name: crossplane-team-namespace
revision: 1.11.2
url: https://charts.crossplane.io/stable
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/admin/workloads/wa1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
labels:
apl.io/teamId: admin
spec:
name: wa1
path: /
revision: HEAD
url: https://myrepo.local/mychart.git
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/admin/workloads/wa2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ metadata:
apl.io/teamId: admin
spec:
chart: mychart
name: wa2
revision: 1.2.3
url: https://myregistry.local/mychart
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/backups/bu1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
labels:
apl.io/teamId: demo
spec:
name: bu1
schedule: 0 0 0 * *
snapshotVolumes: true
ttl: 8h
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/backups/bu2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ spec:
value: hello
- name: backup
value: all
name: bu2
schedule: 0 0 0 * *
snapshotVolumes: true
ttl: 8h
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/builds/demo-java1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ spec:
repoUrl: https://github.com/buildpacks/samples
revision: HEAD
type: docker
name: demo-java1
scanSource: true
tag: v.0.0.1
trigger: false
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/builds/demo-java2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ spec:
repoUrl: https://github.com/buildpacks/samples
revision: HEAD
type: buildpacks
name: demo-java2
scanSource: false
tag: v.0.0.1
trigger: false
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/builds/demo-java3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ spec:
repoUrl: https://github.com/buildpacks/samples
revision: HEAD
type: docker
name: demo-java3
scanSource: true
secretName: my-secret
tag: v_0_0_1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ metadata:
name: buildpacks-samples
spec:
gitService: github
name: buildpacks-samples
private: false
repositoryUrl: https://github.com/buildpacks/samples
teamId: demo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
labels:
apl.io/teamId: demo
spec:
name: allow-egress-1
ruleType:
egress:
domain: demo.local
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
labels:
apl.io/teamId: demo
spec:
name: allow-egress-2
ruleType:
egress:
domain: demo.local
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
labels:
apl.io/teamId: demo
spec:
name: allow-ingress-1
ruleType:
ingress:
allow:
Expand Down
18 changes: 18 additions & 0 deletions tests/fixtures/env/teams/demo/sealedsecrets/demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
kind: AplTeamSecret
metadata:
name: demo
labels:
apl.io/teamId: demo
spec:
encryptedData:
foo: bar
metadata:
annotations:
- key: test
value: annotation
finalizers:
- sealedsecrets.bitnami.com/finalizer-sealedsecret-v1alpha1
labels:
- key: test
value: label
type: kubernetes.io/opaque
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/services/has-cert-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
apl.io/teamId: demo
spec:
hasCert: true
name: has-cert-svc
paths:
- /jeho
type: public
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/services/hello-auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ spec:
domain: tlspass.dev.linode-apl.net
ksvc:
predeployed: true
name: hello-auth
ownHost: true
paths: []
port: 80
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ spec:
ingressClassName: platform
ksvc:
predeployed: false
name: hello-blue-green
ownHost: true
paths: []
port: 80
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/services/hello.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ spec:
value: same-origin
ksvc:
predeployed: true
name: hello
ownHost: true
port: 80
tlsPass: true
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/services/service-a.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ metadata:
labels:
apl.io/teamId: demo
spec:
name: service-a
type: cluster
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/services/service-b.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ metadata:
labels:
apl.io/teamId: demo
spec:
name: service-b
type: cluster
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/services/service-d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ metadata:
labels:
apl.io/teamId: demo
spec:
name: service-d
type: cluster
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/services/service-e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ spec:
- name: sander
value: same-origin
ingressClassName: net-a
name: service-e
trafficControl:
enabled: true
weightV1: 50
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/services/some-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ metadata:
labels:
apl.io/teamId: demo
spec:
name: some-svc
port: 80
type: cluster
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/services/tlspass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
spec:
ksvc:
predeployed: true
name: tlspass
port: 443
tlsPass: true
type: public
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ spec:
channel: aaaaa
channelCrit: aaaaa
url: https://slack.con
id: demo
managedMonitoring:
alertmanager: true
grafana: true
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/workloads/wd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
spec:
imageUpdateStrategy:
type: disabled
name: wd
path: ./
revision: main
url: https://myrepo.local/mychart.git
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/workloads/wd1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ spec:
tag: latest
tagParameter: v2.image.tag
type: digest
name: wd1
path: ./
revision: main
url: https://myrepo.local/mychart.git
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/workloads/wd2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ spec:
imageRepository: harbor.try-otomi.net/team-orange/green
versionConstraint: '1.12'
type: semver
name: wd2
path: ./
revision: main
url: https://myrepo.local/mychart.git
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/demo/workloads/wd3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
spec:
imageUpdateStrategy:
type: disabled
name: wd3
path: ./
revision: main
url: https://myrepo.local/mychart.git
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/dev/netpols/allow-egress-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
labels:
apl.io/teamId: dev
spec:
name: allow-egress-2
ruleType:
type: egress
egress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
labels:
apl.io/teamId: dev
spec:
name: allow-ingress-1
ruleType:
ingress:
allow:
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/env/teams/dev/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
labels:
apl.io/teamId: dev
spec:
id: dev
managedMonitoring:
alertmanager: true
grafana: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ spec:
lastName: admin
teams:
- demo
id: 23d63558-49ed-48ba-bc28-8037a7236ddf
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ spec:
lastName: member
teams:
- demo
id: 9a3a478b-a747-4b4a-be69-a9abf1979df2
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ spec:
isPlatformAdmin: true
isTeamAdmin: true
lastName: admin
id: a83e20b7-474a-4262-a3ad-b09813364ece