From 9b69dbad34bed708c76af64fb5629eac8c6c5d2f Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 14 Feb 2022 07:41:44 +0000 Subject: [PATCH] feat(system.rb): add `build_platform_codename` Use to remove duplicate code introduced in: * https://github.com/saltstack-formulas/nginx-formula/pull/289 * https://github.com/saltstack-formulas/postgres-formula/pull/322 * https://github.com/saltstack-formulas/docker-formula/pull/312 --- ssf/defaults.yaml | 4 +- .../integration/share/libraries/system.rb | 44 ++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/ssf/defaults.yaml b/ssf/defaults.yaml index 05757dc6..82c503f9 100644 --- a/ssf/defaults.yaml +++ b/ssf/defaults.yaml @@ -64,8 +64,8 @@ ssf_node_anchors: upstream: 'upstream' commit: # yamllint disable rule:line-length rule:quoted-strings - title: "ci: update linters to latest versions [skip ci]" - body: '* Automated using https://github.com/myii/ssf-formula/pull/414' + title: "test(system): add '`'build_platform_codename'`' [skip ci]" + body: '* Automated using https://github.com/myii/ssf-formula/pull/415' # yamllint enable rule:line-length rule:quoted-strings github: owner: 'saltstack-formulas' diff --git a/ssf/files/default/test/integration/share/libraries/system.rb b/ssf/files/default/test/integration/share/libraries/system.rb index 7471ddcf..64fe7ea7 100644 --- a/ssf/files/default/test/integration/share/libraries/system.rb +++ b/ssf/files/default/test/integration/share/libraries/system.rb @@ -4,6 +4,7 @@ # Author: Daniel Dehennin # Copyright (C) 2020 Daniel Dehennin +# rubocop:disable Metrics/ClassLength class SystemResource < Inspec.resource(1) name 'system' @@ -21,7 +22,8 @@ def build_platform family: build_platform_family, name: build_platform_name, release: build_platform_release, - finger: build_platform_finger + finger: build_platform_finger, + codename: build_platform_codename } end @@ -89,4 +91,44 @@ def build_finger_release build_platform_release.split('.')[0] end end + + # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity + def build_platform_codename + case build_platform_finger + when 'ubuntu-20.04' + 'focal' + when 'ubuntu-18.04' + 'bionic' + when 'debian-11' + 'bullseye' + when 'debian-10' + 'buster' + when 'debian-9' + 'stretch' + when 'almalinux-8' + "AlmaLinux #{build_platform_release} (Arctic Sphynx)" + when 'amazonlinux-2' + 'Amazon Linux 2' + when 'arch-base-latest' + 'Arch Linux' + when 'centos-7' + 'CentOS Linux 7 (Core)' + when 'centos-8' + 'CentOS Stream 8' + when 'opensuse-tumbleweed' + 'openSUSE Tumbleweed' + when 'opensuse-15' + "openSUSE Leap #{build_platform_release}" + when 'oraclelinux-8', 'oraclelinux-7' + "Oracle Linux Server #{build_platform_release}" + when 'gentoo-2-sysd', 'gentoo-2-sysv' + 'Gentoo/Linux' + when 'rockylinux-8' + "Rocky Linux #{build_platform_release} (Green Obsidian)" + else + '' + end + end + # rubocop:enable Metrics/MethodLength,Metrics/CyclomaticComplexity end +# rubocop:enable Metrics/ClassLength