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

[QUESTION] Failed to resolve dependencies in GoLand #2005

Open
1 task done
EricGao888 opened this issue Apr 26, 2024 · 3 comments
Open
1 task done

[QUESTION] Failed to resolve dependencies in GoLand #2005

EricGao888 opened this issue Apr 26, 2024 · 3 comments
Labels
question Further information is requested

Comments

@EricGao888
Copy link

  • ✋ I have searched the open/closed issues and my issue is not listed.

Please describe your question here

I opened the project with GoLand, and got some errors like

go: k8s.io/controller-manager@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/dynamic-resource-allocation@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/endpointslice@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/mount-utils@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/pod-security-admission@v0.0.0: invalid version: unknown revision v0.0.0

After I commented out k8s.io/kubernetes v1.29.3 in go.mod, errors disappeared and all dependencies got resolved. Not sure whether it is a bug or I missed something.

Any help will be appreciated.

Provide a link to the example/module related to the question

k8s.io/kubernetes v1.29.3

Additional context

I found some issues might be related to this one:

#1197

kubernetes/kubernetes#79384

@EricGao888 EricGao888 added the question Further information is requested label Apr 26, 2024
@Wangdaoshuai
Copy link

I recently encountered the same problem, and I solved it in the following way.
Create script get.sh in the go.mod directory.
Then execute bash get.sh v1.20.4 (here select the k8s version you need to use)

#!/bin/sh
set -euo pipefail

VERSION=${1#"v"}
if [ -z "$VERSION" ]; then
    echo "Must specify version!"
    exit 1
fi
MODS=($(
    curl -sS https://raw.githubusercontent.com/kubernetes/kubernetes/v${VERSION}/go.mod |
    sed -n 's|.*k8s.io/\(.*\) => ./staging/src/k8s.io/.*|k8s.io/\1|p'
))
for MOD in "${MODS[@]}"; do
    V=$(
        go mod download -json "${MOD}@kubernetes-${VERSION}" |
        sed -n 's|.*"Version": "\(.*\)".*|\1|p'
    )
    go mod edit "-replace=${MOD}=${MOD}@${V}"
done
go get "k8s.io/kubernetes@v${VERSION}"

@EricGao888
Copy link
Author

I recently encountered the same problem, and I solved it in the following way. Create script get.sh in the go.mod directory. Then execute bash get.sh v1.20.4 (here select the k8s version you need to use)

#!/bin/sh
set -euo pipefail

VERSION=${1#"v"}
if [ -z "$VERSION" ]; then
    echo "Must specify version!"
    exit 1
fi
MODS=($(
    curl -sS https://raw.githubusercontent.com/kubernetes/kubernetes/v${VERSION}/go.mod |
    sed -n 's|.*k8s.io/\(.*\) => ./staging/src/k8s.io/.*|k8s.io/\1|p'
))
for MOD in "${MODS[@]}"; do
    V=$(
        go mod download -json "${MOD}@kubernetes-${VERSION}" |
        sed -n 's|.*"Version": "\(.*\)".*|\1|p'
    )
    go mod edit "-replace=${MOD}=${MOD}@${V}"
done
go get "k8s.io/kubernetes@v${VERSION}"

@Wangdaoshuai Thanks, I will give a try later.

@iheme
Copy link

iheme commented May 15, 2024

please add replace in go.mod

replace (
k8s.io/dynamic-resource-allocation => k8s.io/dynamic-resource-allocation v0.29.3
k8s.io/endpointslice => k8s.io/endpointslice v0.29.3
k8s.io/mount-utils => k8s.io/mount-utils v0.29.3
k8s.io/controller-manager => k8s.io/controller-manager v0.29.3
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.29.3
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants