差異處
這裏顯示兩個版本的差異處。
| tech:perl:yaml [2021/08/28 13:41] – 建立 jonathan | tech:perl:yaml [2021/08/28 20:40] (目前版本) – jonathan | ||
|---|---|---|---|
| 行 3: | 行 3: | ||
| * Ubuntu : < | * Ubuntu : < | ||
| + | ===== Example ===== | ||
| + | <code perl> | ||
| + | # | ||
| + | |||
| + | use YAML:: | ||
| + | use Data:: | ||
| + | |||
| + | # Load a YAML stream of 3 YAML documents into Perl data structures. | ||
| + | my $loader = YAML:: | ||
| + | my $hash = $loader-> | ||
| + | stages: | ||
| + | - name: Deploy--DB | ||
| + | iiidevops: deployed-environments | ||
| + | steps: | ||
| + | - applyAppConfig: | ||
| + | answers: | ||
| + | db.gui: true | ||
| + | db.name: todo_db | ||
| + | db.password: | ||
| + | db.tag: 13 | ||
| + | db.type: postgresql | ||
| + | db.username: | ||
| + | git.branch: ${CICD_GIT_BRANCH} | ||
| + | git.commitID: | ||
| + | git.repoName: | ||
| + | git.url: ${CICD_GIT_URL} | ||
| + | catalogTemplate: | ||
| + | name: ${CICD_GIT_REPO_NAME}-${CICD_GIT_BRANCH}-db | ||
| + | targetNamespace: | ||
| + | version: 0.3.1 | ||
| + | when: | ||
| + | branch: | ||
| + | include: | ||
| + | - master | ||
| + | |||
| + | - name: Deploy--Wait DB deployment | ||
| + | iiidevops: deployed-environments | ||
| + | steps: | ||
| + | - env: | ||
| + | deploy_name: | ||
| + | max_wait: 128 | ||
| + | namespace: ${CICD_GIT_REPO_NAME} | ||
| + | envFrom: | ||
| + | - sourceKey: API_TOKEN | ||
| + | sourceName: pipeline-api-key | ||
| + | targetKey: rancher_api_token | ||
| + | - sourceKey: rancher-url | ||
| + | sourceName: rancher | ||
| + | targetKey: rancher_url | ||
| + | runScriptConfig: | ||
| + | image: iiiorg/ | ||
| + | shellScript: | ||
| + | when: | ||
| + | branch: | ||
| + | include: | ||
| + | - master | ||
| + | ... | ||
| + | |||
| + | # Dump the Perl data structures back into YAML. | ||
| + | #print Dumper($hash); | ||
| + | |||
| + | $i=0; | ||
| + | while ($hash-> | ||
| + | $hash_t = $hash-> | ||
| + | #print Dumper($hash_t); | ||
| + | print(" | ||
| + | print(" | ||
| + | $i++; | ||
| + | } | ||
| + | </ | ||
| + | ~$ perl example.pl | ||
| + | ----- Deploy--DB --- | ||
| + | | ||
| + | ----- Deploy--Wait DB deployment --- | ||
| + | | ||
| + | ~$ | ||
| + | </ | ||
| ===== 參考網址 ===== | ===== 參考網址 ===== | ||