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

Support go 1.16 module aware install with version #3618

Closed
yhrn opened this issue Feb 18, 2021 · 14 comments
Closed

Support go 1.16 module aware install with version #3618

yhrn opened this issue Feb 18, 2021 · 14 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@yhrn
Copy link
Contributor

yhrn commented Feb 18, 2021

Is your feature request related to a problem? Please describe.

Go 1.16 supports installing tools via go install [package@version], which will build and install a specific version of that tool without interacting with the local go.mod. This does not work for Kustomize because its go.mod contains replace and exclude directives (more context here).

It would be nice if this worked for Kustomize as well as that would allow us to handle all of our tool dependencies in a consistent and deterministic manner.

Describe the solution you'd like

I don't really have a suggestion for how to change the current module structure for this to work or if it is really feasible but I thought it might be worth bringing up at least.

@Shell32-Natsu Shell32-Natsu added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 18, 2021
@Shell32-Natsu
Copy link
Contributor

The replacements are not included in the a released version I believe. Are you trying to install a specific commit?

@yhrn
Copy link
Contributor Author

yhrn commented Feb 18, 2021

No I was just doing go install sigs.k8s.io/kustomize/kustomize/v4@v4.0.1

> go install sigs.k8s.io/kustomize/kustomize/v4@v4.0.1
go install sigs.k8s.io/kustomize/kustomize/v4@v4.0.1: sigs.k8s.io/kustomize/kustomize/v4@v4.0.1
        The go.mod file for the module providing named packages contains one or
        more exclude directives. It must not contain directives that would cause
        it to be interpreted differently than if it were the main module.

@Shell32-Natsu
Copy link
Contributor

zoetrope added a commit to cybozu-go/pod-security-admission that referenced this issue Mar 24, 2021
@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-contributor-experience at kubernetes/community.
/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 May 19, 2021
@yhrn
Copy link
Contributor Author

yhrn commented May 19, 2021

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 19, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/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 Aug 17, 2021
@yhrn
Copy link
Contributor Author

yhrn commented Aug 18, 2021

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 18, 2021
@yhrn
Copy link
Contributor Author

yhrn commented Aug 23, 2021

I think this is more relevant now that go 1.17 has deprecated installing executables with go get.

@neha-viswanathan
Copy link

neha-viswanathan commented Nov 18, 2021

Hello @yhrn! any updates on this issue?

@yhrn
Copy link
Contributor Author

yhrn commented Nov 18, 2021

@neha-viswanathan I just reported this, I'm not deeply involved with the development of Kustomize so I don't know how feasible this is to fix.

@natasha41575
Copy link
Contributor

I'm trying to understand why these exclude statements were added.

Commits:

I just tried removing the exclude statements, kustomize builds fine. I'm inclined to just remove them, but I'd really like to know their context before doing that.

@Neo2308
Copy link
Contributor

Neo2308 commented Dec 19, 2021

@natasha41575 The exclude statements seem to just be artifacts from older release cycles. I dont see a point in excluding apis v2 when we are already on version v10

@vitorenesduarte
Copy link

With #4387, I can now install kustomize with go install.

mflendrich added a commit to Kong/kubernetes-ingress-controller that referenced this issue Mar 18, 2022
reason:

    go: creating new go.mod: module tmp
    Downloading sigs.k8s.io/kustomize/kustomize/v4@v4.3.0
    go: downloading sigs.k8s.io/kustomize/kustomize/v4 v4.3.0
    go: sigs.k8s.io/kustomize/kustomize/v4@v4.3.0 (in sigs.k8s.io/kustomize/kustomize/v4@v4.3.0):
	    The go.mod file for the module providing named packages contains one or
	    more exclude directives. It must not contain directives that would cause
	    it to be interpreted differently than if it were the main module.
    make: *** [Makefile:36: kustomize] Error 1

the version bump seems to fix the issue as per
kubernetes-sigs/kustomize#3618
mflendrich added a commit to Kong/kubernetes-ingress-controller that referenced this issue Mar 18, 2022
reason:

    go: creating new go.mod: module tmp
    Downloading sigs.k8s.io/kustomize/kustomize/v4@v4.3.0
    go: downloading sigs.k8s.io/kustomize/kustomize/v4 v4.3.0
    go: sigs.k8s.io/kustomize/kustomize/v4@v4.3.0 (in sigs.k8s.io/kustomize/kustomize/v4@v4.3.0):
	    The go.mod file for the module providing named packages contains one or
	    more exclude directives. It must not contain directives that would cause
	    it to be interpreted differently than if it were the main module.
    make: *** [Makefile:36: kustomize] Error 1

