-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(refactor): plugin refactor for v4
- Loading branch information
1 parent
fb262d8
commit e19754e
Showing
52 changed files
with
3,134 additions
and
1,322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: golangci-lint | ||
on: | ||
push: | ||
paths: | ||
- '**.go' | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
permissions: | ||
# Required: allow read access to the content for analysis. | ||
contents: read | ||
# Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
pull-requests: read | ||
# Optional: Allow write access to checks to allow the action to annotate code in the PR. | ||
checks: write | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21' | ||
cache: false | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59.1 | ||
args: -c .golang-ci.yml -v --timeout=5m | ||
env: | ||
GO111MODULES: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
example/packer_cache | ||
.envrc | ||
packer-plugin-goss | ||
*.tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
linters-settings: | ||
lll: | ||
line-length: 180 | ||
allow-leading-space: true | ||
linters: | ||
enable-all: true | ||
disable: | ||
- testpackage | ||
- forbidigo | ||
- paralleltest | ||
- wrapcheck | ||
- gochecknoglobals | ||
- varnamelen | ||
- funlen | ||
- gomnd | ||
- containedctx | ||
- nlreturn | ||
- wsl | ||
- err113 | ||
- exhaustruct | ||
- nolintlint | ||
- maintidx | ||
- dupl | ||
- revive | ||
- depguard | ||
- tagalign | ||
- perfsprint | ||
- godox | ||
- intrange | ||
- copyloopvar | ||
- gomoddirectives | ||
- goconst | ||
- godot | ||
- execinquery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
repos: | ||
- repo: https://github.com/tekwizely/pre-commit-golang | ||
rev: v1.0.0-rc.1 | ||
hooks: | ||
- id: go-build-mod | ||
- id: go-test-mod | ||
- id: go-vet-mod | ||
- id: go-staticcheck-mod | ||
- id: go-fmt | ||
- id: go-fumpt | ||
- id: go-imports | ||
- id: go-lint | ||
- id: golangci-lint-mod | ||
args: [-c.golang-ci.yml] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
E2E_DIR ?= example | ||
|
||
default: help | ||
|
||
.PHONY: help | ||
help: ## list makefile targets | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
PHONY: lint | ||
lint: ## lint go files | ||
golangci-lint run -c .golang-ci.yml | ||
|
||
.PHONY: fmt | ||
fmt: ## format go files | ||
gofumpt -w . | ||
gci write . | ||
packer fmt -recursive -write . | ||
|
||
.PHONY: build | ||
build: generate ## build the plugin | ||
go build -ldflags="-X github.com/YaleUniversity/packer-provisioner-goss/version.VersionPrerelease=dev" -o packer-plugin-goss | ||
|
||
.PHONY: install | ||
install: ## install the plugin | ||
packer plugins install --path packer-plugin-goss github.com/YaleUniversity/goss | ||
|
||
.PHONY: test | ||
test: ## run tests | ||
PACKER_ACC=1 gotestsum | ||
|
||
.PHONY: test-acc | ||
test-acc: clean build install ## run acceptance tests | ||
PACKER_ACC=1 go test -count 1 -v ./provisioner/goss/provisioner_goss_test.go -timeout=120m | ||
|
||
.PHONY: test-e2e | ||
test-e2e: clean build install ## run e2e tests | ||
cd $(E2E_DIR) && packer init . | ||
cd $(E2E_DIR) && packer build complete_example.pkr.hcl | ||
|
||
.PHONY: clean | ||
clean: ## remove tmp files | ||
rm -f $(E2E_DIR)/*.tar $(E2E_DIR)/test-results.xml packer-plugin-goss | ||
|
||
.PHONY: generate | ||
generate: ## go generate | ||
go generate ./... | ||
|
||
.PHONY: plugin-check | ||
plugin-check: build ## will check whether a plugin binary seems to work with packer | ||
@packer-sdc plugin-check packer-plugin-goss | ||
|
||
.PHONY: docs | ||
docs: ## gen packer plugin docs | ||
@go generate ./... | ||
@rm -rf .docs | ||
@packer-sdc renderdocs -src "docs" -partials docs-partials/ -dst ".docs/" | ||
@./.web-docs/scripts/compile-to-webdocs.sh "." ".docs" ".web-docs" "YaleUniversity" | ||
@rm -r ".docs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,95 +13,91 @@ packer { | |
required_plugins { | ||
goss = { | ||
version = "~> 3" | ||
version = "~> 4" | ||
source = "github.com/YaleUniversity/goss" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Additional (optional) properties | ||
|
||
## Usage | ||
```hcl | ||
build { | ||
sources = [".."] | ||
sources = [""] | ||
provisioner "goss" { | ||
# Provisioner Args | ||
arch ="amd64" | ||
download_path = "/tmp/goss-VERSION-linux-ARCH" | ||
inspect = "{{ inspect_mode }}", | ||
password = "" | ||
skip_install = false | ||
url = "https://github.com/aelsabbahy/goss/releases/download/vVERSION/goss-linux-ARCH" | ||
username = "" | ||
version = "0.3.2" | ||
# GOSS Args | ||
tests = [ | ||
"goss/goss.yaml" | ||
] | ||
remote_folder = "/tmp" | ||
remote_path = "/tmp/goss" | ||
skip_ssl = false | ||
use_sudo = false | ||
format = "" | ||
goss_file = "" | ||
vars_file = "" | ||
target_os = "Linux" | ||
vars_env = { | ||
ARCH = "amd64" | ||
PROVIDER = "{{ cloud-provider }}" | ||
} | ||
vars_inline = { | ||
OS = "centos", | ||
version = "{{ version }}" | ||
} | ||
# block specifying any goss download parameters. Goss is downloaded using curl and wget as a fallback installation method | ||
installation { | ||
# wether to use sudo for the curl/wget download; # optional; default: false | ||
use_sudo = false | ||
retry_timeout = "0s" | ||
sleep = "1s" | ||
} | ||
} | ||
``` | ||
# the goss version to download; optional; default: "latest" | ||
version = "latest" | ||
## Spec files | ||
Goss spec file and debug spec file (`goss render -d`) are downloaded to `/tmp` folder on local machine from the remote VM. These files are exact specs GOSS validated on the VM. The downloaded GOSS spec can be used to validate any other VM image for equivalency. | ||
# the architecture to download; optional; default: "amd64" | ||
arch = "amd64" | ||
## Windows support | ||
# the operating system to download; optional; default: "Linux", options: "Windows", "Linux" | ||
os = "" | ||
This now has support for Windows. Set the optional parameter `target_os` to `Windows`. Currently, the `vars_env` parameter must include `GOSS_USE_ALPHA=1` as specified in [goss's feature parity document](https://github.com/aelsabbahy/goss/blob/master/docs/platform-feature-parity.md#platform-feature-parity). In the future when goss come of of alpha for Windows this parameter will not be required. | ||
# the url to download goss from; optional; default: "https://github.com/goss-org/goss/releases/download/{{ Version }}/goss-{{ Version }}-{{ Os }}-{{ Arch }}" | ||
url = "" | ||
## Build | ||
# the checksum to verify the downloaded goss binary; optional; default: false | ||
skip_ssl = false | ||
### Using Golang docker image | ||
# the path to download goss to; optional; default: "/tmp/goss-{{ Version }}-{{ Os }}-{{ Arch }}" | ||
download_path = "" | ||
```bash | ||
docker run --rm -it -v "$PWD":/usr/src/packer-provisioner-goss -w /usr/src/packer-provisioner-goss -e 'VERSION=v1.0.0' golang:1.13 bash | ||
go test ./... | ||
for GOOS in darwin linux windows; do | ||
for GOARCH in 386 amd64; do | ||
export GOOS GOARCH | ||
go get -v ./... | ||
go build -v -o packer-provisioner-goss-${VERSION}-$GOOS-$GOARCH | ||
done | ||
done | ||
``` | ||
# username for basic auth; optional; default: "" | ||
username = "" | ||
# password for basic auth; optional; default: "" | ||
password = "" | ||
## Author | ||
# a map of any extra env vars to pass to the download request; optional; default: {} | ||
env_vars = nil | ||
E. Camden Fisher <[email protected]> | ||
# wether to skip the installation | ||
skip_installation = false | ||
} | ||
# block specifying any goss validate parameters | ||
validate { | ||
# wether to use sudo for the goss validate command; # optional; default: false | ||
use_sudo = false | ||
# the path to cd into before running goss validate; optional; default: "/tmp/" | ||
remote_path = "" | ||
# a goss vars file; optional; default: "" | ||
vars_file = "" | ||
# a gossfile; optional; default: "./goss.yaml" | ||
goss_file = "" | ||
## License | ||
# a map of any goss inline vars for rendering a gossfile; optional; default: {} | ||
vars_inline = nil | ||
### MIT | ||
# a map of any extra env vars to pass to the download request; optional; default: {} | ||
env_vars = nil | ||
Copyright 2017-2021 Yale University | ||
# where to write the goss test results to; optional; default: "" | ||
output_file = "" | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
# a retry timeout for goss validate; optional; default: "0s" | ||
retry_timeut = "" | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
# a sllep timeout for goss validate; optonal; default: "1s" | ||
sleep = "" | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# the goss test results format; optional; values: "documentation", "json", "json_oneline", "junit", "nagios", "nagios_verbose", "rspecish", "silent", "tap" | ||
format = "" | ||
# the goss test results format options; values; default: "perfdata", "verbose", "pretty" | ||
format_options = "" | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- Code generated from the comments of the Config struct in provisioner/goss/provisioner_goss.go; DO NOT EDIT MANUALLY --> | ||
|
||
- `installation` (Installation) - Installation | ||
|
||
<!-- End of code generated from the comments of the Config struct in provisioner/goss/provisioner_goss.go; --> |
25 changes: 25 additions & 0 deletions
25
docs-partials/provisioner/goss/Installation-not-required.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!-- Code generated from the comments of the Installation struct in provisioner/goss/goss_installation.go; DO NOT EDIT MANUALLY --> | ||
|
||
- `use_sudo` (bool) - execute goss validate with sudo permissions | ||
|
||
- `version` (string) - / Goss Version to download | ||
|
||
- `arch` (string) - Architecture of the target system | ||
|
||
- `os` (string) - OS of the target system. | ||
|
||
- `url` (string) - URL to download the goss binary from. | ||
|
||
- `skip_ssl` (bool) - If true SSL checks are skipped. | ||
|
||
- `download_path` (string) - Path to download the goss binary to. | ||
|
||
- `username` (string) - Username for basic auth. | ||
|
||
- `password` (string) - Password for basic auth. | ||
|
||
- `env_vars` (map[string]string) - EnvVars any env vars. | ||
|
||
- `skip_installation` (bool) - If true installation of the goss binary is skipped. | ||
|
||
<!-- End of code generated from the comments of the Installation struct in provisioner/goss/goss_installation.go; --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- Code generated from the comments of the Installation struct in provisioner/goss/goss_installation.go; DO NOT EDIT MANUALLY --> | ||
|
||
Installation holds all installation params. | ||
|
||
<!-- End of code generated from the comments of the Installation struct in provisioner/goss/goss_installation.go; --> |
Oops, something went wrong.