Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
120 changes: 120 additions & 0 deletions ci-operator/config/app-sre/infra/app-sre-infra-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ build_root:
project_image:
dockerfile_path: ci/build-root/Dockerfile
prowgen:
disable_sparse_checkout: true
enable_secrets_store_csi_driver: true
expose: true
private: true
Expand All @@ -15,6 +16,125 @@ tests:
commands: make lint
container:
from: src
- as: validate
run_if_changed: ^(terraform|hcp-terraform)/
steps:
test:
- as: validate
commands: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
git config --global credential.helper '!f() {
if [ "$1" = "get" ]; then
host="" proto=""
while IFS= read -r line; do
[ -z "$line" ] && break
case "$line" in
host=*) host="${line#host=}" ;;
protocol=*) proto="${line#protocol=}" ;;
esac
done
if [ "$proto" = "https" ] && [ "$host" = "github.com" ]; then
echo "username=x-access-token"
echo "password=$(cat /etc/github-private/oauth)"
else
exit 1
fi
fi
}; f'
umask 077
cat > "$HOME/.terraformrc" <<TFRC
credentials "app.terraform.io" {
token = "$(cat /etc/terraform-cloud/token)"
}
TFRC
export TF_PLUGIN_CACHE_DIR="${TMPDIR:-/tmp}/terraform-plugin-cache"
mkdir -p "${TF_PLUGIN_CACHE_DIR}"
if [ "${REPO_OWNER}/${REPO_NAME}" != "app-sre/infra" ]; then
echo "Skipping validate: job context is not app-sre/infra"
exit 0
fi
# Credentials are mounted here, so the tooling that drives Terraform is
# restored from the trusted base revision. Without this a pull request
# could simply edit hack/lint.sh or the Makefile to read the token. The
# Terraform configuration under test stays as the PR wrote it.
git checkout "${PULL_BASE_SHA}" -- Makefile hack/
make validate
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
credentials:
- as: oauth
collection: test-platform-infra
field: private-git-cloner
group: openshift-ci-robot
mount_path: /etc/github-private
- collection: app-sre-infra-terraform-cloud
group: tfcloud-token
mount_path: /etc/terraform-cloud
from: src
resources:
requests:
cpu: "4"
memory: 4Gi
- as: terraform-plan
run_if_changed: ^(terraform|hcp-terraform)/
steps:
test:
- as: plan
commands: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
git config --global credential.helper '!f() {
if [ "$1" = "get" ]; then
host="" proto=""
while IFS= read -r line; do
[ -z "$line" ] && break
case "$line" in
host=*) host="${line#host=}" ;;
protocol=*) proto="${line#protocol=}" ;;
esac
done
if [ "$proto" = "https" ] && [ "$host" = "github.com" ]; then
echo "username=x-access-token"
echo "password=$(cat /etc/github-private/oauth)"
else
exit 1
fi
fi
}; f'
umask 077
cat > "$HOME/.terraformrc" <<TFRC
credentials "app.terraform.io" {
token = "$(cat /etc/terraform-cloud/token)"
}
TFRC
export TF_PLUGIN_CACHE_DIR="${TMPDIR:-/tmp}/terraform-plugin-cache"
mkdir -p "${TF_PLUGIN_CACHE_DIR}"
# Never execute fork-controlled Makefile or planner code with
# credentials: the base revision is trusted, and the planner itself
# refuses pull requests whose author is not an organization member or
# repository collaborator before Terraform is invoked.
if [ "${REPO_OWNER}/${REPO_NAME}" != "app-sre/infra" ]; then
echo "Skipping plan: job context is not app-sre/infra"
exit 0
fi
set -o pipefail
# -I (isolated) is required, not cosmetic: for `python3 -`, CPython sets
# sys.path[0] to the working directory, which is the PR checkout. A
# PR-added json.py (or any other stdlib name) at the repository root
# would then be imported by the trusted planner and execute before any
# of its checks ran.
git show "${PULL_BASE_SHA}:hack/tfc-speculative-plan.py" | python3 -I -
Comment thread
devppratik marked this conversation as resolved.
Resolved
credentials:
- as: oauth
collection: test-platform-infra
field: private-git-cloner
group: openshift-ci-robot
mount_path: /etc/github-private
- collection: app-sre-infra-terraform-cloud
group: tfcloud-token
mount_path: /etc/terraform-cloud
from: src
resources:
requests:
cpu: "2"
memory: 2Gi
zz_generated_metadata:
branch: main
org: app-sre
Expand Down
200 changes: 200 additions & 0 deletions ci-operator/jobs/app-sre/infra/app-sre-infra-main-presubmits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,203 @@ presubmits:
secret:
secretName: result-aggregator
trigger: (?m)^/test( | .* )lint,?($|\s.*)
- agent: kubernetes
always_run: false
branches:
- ^main$
- ^main-
cluster: build01
context: ci/prow/terraform-plan
decorate: true
decoration_config:
skip_cloning: true
labels:
ci.openshift.io/generator: prowgen
pj-rehearse.openshift.io/can-be-rehearsed: "true"
name: pull-ci-app-sre-infra-main-terraform-plan
rerun_command: /test terraform-plan
run_if_changed: ^(terraform|hcp-terraform)/
spec:
containers:
- args:
- --enable-secrets-store-csi-driver=true
- --gcs-upload-secret=/secrets/gcs/service-account.json
- --gsm-config=/etc/gsm-config/gsm-config.yaml
- --gsm-credentials-file=/etc/gsm-credentials/key.json
- --gsm-project-config=/etc/gsm-config/gsm-project-config.yaml
- --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson
- --lease-server-credentials-file=/etc/boskos/credentials
- --oauth-token-path=/usr/local/github-credentials/oauth
- --report-credentials-file=/etc/report/credentials
- --target=terraform-plan
command:
- ci-operator
env:
- name: HTTP_SERVER_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
image: quay-proxy.ci.openshift.org/openshift/ci:ci_ci-operator_latest
imagePullPolicy: Always
name: ""
ports:
- containerPort: 8080
name: http
resources:
requests:
cpu: 10m
volumeMounts:
- mountPath: /etc/boskos
name: boskos
readOnly: true
- mountPath: /secrets/gcs
name: gcs-credentials
readOnly: true
- mountPath: /usr/local/github-credentials
name: github-credentials-openshift-ci-robot-private-git-cloner
readOnly: true
- mountPath: /etc/gsm-config
name: gsm-config
readOnly: true
- mountPath: /etc/gsm-credentials
name: gsm-sa-key
readOnly: true
- mountPath: /secrets/manifest-tool
name: manifest-tool-local-pusher
readOnly: true
- mountPath: /etc/pull-secret
name: pull-secret
readOnly: true
- mountPath: /etc/report
name: result-aggregator
readOnly: true
serviceAccountName: ci-operator
volumes:
- name: boskos
secret:
items:
- key: credentials
path: credentials
secretName: boskos-credentials
- name: github-credentials-openshift-ci-robot-private-git-cloner
secret:
secretName: github-credentials-openshift-ci-robot-private-git-cloner
- configMap:
name: gsm-config
name: gsm-config
- csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: ci-operator-sa-key-spc
name: gsm-sa-key
- name: manifest-tool-local-pusher
secret:
secretName: manifest-tool-local-pusher
- name: pull-secret
secret:
secretName: registry-pull-credentials
- name: result-aggregator
secret:
secretName: result-aggregator
trigger: (?m)^/test( | .* )terraform-plan,?($|\s.*)
- agent: kubernetes
always_run: false
branches:
- ^main$
- ^main-
cluster: build01
context: ci/prow/validate
decorate: true
decoration_config:
skip_cloning: true
labels:
ci.openshift.io/generator: prowgen
pj-rehearse.openshift.io/can-be-rehearsed: "true"
name: pull-ci-app-sre-infra-main-validate
rerun_command: /test validate
run_if_changed: ^(terraform|hcp-terraform)/
spec:
containers:
- args:
- --enable-secrets-store-csi-driver=true
- --gcs-upload-secret=/secrets/gcs/service-account.json
- --gsm-config=/etc/gsm-config/gsm-config.yaml
- --gsm-credentials-file=/etc/gsm-credentials/key.json
- --gsm-project-config=/etc/gsm-config/gsm-project-config.yaml
- --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson
- --lease-server-credentials-file=/etc/boskos/credentials
- --oauth-token-path=/usr/local/github-credentials/oauth
- --report-credentials-file=/etc/report/credentials
- --target=validate
command:
- ci-operator
env:
- name: HTTP_SERVER_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
image: quay-proxy.ci.openshift.org/openshift/ci:ci_ci-operator_latest
imagePullPolicy: Always
name: ""
ports:
- containerPort: 8080
name: http
resources:
requests:
cpu: 10m
volumeMounts:
- mountPath: /etc/boskos
name: boskos
readOnly: true
- mountPath: /secrets/gcs
name: gcs-credentials
readOnly: true
- mountPath: /usr/local/github-credentials
name: github-credentials-openshift-ci-robot-private-git-cloner
readOnly: true
- mountPath: /etc/gsm-config
name: gsm-config
readOnly: true
- mountPath: /etc/gsm-credentials
name: gsm-sa-key
readOnly: true
- mountPath: /secrets/manifest-tool
name: manifest-tool-local-pusher
readOnly: true
- mountPath: /etc/pull-secret
name: pull-secret
readOnly: true
- mountPath: /etc/report
name: result-aggregator
readOnly: true
serviceAccountName: ci-operator
volumes:
- name: boskos
secret:
items:
- key: credentials
path: credentials
secretName: boskos-credentials
- name: github-credentials-openshift-ci-robot-private-git-cloner
secret:
secretName: github-credentials-openshift-ci-robot-private-git-cloner
- configMap:
name: gsm-config
name: gsm-config
- csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: ci-operator-sa-key-spc
name: gsm-sa-key
- name: manifest-tool-local-pusher
secret:
secretName: manifest-tool-local-pusher
- name: pull-secret
secret:
secretName: registry-pull-credentials
- name: result-aggregator
secret:
secretName: result-aggregator
trigger: (?m)^/test( | .* )validate,?($|\s.*)