test(ethtool): add basic checks to validate image
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 872657a..dcbff92 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -12,3 +12,29 @@
env:
GITHUB_ACTIONS: true
GITHUB_WORKFLOW: "{{ github.workflow.name }}"
+
+ images:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3.0.2
+
+ - name: Set up Go
+ uses: actions/setup-go@v3.3.0
+ with:
+ go-version-file: go.mod
+ cache: true
+
+ - name: Set up gotestfmt
+ uses: haveyoudebuggedit/gotestfmt-action@v2
+ - run: |
+ set -euo pipefail
+ go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
+
+ - name: Upload test log
+ uses: actions/upload-artifact@v2
+ if: always()
+ with:
+ name: test-log
+ path: /tmp/gotest.log
+ if-no-files-found: error
diff --git a/ci/image_tags_test.go b/ci/image_tags_test.go
new file mode 100644
index 0000000..7478560
--- /dev/null
+++ b/ci/image_tags_test.go
@@ -0,0 +1,29 @@
+package linters
+
+import (
+ "os"
+ "strings"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+ "gopkg.in/yaml.v3"
+)
+
+func TestPrometheusEthtoolExporterTag(t *testing.T) {
+ imageFile, err := os.ReadFile("../images/prometheus-ethtool-exporter/ref")
+ assert.NoError(t, err)
+
+ imageTag := strings.TrimSpace(string(imageFile))
+
+ data, err := os.ReadFile("../roles/prometheus_ethtool_exporter/defaults/main.yml")
+ assert.NoError(t, err)
+
+ defaults := make(map[interface{}]interface{})
+ err = yaml.Unmarshal(data, &defaults)
+ assert.NoError(t, err)
+
+ ansibleTag, ok := defaults["prometheus_ethtool_exporter_image_tag"]
+ if assert.True(t, ok) {
+ assert.Equal(t, imageTag, ansibleTag)
+ }
+}
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..70f8808
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,13 @@
+module github.com/vexxhost/atmosphere
+
+go 1.19
+
+require (
+ github.com/stretchr/testify v1.8.0
+ gopkg.in/yaml.v3 v3.0.1
+)
+
+require (
+ github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/pmezard/go-difflib v1.0.0 // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..5164829
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,15 @@
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=