Skip to content

Commit

Permalink
Refactors Go module installation
Browse files Browse the repository at this point in the history
Resolves #172
  • Loading branch information
Steve Moyer committed Dec 2, 2019
1 parent c095a8e commit f08ec73
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
15 changes: 15 additions & 0 deletions install_go_packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# File: install_go_packages.yml

# - name: debug
# debug:
# var: "packages"

- name: "{{ name }}"
shell:
cmd: "GO111MODULE=on go get -u {{ item }}"
environment:
GOPATH: "{{ go_tools_directory }}"
with_items: "{{ packages }}"
register: "go_get_result"
changed_when: "'downloading' in go_get_result.stderr"
14 changes: 6 additions & 8 deletions roles/containerization/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,19 @@
# kind
#

- name: install kind
command:
cmd: "go get -u sigs.k8s.io/kind"
environment:
GOPATH: "{{ go_tools_directory }}"
register: kind_output
changed_when: "kind_output.stdout != '' and kind_output.stderr != ''"
- include: "../../install_go_packages.yml"
vars:
name: "install kind"
packages:
- "sigs.k8s.io/kind"
tags:
- containerization
- Kubernetes
- kind

- name: add kind's bash completion
shell: /usr/share/go-tools/bin/kind completion bash > /etc/bash_completion.d/kind
when: "kind_output.stdout != '' and kind_output.stderr != ''"
when: "go_get_result.changed"
tags:
- containerization
- Kubernetes
Expand Down
32 changes: 14 additions & 18 deletions roles/development/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,20 @@
- "go"
- "go-tools"

- name: add useful go packages
shell:
cmd: "GO111MODULE=on go get -u {{ item }}"
environment:
GOPATH: "{{ go_tools_directory }}"
with_items:
- "github.com/uudashr/gopkgs/cmd/gopkgs"
- "github.com/kisielk/errcheck"
- "github.com/tsliwowicz/go-wrk"
- "github.com/uber/go-torch"
- "github.com/google/pprof"
- "golang.org/x/tools/cmd/guru"
- "github.com/golangci/golangci-lint/cmd/golangci-lint"
- "github.com/zimmski/go-mutesting/cmd/go-mutesting"
- "golang.org/x/tools/cmd/gopls"
- "golang.org/x/tools/cmd/godoc"
register: go_packages
changed_when: "go_packages.stdout != '' and go_packages.stderr != ''"
- include: "../../install_go_packages.yml"
vars:
name: "add useful go packages"
packages:
- "github.com/uudashr/gopkgs/cmd/gopkgs"
- "github.com/kisielk/errcheck"
- "github.com/tsliwowicz/go-wrk"
- "github.com/uber/go-torch"
- "github.com/google/pprof"
- "golang.org/x/tools/cmd/guru"
- "github.com/golangci/golangci-lint/cmd/golangci-lint"
- "github.com/zimmski/go-mutesting/cmd/go-mutesting"
- "golang.org/x/tools/cmd/gopls"
- "golang.org/x/tools/cmd/godoc"
tags:
- "languages"
- "go"
Expand Down

0 comments on commit f08ec73

Please sign in to comment.