From a46296d923a4fe34b80122cd674315f7522322c3 Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Fri, 2 Apr 2021 16:19:14 +0100 Subject: [PATCH 1/3] feat(schema constraints): use cuelang for schema constraints --- .gitlab-ci.yml | 1 + TEMPLATE/parameters/schema.cue | 47 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 TEMPLATE/parameters/schema.cue diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e9c68f5..4ab1aee6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,7 @@ only_branch_master_parent_repo: &only_branch_master_parent_repo - 'master@saltstack-formulas/template-formula' # `stage` + stage_constraints: &stage_constraints 'constraints' stage_lint: &stage_lint 'lint' stage_release: &stage_release 'release' stage_test: &stage_test 'test' diff --git a/TEMPLATE/parameters/schema.cue b/TEMPLATE/parameters/schema.cue new file mode 100755 index 00000000..51d3bc06 --- /dev/null +++ b/TEMPLATE/parameters/schema.cue @@ -0,0 +1,47 @@ +// -*- coding: utf-8 -*- +// vim: ft=yaml +// +// Constraints Schema: +// This is not a prescriptive or forced schema! Many variants of +// formula (and yaml data) exist in the salt user community. +// Therefore the use of cue '?' and "aliases" is recommended. + +// template-formula +#template: { + pkg?: name?: string + rootgroup?: string + hide_output?: bool + dir_mode?: =~"^0?[124567]{3}$" // any mode of length 3, with 0 prefix optional + mode?: =~"^0?[124567]{3}$" // any mode of length 3, with 0 prefix optional + config?: string + service?: name?: string + subcomponent?: config?: string + + // legacy + pip_pkg?: string + pkgs_add?: [...] + pips?: [...] + + // Just here for testing + added_in_defaults?: string + winner?: string + ... +} +values?: {...#template} // probable yaml namespace + +// +// support formula diversity :-) +// + +template?: {...#template} // another probable namespace + +Debian?: #template +Suse?: #template +Gentoo?: #template +Arch?: #template +Alpine?: #template +FreeBSD?: #template +OpenBSD?: #template +Solaris?: #template +Windows?: #template +MacOS?: #template From 5faae28e6aa0ecee43dfcabc1f141c1ebac70cef Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 5 Apr 2021 18:22:50 +0100 Subject: [PATCH 2/3] chore: update `CODEOWNERS` & `.yamllint` re: `kitchen-vagrant` [skip ci] * Automated using https://github.com/myii/ssf-formula/pull/310 --- .yamllint | 2 ++ CODEOWNERS | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.yamllint b/.yamllint index 5a060ef9..72dc99f2 100644 --- a/.yamllint +++ b/.yamllint @@ -10,12 +10,14 @@ extends: 'default' # 3. All YAML files under directory `node_modules/`, introduced during the Travis run # 4. Any SLS files under directory `test/`, which are actually state files # 5. Any YAML files under directory `.kitchen/`, introduced during local testing +# 6. `kitchen.vagrant.yml`, which contains Embedded Ruby (ERB) template syntax ignore: | .cache/ .git/ node_modules/ test/**/states/**/*.sls .kitchen/ + kitchen.vagrant.yml yaml-files: # Default settings diff --git a/CODEOWNERS b/CODEOWNERS index f0221bfb..60a18662 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -39,6 +39,8 @@ /Gemfile @saltstack-formulas/ssf /Gemfile.lock @saltstack-formulas/ssf /kitchen.yml @saltstack-formulas/ssf +/kitchen.vagrant.yml @saltstack-formulas/ssf +/kitchen.windows.yml @saltstack-formulas/ssf /pre-commit_semantic-release.sh @saltstack-formulas/ssf /release-rules.js @saltstack-formulas/ssf /release.config.js @saltstack-formulas/ssf From 1bdaabeffb00a199ee1d10bebb327e1b9d8ded01 Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Mon, 12 Apr 2021 13:40:42 +0100 Subject: [PATCH 3/3] ci(schema): add cuelange example schema job --- .gitlab-ci.yml | 16 +++++++++- TEMPLATE/parameters/schema.cue | 54 +++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ab1aee6..d5b8e6c2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,12 +9,15 @@ only_branch_master_parent_repo: &only_branch_master_parent_repo - 'master@saltstack-formulas/template-formula' # `stage` - stage_constraints: &stage_constraints 'constraints' + stage_schema: &stage_schema 'schema' stage_lint: &stage_lint 'lint' stage_release: &stage_release 'release' stage_test: &stage_test 'test' # `image` image_commitlint: &image_commitlint 'myii/ssf-commitlint:11' + image_cuelang: &image_cuelang + name: 'myii/ssf-cue:0.3.2' # instead of cuelang/cue + entrypoint: ['/bin/ash', '-c'] image_dindruby: &image_dindruby 'myii/ssf-dind-ruby:2.7.1-r3' image_dindrubybionic: &image_dindrubybionic 'myii/ssf-dind-ruby-bionic:1_2.5.1' image_precommit: &image_precommit @@ -42,6 +45,7 @@ ############################################################################### stages: - *stage_lint + - *stage_schema - *stage_test - *stage_release variables: @@ -101,6 +105,16 @@ rubocop: script: - 'rubocop -d -P -S --enable-pending-cops' +cue: + allow_failure: true + stage: *stage_schema + image: *image_cuelang + variables: + DIR: 'TEMPLATE/parameters' + RULES: 'schema.cue' + script: + - 'cue vet -v $(find ${DIR} -name "*.yaml") ${DIR}/${RULES} --schema "#Values"' + ############################################################################### # Define `test` template ############################################################################### diff --git a/TEMPLATE/parameters/schema.cue b/TEMPLATE/parameters/schema.cue index 51d3bc06..6cb5c65a 100755 --- a/TEMPLATE/parameters/schema.cue +++ b/TEMPLATE/parameters/schema.cue @@ -1,14 +1,18 @@ // -*- coding: utf-8 -*- // vim: ft=yaml + +// +// Data Constaints - Example from Saltstack-formulas // -// Constraints Schema: -// This is not a prescriptive or forced schema! Many variants of -// formula (and yaml data) exist in the salt user community. -// Therefore the use of cue '?' and "aliases" is recommended. -// template-formula -#template: { - pkg?: name?: string +#Schema: #Values + +// +// Rule +// +#Optional: { + pkg?: + name?: string rootgroup?: string hide_output?: bool dir_mode?: =~"^0?[124567]{3}$" // any mode of length 3, with 0 prefix optional @@ -27,21 +31,31 @@ winner?: string ... } -values?: {...#template} // probable yaml namespace // -// support formula diversity :-) +// Schema Name // +#Values: { + values?: {...#Optional} +} +values?: {...#Values} // Namespace + -template?: {...#template} // another probable namespace +// +// Older schema +// +#TEMPLATE: { + TEMPLATE?: {...#Optional} +} +TEMPLATE?: {...#Optional} -Debian?: #template -Suse?: #template -Gentoo?: #template -Arch?: #template -Alpine?: #template -FreeBSD?: #template -OpenBSD?: #template -Solaris?: #template -Windows?: #template -MacOS?: #template +Debian?: #Optional +Suse?: #Optional +Gentoo?: #Optional +Arch?: #Optional +Alpine?: #Optional +FreeBSD?: #Optional +OpenBSD?: #Optional +Solaris?: #Optional +Windows?: #Optional +MacOS?: #Optional