the version bump seems to fix the issue as per
kubernetes-sigs/kustomize#3618
ivyostosh added a commit to ivyostosh/eks-anywhere-packages that referenced this issue Apr 27, 2022
Command 'go get' can no longer be used to build packages starting Go v1.18 (https://go.dev/doc/go-get-install-deprecation). Kustomize version also needs to be updated to v4.5 since go install doesn't support exclude directives (kubernetes-sigs/kustomize#3618). The change has been tested on both Go v1.17 and Go v1.18 to ensure the Makefile works properly.
eks-distro-bot pushed a commit to aws/eks-anywhere-packages that referenced this issue Apr 27, 2022
Command 'go get' can no longer be used to build packages starting Go v1.18 (https://go.dev/doc/go-get-install-deprecation). Kustomize version also needs to be updated to v4.5 since go install doesn't support exclude directives (kubernetes-sigs/kustomize#3618). The change has been tested on both Go v1.17 and Go v1.18 to ensure the Makefile works properly.
mbaldessari added a commit to mbaldessari/patterns-operator that referenced this issue Jul 5, 2022
The 3.8.x version constantly errors with go modules:
go install sigs.k8s.io/kustomize/kustomize/v3@v3.8.7: sigs.k8s.io/kustomize/kustomize/v3@v3.8.7
        The go.mod file for the module providing named packages contains one or
        more exclude directives. It must not contain directives that would cause
        it to be interpreted differently than if it were the main module.

See kubernetes-sigs/kustomize#3618

This is fixed in kubernetes-sigs/kustomize#4387
and kustomize v4.5.2

In the future, once we will switch to operator-sdk 1.22 there will be a
separate script to install kustomize:
https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh
mbaldessari added a commit to mbaldessari/patterns-operator that referenced this issue Jul 5, 2022
The 3.8.x version constantly errors with go modules:
go install sigs.k8s.io/kustomize/kustomize/v3@v3.8.7: sigs.k8s.io/kustomize/kustomize/v3@v3.8.7
        The go.mod file for the module providing named packages contains one or
        more exclude directives. It must not contain directives that would cause
        it to be interpreted differently than if it were the main module.

See kubernetes-sigs/kustomize#3618

This is fixed in kubernetes-sigs/kustomize#4387
and kustomize v4.5.2

In the future, once we will switch to operator-sdk 1.22 there will be a
separate script to install kustomize:
https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh
stleerh added a commit to stleerh/network-observability-operator that referenced this issue Aug 3, 2022
Use 'go install' to install the executable.  Note that it still calls
'go get' to update dependencies in go.mod.  This stopped working in
go1.18 because of https://go.dev/doc/go-get-install-deprecation.

In making this change, kustomize broke and no longer installed.  The problem
is documented in kubernetes-sigs/kustomize#3618.
The solution is to use at least v4.5.2.  kustomize was upgraded to 4.5.7
from 3.8.8 and everything still worked.
openshift-ci bot pushed a commit to netobserv/network-observability-operator that referenced this issue Aug 5, 2022
* NETOBSERV-505 NOO fails to build with go1.18 and above

Use 'go install' to install the executable.  Note that it still calls
'go get' to update dependencies in go.mod.  This stopped working in
go1.18 because of https://go.dev/doc/go-get-install-deprecation.

In making this change, kustomize broke and no longer installed.  The problem
is documented in kubernetes-sigs/kustomize#3618.
The solution is to use at least v4.5.2.  kustomize was upgraded to 4.5.7
from 3.8.8 and everything still worked.

* Set GOFLAGS to ignore vendor directory.

There is also no need to update dependencies since it is installing a
specific version of an executable.
eranco74 added a commit to eranco74/cluster-api-provider-agent that referenced this issue Sep 19, 2022
eranco74 added a commit to eranco74/cluster-api-provider-agent that referenced this issue Sep 19, 2022
eranco74 added a commit to eranco74/cluster-api-provider-agent that referenced this issue Sep 19, 2022
eranco74 added a commit to eranco74/cluster-api-provider-agent that referenced this issue Sep 19, 2022
eranco74 added a commit to eranco74/cluster-api-provider-agent that referenced this issue Sep 19, 2022
openshift-merge-robot pushed a commit to openshift/cluster-api-provider-agent that referenced this issue Sep 19, 2022
* go 1.17 has deprecated installing executables with `go get`
Use go install instead
Set GOFLAGS to empty string to overcome the `cannot query module due to
-mod=vendor` error we get in presubmit job

* Updated kustomize version to a version that support go install
See kubernetes-sigs/kustomize#3618

* Install golangci-lint from source
See golangci/golangci-lint#2374

* Fix lint issue
See golangci/golangci-lint#2601

* Refactor - don't pass around origRes and origErr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

9 participants