Skip to content

Commit e926a71

Browse files
Merge pull request #37 from noelmcloughlin/cleanup
feat(macos): add homebrew support & tidyup stuff
2 parents 5aa5afb + 074072c commit e926a71

File tree

16 files changed

+154
-188
lines changed

16 files changed

+154
-188
lines changed

.travis.yml

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ stages:
2525
- name: 'release'
2626
if: 'branch = master AND type != pull_request'
2727
jobs:
28-
allow_failures:
29-
- env: Lint_rubocop
30-
fast_finish: true
3128
include:
3229
## Define the test stage that runs the linters (and testing matrix, if applicable)
3330

34-
# Run all of the linters in a single job (except `rubocop`)
31+
# Run all of the linters in a single job
3532
- language: 'node_js'
3633
node_js: 'lts/*'
3734
env: 'Lint'
38-
name: 'Lint: salt-lint, yamllint, shellcheck & commitlint'
35+
name: 'Lint: salt-lint, yamllint, rubocop, shellcheck & commitlint'
3936
before_install: 'skip'
4037
script:
4138
# Install and run `salt-lint`
@@ -46,6 +43,9 @@ jobs:
4643
# Need at least `v1.17.0` for the `yaml-files` setting
4744
- pip install --user yamllint>=1.17.0
4845
- yamllint -s .
46+
# Install and run `rubocop`
47+
- gem install rubocop
48+
- rubocop -d
4949
# Run `shellcheck` (already pre-installed in Travis)
5050
- shellcheck --version
5151
- git ls-files -- '*.sh' '*.bash' '*.ksh'
@@ -54,50 +54,39 @@ jobs:
5454
- npm i -D @commitlint/config-conventional
5555
@commitlint/travis-cli
5656
- commitlint-travis
57-
# Run the `rubocop` linter in a separate job that is allowed to fail
58-
# Once these lint errors are fixed, this can be merged into a single job
59-
- language: node_js
60-
node_js: lts/*
61-
env: Lint_rubocop
62-
name: 'Lint: rubocop'
63-
before_install: skip
64-
script:
65-
# Install and run `rubocop`
66-
- gem install rubocop
67-
- rubocop -d
6857

6958
## Define the rest of the matrix based on Kitchen testing
7059
# Make sure the instances listed below match up with
7160
# the `platforms` defined in `kitchen.yml`
7261
- env: INSTANCE=default-debian-10-master-py3
7362
# - env: INSTANCE=default-ubuntu-1804-master-py3
74-
# - env: INSTANCE=default-centos-8-master-py3
75-
# - env: INSTANCE=default-fedora-31-master-py3
76-
# - env: INSTANCE=default-opensuse-leap-151-master-py3
63+
- env: INSTANCE=default-centos-8-master-py3
64+
- env: INSTANCE=default-fedora-31-master-py3
65+
- env: INSTANCE=default-opensuse-leap-151-master-py3
7766
# - env: INSTANCE=default-amazonlinux-2-master-py3
67+
# - env: INSTANCE=default-debian-10-3000-2-py3
68+
# - env: INSTANCE=default-debian-9-3000-2-py3
69+
# - env: INSTANCE=default-ubuntu-1804-3000-2-py3
70+
# - env: INSTANCE=default-centos-8-3000-2-py3
71+
# - env: INSTANCE=default-centos-7-3000-2-py3
72+
# - env: INSTANCE=default-fedora-31-3000-2-py3
73+
# - env: INSTANCE=default-opensuse-leap-151-3000-2-py3
74+
# - env: INSTANCE=default-amazonlinux-2-3000-2-py3
75+
# - env: INSTANCE=default-ubuntu-1804-3000-2-py2
76+
# - env: INSTANCE=default-ubuntu-1604-3000-2-py2
77+
# - env: INSTANCE=arch-arch-base-latest-3000-2-py2
7878
# - env: INSTANCE=default-debian-10-2019-2-py3
7979
# - env: INSTANCE=default-debian-9-2019-2-py3
80-
- env: INSTANCE=default-ubuntu-1804-2019-2-py3
80+
# - env: INSTANCE=default-ubuntu-1804-2019-2-py3
81+
# - env: INSTANCE=default-ubuntu-1604-2019-2-py3
8182
# - env: INSTANCE=default-centos-8-2019-2-py3
83+
# - env: INSTANCE=default-centos-7-2019-2-py3
8284
# - env: INSTANCE=default-fedora-31-2019-2-py3
8385
# - env: INSTANCE=default-opensuse-leap-151-2019-2-py3
84-
# - env: INSTANCE=default-centos-7-2019-2-py2
85-
- env: INSTANCE=default-amazonlinux-2-2019-2-py3
86-
# - env: INSTANCE=default-arch-base-latest-2019-2-py2
87-
- env: INSTANCE=default-fedora-30-2018-3-py3
88-
- env: INSTANCE=default-debian-9-2018-3-py2
89-
# - env: INSTANCE=default-ubuntu-1604-2018-3-py2
90-
# - env: INSTANCE=default-centos-7-2018-3-py2
91-
# - env: INSTANCE=default-opensuse-leap-151-2018-3-py2
92-
# - env: INSTANCE=default-amazonlinux-1-2018-3-py2
93-
# - env: INSTANCE=default-arch-base-latest-2018-3-py2
94-
# - env: INSTANCE=default-debian-8-2017-7-py2
95-
# - env: INSTANCE=default-ubuntu-1604-2017-7-py2
96-
- env: INSTANCE=default-centos-6-2017-7-py2
97-
# - env: INSTANCE=default-fedora-30-2017-7-py2
98-
# - env: INSTANCE=default-opensuse-leap-151-2017-7-py2
99-
# - env: INSTANCE=default-amazonlinux-1-2017-7-py2
100-
# - env: INSTANCE=default-arch-base-latest-2017-7-py2
86+
# - env: INSTANCE=default-amazonlinux-2-2019-2-py3
87+
# - env: INSTANCE=default-centos-6-2019-2-py2
88+
# - env: INSTANCE=default-amazonlinux-1-2019-2-py2
89+
# env: INSTANCE=arch-arch-base-latest-2019-2-py2
10190

10291
## Define the release stage that runs `semantic-release`
10392
- stage: 'release'

.yamllint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ignore: |
1212
node_modules/
1313
test/**/states/**/*.sls
1414
.kitchen/
15+
golang/osfamilymap.yaml
1516
1617
yaml-files:
1718
# Default settings

