Skip to content

Commit 81027bd

Browse files
openshift-cherrypick-robotdeerskindollthemr0cPatAKnight
authored
[release-1.10] RHDHBUGS-2702: defaultEnvironment parameters (#2327)
* RHDHBUGS-2702 * RHDHBUGS-2702 * Apply suggestion from @themr0c * Update modules/shared/ref-default-environment-parameters-and-secrets.adoc Co-authored-by: Patrick Knight <pknight@redhat.com> * Update modules/shared/ref-default-environment-parameters-and-secrets.adoc Co-authored-by: Patrick Knight <pknight@redhat.com> * RHDHBUGS-2702 --------- Co-authored-by: deerskindoll <jvrbkova@redhat.com> Co-authored-by: Fabrice Flore-Thébault <ffloreth@redhat.com> Co-authored-by: Patrick Knight <pknight@redhat.com>
1 parent be7d68d commit 81027bd

2 files changed

Lines changed: 91 additions & 1 deletion

File tree

assemblies/configure_customizing-rhdh/assembly-standardize-project-development-with-software-templates.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ include::../modules/shared/con-software-templates-in-rhdh.adoc[leveloffset=+1]
1414

1515
include::../modules/shared/proc-create-a-basic-software-template.adoc[leveloffset=+1]
1616

17+
include::../modules/shared/ref-default-environment-parameters-and-secrets.adoc[leveloffset=+1]
18+
1719
include::../modules/shared/ref-sample-software-template.adoc[leveloffset=+1]
1820

1921
include::../modules/shared/proc-share-software-templates-with-your-organization.adoc[leveloffset=+1]
2022

21-
include::../modules/shared/ref-extending-software-templates-for-complex-project-requirements.adoc[leveloffset=+1]
23+
include::../modules/shared/ref-extending-software-templates-for-complex-project-requirements.adoc[leveloffset=+1]
2224

2325
:context: {previouscontext}
2426
:!previouscontext:
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
:_mod-docs-content-type: REFERENCE
2+
3+
[id="default-environment-parameters-and-secrets_{context}"]
4+
= Default environment parameters and secrets
5+
6+
[role="_abstract"]
7+
The scaffolder supports a `defaultEnvironment` configuration
8+
that provides default parameters and secrets to all templates.
9+
Use this configuration in your {my-app-config-file} file to reduce template complexity and improve security by centralizing common values.
10+
11+
Example of an {my-app-config-file} configured for default parameters and secrets::
12+
[source,yaml]
13+
----
14+
scaffolder:
15+
defaultEnvironment:
16+
parameters:
17+
githubOrg: my-org
18+
defaultOwner: platform-team
19+
secrets:
20+
GITHUB_TOKEN: ${GITHUB_TOKEN}
21+
----
22+
23+
[NOTE]
24+
====
25+
Default parameters are isolated in their own context to avoid naming conflicts.
26+
====
27+
28+
Default parameters are accessible via `${{ environment.parameters.* }}` in templates.
29+
30+
Example of default parameters configuration for application deployment::
31+
32+
[source,yaml]
33+
----
34+
spec:
35+
parameters:
36+
- title: Project details
37+
required:
38+
- name
39+
properties:
40+
name:
41+
title: Name
42+
type: string
43+
description: Unique name for the new repository.
44+
45+
steps:
46+
- id: fetch-base
47+
name: Fetch skeleton
48+
action: fetch:template
49+
input:
50+
url: ./skeleton
51+
values:
52+
name: ${{ parameters.name }} # Resolves to frontend input value
53+
owner: ${{ environment.parameters.defaultOwner }} # Resolves to defaultEnvironment.parameters.defaultOwner
54+
----
55+
56+
Default secrets are resolved from environment variables and accessible via `${{ environment.secrets.* }}` in template actions.
57+
58+
Example of a default secret configuration::
59+
60+
[source,yaml]
61+
----
62+
spec:
63+
parameters:
64+
- title: Project details
65+
required:
66+
- name
67+
properties:
68+
name:
69+
title: Name
70+
type: string
71+
description: Unique name for the new repository.
72+
73+
steps:
74+
- id: publish
75+
name: Publish to GitHub
76+
action: publish:github
77+
input:
78+
allowedHosts: ['github.com']
79+
description: ${{ parameters.name }}
80+
repoUrl: github.com?owner=${{ environment.parameters.githubOrg }}&repo=${{ parameters.name }}
81+
token: ${{ environment.secrets.GITHUB_TOKEN }} # Resolves to defaultEnvironment.secrets.GITHUB_TOKEN
82+
----
83+
84+
[IMPORTANT]
85+
====
86+
Secrets are automatically masked in logs. They are only available to backend actions, never exposed to the frontend.
87+
====
88+

0 commit comments

Comments
 (0)