Skip to content

Commit

Permalink
Merge pull request #12 from viaduct-ai/devstein/kustomize/api/v0.3.1
Browse files Browse the repository at this point in the history
Upgrade to Go 1.13 and Latest Kustomize Refactor
  • Loading branch information
devstein authored Jan 10, 2020
2 parents 9884d72 + 39c0f4e commit 0cc372a
Show file tree
Hide file tree
Showing 9 changed files with 361 additions and 106 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ go get -u github.com/viaduct-ai/kustomize-sops
```


### Install (or Reinstall) kustomize with the Same Version (v3.2.0) Used in KSOPS
### Install (or Reinstall) the Latest kustomize with in KSOPS

```bash
# KSOPS is built with [email protected]
# If you want to change versions, make sure to check that the KSOPS tests still pass
# KSOPS is built with latest kustomize
# If you want to change versions, update the installation script with your desired version and make sure to check that the KSOPS tests still pass
# If you want to change versions below kustomize v3.3.0, use the KSOPS v1.0 or go-1.12 release!
./scripts/install-kustomize.sh
```

Expand Down Expand Up @@ -278,7 +279,7 @@ ARG PKG_NAME=ksops
COPY --from=ksops-builder /go/bin/kustomize /usr/local/bin/kustomize
# Copy the plugin to kustomize plugin path
COPY --from=ksops-builder /go/src/github.com/viaduct-ai/kustomize-sops/{PKG_NAME}.so $KUSTOMIZE_PLUGIN_PATH/viaduct.ai/v1/${PKG_NAME}/
COPY --from=ksops-builder /go/src/github.com/viaduct-ai/kustomize-sops/* $KUSTOMIZE_PLUGIN_PATH/viaduct.ai/v1/${PKG_NAME}/
# Switch back to non-root user
USER argocd
Expand Down
47 changes: 22 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
module github.com/viaduct-ai/kustomize-sops

go 1.12
go 1.13

require (
cloud.google.com/go v0.47.0 // indirect
contrib.go.opencensus.io/exporter/ocagent v0.6.0 // indirect
github.com/Azure/azure-sdk-for-go v34.4.0+incompatible // indirect
github.com/Azure/go-autorest/autorest/adal v0.8.0 // indirect
github.com/Azure/go-autorest/autorest/azure/auth v0.4.0 // indirect
github.com/Azure/go-autorest/autorest/to v0.3.0 // indirect
github.com/Azure/go-autorest/autorest/validation v0.2.0 // indirect
github.com/aws/aws-sdk-go v1.25.19 // indirect
github.com/golang/groupcache v0.0.0-20191025150517-4a4ac3fbac33 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.11.3 // indirect
github.com/hashicorp/golang-lru v0.5.3 // indirect
cloud.google.com/go v0.51.0 // indirect
github.com/Azure/azure-sdk-for-go v38.0.0+incompatible // indirect
github.com/Azure/go-autorest/autorest/azure/auth v0.4.2 // indirect
github.com/aws/aws-sdk-go v1.27.2 // indirect
github.com/emicklei/go-restful v2.11.1+incompatible // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/go-openapi/jsonreference v0.19.3 // indirect
github.com/go-openapi/spec v0.19.5 // indirect
github.com/go-openapi/swag v0.19.6 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect
github.com/json-iterator/go v1.1.9 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
github.com/lib/pq v1.3.0 // indirect
github.com/mailru/easyjson v0.7.0 // indirect
github.com/pkg/errors v0.8.1
go.mozilla.org/sops v0.0.0-20190912205235-14a22d7a7060
go.opencensus.io v0.22.1 // indirect
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect
golang.org/x/net v0.0.0-20191021144547-ec77196f6094 // indirect
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
google.golang.org/api v0.11.0 // indirect
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/grpc v1.24.0 // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
sigs.k8s.io/kustomize/v3 v3.2.0
go.mozilla.org/sops/v3 v3.5.0
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.0.0-20200107162124-548cf772de50 // indirect
gopkg.in/ini.v1 v1.51.1 // indirect
gopkg.in/yaml.v2 v2.2.7 // indirect
sigs.k8s.io/kustomize/api v0.3.1
sigs.k8s.io/yaml v1.1.0
)
361 changes: 303 additions & 58 deletions go.sum

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions ksops.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"bytes"

"github.com/pkg/errors"
"go.mozilla.org/sops/decrypt"
"sigs.k8s.io/kustomize/v3/pkg/ifc"
"sigs.k8s.io/kustomize/v3/pkg/resmap"
"go.mozilla.org/sops/v3/decrypt"
"sigs.k8s.io/kustomize/api/ifc"
"sigs.k8s.io/kustomize/api/resmap"
"sigs.k8s.io/yaml"
)

Expand All @@ -32,9 +32,9 @@ type plugin struct {
var KustomizePlugin plugin

func (p *plugin) Config(
ldr ifc.Loader, rf *resmap.Factory, c []byte) error {
p.rf = rf
p.ldr = ldr
ph *resmap.PluginHelpers, c []byte) error {
p.rf = ph.ResmapFactory()
p.ldr = ph.Loader()
return yaml.Unmarshal(c, p)
}

Expand Down
22 changes: 11 additions & 11 deletions ksops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
"path"
"testing"

kusttest_test "sigs.k8s.io/kustomize/v3/pkg/kusttest"
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
)

/*
Expand Down Expand Up @@ -46,13 +45,14 @@ func check(e error) {
}

func TestKSOPSPluginSingleResource(t *testing.T) {
tc := plugins_test.NewEnvForTest(t).Set()
defer tc.Reset()
th := kusttest_test.MakeEnhancedHarness(t)

tc.BuildGoPlugin(
defer th.Reset()

th.BuildGoPlugin(
kustomizePluginOwner, kustomizePluginVersion, kustomizePluginName)

th := kusttest_test.NewKustTestPluginHarness(t, pluginTestDir)
th.ResetLoaderRoot(pluginTestDir)

// Load files from testing directory
encryptedResource, err := ioutil.ReadFile(path.Join(localTestDir, encryptedResourceFile))
Expand All @@ -73,13 +73,13 @@ func TestKSOPSPluginSingleResource(t *testing.T) {
}

func TestKSOPSPluginMultipleResources(t *testing.T) {
tc := plugins_test.NewEnvForTest(t).Set()
defer tc.Reset()
th := kusttest_test.MakeEnhancedHarness(t)
defer th.Reset()

tc.BuildGoPlugin(
kustomizePluginOwner, kustomizePluginVersion, kustomizePluginName)
th.ResetLoaderRoot(pluginTestDir)

th := kusttest_test.NewKustTestPluginHarness(t, pluginTestDir)
th.BuildGoPlugin(
kustomizePluginOwner, kustomizePluginVersion, kustomizePluginName)

// Load files from testing directory
for _, v := range resourceVersions {
Expand Down
9 changes: 9 additions & 0 deletions scripts/build-and-install-ksops.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
set -e

if [[ -z "$XDG_CONFIG_HOME" ]]; then
Expand All @@ -9,9 +10,14 @@ fi


PLUGIN_PATH="$XDG_CONFIG_HOME/kustomize/plugin/viaduct.ai/v1/ksops/"
# Unclear why the kustomize test harness looks for the plugin relative to the current path
# https://github.com/kubernetes-sigs/kustomize/blob/f749a4a194e1bfa50287e0c60889ca1f6eaf14bd/api/internal/plugins/compiler/compiler.go#L35
TEST_PLUGIN_PATH="$HOME/sigs.k8s.io/kustomize/plugin/viaduct.ai/v1/ksops/"

PLUGIN_NAME="ksops.so"

mkdir -p $PLUGIN_PATH
mkdir -p $TEST_PLUGIN_PATH

# Build Go plugin
echo "Building KSOPS Go plugin..."
Expand All @@ -22,3 +28,6 @@ echo "Copying executable plugin to the kustomize plugin path..."
echo "cp $PLUGIN_NAME $PLUGIN_PATH"
cp $PLUGIN_NAME $PLUGIN_PATH

echo "Copying executable plugin to the test kustomize plugin path..."
echo "cp $PLUGIN_NAME $TEST_PLUGIN_PATH"
cp $PLUGIN_NAME $TEST_PLUGIN_PATH
3 changes: 2 additions & 1 deletion scripts/install-kustomize.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
set -e

KUSTOMIZE="kustomize"

function install_kustomize() {
echo "Installing $KUSTOMIZE..."
go install sigs.k8s.io/kustomize/v3/cmd/kustomize
GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v3

echo "Successfully installed $KUSTOMIZE!"
kustomize version
Expand Down
3 changes: 2 additions & 1 deletion scripts/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
set -e

sh ./scripts/build-and-install-ksops.sh
Expand All @@ -7,4 +8,4 @@ sh ./scripts/setup-test-files.sh

# Run the tests
echo "Running tests..."
go test
go test -v
1 change: 1 addition & 0 deletions scripts/setup-test-files.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
set -e

# EXPECTS .sops.yaml TO SPECIFY CREATION RULES
Expand Down

0 comments on commit 0cc372a

Please sign in to comment.