CODEOWNERS

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
22

33
# SECTION: Owner(s) for everything in the repo, unless a later match takes precedence
4-
# **************************************************************************
5-
# *** NO GLOBAL OWNER(S) SPECIFIED ***
6-
# *** Ideally this will be defined for a healthy, well-maintained repo ***
7-
# **************************************************************************
84
# FILE PATTERN OWNER(S)
9-
* @NONE
5+
* @noelmcloughlin
106

117
# SECTION: Owner(s) for specific directories
128
# FILE PATTERN OWNER(S)

FORMULA

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: golang
2-
os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, Windows, MacOS
2+
os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Amazon, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, Windows, MacOS
33
os_family: Debian, RedHat, Suse, Gentoo, Arch, Alpine, FreeBSD, OpenBSD, Solaris, Windows, MacOS
44
version: 0.6.5
55
release: 1
6-
minimum_version: 2016.11
6+
minimum_version: 2019.2
77
summary: golang formula
8-
description: Formula for golang
8+
description: Formula to install golang and configure it
99
top_level_dir: golang

golang/archive/clean.sls

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
golang-cli-package-archive-clean-file-absent:
99
file.absent:
1010
- names:
11-
- {{ golang.pkg.archive.name }}/go
11+
- {{ golang.pkg.archive.name }}
12+
- /usr/local/go
1213
{%- if golang.kernel == 'linux' %}
13-
- {{ golang.linux.base_dir }}
14+
- {{ golang.path }}
1415
{%- endif %}

golang/archive/install.sls

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,17 @@ golang-package-archive-install-file-directory:
2525
golang-package-archive-install-archive-extracted:
2626
archive.extracted:
2727
{{- format_kwargs(golang.pkg.archive) }}
28-
- retry:
29-
attempts: 3
30-
until: True
31-
interval: 60
32-
splay: 10
28+
- retry: {{ golang.retry_option }}
3329
- user: {{ golang.rootuser }}
3430
- group: {{ golang.rootgroup }}
31+
32+
{%- if golang.linux.altpriority|int == 0 or grains.os_family in ('Arch', 'MacOS',) %}
33+
34+
golang-archive-install-file-symlink-golang:
35+
file.symlink:
36+
- name: /usr/local/bin/go
37+
- target: {{ golang.path }}/{{ golang.command }}
38+
- force: True
39+
- onlyif: test -f {{ golang.path }}/{{ golang.command }}
40+
41+
{%- endif %}

golang/config/alternatives/clean.sls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ include:
1515
golang-package-archive-remove-home-alternative-remove:
1616
alternatives.remove:
1717
- name: golang-home
18-
- path: {{ golang.linux.base_dir }}/go
18+
- path: {{ golang.path }}/go
1919
- onlyif: update-alternatives --get-selections |grep ^golang-home
2020
- require:
2121
- sls: {{ sls_archive_clean if golang.pkg.use_upstream_archive else sls_package_clean }}
@@ -25,7 +25,7 @@ golang-package-archive-remove-home-alternative-remove:
2525
golang-package-archive-remove-{{ i }}-alternative-remove:
2626
alternatives.remove:
2727
- name: link-{{ i }}
28-
- path: {{ golang.linux.base_dir }}/go/bin/{{ i }}
28+
- path: {{ golang.path }}/go/bin/{{ i }}
2929
- onlyif: update-alternatives --get-selections |grep ^link-{{ i }}
3030
- require:
3131
- sls: {{ sls_archive_clean if golang.pkg.use_upstream_archive else sls_package_clean }}

golang/config/alternatives/install.sls

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ include:
1515
1616
golang-package-archive-install-home-alternative-install:
1717
cmd.run:
18-
- name: update-alternatives --install {{ golang.linux.dir }} golang-home {{ golang.linux.base_dir }}/go {{ golang.linux.altpriority }}
18+
- name: update-alternatives --install {{ golang.linux.dir }} golang-home {{ golang.path }}/go {{ golang.linux.altpriority }}
1919
- watch:
2020
- archive: golang-package-archive-install-archive-extracted
2121
- require:
@@ -24,7 +24,7 @@ golang-package-archive-install-home-alternative-install:
2424
alternatives.install:
2525
- name: golang-home
2626
- link: {{ golang.linux.dir }}
27-
- path: {{ golang.linux.base_dir }}/go
27+
- path: {{ golang.path }}/go
2828
- priority: {{ golang.linux.altpriority }}
2929
- order: 10
3030
- watch:
@@ -36,7 +36,7 @@ golang-package-archive-install-home-alternative-install:
3636
golang-package-archive-install-home-alternative-set:
3737
alternatives.set:
3838
- name: golang-home
39-
- path: {{ golang.linux.base_dir }}/go
39+
- path: {{ golang.path }}/go
4040
- require:
4141
- alternatives: golang-package-archive-install-home-alternative-install
4242
- unless: {{ grains.os_family in ('Suse',) }}
@@ -45,14 +45,14 @@ golang-package-archive-install-home-alternative-set:
4545
4646
golang-package-archive-install-{{ i }}-alternative-install:
4747
cmd.run:
48-
- name: update-alternatives --install /usr/bin/{{ i }} link-{{ i }} {{ golang.linux.base_dir }}/go/bin/{{ i }} {{ golang.linux.altpriority }}
48+
- name: update-alternatives --install /usr/bin/{{ i }} link-{{ i }} {{ golang.path }}/go/bin/{{ i }} {{ golang.linux.altpriority }}
4949
- require:
5050
- cmd: golang-package-archive-install-home-alternative-install
5151
- onlyif: {{ grains.os_family in ('Suse',) }}
5252
alternatives.install:
5353
- name: link-{{ i }}
5454
- link: /usr/bin/{{ i }}
55-
- path: {{ golang.linux.base_dir }}/go/bin/{{ i }}
55+
- path: {{ golang.path }}/go/bin/{{ i }}
5656
- priority: {{ golang.linux.altpriority }}
5757
- order: 10
5858
- require:
@@ -62,7 +62,7 @@ golang-package-archive-install-{{ i }}-alternative-install:
6262
golang-package-archive-install-{{ i }}-alternative-set:
6363
alternatives.set:
6464
- name: link-{{ i }}
65-
- path: {{ golang.linux.base_dir }}/go/bin/{{ i }}
65+
- path: {{ golang.path }}/go/bin/{{ i }}
6666
- require:
6767
- alternatives: golang-package-archive-install-{{ i }}-alternative-install
6868
- unless: {{ grains.os_family in ('Suse',) }}

golang/config/environ.sls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ golang-config-file-managed-environ_file:
3636
golang-config-file-symlink-{{ i }}-golang-binary:
3737
file.symlink:
3838
- name: /usr/local/bin/{{ i }}
39-
- target: {{ golang.linux.base_dir }}/ {{ i }}
39+
- target: {{ golang.path }}/ {{ i }}
4040
- mode: '0755'
4141
- force: True
4242
- onlyif:
4343
- {{ grains.os_family in ('Arch', 'FreeBSD', 'MacOS') }}
44-
- test -x {{ golang.linux.base_dir }}/ {{ i }}
44+
- test -x {{ golang.path }}/ {{ i }}
4545
4646
{%- endfor %}

golang/defaults.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ golang:
66
go_path: /usr/local/golang/packages # non-default GOPATH
77
rootuser: root
88
rootgroup: root
9+
command: go/bin/go
910
pkg:
1011
name: go
1112
use_upstream_repo: false
@@ -42,3 +43,10 @@ golang:
4243
cmd:
4344
goget: []
4445
clean: []
46+
47+
retry_option:
48+
# https://docs.saltstack.com/en/latest/ref/states/requisites.html#retrying-states
49+
attempts: 2
50+
until: true
51+
interval: 10
52+
splay: 10

golang/files/default/golang.sh.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
##portable shell syntax
77

88
[ -n "${GOROOT}" ] && export GOROOT=${GOROOT}
9-
[ -n "{{ golang.linux.base_dir }}" ] && export GOROOT={{ golang.linux.base_dir }}
9+
[ -n "{{ golang.path }}" ] && export GOROOT={{ golang.path }}
1010

1111
[ -n "${GOPATH}" ] && export GOPATH=${GOPATH}
1212
[ -n "{{ golang.go_path }}" ] && export GOPATH={{ golang.go_path }}

golang/map.jinja

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=jinja
33

4-
{#- Get the `tplroot` from `tpldir` #}
54
{%- set tplroot = tpldir.split('/')[0] %}
6-
{#- Start imports as #}
75
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
86
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
97
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
108
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
119
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}
1210

13-
{#- Retrieve the config dict only once #}
1411
{%- set _config = salt['config.get'](tplroot, default={}) %}
1512

1613
{%- set defaults = salt['grains.filter_by'](
@@ -47,7 +44,6 @@
4744
%}
4845
{%- set golang = config %}
4946

50-
{#- Post-processing for specific non-YAML customisations #}
5147
{%- do golang.update({'kernel': grains.kernel | lower}) %}
5248
{%- if grains.os == 'MacOS' %}
5349
{%- set macos_user = salt['cmd.run']("stat -f '%Su' /dev/console") %}
@@ -58,7 +54,6 @@
5854
}) %}
5955
{%- endif %}
6056

61-
{#- archive jinja #}
6257
{%- if golang.pkg.use_upstream_archive %}
6358
{%- set name = 'go%s.%s-%s'|format(golang.version, golang.kernel, golang.arch) %}
6459
{%- set uri = golang.pkg.archive.uri + '/' + name %}
@@ -68,11 +63,11 @@
6863
'source_hash': uri + '.' + golang.pkg.archive.archive_suffix + '.sha256',
6964
'archive_format': golang.pkg.archive.archive_format
7065
}) %}
71-
{%- do golang.linux.update({'base_dir': golang.pkg.archive.name}) %}
66+
{%- do golang.update({'path': golang.pkg.archive.name}) %}
7267
{%- do golang.environ.append('export PATH=${PATH}:%s/go/bin'|format(golang.pkg.archive.name)) %}
7368
{%- endif %}
7469

75-
{#- Post-processing for specific YAML keys depreciated in a major releases #}
70+
{#- Depreciated parameter 'golang.dir' #}
7671
{%- if 'dir' in golang and golang.dir and golang.kernel == 'linux' %}
7772
{%- do golang.linux.update({'dir': golang.dir}) %}
7873
{%- endif %}

golang/package/clean.sls

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=sls
33

4-
{#- Get the `tplroot` from `tpldir` #}
54
{%- set tplroot = tpldir.split('/')[0] %}
65
{%- set sls_config_clean = tplroot ~ '.config.clean' %}
6+
{%- set sls_repo_clean = '.repo.clean' %}
77
{%- from tplroot ~ "/map.jinja" import golang with context %}
88
99
include:
1010
- {{ sls_config_clean }}
11+
{%- if grains.kernel|lower == 'linux' %}
12+
- {{ sls_repo_clean }}
1113
12-
{%- if golang.pkg.use_upstream_repo %}
13-
include:
14-
- .repo.clean
15-
{%- endif %}
16-
17-
golang-package-clean-pkg-removed:
14+
golang-package-clean-pkg-cleaned:
1815
pkg.removed:
1916
- name: {{ golang.pkg.name }}
2017
- require:
2118
- sls: {{ sls_config_clean }}
19+
- sls: {{ sls_repo_clean }}
20+
21+
{%- elif grains.os_family == 'MacOS' %}
22+
23+
golang-package-clean-cmd-run-brew:
24+
cmd.run:
25+
- name: brew uninstall --force {{ golang.pkg.name }}
26+
- runas: {{ golang.rootuser }}
27+
- onlyif: test -x /usr/local/bin/brew
28+
- require:
29+
- sls: {{ sls_config_clean }}
30+
31+
{%- endif %}

0 commit comments

Comments
 (0)