diff --git a/.gitignore b/.gitignore index 5cad884..dcbbea0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ -example/packer_cache \ No newline at end of file +example/packer_cache +.envrc +packer-plugin-goss +tests/debug-goss-spec.yaml +tests/goss-spec.yaml +tests/goss.json \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..10f75af --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +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: fmt +fmt: ## format go files + gofumpt -w . + gci write . + packer fmt -recursive -write . + +.PHONY: build +build: ## 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: local +local: clean build install ## build and install the plugin locally + cd example && packer init . + cd example && packer build alpine.pkr.hcl + +.PHONY: clean +clean: ## remove tmp files + rm -f example/alpine.tar example/goss_test_results.xml example/debug-goss-spec.yaml example/goss-spec.yaml packer-plugin-goss + +.PHONY: generate +generate: ## go generate + go generate ./... \ No newline at end of file diff --git a/README.md b/README.md index 2cfe159..fe18f2a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Wouldn't it be nice if you could run [goss](https://github.com/aelsabbahy/goss) Well, I thought it would, so now you can! This runs during the provisioning process since the machine being provisioned is only available at that time. -There is an example packer build with goss tests in the `example/` directory. +There is an example packer build with `goss` tests in the [`example/`](https://github.com/YaleUniversity/packer-plugin-goss/tree/master/example) directory. ## Configuration @@ -20,6 +20,58 @@ packer { } ``` +## Quickstart Example +**This example assumes you have a file `goss.yaml` in your `PWD` containing goss tests**: +```hcl +# example/alpine.pkr.hcl +packer { + required_version = ">= 1.9.0" + + required_plugins { + goss = { + version = "v0.0.1" + source = "github.com/YaleUniversity/goss" + } + docker = { + source = "github.com/hashicorp/docker" + version = "v1.0.10" + } + } +} + +# fetch a normal alpine container and export the image as alpine.tar +source "docker" "alpine" { + image = "alpine" + export_path = "alpine.tar" +} + +build { + # apply build params against the alpine container + sources = ["docker.alpine"] + + # run goss tests using goss provisioner + provisioner "goss" { + # download and install goss to /tmp/goss_install within the target system + download_path = "/tmp/goss_install" + + # run goss tests in goss.yaml + tests = ["./goss.yaml"] + + # output results as junit + format = "junit" + + # write results to /tmp/goss_test_results.xml, which will then be copied to the hosts CWD that is running packer + output_file = "/tmp/goss_test_results.xml" + } + + + # output the test results just for demo purposes + provisioner "shell-local" { + inline = ["cat goss_test_results.xml"] + } +} +``` + ### Additional (optional) properties ```hcl @@ -30,7 +82,7 @@ build { # Provisioner Args arch ="amd64" download_path = "/tmp/goss-VERSION-linux-ARCH" - inspect = "{{ inspect_mode }}", + inspect = "{{ inspect_mode }}" password = "" skip_install = false url = "https://github.com/aelsabbahy/goss/releases/download/vVERSION/goss-linux-ARCH" @@ -74,22 +126,6 @@ Goss spec file and debug spec file (`goss render -d`) are downloaded to `/tmp` f 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. -## Build - -### Using Golang docker image - -```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 -``` - ## Author E. Camden Fisher diff --git a/example/alpine.pkr.hcl b/example/alpine.pkr.hcl new file mode 100644 index 0000000..2189093 --- /dev/null +++ b/example/alpine.pkr.hcl @@ -0,0 +1,46 @@ +packer { + required_version = ">= 1.9.0" + + required_plugins { + goss = { + version = "v0.0.1" + source = "github.com/YaleUniversity/goss" + } + docker = { + source = "github.com/hashicorp/docker" + version = "v1.0.10" + } + } +} + +# fetch a normal alpine container and export the image as alpine.tar +source "docker" "alpine" { + image = "alpine" + export_path = "alpine.tar" +} + +build { + # apply build params against the alpine container + sources = ["docker.alpine"] + + # run goss tests using goss provisioner + provisioner "goss" { + # download and install goss to /tmp/goss_install + download_path = "/tmp/goss_install" + + # run goss tests in goss.yaml + tests = ["./goss.yaml"] + + # output results as junit + format = "junit" + + # write results to /tmp/goss_test_results.xml, which will be copied to the host + output_file = "/tmp/goss_test_results.xml" + } + + + # output the test results just for demo purposes + provisioner "shell-local" { + inline = ["cat goss_test_results.xml"] + } +} \ No newline at end of file diff --git a/example/goss.yaml b/example/goss.yaml new file mode 100644 index 0000000..b9b8c33 --- /dev/null +++ b/example/goss.yaml @@ -0,0 +1,3 @@ +process: + sshd: + running: true \ No newline at end of file diff --git a/example/goss/goss.yaml b/example/goss/goss.yaml deleted file mode 100644 index ba5f41e..0000000 --- a/example/goss/goss.yaml +++ /dev/null @@ -1,47 +0,0 @@ -port: - tcp:22: - listening: true - ip: - - 0.0.0.0 - tcp6:22: - listening: true - ip: - - '::' -service: - sshd: - enabled: true - running: true -user: - sshd: - exists: true - uid: 74 - gid: 74 - groups: - - sshd - home: /var/empty/sshd - shell: /sbin/nologin - vagrant: - exists: true - groups: - - vagrant - - wheel - home: /home/vagrant -group: - sshd: - exists: true - gid: 74 - vagrant: - exists: true -process: - sshd: - running: true -file: - /home/vagrant/.ssh: - exists: true - filetype: directory - /home/vagrant/.ssh/authorized_keys: - filetype: file - exists: true - mode: "0600" - owner: vagrant - group: vagrant \ No newline at end of file diff --git a/example/http/ks7.cfg b/example/http/ks7.cfg deleted file mode 100644 index 0e269ab..0000000 --- a/example/http/ks7.cfg +++ /dev/null @@ -1,108 +0,0 @@ -install -url --url=http://mirrors.kernel.org/centos/7/os/x86_64 - -lang en_US.UTF-8 -keyboard us -timezone America/New_York - -network --bootproto=dhcp -firewall --disabled - -authconfig --enableshadow --passalgo=sha512 -selinux --disabled -rootpw changeme - -text -skipx - -clearpart --all --initlabel -zerombr -autopart -bootloader --location=mbr - -firstboot --disabled -reboot - -%packages --nobase --ignoremissing --excludedocs -# vagrant needs this to copy initial files via scp -openssh-clients -sudo -kernel-headers -kernel-devel -gcc -make -perl -wget -nfs-utils -net-tools -bzip2 - --fprintd-pam --intltool --avahi --bluez-utils --dogtail --kudzu - -# unnecessary firmware --aic94xx-firmware --atmel-firmware --b43-openfwwf --bfa-firmware --ipw2100-firmware --ipw2200-firmware --ivtv-firmware --iwl100-firmware --iwl105-firmware --iwl135-firmware --iwl1000-firmware --iwl2000-firmware --iwl2030-firmware --iwl3160-firmware --iwl3945-firmware --iwl4965-firmware --iwl5000-firmware --iwl5150-firmware --iwl6000-firmware --iwl6000g2a-firmware --iwl6000g2b-firmware --iwl6050-firmware --iwl7260-firmware --libertas-usb8388-firmware --libertas-sd8686-firmware --libertas-sd8787-firmware --ql2100-firmware --ql2200-firmware --ql23xx-firmware --ql2400-firmware --ql2500-firmware --rt61pci-firmware --rt73usb-firmware --xorg-x11-drv-ati-firmware --zd1211-firmware -%end - -%post -yum update -y - -# disable unnecessary services -chkconfig acpid off -chkconfig auditd off -chkconfig blk-availability off -chkconfig bluetooth off -chkconfig certmonger off -chkconfig cpuspeed off -chkconfig cups off -chkconfig haldaemon off -chkconfig ip6tables off -chkconfig lvm2-monitor off -chkconfig messagebus off -chkconfig mdmonitor off -chkconfig rpcbind off -chkconfig rpcgssd off -chkconfig rpcidmapd off -chkconfig yum-updateonboot off - -echo 'useDNS no' >> /etc/ssh/sshd_config -yum clean all -%end diff --git a/example/packer.json b/example/packer.json deleted file mode 100644 index 1b06791..0000000 --- a/example/packer.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "builders": [ - { - "boot_command": [ - " text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks7.cfg" - ], - "boot_wait": "10s", - "communicator": "ssh", - "disk_size": 10240, - "guest_os_type": "RedHat_64", - "hard_drive_interface": "scsi", - "headless": true, - "http_directory": "http", - "iso_checksum": "sha256:{{user `iso_checksum`}}", - "iso_url": "{{user `iso_url`}}", - "name": "centos-7-x86_64", - "output_directory": "img_centos_7_virtualbox", - "shutdown_command": "echo 'packer'|sudo -S /sbin/halt -h -p", - "ssh_handshake_attempts": 50, - "ssh_password": "changeme", - "ssh_port": 22, - "ssh_timeout": "20000s", - "ssh_username": "root", - "type": "virtualbox-iso", - "vboxmanage": [ - [ - "modifyvm", - "{{.Name}}", - "--paravirtprovider", - "kvm" - ], - [ - "modifyvm", - "{{.Name}}", - "--nictype1", - "virtio" - ], - [ - "modifyvm", - "{{.Name}}", - "--memory", - "1024" - ], - [ - "modifyvm", - "{{.Name}}", - "--cpus", - "1" - ] - ], - "virtualbox_version_file": ".vbox_version" - } - ], - "post-processors": [ - { - "type": "vagrant" - } - ], - "provisioners": [ - { - "execute_command": "{{ .Vars }} /bin/sh '{{.Path}}'", - "scripts": [ - "scripts/vagrant.sh" - ], - "type": "shell" - }, - { - "goss_file": "goss.yaml", - "retry_timeout": "5s", - "sleep": "2s", - "tests": [ - "goss/goss.yaml" - ], - "type": "goss" - }, - { - "execute_command": "{{ .Vars }} /bin/sh '{{.Path}}'", - "scripts": [ - "scripts/cleanup.sh", - "scripts/zerodisk.sh" - ], - "type": "shell" - } - ], - "variables": { - "iso_checksum": "b79079ad71cc3c5ceb3561fff348a1b67ee37f71f4cddfec09480d4589c191d6", - "iso_checksum_type ": "sha256", - "iso_url": "http://mirror.net.cen.ct.gov/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-NetInstall-2009.iso" - } -} - diff --git a/example/scripts/cleanup.sh b/example/scripts/cleanup.sh deleted file mode 100644 index 5025c03..0000000 --- a/example/scripts/cleanup.sh +++ /dev/null @@ -1,11 +0,0 @@ -echo "Cleaning up ..." - -yum -y erase gtk2 libX11 hicolor-icon-theme avahi bitstream-vera-fonts -yum -y clean all -rm -rf /etc/yum.repos.d/{puppetlabs,epel}.repo -rm -rf /etc/yum.repos.d/mysql*.repo -rm -rf VBoxGuestAdditions_*.iso - -# Remove traces of mac address from network configuration -sed -i /HWADDR/d /etc/sysconfig/network-scripts/ifcfg-eth0 -rm -f /etc/udev/rules.d/70-persistent-net.rules diff --git a/example/scripts/vagrant.sh b/example/scripts/vagrant.sh deleted file mode 100644 index a431942..0000000 --- a/example/scripts/vagrant.sh +++ /dev/null @@ -1,31 +0,0 @@ -echo "Configuring vagrant-specific stuff ..." - -# Vagrant specific -date > /etc/vagrant_box_build_time - -# install wget -yum -y install wget - -# disable iptables -/etc/init.d/iptables stop -/sbin/chkconfig iptables off - -# Add vagrant user -/usr/sbin/groupadd vagrant -/usr/sbin/useradd vagrant -g vagrant -G wheel -echo "vagrant"|passwd --stdin vagrant -/bin/sed -i 's/[^\!]requiretty/\!requiretty/' /etc/sudoers -/bin/sed -i 's/^\(Default.*secure_path.*$\)/\1:\/usr\/local\/bin/' /etc/sudoers -echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant -chmod 0440 /etc/sudoers.d/vagrant - -# Speed up ssh connections -/bin/sed -i 's/^#UseDNS.*$/UseDNS no/' /etc/ssh/sshd_config -/bin/sed -i 's/^.*GSSAPIAuthentication.*$/GSSAPIAuthentication no/' /etc/ssh/sshd_config - -# Installing vagrant keys -mkdir -pm 700 /home/vagrant/.ssh -wget --no-check-certificate 'https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub' -O /home/vagrant/.ssh/authorized_keys -chmod 0600 /home/vagrant/.ssh/authorized_keys -chown -R vagrant:vagrant /home/vagrant/.ssh - \ No newline at end of file diff --git a/example/scripts/zerodisk.sh b/example/scripts/zerodisk.sh deleted file mode 100644 index 37bdb66..0000000 --- a/example/scripts/zerodisk.sh +++ /dev/null @@ -1,5 +0,0 @@ -echo "Zeroing out free space ..." - -# Zero out the free space to save space in the final image: -dd if=/dev/zero of=/EMPTY bs=1M -rm -f /EMPTY diff --git a/main.go b/main.go index f7bd4d2..7efa7d4 100644 --- a/main.go +++ b/main.go @@ -4,15 +4,12 @@ import ( "fmt" "os" + "github.com/YaleUniversity/packer-provisioner-goss/provisioner/goss" "github.com/hashicorp/packer-plugin-sdk/plugin" "github.com/hashicorp/packer-plugin-sdk/version" - - "github.com/YaleUniversity/packer-provisioner-goss/provisioner/goss" ) -var ( - Version = "0.0.1" -) +var Version = "0.0.1" func main() { pps := plugin.NewSet() @@ -20,7 +17,6 @@ func main() { pps.SetVersion(version.InitializePluginVersion(Version, "")) err := pps.Run() - if err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) diff --git a/provisioner/goss/packer-provisioner-goss.go b/provisioner/goss/packer-provisioner-goss.go index e9a6bc9..72db95e 100644 --- a/provisioner/goss/packer-provisioner-goss.go +++ b/provisioner/goss/packer-provisioner-goss.go @@ -12,13 +12,13 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/template/config" "github.com/hashicorp/packer-plugin-sdk/template/interpolate" ) const ( + gossVersion = "0.4.7" gossSpecFile = "/tmp/goss-spec.yaml" gossDebugSpecFile = "/tmp/debug-goss-spec.yaml" linux = "Linux" @@ -83,6 +83,9 @@ type GossConfig struct { // Default: rspecish Format string `mapstructure:"format"` + // Destination of the file to write the output to. + OutputFile string `mapstructure:"output_file"` + // The format options to use for printing test output // Available: [perfdata verbose pretty] // Default: verbose @@ -91,8 +94,10 @@ type GossConfig struct { ctx interpolate.Context } -var validFormats = []string{"documentation", "json", "json_oneline", "junit", "nagios", "nagios_verbose", "rspecish", "silent", "tap"} -var validFormatOptions = []string{"perfdata", "verbose", "pretty"} +var ( + validFormats = []string{"documentation", "json", "json_oneline", "junit", "nagios", "nagios_verbose", "rspecish", "silent", "tap"} + validFormatOptions = []string{"perfdata", "verbose", "pretty"} +) // Provisioner implements a packer Provisioner type Provisioner struct { @@ -117,7 +122,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } if p.config.Version == "" { - p.config.Version = "0.4.2" + p.config.Version = gossVersion } if p.config.Arch == "" { @@ -292,6 +297,13 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C return fmt.Errorf("Error running Goss: %s", err) } + if p.config.OutputFile != "" { + ui.Say("\n\n\nDownloading Goss test result file") + if err := p.downloadTestResults(ui, comm); err != nil { + return err + } + } + if !p.config.SkipDownload { ui.Say("\n\n\nDownloading spec file and debug info") if err := p.downloadSpecs(ui, comm); err != nil { @@ -304,6 +316,24 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C return nil } +// downloadSpecs downloads the Goss specs from the remote host to current working dir on local machine +func (p *Provisioner) downloadTestResults(ui packer.Ui, comm packer.Communicator) error { + ui.Message(fmt.Sprintf("Downloading Goss test results from %s to current dir", p.config.OutputFile)) + + f, err := os.Create(filepath.Base(p.config.OutputFile)) + if err != nil { + return fmt.Errorf("Error opening: %s", err) + } + + defer f.Close() + + if err := comm.Download(p.config.OutputFile, f); err != nil { + return fmt.Errorf("Error downloading %s: %s", p.config.OutputFile, err) + } + + return nil +} + // downloadSpecs downloads the Goss specs from the remote host to current working dir on local machine func (p *Provisioner) downloadSpecs(ui packer.Ui, comm packer.Communicator) error { ui.Message(fmt.Sprintf("Downloading Goss specs from, %s and %s to current dir", gossSpecFile, gossDebugSpecFile)) @@ -334,6 +364,7 @@ func (p *Provisioner) installGoss(ui packer.Ui, comm packer.Communicator) error p.sslFlag("curl"), p.userPass("curl"), p.config.DownloadPath, p.config.URL, p.sslFlag("wget"), p.userPass("wget"), p.config.DownloadPath, p.config.URL), } + ui.Message(fmt.Sprintf("Downloading Goss to %s", p.config.DownloadPath)) if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return fmt.Errorf("Unable to download Goss: %s", err) @@ -361,9 +392,9 @@ func (p *Provisioner) runGoss(ui packer.Ui, comm packer.Communicator) error { p.config.RemotePath, p.envVars(), goss, p.config.GossFile, p.vars(), p.inline_vars(), gossDebugSpecFile, ), - "validate": fmt.Sprintf("cd %s && %s %s %s %s %s %s validate --retry-timeout %s --sleep %s %s %s", + "validate": fmt.Sprintf("cd %s && %s %s %s %s %s %s validate --retry-timeout %s --sleep %s %s %s %s", p.config.RemotePath, p.enableSudo(), p.envVars(), goss, p.config.GossFile, - p.vars(), p.inline_vars(), p.retryTimeout(), p.sleep(), p.format(), p.formatOptions(), + p.vars(), p.inline_vars(), p.retryTimeout(), p.sleep(), p.format(), p.formatOptions(), p.outputFile(), ), } @@ -397,6 +428,20 @@ func (p *Provisioner) runGossCmd(ui packer.Ui, comm packer.Communicator, cmd *pa return nil } +func (p *Provisioner) outputFile() string { + if p.config.OutputFile == "" { + return "" + } + + // winodws + if p.config.TargetOs == windows { + return fmt.Sprintf("| Tee-Object -FilePath \"%s\"", p.config.OutputFile) + } + + // linux + return fmt.Sprintf("| tee \"%s\"", p.config.OutputFile) +} + func (p *Provisioner) retryTimeout() string { if p.config.RetryTimeout == "" { return "0s" // goss default @@ -479,7 +524,6 @@ func (p *Provisioner) envVars() string { default: sb.WriteString(fmt.Sprintf("%s=\"%s\" ", env_var, value)) } - } return sb.String() } diff --git a/provisioner/goss/packer-provisioner-goss.hcl2spec.go b/provisioner/goss/packer-provisioner-goss.hcl2spec.go index e6f13db..1a668d2 100644 --- a/provisioner/goss/packer-provisioner-goss.hcl2spec.go +++ b/provisioner/goss/packer-provisioner-goss.hcl2spec.go @@ -32,6 +32,7 @@ type FlatGossConfig struct { RemotePath *string `mapstructure:"remote_path" cty:"remote_path" hcl:"remote_path"` SkipDownload *bool `mapstructure:"skip_download" cty:"skip_download" hcl:"skip_download"` Format *string `mapstructure:"format" cty:"format" hcl:"format"` + OutputFile *string `mapstructure:"output_file" cty:"output_file" hcl:"output_file"` FormatOptions *string `mapstructure:"format_options" cty:"format_options" hcl:"format_options"` } @@ -69,6 +70,7 @@ func (*FlatGossConfig) HCL2Spec() map[string]hcldec.Spec { "remote_path": &hcldec.AttrSpec{Name: "remote_path", Type: cty.String, Required: false}, "skip_download": &hcldec.AttrSpec{Name: "skip_download", Type: cty.Bool, Required: false}, "format": &hcldec.AttrSpec{Name: "format", Type: cty.String, Required: false}, + "output_file": &hcldec.AttrSpec{Name: "output_file", Type: cty.String, Required: false}, "format_options": &hcldec.AttrSpec{Name: "format_options", Type: cty.String, Required: false}, } return s diff --git a/provisioner/goss/packer-provisioner-goss_test.go b/provisioner/goss/packer-provisioner-goss_test.go index 5104c84..12bed83 100644 --- a/provisioner/goss/packer-provisioner-goss_test.go +++ b/provisioner/goss/packer-provisioner-goss_test.go @@ -1,5 +1,3 @@ -//go:generate packer-sdc mapstructure-to-hcl2 -type GossConfig - package goss import ( @@ -27,8 +25,7 @@ func fakeContext() interpolate.Context { } func TestProvisioner_Prepare(t *testing.T) { - - var tests = []struct { + tests := []struct { name string input []interface{} wantErr bool @@ -43,10 +40,10 @@ func TestProvisioner_Prepare(t *testing.T) { }, wantErr: false, wantConfig: GossConfig{ - Version: "0.4.2", + Version: "0.4.7", Arch: "amd64", - URL: "https://github.com/goss-org/goss/releases/download/v0.4.2/goss-linux-amd64", - DownloadPath: "/tmp/goss-0.4.2-linux-amd64", + URL: "https://github.com/goss-org/goss/releases/download/v0.4.7/goss-linux-amd64", + DownloadPath: "/tmp/goss-0.4.7-linux-amd64", Username: "", Password: "", SkipInstall: false, @@ -65,6 +62,7 @@ func TestProvisioner_Prepare(t *testing.T) { RemotePath: "/tmp/goss", Format: "", FormatOptions: "", + OutputFile: "", ctx: fakeContext(), }, }, @@ -81,10 +79,10 @@ func TestProvisioner_Prepare(t *testing.T) { }, wantErr: false, wantConfig: GossConfig{ - Version: "0.4.2", + Version: "0.4.7", Arch: "amd64", - URL: "https://github.com/goss-org/goss/releases/download/v0.4.2/goss-alpha-windows-amd64.exe", - DownloadPath: "/tmp/goss-0.4.2-windows-amd64.exe", + URL: "https://github.com/goss-org/goss/releases/download/v0.4.7/goss-alpha-windows-amd64.exe", + DownloadPath: "/tmp/goss-0.4.7-windows-amd64.exe", Username: "", Password: "", SkipInstall: false, @@ -105,6 +103,7 @@ func TestProvisioner_Prepare(t *testing.T) { RemotePath: "/tmp/goss", Format: "", FormatOptions: "", + OutputFile: "", ctx: fakeContext(), }, }, @@ -118,10 +117,10 @@ func TestProvisioner_Prepare(t *testing.T) { }, wantErr: false, wantConfig: GossConfig{ - Version: "0.4.2", + Version: "0.4.7", Arch: "amd64", - URL: "https://github.com/goss-org/goss/releases/download/v0.4.2/goss-windows-amd64.exe", - DownloadPath: "/tmp/goss-0.4.2-windows-amd64.exe", + URL: "https://github.com/goss-org/goss/releases/download/v0.4.7/goss-windows-amd64.exe", + DownloadPath: "/tmp/goss-0.4.7-windows-amd64.exe", Username: "", Password: "", SkipInstall: false, @@ -140,6 +139,7 @@ func TestProvisioner_Prepare(t *testing.T) { RemotePath: "/tmp/goss", Format: "", FormatOptions: "", + OutputFile: "", ctx: fakeContext(), }, }, @@ -161,13 +161,11 @@ func TestProvisioner_Prepare(t *testing.T) { t.Logf("got config= %v", p.config) t.Logf("want config= %v", tt.wantConfig) } - }) } } func TestProvisioner_envVars(t *testing.T) { - tests := []struct { name string config GossConfig