Skip to content

Commit cf24c66

Browse files
authored
Merge branch 'main' into ci-update-external-dns-to-8.7.8
2 parents 5d0ad99 + 7b3ce79 commit cf24c66

File tree

10 files changed

+50
-40
lines changed

10 files changed

+50
-40
lines changed

.env.sample

+1-14
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,11 @@ DISABLE_SYNC=1
88
# ENV_DIR=''
99

1010
# KMS access from here on
11-
# Google (paste json key here without newlines nor spaces and double quotes escaped)
12-
GCLOUD_SERVICE_KEY="\"some\":\"key\""
13-
# Azure:
14-
AZURE_TENANT_ID=''
15-
AZURE_CLIENT_ID=''
16-
AZURE_CLIENT_SECRET=''
17-
# AWS:
18-
AWS_DEFAULT_REGION=''
19-
AWS_REGION=''
20-
AWS_ACCESS_KEY_ID=''
21-
AWS_SECRET_ACCESS_KEY=''
22-
# AGE:
2311
SOPS_AGE_KEY=''
2412

2513
OTOMI_CHARTS_URL='https://github.com/linode/apl-charts.git'
2614

27-
2815
RETRIES=6
2916
RANDOM=false
3017
MIN_TIMEOUT=10000
31-
FACTOR=1
18+
FACTOR=1

charts/team-ns/templates/rbac.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ rules:
220220
resources: ["secrets"]
221221
verbs: ["get", "watch", "list", "delete", "create", "update"]
222222
---
223+
apiVersion: rbac.authorization.k8s.io/v1
224+
kind: ClusterRole
225+
metadata:
226+
name: apl-gitea-operator-team-{{ $v.teamId }}-trigger-template-pipeline-watcher
227+
rules:
228+
- apiGroups: ["tekton.dev"]
229+
resources: ["pipelines"]
230+
verbs: ["watch", "list", "get"]
231+
- apiGroups: ["triggers.tekton.dev"]
232+
resources: ["triggertemplates"]
233+
verbs: ["watch", "list", "get"]
234+
---
223235
# RoleBinding for the above Role in team namespace
224236
apiVersion: rbac.authorization.k8s.io/v1
225237
kind: RoleBinding
@@ -234,4 +246,17 @@ roleRef:
234246
kind: Role
235247
name: apl-gitea-operator-service-account
236248
apiGroup: rbac.authorization.k8s.io
249+
---
250+
apiVersion: rbac.authorization.k8s.io/v1
251+
kind: ClusterRoleBinding
252+
metadata:
253+
name: apl-gitea-operator-team-{{ $v.teamId }}-trigger-template-pipeline-binding
254+
subjects:
255+
- kind: ServiceAccount
256+
namespace: apl-gitea-operator
257+
name: apl-gitea-operator
258+
roleRef:
259+
kind: ClusterRole
260+
name: apl-gitea-operator-team-{{ $v.teamId }}-trigger-template-pipeline-watcher
261+
apiGroup: rbac.authorization.k8s.io
237262
---

src/cmd/bootstrap.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ export const bootstrapSops = async (
117117
}
118118
}
119119
// now do a round of encryption and decryption to make sure we have all the files in place for later
120-
await deps.encrypt()
121-
await deps.decrypt()
120+
await deps.encrypt(envDir)
121+
await deps.decrypt(envDir)
122122
}
123123
}
124124

src/cmd/validate-values.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const validateValues = async (envDir = env.ENV_DIR): Promise<void> => {
1919
// TODO: Make this return true or error tree
2020
// Create an end point function (when running otomi validate-values) to print current messages.
2121
const argv: HelmArguments = getParsedArgs()
22-
d.log('Values validation STARTED')
22+
d.log('Values validation STARTED on ', envDir)
2323

2424
if (argv.l || argv.label) {
2525
const labelOpts = [...new Set([...(argv.l ?? []), ...(argv.label ?? [])])]

src/common/crypt.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ const preCrypt = async (path): Promise<void> => {
4242

4343
const getAllSecretFiles = async (path) => {
4444
const d = terminal(`common:crypt:getAllSecretFiles`)
45-
const files = (await readdirRecurse(`${path}/env`, { skipHidden: true }))
46-
.filter((file) => file.endsWith('.yaml') && file.includes('/secrets.'))
47-
.map((file) => file.replace(`${path}/`, ''))
45+
const files = (await readdirRecurse(`${path}/env`, { skipHidden: true })).filter(
46+
(file) => file.endsWith('.yaml') && file.includes('/secrets.'),
47+
)
48+
4849
d.debug('getAllSecretFiles: ', files)
4950
return files
5051
}
@@ -92,8 +93,6 @@ const runOnSecretFiles = async (path: string, crypt: CR, filesArgs: string[] = [
9293
const d = terminal(`common:crypt:runOnSecretFiles`)
9394
let files: string[] = filesArgs
9495

95-
cd(path)
96-
9796
if (files.length === 0) {
9897
files = await getAllSecretFiles(path)
9998
}

src/server.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import $RefParser, { JSONSchema } from '@apidevtools/json-schema-ref-parser'
33
import express, { Request, Response } from 'express'
44
import { Server } from 'http'
55
import { bootstrapSops } from 'src/cmd/bootstrap'
6-
import { validateValues } from 'src/cmd/validate-values'
76
import { decrypt, encrypt } from 'src/common/crypt'
87
import { terminal } from 'src/common/debug'
98
import { hfValues } from './common/hf'
@@ -25,12 +24,13 @@ app.get('/', async (req: Request, res: Response): Promise<Response<any>> => {
2524

2625
type QueryParams = {
2726
envDir: string
27+
files?: string[]
2828
}
2929

3030
app.get('/init', async (req: Request, res: Response) => {
3131
const { envDir } = req.query as QueryParams
3232
try {
33-
d.log('Request to initialize values repo')
33+
d.log('Request to initialize values repo on', envDir)
3434
await decrypt(envDir)
3535
res.status(200).send('ok')
3636
} catch (error) {
@@ -40,21 +40,20 @@ app.get('/init', async (req: Request, res: Response) => {
4040
})
4141

4242
app.get('/prepare', async (req: Request, res: Response) => {
43-
const { envDir } = req.query as QueryParams
43+
const { envDir, files } = req.query as QueryParams
4444
try {
45-
d.log('Request to prepare values repo')
45+
d.log('Request to prepare values repo on', envDir)
4646
await bootstrapSops(envDir)
4747
await setValuesFile(envDir)
4848
// Encrypt ensures that a brand new secret file is encrypted in place
49-
await encrypt(envDir)
49+
await encrypt(envDir, ...(files ?? []))
5050
// Decrypt ensures that a brand new encrypted secret file is decrypted to the .dec file
51-
await decrypt(envDir)
52-
await validateValues(envDir)
51+
await decrypt(envDir, ...(files ?? []))
5352
res.status(200).send('ok')
5453
} catch (error) {
5554
const err = `${error}`
5655
let status = 500
57-
d.error(err)
56+
d.error(`Request to prepare values went wrong: ${err}`)
5857
if (err.includes('Values validation FAILED')) {
5958
status = 422
6059
}

tests/integration/minimal-with-team.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ teamConfig:
9797
path: chart/hello-world
9898
revision: HEAD
9999
files:
100-
env/teams/demo/workloadsValues/nodejs-helloworld.yaml: |
100+
env/teams/demo/workloadValues/nodejs-helloworld.yaml: |
101101
values: |
102102
image:
103103
repository: otomi/nodejs-helloworld
104104
tag: v1.2.13
105-
env/teams/demo/workloadsValues/nginx-deployment.yaml: |
105+
env/teams/demo/workloadValues/nginx-deployment.yaml: |
106106
values: |
107107
fullnameOverride: nginx-deployment
108108
image:
@@ -119,7 +119,7 @@ files:
119119
autoscaling:
120120
minReplicas: 2
121121
maxReplicas: 10
122-
env/teams/demo/workloadsValues/nginx-ksvc.yaml: |
122+
env/teams/demo/workloadValues/nginx-ksvc.yaml: |
123123
values: |
124124
fullnameOverride: nginx-ksvc
125125
image:
@@ -140,10 +140,10 @@ files:
140140
autoscaling:
141141
minReplicas: 0
142142
maxReplicas: 10
143-
env/teams/demo/workloadsValues/httpbin.yaml: |
143+
env/teams/demo/workloadValues/httpbin.yaml: |
144144
values: |
145145
{}
146-
env/teams/admin/workloadsValues/nodejs-helloworld.yaml: |
146+
env/teams/admin/workloadValues/nodejs-helloworld.yaml: |
147147
values: |
148148
image:
149149
repository: otomi/nodejs-helloworld

tests/integration/monitoring-with-team.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ teamConfig:
7575
workloads: []
7676

7777
files:
78-
env/teams/demo/workloadsValues/petclinic.yaml: |
78+
env/teams/demo/workloadValues/petclinic.yaml: |
7979
values: |
8080
image:
8181
repository: springcommunity/spring-framework-petclinic

values/otomi-api/otomi-api.gotmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{{- $cm := $v.apps | get "cert-manager" }}
66
{{- $d := $v.apps.drone }}
77
{{- $sops := $v | get "kms.sops" dict }}
8-
{{- $giteaValuesUrl := printf "gitea.%s/otomi/values" $v.cluster.domainSuffix }}
8+
{{- $giteaValuesUrl := "http://gitea-http.gitea.svc.cluster.local:3000/otomi/values" }}
99
{{- $helmChartCatalog := printf "https://gitea.%s/otomi/charts.git" $v.cluster.domainSuffix }}
1010
{{- $defaultPlatformAdminEmail := printf "platform-admin@%s" $v.cluster.domainSuffix }}
1111
{{- $sopsEnv := tpl (readFile "../../helmfile.d/snippets/sops-env.gotmpl") $sops }}

versions.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
api: 4.0.0
2-
console: 4.0.0
1+
api: 4.0.1
2+
console: 4.0.1
33
consoleLogin: v3.5.0
4-
tasks: 3.7.0
4+
tasks: 3.8.0
55
tools: 2.8.7

0 commit comments

Comments
 (0)