Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Template Guide doesnt work #16

Closed
mikebollandajw opened this issue Feb 23, 2022 · 33 comments · Fixed by crossplane/terrajet#242
Closed

Template Guide doesnt work #16

mikebollandajw opened this issue Feb 23, 2022 · 33 comments · Fixed by crossplane/terrajet#242
Labels
bug Something isn't working

Comments

@mikebollandajw
Copy link

mikebollandajw commented Feb 23, 2022

What happened?

the make file appears to not work, im not sure if there is dependencies im expected to do but they arent in the guide

make generate
make: *** No rule to make target 'generate'.  Stop.

even just make does

make
make: installing: Command not found
Makefile:64: recipe for target '/terraform-1.1.6' failed
make: *** [/terraform-1.1.6] Error 127

How can we reproduce it?

follow the guide on ubuntu wsl

@turkenh
Copy link
Collaborator

turkenh commented Feb 23, 2022

@mikebollandajw thanks for reporting.

This was caused due to a recent change where we started consuming upbound build utilities as a submodule. I'll update the guide accordingly.

In the meantime, you can workaround by running the following once after cloning the repository to your local:

make submodules

@mikebollandajw
Copy link
Author

mikebollandajw commented Feb 23, 2022

make submodules
Submodule 'build' (https://github.com/upbound/build) registered for path 'build'
Cloning into '/mnt/c/dev/git/provider-jet-azuread/build'...
Submodule path 'build': checked out 'bd63a4167ae20a71788537217b022fced8f2f854'
make generate
13:47:57 [ .. ] verify dependencies have expected content
go: unknown subcommand "mod"
Run 'go help' for usage.
13:47:57 [FAIL]
build/makelib/golang.mk:217: recipe for target 'go.vendor.lite' failed
make[1]: *** [go.vendor.lite] Error 1
build/makelib/common.mk:418: recipe for target 'generate' failed
make: *** [generate] Error 2

@turkenh
Copy link
Collaborator

turkenh commented Feb 23, 2022

What do you see with:

go mod tidy

What is your go version?

Please see: https://stackoverflow.com/questions/60410729/unknown-subcommand-mod-error-while-running-go-mod-init

@mikebollandajw
Copy link
Author

oh good point let me try updating that

@turkenh
Copy link
Collaborator

turkenh commented Feb 23, 2022

I would also suggest to get latest template from main, just merged a big change bumping Terrajet to v0.4.0!

@mikebollandajw
Copy link
Author

my go version is 1.10.4 from ubuntu 18.04 which is the required version for this?

@turkenh
Copy link
Collaborator

turkenh commented Feb 23, 2022

We need go 1.17 here

@mikebollandajw
Copy link
Author

mikebollandajw commented Feb 23, 2022

go mod tidy is using 'crossplane-contrib/*' as its domain path for my provider despite me changing it in the template guide steps

go: finding module for package github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1
github.com/crossplane-contrib/provider-jet-azuread/apis imports
        github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1: cannot find module providing package github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1: module github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1: git ls-remote -q origin in /home/mikebolland/go/pkg/mod/cache/vcs/9d596c92663b390be4f17e07a299aec94dbc59b1689b685c82c49c74ac240577: exit status 128:

@mikebollandajw
Copy link
Author

i started from scratch with the new template and go 1.17 but it is still the above issues @turkenh

@mikebollandajw
Copy link
Author

make submodules
Synchronizing submodule url for 'build'
make generate
17:22:02 [ .. ] verify dependencies have expected content
all modules verified
17:22:10 [ OK ] go modules dependencies verified
17:22:10 [ .. ] installing terraform linux-x86_64
Archive:  /mnt/c/dev/git/provider-jet-azuread/.cache/tools/linux_x86_64/tmp-terraform/terraform.zip
  inflating: /mnt/c/dev/git/provider-jet-azuread/.cache/tools/linux_x86_64/tmp-terraform/terraform
17:22:14 [ OK ] installing terraform linux-x86_64
17:22:14 [ .. ] generating provider schema for hashicorp/terraform-provider-azuread 2.18.0
Makefile:87: recipe for target 'config/schema.json' failed
make[1]: *** [config/schema.json] Error 1
build/makelib/common.mk:418: recipe for target 'generate' failed
make: *** [generate] Error 2
go mod tidy
go: downloading github.com/crossplane/crossplane-runtime v0.15.1-0.20220106140106-428b7c390375
go: downloading github.com/crossplane/terrajet v0.4.0
go: downloading k8s.io/apimachinery v0.23.0
go: downloading sigs.k8s.io/controller-runtime v0.11.0
go: downloading k8s.io/client-go v0.23.0
go: downloading sigs.k8s.io/controller-tools v0.8.0
go: downloading github.com/evanphx/json-patch v4.12.0+incompatible
go: downloading github.com/onsi/ginkgo v1.16.5
go: downloading github.com/onsi/gomega v1.17.0
go: downloading k8s.io/api v0.23.0
go: downloading k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b
go: downloading github.com/go-logr/logr v1.2.0
go: downloading github.com/spf13/afero v1.8.0
go: downloading github.com/go-logr/zapr v1.2.0
go: downloading go.uber.org/zap v1.19.1
go: downloading golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff
go: downloading k8s.io/klog/v2 v2.30.0
go: downloading sigs.k8s.io/structured-merge-diff/v4 v4.2.0
go: downloading sigs.k8s.io/yaml v1.3.0
go: downloading sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6
go: downloading k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65
go: downloading golang.org/x/net v0.0.0-20210825183410-e898025ed96a
go: downloading k8s.io/apiextensions-apiserver v0.23.0
go: downloading go.uber.org/goleak v1.1.12
go: downloading k8s.io/component-base v0.23.0
go: downloading golang.org/x/text v0.3.7
go: downloading github.com/json-iterator/go v1.1.12
go: downloading golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
go: downloading golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
go: downloading golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8
go: downloading google.golang.org/protobuf v1.27.1
go: downloading github.com/prometheus/common v0.28.0
go: downloading github.com/modern-go/reflect2 v1.0.2
go: downloading github.com/fsnotify/fsnotify v1.5.1
go: finding module for package github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1
github.com/crossplane-contrib/provider-jet-azuread/apis imports
        github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1: cannot find module providing package github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1: module github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1: git ls-remote -q origin in /home/mikebolland/go/pkg/mod/cache/vcs/9d596c92663b390be4f17e07a299aec94dbc59b1689b685c82c49c74ac240577: exit status 128:
        fatal: could not read Username for 'https://github.com': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.

@mikebollandajw
Copy link
Author

can you reopen this since i still cant build from the template guide

thanks!

@mikebollandajw
Copy link
Author

@turkenh

@mikebollandajw
Copy link
Author

actually, nm, looks like the terraform provider argument i used was not correct

@turkenh
Copy link
Collaborator

turkenh commented Feb 24, 2022

actually, nm, looks like the terraform provider argument i used was not correct

@mikebollandajw does this mean you're good to go and we don't need to reopen ticket?

@mikebollandajw
Copy link
Author

generate is stuck on

go: finding module for package github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1
github.com/crossplane-contrib/provider-jet-azuread/apis imports
        github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1: cannot find module providing package github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1: module github.com/crossplane-contrib/provider-jet-azuread/apis/null/v1alpha1: git ls-remote -q origin in /mnt/c/dev/git/provider-jet-azuread/.work/pkg/pkg/mod/cache/vcs/9d596c92663b390be4f17e07a299aec94dbc59b1689b685c82c49c74ac240577: exit status 128:
        fatal: could not read Username for 'https://github.com': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
07:57:17 [FAIL]
build/makelib/golang.mk:270: recipe for target 'go.generate' failed
make[1]: *** [go.generate] Error 1
build/makelib/common.mk:418: recipe for target 'generate' failed
make: *** [generate] Error 2

@turkenh
Copy link
Collaborator

turkenh commented Feb 24, 2022

Did you change module name here: https://github.com/crossplane-contrib/provider-jet-template/blob/main/go.mod#L1 ?

This would require all import paths to be updated.

@mikebollandajw
Copy link
Author

no sir i just followed the guide, i guess some script is doing that?

@turkenh
Copy link
Collaborator

turkenh commented Feb 24, 2022

I can check if you could share your code/repo.

@mikebollandajw
Copy link
Author

@mikebollandajw
Copy link
Author

mikebollandajw commented Feb 24, 2022

# We need to be careful while replacing "template" keyword in go.mod as it could tamper
# some imported packages under require section.
sed -i.bak "s/provider-jet-template/provider-jet-${ProviderNameLower}/g" go.mod

thi sis in the hack/prepare.sh

@turkenh
Copy link
Collaborator

turkenh commented Feb 24, 2022

https://github.com/ajwgroup/provider-jet-azuread

make generate succeded on my side 🤔

make generate
12:45:48 [ .. ] installing terraform darwin-x86_64
Archive:  /Users/hasanturken/Workspace/tmp/provider-jet-azuread/.cache/tools/darwin_x86_64/tmp-terraform/terraform.zip
  inflating: /Users/hasanturken/Workspace/tmp/provider-jet-azuread/.cache/tools/darwin_x86_64/tmp-terraform/terraform
12:45:52 [ OK ] installing terraform darwin-x86_64
12:45:52 [ .. ] generating provider schema for hashicorp/null 3.1.0
12:46:00 [ OK ] generating provider schema for hashicorp/null 3.1.0
12:46:00 [ .. ] verify dependencies have expected content
all modules verified
12:46:01 [ OK ] go modules dependencies verified
12:46:01 [ .. ] go generate darwin_amd64
go: downloading github.com/crossplane/crossplane-tools v0.0.0-20210916125540-071de511ae8e
go: downloading sigs.k8s.io/controller-tools v0.8.0
go: downloading github.com/muvaf/typewriter v0.0.0-20220131201631-921e94e8e8d7
go: downloading golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff
go: downloading github.com/dave/jennifer v1.4.1
go: downloading github.com/spf13/cobra v1.2.1
go: downloading github.com/fatih/color v1.12.0
go: downloading github.com/gobuffalo/flect v0.2.3
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading github.com/mattn/go-colorable v0.1.8
go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
go: downloading golang.org/x/mod v0.4.2

Generated 1 resources!
12:46:22 [ OK ] go generate darwin_amd64
12:46:22 [ .. ] go mod tidy
go: downloading github.com/onsi/gomega v1.17.0
go: downloading github.com/golang/mock v1.6.0
go: downloading github.com/stretchr/testify v1.7.0
go: downloading github.com/onsi/ginkgo v1.16.5
go: downloading go.uber.org/goleak v1.1.12
go: downloading github.com/inconshreveable/mousetrap v1.0.0
go: downloading github.com/benbjohnson/clock v1.1.0
go: downloading github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0
go: downloading github.com/go-test/deep v1.0.3
go: downloading github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce
go: downloading gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
go: downloading google.golang.org/appengine v1.6.7
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading github.com/kr/pretty v0.2.1
go: downloading github.com/kylelemons/godebug v1.1.0
go: downloading github.com/nxadm/tail v1.4.8
go: downloading github.com/kr/text v0.2.0
go: downloading gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: downloading github.com/hashicorp/terraform-plugin-sdk v1.17.2
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/apparentlymart/go-textseg v1.0.0
go: downloading github.com/cespare/xxhash v1.1.0
12:46:26 [ OK ] go mod tidy
12:46:26 [ .. ] cleaning generated CRDs
12:46:26 [ OK ] cleaned generated CRDs

@turkenh
Copy link
Collaborator

turkenh commented Feb 24, 2022

no sir i just followed the guide, i guess some script is doing that?

yeah, I was asking for manual changes other than that.

@turkenh
Copy link
Collaborator

turkenh commented Feb 24, 2022

This does not look like your final state btw:

https://github.com/ajwgroup/provider-jet-azuread/blob/main/Makefile#L4

@mikebollandajw
Copy link
Author

oh i havent commited sorry one sec

@mikebollandajw
Copy link
Author

deployed

@turkenh
Copy link
Collaborator

turkenh commented Feb 24, 2022

Run the guide on my side and generation was successful: https://github.com/turkenh/provider-jet-azuread

Comparing our codes, I found the following diff which seems to be the culprit:

diff provider-jet-azuread/Makefile try/provider-jet-azuread/Makefile
5c5
< PROJECT_REPO := github.com/ajwgroup/$(PROJECT_NAME)
---
> PROJECT_REPO := github.com/crossplane-contrib/$(PROJECT_NAME)

I would suggest you replace all occurrences of that string inside the repository if you want to change it.

@mikebollandajw
Copy link
Author

Oh but people wanting to contribute cannot deploy to crossplane-contrib so it is a little confusing

Are you saiyng we shouldnt change the PROJECT_REPO variable? Can the guide be updated to reflect this? Thanks!

@turkenh
Copy link
Collaborator

turkenh commented Feb 24, 2022

You can still host it on your github org without changing that variable. It would simply work.
It causes problems when it is changed for some occurrences but not all.

But I totally agree that is confusing and we should clarify in the guide. May be a step which finds and replaces all crossplane-contribs to <your-org>. Would you mind creating a ticket for that in Terrajet?

@mikebollandajw
Copy link
Author

yeah of course! thanks for getting this working for us we are hoping to migrate some of our old terraform over to helm with crossplane so this provider converter to use azuread is a big help

@mikebollandajw
Copy link
Author

Raised, thanks! crossplane/terrajet#243

mikebollandajw added a commit to ajwgroup/provider-jet-azuread that referenced this issue Feb 24, 2022
@mikebollandajw
Copy link
Author

mikebollandajw commented Feb 24, 2022

should the script also be supplying goimports?

13:33:18 [ .. ] go generate linux_amd64
panic: cannot run goimports for apis folder: bash: goimports: command not found
: exit status 127

goroutine 1 [running]:
github.com/crossplane/terrajet/pkg/pipeline.Run(0xc0000ff380, {0xc00098e3f0, 0x23})
        /mnt/c/dev/git/provider-jet-azuread/.work/pkg/pkg/mod/github.com/crossplane/terrajet@v0.4.0/pkg/pipeline/run.go:109 +0xa79
main.main()
        /mnt/c/dev/git/provider-jet-azuread/cmd/generator/main.go:39 +0x68
exit status 2
apis/generate.go:33: running "go": exit status 1
13:34:55 [FAIL]

@mikebollandajw
Copy link
Author

that appeared to be the final issue to finish generate :-) thanks again!

@mikebollandajw
Copy link
Author

seinj0312 added a commit to seinj0312/upjet that referenced this issue Jun 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants