Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore(go-module): migrate vendor to go module #1701

Closed
wants to merge 9 commits into from

Conversation

vaniisgh
Copy link
Contributor

@vaniisgh vaniisgh commented May 19, 2020

wrt #1700

work in progress but would like some review :)
this my first PR as well here and my first time migrating code so just wanted to know if I am moving in the right direction.

using the command GO111MODULE=on make all package can be built successfully without being in the users $GOPATH

Signed-off-by: Vani Singh vanisingh@live.co.uk

also, I ran the tests on both my branches, some tests failed in both ... so I thought the migration was okay.
the tests that fail are :

  • github.com/openebs/maya/cmd/maya-exporter/app/command
  • github.com/openebs/maya/pkg/client/mapiserver

 using the command
wrt openebs-archive#1700 `GO111MODULE=on make all` package can be built successfully

Signed-off-by: Vani Singh <vanisingh@live.co.uk>
- remove Gopkg.lock & Gopkg.toml files
- update readme

Signed-off-by: Vani Singh <vanisingh@live.co.uk>
@vaniisgh vaniisgh changed the title chore chores: migrate code to go module support refract chores: migrate code to go module support May 20, 2020
- update readme

Signed-off-by: Vani Singh <vanisingh@live.co.uk>
@mynktl mynktl changed the title refract chores: migrate code to go module support chore(go-module): migrate vendor to go module May 21, 2020
docs/developer.md Outdated Show resolved Hide resolved
- fix redundancy in command

Signed-off-by: Vani Singh <vanisingh@live.co.uk>
@mynktl
Copy link
Contributor

mynktl commented May 21, 2020

Hi @vaniisgh
Thanks for the PR!

There is one check for vendor dependency using dep check in ./buildscripts/travis-build.sh. Need to remove that check.

- remove golint reference in readme
-  remove  dep check

Signed-off-by: Vani Singh <vanisingh@live.co.uk>
- vendor folder no longer required

Signed-off-by: Vani Singh <vanisingh@live.co.uk>
-  attempt to fix the ci file
Signed-off-by: Vani Singh <vanisingh@live.co.uk>
- change cloning out of $gopath

Signed-off-by: Vani Singh <vanisingh@live.co.uk>
This reverts commit 038bcf6.
@vaniisgh
Copy link
Contributor Author

vaniisgh commented May 22, 2020

so, I ran the make kubegen, and it looks for the vendor/k8s.io/code-generator hence the revert.

@mynktl
Copy link
Contributor

mynktl commented May 26, 2020

so, I ran the make kubegen, and it looks for the vendor/k8s.io/code-generator hence the revert.

No need to add vendor code @vaniisgh .

GNUmakefile and buildscripts/code-gen.sh uses code-generator from vendor. Since we are removing vendor code, you need to use different approach to install these binaries.

For buildscripts/code-gen.sh, you need to apply below patch....

diff --git a/buildscripts/code-gen.sh b/buildscripts/code-gen.sh
index 0cdb74eb0..7d76ef4ae 100755
--- a/buildscripts/code-gen.sh
+++ b/buildscripts/code-gen.sh
@@ -50,11 +50,14 @@ GROUPS_WITH_VERSIONS="$4"
 shift 4
 
 (
-  # To support running this script from anywhere, we have to first cd into this directory
-  # so we can install the tools.
-  #cd $(dirname "${0}")
-  cd vendor/k8s.io/code-generator/ 
-  go install ./cmd/{defaulter-gen,client-gen,lister-gen,informer-gen,deepcopy-gen}
+  # List of tools used for code generation
+  TOOL=(client-gen deepcopy-gen lister-gen informer-gen)
+  for i in ${TOOL[@]}; do
+    if [ ! -f "${GOPATH}/bin/$i" ]; then
+      echo "$i binary not found, installing at ${GOPATH}/bin"
+      go get k8s.io/code-generator/cmd/$i
+    fi
+  done
 )
 
 function codegen::join() { local IFS="$1"; shift; echo "$*"; }

For GNUmakefile you can replace
go install ./vendor/k8s.io/code-generator/cmd/<deepcopy-gen,client-gen,lister-gen,informer-gen>
with
go get ./vendor/k8s.io/code-generator/cmd/<deepcopy-gen,client-gen,lister-gen,informer-gen>.

Please let me know if you are having any issues.

@vaniisgh
Copy link
Contributor Author

vaniisgh commented May 26, 2020

thanks for the help, I just panicked when the code broke tbh and though I'd just put them back in, tbh I don't think it solved much! will give this a go (and will be sure to bother you for future issues )
thanks again :)

@vaniisgh
Copy link
Contributor Author

closing this pull request because it was quite messy for me to revert the commits and sign the DCO, I hope thats ok :)
opened a fresh one with the same name. (#1702)

also, thank you for letting me make these changes even though you had it figured out it really helped me learn :)

regards,
vani

@vaniisgh vaniisgh closed this May 27, 2020
@vaniisgh vaniisgh deleted the add_GoModuleSupport branch June 7, 2020 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants