mirror of
https://github.com/saltstack-formulas/packages-formula.git
synced 2025-04-16 01:30:22 +00:00
Merge pull request #58 from noelmcloughlin/go
feat(golang): add go package management
This commit is contained in:
commit
1aa6f50091
14 changed files with 122 additions and 13 deletions
10
README.rst
10
README.rst
|
@ -176,6 +176,16 @@ You can specify:
|
||||||
|
|
||||||
Centos has no native ``snapd`` package at this time.
|
Centos has no native ``snapd`` package at this time.
|
||||||
|
|
||||||
|
|
||||||
|
``packages.golang``
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
You can specify:
|
||||||
|
|
||||||
|
* ``clean`` golang packages, removed using ``go clean -i <item>...``.
|
||||||
|
* ``goget`` golang packages, installed using ``go get``.
|
||||||
|
|
||||||
|
|
||||||
``packages.remote_pkgs``
|
``packages.remote_pkgs``
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,16 @@ platforms:
|
||||||
run_command: /lib/systemd/systemd
|
run_command: /lib/systemd/systemd
|
||||||
provision_command:
|
provision_command:
|
||||||
- apt-get update && apt-get install -y udev locales git
|
- apt-get update && apt-get install -y udev locales git
|
||||||
|
- echo 'export PATH=${PATH}:/usr/local/go/bin' >/etc/default/golang.sh
|
||||||
|
- export PATH="${PATH}:/usr/local/go/bin"
|
||||||
- name: ubuntu-18.04
|
- name: ubuntu-18.04
|
||||||
driver_config:
|
driver_config:
|
||||||
image: ubuntu:18.04
|
image: ubuntu:18.04
|
||||||
run_command: /lib/systemd/systemd
|
run_command: /lib/systemd/systemd
|
||||||
provision_command:
|
provision_command:
|
||||||
- apt-get update && apt-get install -y udev locales git
|
- apt-get update && apt-get install -y udev locales git
|
||||||
|
- echo 'export PATH=${PATH}:/usr/local/go/bin' >/etc/default/golang.sh
|
||||||
|
- export PATH="${PATH}:/usr/local/go/bin"
|
||||||
- name: ubuntu-16.04
|
- name: ubuntu-16.04
|
||||||
driver_config:
|
driver_config:
|
||||||
image: ubuntu:16.04
|
image: ubuntu:16.04
|
||||||
|
@ -35,6 +39,8 @@ platforms:
|
||||||
- apt-get update && apt-get install -y udev locales git
|
- apt-get update && apt-get install -y udev locales git
|
||||||
- locale-gen en_US.UTF-8
|
- locale-gen en_US.UTF-8
|
||||||
- update-locale LANG=en_US.UTF-8
|
- update-locale LANG=en_US.UTF-8
|
||||||
|
- echo 'export PATH=${PATH}:/usr/local/go/bin' >/etc/default/golang.sh
|
||||||
|
- export PATH="${PATH}:/usr/local/go/bin"
|
||||||
- name: centos-7
|
- name: centos-7
|
||||||
driver_config:
|
driver_config:
|
||||||
image: centos:7
|
image: centos:7
|
||||||
|
|
|
@ -33,7 +33,7 @@ packages-archive-wanted-target-{{ package }}-directory:
|
||||||
{%- if packages.tmpdir != '/tmp' %}
|
{%- if packages.tmpdir != '/tmp' %}
|
||||||
- {{ packages.tmpdir }}
|
- {{ packages.tmpdir }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
- user: {{ 'root' if 'user' not in archive else archive.user }}
|
- user: {{ packages.rootuser if 'user' not in archive else archive.user }}
|
||||||
- mode: {{ '0755' if 'mode' not in archive else archive.mode }}
|
- mode: {{ '0755' if 'mode' not in archive else archive.mode }}
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
- require_in:
|
- require_in:
|
||||||
|
@ -85,7 +85,7 @@ packages-archive-wanted-download-{{ package }}:
|
||||||
- name: {{ archive.dest }}/{{ archivename }}
|
- name: {{ archive.dest }}/{{ archivename }}
|
||||||
- source: {{ archive.dl.source }}
|
- source: {{ archive.dl.source }}
|
||||||
- mode: {{ '0755' if archive.dl.format in ('bin',) else '0644' if 'mode' not in archive else archive.mode }}
|
- mode: {{ '0755' if archive.dl.format in ('bin',) else '0644' if 'mode' not in archive else archive.mode }}
|
||||||
- user: {{ 'root' if 'user' not in archive else archive.user }}
|
- user: {{ packages.rootuser if 'user' not in archive else archive.user }}
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
{%- if 'hashsum' in archive.dl and archive.dl.hashsum %}
|
{%- if 'hashsum' in archive.dl and archive.dl.hashsum %}
|
||||||
- source_hash: {{ archive.dl.hashsum }}
|
- source_hash: {{ archive.dl.hashsum }}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# vim: ft=yaml
|
# vim: ft=yaml
|
||||||
packages:
|
packages:
|
||||||
tmpdir: /tmp/saltstack-packages-formula-archives
|
tmpdir: /tmp/saltstack-packages-formula-archives
|
||||||
|
rootuser: root
|
||||||
remote_pkgs: {}
|
remote_pkgs: {}
|
||||||
pkgs:
|
pkgs:
|
||||||
held: {}
|
held: {}
|
||||||
|
@ -40,6 +41,9 @@ packages:
|
||||||
required:
|
required:
|
||||||
states: []
|
states: []
|
||||||
pkgs: []
|
pkgs: []
|
||||||
|
golang:
|
||||||
|
goget: []
|
||||||
|
clean: []
|
||||||
archives:
|
archives:
|
||||||
pkgs:
|
pkgs:
|
||||||
required: ['curl', 'bzip2', 'gzip']
|
required: ['curl', 'bzip2', 'gzip']
|
||||||
|
|
15
packages/golang/clean.sls
Normal file
15
packages/golang/clean.sls
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import packages with context %}
|
||||||
|
|
||||||
|
{%- for package in packages.golang.clean %}
|
||||||
|
|
||||||
|
packages-golang-clean-{{ package }}-cmd-run:
|
||||||
|
cmd.run:
|
||||||
|
- name: go clean -i {{ package }}...
|
||||||
|
- runas: {{ packages.rootuser }}
|
||||||
|
|
||||||
|
{%- endfor %}
|
15
packages/golang/goget.sls
Normal file
15
packages/golang/goget.sls
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import packages with context %}
|
||||||
|
|
||||||
|
{%- for package in packages.golang.goget %}
|
||||||
|
|
||||||
|
packages-golang-goget-{{ package }}-cmd-run:
|
||||||
|
cmd.run:
|
||||||
|
- name: go get {{ package }}
|
||||||
|
- runas: {{ packages.rootuser }}
|
||||||
|
|
||||||
|
{%- endfor %}
|
6
packages/golang/init.sls
Normal file
6
packages/golang/init.sls
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
include:
|
||||||
|
- .clean
|
||||||
|
- .goget
|
|
@ -18,3 +18,10 @@
|
||||||
),
|
),
|
||||||
base='packages')
|
base='packages')
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
{#- Post-processing for specific non-YAML customisations #}
|
||||||
|
{%- do packages.update({'kernel': grains.kernel | lower}) %}
|
||||||
|
{%- if grains.os == 'MacOS' %}
|
||||||
|
{%- set macos_user = salt['cmd.run']("stat -f '%Su' /dev/console") %}
|
||||||
|
{%- do packages.update({'rootuser': macos_user}) %}
|
||||||
|
{%- endif %}
|
||||||
|
|
|
@ -32,8 +32,8 @@ npm_req_pkgs:
|
||||||
npms_dir:
|
npms_dir:
|
||||||
file.directory:
|
file.directory:
|
||||||
- name: {{ packages.npms.dir }}
|
- name: {{ packages.npms.dir }}
|
||||||
- user: {{ 'root' if 'user' not in packages.npms else packages.npms.user }}
|
- user: {{ packages.rootuser if 'user' not in packages.npms else packages.npms.user }}
|
||||||
- group: {{ 'root' if 'group' not in packages.npms else packages.npms.group }}
|
- group: {{ packages.rootuser if 'group' not in packages.npms else packages.npms.group }}
|
||||||
- mode: {{ '0755' if 'mode' not in packages.npms else packages.npms.mode }}
|
- mode: {{ '0755' if 'mode' not in packages.npms else packages.npms.mode }}
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -61,6 +61,14 @@ packages:
|
||||||
unwanted:
|
unwanted:
|
||||||
- goodbye-world
|
- goodbye-world
|
||||||
|
|
||||||
|
golang:
|
||||||
|
goget:
|
||||||
|
- github.com/golang/example/hello
|
||||||
|
- github.com/golang/example/outyet
|
||||||
|
clean:
|
||||||
|
- github.com/golang/example/hello
|
||||||
|
- github.com/golang/example/outyet
|
||||||
|
|
||||||
npms:
|
npms:
|
||||||
dir: /home/kitchen/npms # The target directory in which to install the package, or None for global installation
|
dir: /home/kitchen/npms # The target directory in which to install the package, or None for global installation
|
||||||
user: kitchen # The user to run NPM with (and to assign to `dir`)
|
user: kitchen # The user to run NPM with (and to assign to `dir`)
|
||||||
|
|
|
@ -15,7 +15,7 @@ control 'Archive packages' do
|
||||||
it { should exist }
|
it { should exist }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
describe file('/usr/local/bin/kubectl') do
|
describe file('/usr/local/go/bin/go') do
|
||||||
it { should be_executable }
|
it { should be_executable }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
22
test/integration/default/golang_spec.rb
Normal file
22
test/integration/default/golang_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
go_path = '/home/kitchen/go'
|
||||||
|
|
||||||
|
# GO GET
|
||||||
|
control 'go get github.com/golang/example/hello' do
|
||||||
|
title 'should be installed'
|
||||||
|
desc '(only testing in the Debian platform, as these are OS-independent'
|
||||||
|
|
||||||
|
only_if do
|
||||||
|
os.debian?
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/usr/local/go/bin/go') do
|
||||||
|
it { should be_executable }
|
||||||
|
end
|
||||||
|
|
||||||
|
%w(
|
||||||
|
github.com/golang/example/hello
|
||||||
|
).each do |f|
|
||||||
|
describe file("#{go_path}/src/#{f}") do
|
||||||
|
it { should exist }
|
||||||
|
end
|
||||||
|
end
|
|
@ -79,14 +79,22 @@ packages:
|
||||||
format: raw
|
format: raw
|
||||||
source: https://raw.githubusercontent.com/openstack/cinder/master/contrib/block-box/docker-compose.yml
|
source: https://raw.githubusercontent.com/openstack/cinder/master/contrib/block-box/docker-compose.yml
|
||||||
hashsum: 1751f8e4f6b4cddd8c4843a0f4473274
|
hashsum: 1751f8e4f6b4cddd8c4843a0f4473274
|
||||||
kubectl:
|
golang:
|
||||||
dest: /usr/local/bin
|
dest: /usr/local
|
||||||
dl:
|
dl:
|
||||||
format: bin
|
format: tar
|
||||||
source: https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/darwin/amd64/kubectl
|
source: https://dl.google.com/go/go1.12.7.linux-amd64.tar.gz
|
||||||
|
hashsum: 66d83bfb5a9ede000e33c6579a91a29e6b101829ad41fffb5c5bb6c900e109d9
|
||||||
unwanted:
|
unwanted:
|
||||||
- /usr/local/boring_archive_software
|
- /usr/local/boring_archive_software
|
||||||
|
|
||||||
remote_pkgs:
|
remote_pkgs:
|
||||||
zoom: 'https://zoom.us/client/latest/zoom_amd64.deb'
|
zoom: 'https://zoom.us/client/latest/zoom_amd64.deb'
|
||||||
|
|
||||||
|
golang:
|
||||||
|
goget:
|
||||||
|
- github.com/golang/example/hello
|
||||||
|
- github.com/golang/example/outyet
|
||||||
|
clean:
|
||||||
|
- github.com/golang/example/hello
|
||||||
|
- github.com/golang/example/outyet
|
||||||
|
|
|
@ -81,14 +81,22 @@ packages:
|
||||||
format: raw
|
format: raw
|
||||||
source: https://raw.githubusercontent.com/openstack/cinder/master/contrib/block-box/docker-compose.yml
|
source: https://raw.githubusercontent.com/openstack/cinder/master/contrib/block-box/docker-compose.yml
|
||||||
hashsum: 1751f8e4f6b4cddd8c4843a0f4473274
|
hashsum: 1751f8e4f6b4cddd8c4843a0f4473274
|
||||||
kubectl:
|
golang:
|
||||||
dest: /usr/local/bin
|
dest: /usr/local
|
||||||
dl:
|
dl:
|
||||||
format: bin
|
format: tar
|
||||||
source: https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/darwin/amd64/kubectl
|
source: https://dl.google.com/go/go1.12.7.linux-amd64.tar.gz
|
||||||
|
hashsum: 66d83bfb5a9ede000e33c6579a91a29e6b101829ad41fffb5c5bb6c900e109d9
|
||||||
unwanted:
|
unwanted:
|
||||||
- /usr/local/boring_archive_software
|
- /usr/local/boring_archive_software
|
||||||
|
|
||||||
remote_pkgs:
|
remote_pkgs:
|
||||||
zoom: 'https://zoom.us/client/latest/zoom_amd64.deb'
|
zoom: 'https://zoom.us/client/latest/zoom_amd64.deb'
|
||||||
|
|
||||||
|
golang:
|
||||||
|
goget:
|
||||||
|
- github.com/golang/example/hello
|
||||||
|
- github.com/golang/example/outyet
|
||||||
|
clean:
|
||||||
|
- github.com/golang/example/hello
|
||||||
|
- github.com/golang/example/outyet
|
||||||
|
|
Loading…
Add table
Reference in a new issue