Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Please review the example docs/plugins/goPluginGuidedExample.md #1524

Closed
s10g opened this issue Sep 11, 2019 · 6 comments
Closed

Please review the example docs/plugins/goPluginGuidedExample.md #1524

s10g opened this issue Sep 11, 2019 · 6 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@s10g
Copy link

s10g commented Sep 11, 2019

Could someone go through this example and update it to a working state? Fulfilling the requirements and following the guide verbatim does not work, and I am not able to work around it.

Here is an attempt at following the guide. I break "verbatism" at my second invocation of go install, where I set GO111MODULE=on (not shown in the example) which seems to at least bring me one step closer:

$ which curl; which git; go version
/usr/bin/curl
/usr/bin/git
go version go1.12 linux/amd64
$ DEMO=$(mktemp -d)
$ tmpGoPath=$(mktemp -d)
$ GOPATH=$tmpGoPath go install sigs.k8s.io/kustomize/v3/cmd/kustomize
can't load package: package sigs.k8s.io/kustomize/v3/cmd/kustomize: cannot find package "sigs.k8s.io/kustomize/v3/cmd/kustomize" in any of:
        /usr/local/go/src/sigs.k8s.io/kustomize/v3/cmd/kustomize (from $GOROOT)
        /tmp/tmp.yf8K7DgBim/src/sigs.k8s.io/kustomize/v3/cmd/kustomize (from $GOPATH)
$ GOPATH=$tmpGoPath GO111MODULE=on go install sigs.k8s.io/kustomize/v3/cmd/kustomize
go: finding sigs.k8s.io/kustomize/v3/cmd/kustomize latest
go: finding sigs.k8s.io/kustomize/v3/cmd latest
go: finding sigs.k8s.io/kustomize/v3 v3.1.0
go: downloading sigs.k8s.io/kustomize/v3 v3.1.0
go: extracting sigs.k8s.io/kustomize/v3 v3.1.0
go: finding github.com/golang/protobuf v1.3.1
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/onsi/gomega v1.5.0
go: finding github.com/go-openapi/spec v0.19.2
go: finding github.com/evanphx/json-patch v4.5.0+incompatible
go: finding github.com/onsi/ginkgo v1.8.0
go: finding github.com/spf13/pflag v1.0.3
go: finding sigs.k8s.io/yaml v1.1.0
go: finding k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208
go: finding golang.org/x/net v0.0.0-20190620200207-3b0461eec859
go: finding github.com/googleapis/gnostic v0.3.0
go: finding k8s.io/client-go v11.0.0+incompatible
go: finding github.com/modern-go/reflect2 v1.0.1
go: finding github.com/emicklei/go-restful v2.9.6+incompatible
go: finding k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1
go: finding github.com/inconshreveable/mousetrap v1.0.0
go: finding github.com/go-openapi/swag v0.19.2
go: finding golang.org/x/sys v0.0.0-20190621203818-d432491b9138
go: finding github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87
go: finding k8s.io/klog v0.3.3
go: finding github.com/googleapis/gnostic v0.0.0-20170426233943-68f4ded48ba9
go: finding golang.org/x/text v0.0.0-20160726164857-2910a502d2bf
go: finding golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8
go: finding github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633
go: finding github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2
go: finding k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6
go: finding github.com/stretchr/testify v1.3.0
go: finding golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59
go: finding gopkg.in/inf.v0 v0.9.1
go: finding golang.org/x/net v0.0.0-20170114055629-f2499483f923
go: finding github.com/PuerkitoBio/purell v1.0.0
go: finding github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c
go: finding golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea
go: finding github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365
go: finding github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2
go: finding github.com/gogo/protobuf v1.2.1
go: finding github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501
go: finding github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: finding github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0
go: finding github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9
go: finding github.com/go-openapi/jsonreference v0.19.2
go: finding github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46
go: finding golang.org/x/sync v0.0.0-20190423024810-112230192c58
go: finding github.com/kr/pty v1.1.5
go: finding github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da
go: finding golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f
go: finding golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: finding github.com/stretchr/objx v0.2.0
go: finding github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367
go: finding github.com/kisielk/errcheck v1.1.0
go: finding github.com/google/gofuzz v1.0.0
go: finding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
go: finding gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
go: finding golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
go: finding golang.org/x/net v0.0.0-20180906233101-161cd47e91fd
go: finding golang.org/x/text v0.3.0
go: finding golang.org/x/net v0.0.0-20190613194153-d28f0bde5980
go: finding github.com/go-openapi/jsonpointer v0.19.2
go: finding github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63
go: finding github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7
go: finding sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e
go: finding golang.org/x/net v0.0.0-20190311183353-d8887717615a
go: finding github.com/spf13/cobra v0.0.2
go: finding github.com/kr/pretty v0.1.0
go: finding github.com/mailru/easyjson v0.0.0-20190620125010-da37f6c1e481
go: finding github.com/PuerkitoBio/purell v1.1.1
go: finding gopkg.in/fsnotify.v1 v1.4.7
go: finding github.com/onsi/ginkgo v1.6.0
go: finding github.com/json-iterator/go v1.1.6
go: finding golang.org/x/sys v0.0.0-20190412213103-97732733099d
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09
go: finding github.com/kisielk/gotool v1.0.0
go: finding golang.org/x/tools v0.0.0-20180221164845-07fd8470d635
go: finding github.com/kr/text v0.1.0
go: gopkg.in/fsnotify.v1@v1.4.7: unknown revision v1.4.7
go: finding github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3
go: finding github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: finding github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1
go: finding gopkg.in/yaml.v2 v2.2.2
go: finding gopkg.in/yaml.v2 v2.2.1
go: finding golang.org/x/text v0.3.2
go: finding github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680
go: finding github.com/davecgh/go-spew v1.1.0
go: finding gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: finding k8s.io/api v0.0.0-20190313235455-40a48860b5ab
go: finding github.com/golang/protobuf v1.2.0
go: finding github.com/stretchr/objx v0.1.0
go: finding github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c
go: finding github.com/fsnotify/fsnotify v1.4.7
go: finding github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff
go: finding k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92
go: finding github.com/hpcloud/tail v1.0.0
go: gopkg.in/tomb.v1@v1.0.0-20141024135613-dd632973f1e7: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/tmp.yf8K7DgBim/pkg/mod/cache/vcs/95acae1f863cd3698780e83ddc42f6ad6cd0ab1cb79143808a7de7300ae4df93: exit status 128:
        error: RPC failed; HTTP 502 curl 22 The requested URL returned error: 502 Bad Gateway
        fatal: The remote end hung up unexpectedly
go: error loading module requirements
$ 

EDIT: At this point, I submitted this issue. However, looking at the error and assuming a 502 Bad Gateway could have been a temporary problem, I tried again:

$ GOPATH=$tmpGoPath GO111MODULE=on go install sigs.k8s.io/kustomize/v3/cmd/kustomize
go: finding sigs.k8s.io/kustomize/v3/cmd/kustomize latest
go: finding sigs.k8s.io/kustomize/v3/cmd latest
go: finding github.com/kr/pty v1.1.1
go: finding golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
go: finding gopkg.in/fsnotify.v1 v1.4.7
go: finding gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
go: downloading github.com/spf13/cobra v0.0.2
go: downloading github.com/spf13/pflag v1.0.3
go: downloading github.com/pkg/errors v0.8.1
go: downloading k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1
go: downloading github.com/evanphx/json-patch v4.5.0+incompatible
go: downloading github.com/go-openapi/spec v0.19.2
go: extracting github.com/evanphx/json-patch v4.5.0+incompatible
go: extracting github.com/pkg/errors v0.8.1
go: extracting github.com/spf13/pflag v1.0.3
go: downloading k8s.io/api v0.0.0-20190313235455-40a48860b5ab
go: extracting github.com/spf13/cobra v0.0.2
go: downloading k8s.io/client-go v11.0.0+incompatible
go: extracting github.com/go-openapi/spec v0.19.2
go: downloading github.com/go-openapi/jsonreference v0.19.2
go: extracting github.com/go-openapi/jsonreference v0.19.2
go: downloading github.com/go-openapi/swag v0.19.2
go: extracting github.com/go-openapi/swag v0.19.2
go: downloading github.com/PuerkitoBio/purell v1.1.1
go: extracting github.com/PuerkitoBio/purell v1.1.1
go: downloading sigs.k8s.io/yaml v1.1.0
go: extracting sigs.k8s.io/yaml v1.1.0
go: downloading github.com/mailru/easyjson v0.0.0-20190620125010-da37f6c1e481
go: extracting k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1
go: extracting github.com/mailru/easyjson v0.0.0-20190620125010-da37f6c1e481
go: downloading gopkg.in/yaml.v2 v2.2.2
go: downloading github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading golang.org/x/text v0.3.2
go: downloading github.com/google/gofuzz v1.0.0
go: downloading golang.org/x/net v0.0.0-20190620200207-3b0461eec859
go: downloading gopkg.in/inf.v0 v0.9.1
go: extracting github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: extracting github.com/davecgh/go-spew v1.1.1
go: downloading github.com/gogo/protobuf v1.2.1
go: extracting github.com/google/gofuzz v1.0.0
go: downloading github.com/go-openapi/jsonpointer v0.19.2
go: extracting github.com/go-openapi/jsonpointer v0.19.2
go: downloading k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208
go: extracting gopkg.in/yaml.v2 v2.2.2
go: extracting k8s.io/api v0.0.0-20190313235455-40a48860b5ab
go: extracting gopkg.in/inf.v0 v0.9.1
go: extracting k8s.io/client-go v11.0.0+incompatible
go: downloading k8s.io/klog v0.3.3
go: downloading github.com/json-iterator/go v1.1.6
go: extracting github.com/json-iterator/go v1.1.6
go: downloading github.com/modern-go/reflect2 v1.0.1
go: extracting k8s.io/klog v0.3.3
go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: extracting github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: extracting github.com/modern-go/reflect2 v1.0.1
go: extracting k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208
go: extracting golang.org/x/net v0.0.0-20190620200207-3b0461eec859
go: downloading github.com/emicklei/go-restful v2.9.6+incompatible
go: downloading github.com/googleapis/gnostic v0.3.0
go: extracting github.com/emicklei/go-restful v2.9.6+incompatible
go: extracting github.com/googleapis/gnostic v0.3.0
go: downloading github.com/golang/protobuf v1.3.1
go: extracting github.com/gogo/protobuf v1.2.1
go: extracting github.com/golang/protobuf v1.3.1
go: extracting golang.org/x/text v0.3.2
$ 

Due to no error message at the second run, I kept following the guide:

$ PLUGIN_ROOT=$DEMO/kustomize/plugin
$ apiVersion=mygenerators
$ kind=SopsEncodedSecrets
$ lKind=$(echo $kind | awk '{print tolower($0)}')
$ for val in $PLUGIN_ROOT $apiVersion $kind $lKind; do echo $val; done
/tmp/tmp.Yl9RJfYtFE/kustomize/plugin
mygenerators
SopsEncodedSecrets
sopsencodedsecrets
$ mkdir -p $PLUGIN_ROOT/${apiVersion}
$ cd $PLUGIN_ROOT/${apiVersion}
$ git clone git@github.com:monopole/sopsencodedsecrets.git
Cloning into 'sopsencodedsecrets'...
...
Resolving deltas: 100% (11/11), done.
$ MY_PLUGIN_DIR=$PLUGIN_ROOT/${apiVersion}/${lKind}
$ cd $MY_PLUGIN_DIR
$ go test SopsEncodedSecrets_test.go
go: finding github.com/lib/pq v1.1.1
go: finding github.com/aws/aws-sdk-go v1.20.6
go: finding github.com/mozilla-services/yaml v0.0.0-20180922153656-28ffe5d0cafb
go: finding github.com/goware/prefixer v0.0.0-20160118172347-395022866408
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/Azure/azure-sdk-for-go v30.1.0+incompatible
...
...
go: extracting github.com/golang/protobuf v1.3.1
go: extracting github.com/gogo/protobuf v1.2.1
go: extracting golang.org/x/text v0.3.2
ok      command-line-arguments  24.083s
$ cd $MY_PLUGIN_DIR
$ GOPATH=$tmpGoPath go build -buildmode plugin -o ${kind}.so ${kind}.go
go: finding github.com/mozilla-services/yaml v0.0.0-20180922153656-28ffe5d0cafb
go: finding github.com/goware/prefixer v0.0.0-20160118172347-395022866408
....
....
go: extracting github.com/mitchellh/go-homedir v1.1.0
go: extracting github.com/dgrijalva/jwt-go v3.2.0+incompatible
go: extracting github.com/grpc-ecosystem/grpc-gateway v1.8.5
$ MYAPP=$DEMO/myapp
$ mkdir -p $MYAPP
$ cat <<EOF >$MYAPP/secGenerator.yaml
> apiVersion: ${apiVersion}
> kind: ${kind}
> metadata:
>   name: mySecretGenerator
> name: forbiddenValues
> namespace: production
> file: myEncryptedData.yaml
> keys:
> - ROCKET
> - CAR
> EOF
$ cat <<EOF >$MYAPP/kustomization.yaml
> commonLabels:
>   app: hello
> generators:
> - secGenerator.yaml
> EOF
$ GOPATH=$tmpGoPath go install go.mozilla.org/sops/cmd/sops
go: finding github.com/google/shlex latest
go: finding gopkg.in/ini.v1 v1.46.0
go: finding gopkg.in/urfave/cli.v1 v1.22.0
go: finding github.com/blang/semver v3.5.1+incompatible
go: downloading github.com/blang/semver v3.5.1+incompatible
go: extracting github.com/blang/semver v3.5.1+incompatible
go: downloading github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf
go: extracting github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf
go: downloading gopkg.in/ini.v1 v1.46.0
go: extracting gopkg.in/ini.v1 v1.46.0
go: downloading gopkg.in/urfave/cli.v1 v1.22.0
build go.mozilla.org/sops/cmd/sops: cannot load gopkg.in/urfave/cli.v1: cannot find module providing package gopkg.in/urfave/cli.v1

Ok, so the above failed. I went ahead and acquired sops manually:

$ sops --version
sops 3.3.1 (latest)
$ cat <<EOF >$MYAPP/myClearData.yaml
> VEGETABLE: carrot
> ROCKET: saturn-v
> FRUIT: apple
> CAR: dymaxion
> EOF
$ SOPS_PGP_FP="1022470DE3F0BC54BC6AB62DE05550BC07FB1A0A"
$ sops --encrypt   --pgp $SOPS_PGP_FP   $MYAPP/myClearData.yaml >$MYAPP/myEncryptedData.yaml
$ tree $DEMO
/tmp/tmp.Yl9RJfYtFE
├── kustomize
│   └── plugin
│       └── mygenerators
│           └── sopsencodedsecrets
│               ├── LICENSE
│               ├── README.md
│               ├── SopsEncodedSecrets.go
│               ├── SopsEncodedSecrets.so
│               ├── SopsEncodedSecrets_test.go
│               ├── go.mod
│               └── go.sum
└── myapp
    ├── kustomization.yaml
    ├── myClearData.yaml
    ├── myEncryptedData.yaml
    └── secGenerator.yaml

Then finally, last step:

$ XDG_CONFIG_HOME=$DEMO $tmpGoPath/bin/kustomize build --enable_alpha_plugins $MYAPP
Error: loading generator plugins: plugin /tmp/tmp.Yl9RJfYtFE/kustomize/plugin/mygenerators/sopsencodedsecrets/SopsEncodedSecrets fails to load: plugin.Open("/tmp/tmp.Yl9RJfYtFE/kustomize/plugin/mygenerators/sopsencodedsecrets/SopsEncodedSecrets"): plugin was built with a di
fferent version of package sigs.k8s.io/kustomize/v3/pkg/gvk

Thank you ever so much in advance.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 10, 2019
@d-goro
Copy link

d-goro commented Dec 15, 2019

same problem here. The provided example doesn't work

@devstein
Copy link
Contributor

devstein commented Jan 8, 2020

Same. @s10g @d-goro If it helps, you can check out my PR to upgrade our SOPS kustomize Go plugin for the recent kustomize package changes. This fixes the same issue you are encountering with the stale plugin used in the documentation.

@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 8, 2020
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

5 participants