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

go mod fails #113

Closed
larytet opened this issue Mar 18, 2021 · 1 comment
Closed

go mod fails #113

larytet opened this issue Mar 18, 2021 · 1 comment

Comments

@larytet
Copy link

larytet commented Mar 18, 2021

Hi, I am trying to build the example file https://github.com/spotahome/kooper/blob/master/examples/config-custom-controller/main.go
My Dockerfile is

FROM golang:1.15

RUN mkdir /build 
WORKDIR /build
COPY *.go ./
COPY go.mod ./

RUN go mod download
RUN cat go.mod
RUN GOOS=linux CGO_ENABLED=1 GOARCH=amd64 go build -a -o /build ./
# RUN go test -v -failfast ./...

I can not resolve the packages

/go/pkg/mod/k8s.io/client-go@v0.17.4/discovery/discovery_client.go:29:2: module github.com/googleapis/gnostic@latest found (v0.5.4), but does not contain package github.com/googleapis/gnostic/OpenAPIv2
/go/pkg/mod/k8s.io/kube-openapi@v0.0.0-20201113171705-d219536bb9fd/pkg/util/proto/document.go:24:2: case-insensitive import collision: "github.com/googleapis/gnostic/openapiv2" and "github.com/googleapis/gnostic/OpenAPIv2"
/go/pkg/mod/k8s.io/client-go@v0.17.4/kubernetes/scheme/register.go:27:2: module k8s.io/api@latest found (v0.20.4), but does not contain package k8s.io/api/auditregistration/v1alpha1
/go/pkg/mod/k8s.io/client-go@v0.17.4/kubernetes/scheme/register.go:58:2: module k8s.io/api@latest found (v0.20.4), but does not contain package k8s.io/api/settings/v1alpha1

What am I doing wrong?
Thanks

@larytet
Copy link
Author

larytet commented Mar 18, 2021

I found this kubernetes/client-go#741
k8s.io/api v0.19.0 solved the problem
Now the build https://github.com/spotahome/kooper/blob/master/examples/config-custom-controller/main.go of fails

	have ("k8s.io/apimachinery/pkg/apis/meta/v1".ListOptions)
	want (context.Context, "k8s.io/apimachinery/pkg/apis/meta/v1".ListOptions)
./ingress-controller.go:53:41: not enough arguments in call to k8scli.CoreV1().Pods("").Watch
	have ("k8s.io/apimachinery/pkg/apis/meta/v1".ListOptions)
	want (context.Context, "k8s.io/apimachinery/pkg/apis/meta/v1".ListOptions)

Is it Ok to do

diff --git a/ingress-controller.go b/ingress-controller.go
index 861ee60..d62b61b 100644
--- a/ingress-controller.go
+++ b/ingress-controller.go
@@ -25,6 +25,7 @@ import (
 )
 
 func run() error {
+       ctx := context.Background()
        // Initialize logger.
        logger := kooperlogrus.New(logrus.NewEntry(logrus.New())).
                WithKV(log.KV{"example": "config-custom-controller"})
@@ -47,10 +48,10 @@ func run() error {
        // Create our retriever so the controller knows how to get/listen for pod events.
        retr := controller.MustRetrieverFromListerWatcher(&cache.ListWatch{
                ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
-                       return k8scli.CoreV1().Pods("").List(options)
+                       return k8scli.CoreV1().Pods("").List(ctx, options)
                },
                WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
-                       return k8scli.CoreV1().Pods("").Watch(options)
+                       return k8scli.CoreV1().Pods("").Watch(ctx, options)
                },
        })

@larytet larytet closed this as completed Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant