Skip to content

Commit 6a0e870

Browse files
fmudrytnevrlka
authored andcommitted
Update nunjucks templates to pass yaml lint
Mostly updated trailing white spaces and indentation Signed-off-by: Filip Mudry <[email protected]>
1 parent 9b2c27b commit 6a0e870

File tree

7 files changed

+158
-163
lines changed

7 files changed

+158
-163
lines changed

templates/gitops-template/azure-pipelines.yml.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{%- set secrets = gitops_secrets -%}
33

44
trigger:
5-
- main
5+
- main
66

77
# Using self-hosted 'Default' agent pool by default
88
# Change accordingly when using a different agent pool
@@ -20,7 +20,7 @@ container:
2020
# Can be deleted if the variables are set differently
2121
# See https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables
2222
variables:
23-
- group: rhtap
23+
- group: rhtap
2424

2525
steps:
2626
{%- filter indent(2) -%}

templates/gitops-template/gitops-promotion.yml.njk

Lines changed: 73 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ env:
1313
# 🖊️ EDIT to change the image registry settings.
1414
# Registries such as GHCR, Quay.io, and Docker Hub are supported.
1515
IMAGE_REGISTRY: ${{ "secrets.IMAGE_REGISTRY" | inCurlies }}
16-
{% filter indent(2) %}
16+
{{ '' }}{# Ensure new line for better readability #}
1717
{%- for var in gitops_variables -%}
1818
{% include "github-variable.njk" %}
1919
{%- endfor %}
20-
# Secrets
20+
# Secrets
2121
{%- for secret in gitops_secrets -%}
2222
{% include "github-secret.njk" %}
2323
{%- endfor %}
24-
{% endfilter %}
2524

2625
# 🖊️ EDIT to specify custom tags for the container image, or default tags will be generated below.
2726
IMAGE_TAGS: ""
@@ -41,97 +40,97 @@ jobs:
4140
environment: production
4241

4342
steps:
44-
- name: Check for required secrets
45-
uses: actions/github-script@v7
46-
with:
47-
script: |
48-
{#-
49-
Perhaps this could use the bash var/secret checker too for consistency
50-
#}
51-
const vars = {
52-
IMAGE_REGISTRY: `${{ "vars.IMAGE_REGISTRY" | inCurlies }}`,
43+
- name: Check for required secrets
44+
uses: actions/github-script@v7
45+
with:
46+
script: |
47+
{#-
48+
Perhaps this could use the bash var/secret checker too for consistency
49+
#}
50+
const vars = {
51+
IMAGE_REGISTRY: `${{ "vars.IMAGE_REGISTRY" | inCurlies }}`,
5352
{% for var in gitops_variables %}
5453
{%- if var | eval_if_condition %}
5554
{%- if var.comment %}
56-
/* {{ var.comment }} */
55+
/* {{ var.comment }} */
5756
{%- endif %}
58-
{% if var.commented_out %}/*{% endif %}{{ var.name }}: `${{ ("vars." + var.name) | inCurlies }}`, {% if var.commented_out %}*/{% endif %}
57+
{% if var.commented_out %}/*{% endif %}{{ var.name }}: `${{ ("vars." + var.name) | inCurlies }}`,{% if var.commented_out %}*/{% endif %}
5958
{%- endif %}
6059
{%- endfor %}
61-
};
60+
};
6261

63-
const missingVars = Object.entries(vars).filter(([ name, value ]) => {
64-
if (value.length === 0) {
65-
core.error(`Variable "${name}" is not set`);
66-
return true;
67-
}
68-
core.info(`✔️ Variable "${name}" is set`);
69-
return false;
70-
});
62+
const missingVars = Object.entries(vars).filter(([ name, value ]) => {
63+
if (value.length === 0) {
64+
core.error(`Variable "${name}" is not set`);
65+
return true;
66+
}
67+
core.info(`✔️ Variable "${name}" is set`);
68+
return false;
69+
});
7170

72-
const secrets = {
71+
const secrets = {
7372
{% for secret in gitops_secrets %}
7473
{%- if secret | eval_if_condition %}
7574
{%- if secret.comment %}
76-
/* {{ secret.comment }} */
75+
/* {{ secret.comment }} */
7776
{%- endif %}
78-
{% if secret.commented_out %}/*{% endif %}{{ secret.name }}: `${{ ("secrets." + secret.name) | inCurlies }}`, {% if secret.commented_out %}*/{% endif %}
77+
{% if secret.commented_out %}/*{% endif %}{{ secret.name }}: `${{ ("secrets." + secret.name) | inCurlies }}`,{% if secret.commented_out %}*/{% endif %}
7978
{%- endif %}
8079
{%- endfor %}
81-
};
80+
};
8281

83-
const missingSecrets = Object.entries(secrets).filter(([ name, value ]) => {
84-
if (value.length === 0) {
85-
core.error(`Secret "${name}" is not set`);
86-
return true;
87-
}
88-
core.info(`✔️ Secret "${name}" is set`);
89-
return false;
90-
});
82+
const missingSecrets = Object.entries(secrets).filter(([ name, value ]) => {
83+
if (value.length === 0) {
84+
core.error(`Secret "${name}" is not set`);
85+
return true;
86+
}
87+
core.info(`✔️ Secret "${name}" is set`);
88+
return false;
89+
});
9190

92-
if (missingVars.length > 0) {
93-
core.error(`❌ At least one required variable is not set in the repository. \n` +
94-
"You can add it using:\n" +
95-
"GitHub UI: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#creating-configuration-variables-for-a-repository \n" +
96-
"GitHub CLI: https://cli.github.com/manual/gh_variable_set \n" +
97-
"Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example");
98-
}
91+
if (missingVars.length > 0) {
92+
core.error(`❌ At least one required variable is not set in the repository. \n` +
93+
"You can add it using:\n" +
94+
"GitHub UI: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#creating-configuration-variables-for-a-repository \n" +
95+
"GitHub CLI: https://cli.github.com/manual/gh_variable_set \n" +
96+
"Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example");
97+
}
9998

100-
if (missingSecrets.length > 0) {
101-
core.error(`❌ At least one required secret is not set in the repository. \n` +
102-
"You can add it using:\n" +
103-
"GitHub UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" +
104-
"GitHub CLI: https://cli.github.com/manual/gh_secret_set \n" +
105-
"Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example");
106-
}
99+
if (missingSecrets.length > 0) {
100+
core.error(`❌ At least one required secret is not set in the repository. \n` +
101+
"You can add it using:\n" +
102+
"GitHub UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" +
103+
"GitHub CLI: https://cli.github.com/manual/gh_secret_set \n" +
104+
"Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example");
105+
}
107106

108-
if (missingVars.length > 0 || missingSecrets.length > 0) {
109-
core.setFailed()
110-
} else {
111-
core.info(`✅ All the required variables and secrets are set`);
112-
}
113-
- name: Check out repository
114-
uses: actions/checkout@v4
115-
with:
116-
fetch-depth: '2'
117-
- name: Pre-init
118-
run: |
119-
buildah --version
120-
syft --version
121-
cosign version
122-
ec version
123-
{# So git doesn't throw "dubious ownership" errors -#}
124-
git config --global --add safe.directory $(pwd)
125-
cat rhtap/env.sh
107+
if (missingVars.length > 0 || missingSecrets.length > 0) {
108+
core.setFailed()
109+
} else {
110+
core.info(`✅ All the required variables and secrets are set`);
111+
}
112+
- name: Check out repository
113+
uses: actions/checkout@v4
114+
with:
115+
fetch-depth: '2'
116+
- name: Pre-init
117+
run: |
118+
buildah --version
119+
syft --version
120+
cosign version
121+
ec version
122+
{# So git doesn't throw "dubious ownership" errors -#}
123+
git config --global --add safe.directory $(pwd)
124+
cat rhtap/env.sh
126125

127126
{%- for step in gitops_steps %}
128-
- name: {{ step.name | title }}
129-
run: |
127+
- name: {{ step.name | title }}
128+
run: |
130129
{%- for substep in step.substeps %}
131-
echo "• {{ substep }}"
132-
bash /work/rhtap/{{ substep }}.sh
130+
echo "• {{ substep }}"
131+
bash /work/rhtap/{{ substep }}.sh
133132
{%- endfor -%}
134133
{%- endfor %}
135-
- name: Done
136-
run: |
137-
echo "Done"
134+
- name: Done
135+
run: |
136+
echo "Done"

templates/partials/github-secret.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{%- if secret | eval_if_condition -%}
22
{%- if secret.comment %}
3-
# {{ secret.comment }}
3+
# {{ secret.comment }}
44
{%- endif %}
5-
{% if secret.commented_out -%}# {% endif -%}{{- secret.name -}}: ${{- ("secrets." + secret.name) | inCurlies -}}
5+
{% if secret.commented_out -%}{{ ' # ' }}{% else %}{{ ' ' }}{% endif -%}{{- secret.name -}}: ${{- ("secrets." + secret.name) | inCurlies -}}
66
{%- endif -%}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{%- if var | eval_if_condition -%}
22
{%- if var.comment %}
3-
# {{ var.comment }}
3+
# {{ var.comment }}
44
{%- endif %}
5-
{% if var.commented_out -%}# {% endif -%}{{- var.name -}}: ${{- ("vars." + var.name) | inCurlies -}}
5+
{% if var.commented_out -%}{{ ' # ' }}{% else %}{{ ' ' }}{% endif -%}{{- var.name -}}: ${{- ("vars." + var.name) | inCurlies -}}
66
{%- endif -%}

templates/source-repo/.gitlab-ci.yml.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ stages:
2727
- results/
2828
{#- The update-deployment should run only after changes are merged -#}
2929
{% if substep == "update-deployment" %}
30-
rules:
30+
rules:
3131
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
3232
{%- endif %}
3333
{%- endfor -%}

templates/source-repo/azure-pipelines.yml.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{%- set secrets = build_secrets -%}
33

44
trigger:
5-
- main
5+
- main
66

77
# Using self-hosted 'Default' agent pool by default
88
# Change accordingly when using a different agent pool
@@ -20,7 +20,7 @@ container:
2020
# Can be deleted if the variables are set differently
2121
# See https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables
2222
variables:
23-
- group: rhtap
23+
- group: rhtap
2424

2525
steps:
2626
{%- filter indent(2) -%}

0 commit comments

Comments
 (0)