Skip to content

Instantly share code, notes, and snippets.

@bentito
Last active March 31, 2020 21:21
Show Gist options
  • Save bentito/b1e48b76d12fc707eccccbf58e2229db to your computer and use it in GitHub Desktop.
Save bentito/b1e48b76d12fc707eccccbf58e2229db to your computer and use it in GitHub Desktop.
operator-metering go mod init work
Started with this:
[operator-metering] (master)$ pwd
/Users/btofel/workspace/operator-metering
[operator-metering] (master)$ echo $GOPATH
/tmp
[operator-metering] (master)$ go mod init github.com/operator-framework/operator-metering
go: creating new go.mod: module github.com/operator-framework/operator-metering
go: copying requirements from Gopkg.lock
go: parsing /Users/btofel/workspace/operator-metering/Gopkg.lock: /Users/btofel/workspace/operator-metering/Gopkg.lock: empty [[projects]] stanza (github.com/operator-framework/operator-lifecycle-manager)
@bentito
Copy link
Author

bentito commented Mar 19, 2020

so then that immediately runs into:

[operator-metering] (master)$ rm -rf vendor
[operator-metering] (master)$ make unit
hack/unit.sh
pkg/apis/metering/v1/hive_table.go:6:2: cannot find package "github.com/operator-framework/operator-metering/pkg/hive" in any of:
	/usr/local/go/src/github.com/operator-framework/operator-metering/pkg/hive (from $GOROOT)
	/tmp/src/github.com/operator-framework/operator-metering/pkg/hive (from $GOPATH)
...

@bentito
Copy link
Author

bentito commented Mar 19, 2020

And actually I think that: Gopkg.lock: empty is a quiet fail, as go.mod is never created.

@bentito
Copy link
Author

bentito commented Mar 19, 2020

not sure how valid, but to proceed I'm trying:

[workspace]$ rm -rf operator-metering/
[workspace]$ git clone https://github.com/operator-framework/operator-metering.git
[workspace]$ cd operator-metering/
[operator-metering] (master)$ rm Gopkg.*
[operator-metering] (master)$ go mod init operator-metering.com/operator-metering
go: creating new go.mod: module operator-metering.com/operator-metering
[operator-metering] (master)$ cat go.mod
module operator-metering.com/operator-metering

go 1.12
[operator-metering] (master)$ go build ./...

[lot's of package downloading...]

@bentito
Copy link
Author

bentito commented Mar 19, 2020

ah and eventually a fail on:

build operator-metering.com/operator-metering/cmd/deploy-metering: cannot load github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1: cannot find module providing package github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1

@bentito
Copy link
Author

bentito commented Mar 19, 2020

so.. what's the right way to fix that?...

@bentito
Copy link
Author

bentito commented Mar 31, 2020

make unit broken at commit
broken: c8efade1

Stopped working locally when I committed those couple clientset related generated files from the docker image
and the CI make unit check failed after that. okay.

So working from this point where make unit isn't working due to the addition of these generated files:

operator-metering/pkg/generated/clientset/versioned
>fake
>>clientset_generated.go
>typed/metering/v1
>>metering_client.go
>>clientset.go```

@bentito
Copy link
Author

bentito commented Mar 31, 2020

try upgrade go get -u -d github.com/operator-framework/operator-lifecycle-manager@master this makes a bunch of go.mod changes...
go mod tidy fails on Azure ambiguous imports (3)

@bentito
Copy link
Author

bentito commented Mar 31, 2020

fix with: go get -u github.com/Azure/go-autorest@latest

@bentito
Copy link
Author

bentito commented Mar 31, 2020

go mod tidy now works once, but not twice. wtf?

@bentito
Copy link
Author

bentito commented Mar 31, 2020

retried the olm go get:
go get -u -d github.com/operator-framework/operator-lifecycle-manager@0.12.0 <- least compatible tag

@bentito
Copy link
Author

bentito commented Mar 31, 2020

go mod tidy runs twice without fail. Duh!
go mod vendor run and changes many things in vendor/ as expected

@bentito
Copy link
Author

bentito commented Mar 31, 2020

run hack/update-codegen.sh
run:

[operator-metering] (go_mod)$ go build ./...
# github.com/operator-framework/operator-metering/pkg/generated/clientset/versioned/typed/metering/v1
pkg/generated/clientset/versioned/typed/metering/v1/metering_client.go:87:45: scheme.Codecs.WithoutConversion undefined (type serializer.CodecFactory has no field or method WithoutConversion)```

@bentito
Copy link
Author

bentito commented Mar 31, 2020

[operator-metering] (go_mod)$ git diff go.mod
diff --git a/go.mod b/go.mod
index d4386dc0..11f180cb 100644
--- a/go.mod
+++ b/go.mod
@@ -11,10 +11,16 @@ require (
        github.com/aws/aws-sdk-go v1.25.18
        github.com/beorn7/perks v1.0.1 // indirect
        github.com/davecgh/go-spew v1.1.1
+       github.com/emicklei/go-restful v2.12.0+incompatible // indirect
        github.com/go-chi/chi v3.3.2+incompatible
-       github.com/golang/mock v1.3.1
+       github.com/go-openapi/spec v0.19.7 // indirect
+       github.com/go-openapi/swag v0.19.8 // indirect
+       github.com/golang/mock v1.4.3
        github.com/gophercloud/gophercloud v0.3.0 // indirect
        github.com/huandu/xstrings v1.3.0 // indirect
+       github.com/json-iterator/go v1.1.9 // indirect
+       github.com/mailru/easyjson v0.7.1 // indirect
+       github.com/onsi/gomega v1.9.0 // indirect
        github.com/openshift/client-go v0.0.0-20190923180330-3b6373338c9b
        // olm 0.12.0
        github.com/operator-framework/operator-lifecycle-manager v0.0.0-20190926160646-a61144936680
@@ -27,12 +33,16 @@ require (
        github.com/spf13/pflag v1.0.5
        github.com/stretchr/testify v1.4.0
        github.com/taozle/go-hive-driver v0.0.0-20181206100408-79951111cb07
-       golang.org/x/sync v0.0.0-20190423024810-112230192c58
+       golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
+       golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
+       golang.org/x/tools v0.0.0-20200331202046-9d5940d49312 // indirect
        k8s.io/api v0.17.1
        k8s.io/apiextensions-apiserver v0.17.1
        k8s.io/apimachinery v0.17.1
        k8s.io/client-go v8.0.0+incompatible
-       k8s.io/code-generator v0.0.0-20190912054826-cd179ad6a269
+       k8s.io/code-generator v0.18.0
+       k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12 // indirect
+       k8s.io/kube-openapi v0.0.0-20200204173128-addea2498afe // indirect
 )

 replace (

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment