Skip to content

Commit

Permalink
feat(go.cmd): basic go command support
Browse files Browse the repository at this point in the history
  • Loading branch information
Noel McLoughlin committed Nov 18, 2019
1 parent ce189fc commit 34653d5
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 1 deletion.
16 changes: 16 additions & 0 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ via include list.
This state will start the golang service and has a dependency on ``golang.config``
via include list.

``golang.cmd``
^^^^^^^^^^^^^^

This is a metastate for go command tasks.

``golang.cmd.clean``
^^^^^^^^^^^^^^^^^^^^

This state runs ``go clean -i <item>...`` for each item in ``cmd.clean`` dict.

``golang.cmd.goget``
^^^^^^^^^^^^^^^^^^^^

This state runs ``go get <item>...`` for each item in ``cmd.get`` dict.


``golang.clean``
^^^^^^^^^^^^^^^^

Expand Down
1 change: 1 addition & 0 deletions golang/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
# vim: ft=sls

include:
- .cmd.clean
- .config.clean
- .archive.clean
15 changes: 15 additions & 0 deletions golang/cmd/clean.sls
Original file line number Diff line number Diff line change
@@ -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 golang with context %}
{%- for package in golang.cmd.clean %}
golang-cmd-clean-cmd-run-go-clean-{{ package }}:
cmd.run:
- name: go clean -i {{ package }}...
- runas: {{ golang.rootuser }}
{%- endfor %}
15 changes: 15 additions & 0 deletions golang/cmd/goget.sls
Original file line number Diff line number Diff line change
@@ -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 golang with context %}
{%- for package in golang.cmd.goget %}
golang-cmd-goget-cmd-run-go-get-{{ package }}:
cmd.run:
- name: go get {{ package }}
- runas: {{ golang.rootuser }}
{%- endfor %}
6 changes: 6 additions & 0 deletions golang/cmd/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

include:
- .clean
- .goget
5 changes: 5 additions & 0 deletions golang/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ golang:
dir: /usr/local/go ## go_root
version: '1.10.1'
go_path: /usr/local/golang/packages
rootuser: root
pkg:
name: go
use_upstream_repo: false
Expand Down Expand Up @@ -35,3 +36,7 @@ golang:
linux:
# 'Alternatives system' priority: zero disables (default)
altpriority: 0

cmd:
goget: []
clean: []
1 change: 1 addition & 0 deletions golang/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
include:
- {{ '.archive' if golang.pkg.use_upstream_archive else '.package' }}
- .config
- .cmd
10 changes: 9 additions & 1 deletion pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ golang:

linux:
# 'Alternatives system' priority: zero disables (default)
altpriority: 1000
altpriority: 9100

cmd:
goget:
- github.com/golang/example/hello
- github.com/golang/example/outyet
clean:
- github.com/golang/example/hello
- github.com/golang/example/outyet

tofs:
# The files_switch key serves as a selector for alternative
Expand Down

0 comments on commit 34653d5

Please sign in to comment.