Closed miguelsorianod closed 5 years ago
I add more information. The Gopkt.toml file we have for an empty 0.3.0 project is what it is automatically generated plus the github.com/operator-framework/operator-sdk/commands/operator-sdk
that we manually add. We execute dep ensure -v
(removing before the 'vendor' directory just in case) after the change.
The content of this Gopkt.toml is:
soriano@localhost:~/go/src/github.com/3scale/testproject (master)$ cat Gopkg.toml
# Force dep to vendor the code generators, which aren't imported just used at dev time.
required = [
"k8s.io/code-generator/cmd/defaulter-gen",
"k8s.io/code-generator/cmd/deepcopy-gen",
"k8s.io/code-generator/cmd/conversion-gen",
"k8s.io/code-generator/cmd/client-gen",
"k8s.io/code-generator/cmd/lister-gen",
"k8s.io/code-generator/cmd/informer-gen",
"k8s.io/code-generator/cmd/openapi-gen",
"k8s.io/gengo/args",
"github.com/operator-framework/operator-sdk/commands/operator-sdk",
]
[[override]]
name = "k8s.io/code-generator"
# revision for tag "kubernetes-1.12.3"
revision = "3dcf91f64f638563e5106f21f50c31fa361c918d"
[[override]]
name = "k8s.io/api"
# revision for tag "kubernetes-1.12.3"
revision = "b503174bad5991eb66f18247f52e41c3258f6348"
[[override]]
name = "k8s.io/apiextensions-apiserver"
# revision for tag "kubernetes-1.12.3"
revision = "0cd23ebeb6882bd1cdc2cb15fc7b2d72e8a86a5b"
[[override]]
name = "k8s.io/apimachinery"
# revision for tag "kubernetes-1.12.3"
revision = "eddba98df674a16931d2d4ba75edc3a389bf633a"
[[override]]
name = "k8s.io/client-go"
# revision for tag "kubernetes-1.12.3"
revision = "d082d5923d3cc0bfbb066ee5fbdea3d0ca79acf8"
[[override]]
name = "sigs.k8s.io/controller-runtime"
version = "=v0.1.8"
[[constraint]]
name = "github.com/operator-framework/operator-sdk"
# The version rule is used for a specific release and the master branch for in between releases.
# branch = "master" #osdk_branch_annotation
version = "=v0.3.0" #osdk_version_annotation
[prune]
go-tests = true
non-go = true
[[prune.project]]
name = "k8s.io/code-generator"
non-go = false
Hello @miguelsorianod, have you done all of these with the following command:
go run ./vendor/github.com/operator-framework/operator-sdk/commands/operator-sdk build myoperator:latest
Since you already have installed operator-sdk
and it's in your path juding by the version output that one should work fine. I tested it locally and it works for me when calling the following command operator-sdk build myoperator:latest
. Let me know if that still doesn't work for you, thanks!
Hello @LiliC,
The locally installed operator-sdk build
works correctly in my local machine.
The motivation on executing the operator-sdk command from the vendored location (go run ./vendor/github.com/operator-framework/operator-sdk/commands/operator-sdk build myoperator:latest
) however is because we execute it from a CI environment where we do not have the operator-sdk locally installed but in the vendor directory (with dep).
@LiliC yes, because we have several projects that are using several operator-sdk versions. We would like to enforce that every project is using version it is locked to.
We prefer not to duplicate dependency locking. Installing a release would require us to download operator-sdk into every project and keep it in sync with the locked version.
@mikz @miguelsorianod The reason you're getting errors is that operator-sdk has declared dependencies in its Gopkg.toml that are not in your Gopkg.toml. You'll need to pull those into your Gopkg.toml to get things working.
Also, note that running the main.go file out of the vendor directory is not the same as running the published release because the go build environment in CI and your project dependencies may cause the compiled binary to differ. For that reason, this is not something we'd suggest or support.
However, if you must, I was able to get the operator-sdk build
command to work by adding the below additions in the operator's Gopkg.toml:
[[override]]
name = "k8s.io/kubernetes"
version = "=1.12.3"
[[override]]
name = "k8s.io/apiserver"
version = "kubernetes-1.12.3"
[[override]]
name = "k8s.io/cli-runtime"
version = "kubernetes-1.12.3"
[[override]]
name = "github.com/sergi/go-diff"
version = "1.0.0"
[[override]]
name = "k8s.io/helm"
version = "=v2.12.0"
[[override]]
name = "github.com/sirupsen/logrus"
version = "1.0.4"
[[override]]
name = "github.com/spf13/cobra"
version = "0.0.3"
[[override]]
name = "github.com/russross/blackfriday"
revision = "300106c228d52c8941d4b3de6054a6062a86dda3"
[[override]]
name = "github.com/docker/distribution"
revision = "edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c"
[[override]]
name = "github.com/docker/docker"
revision = "a9fbbdc8dd8794b20af358382ab780559bca589d"
@miguelsorianod It looks like you were able to resolve your issues? Can this issue be closed as well?
Closing, if @miguelsorianod you still have a problem with this, feel free to reopen or open a new issue.
Hi,
We have our operator-sdk application with the 0.3.0 version and it seems we cannot correctly execute the command
operator-sdk build
command when having it vendored in the project. We do that as part of our CI process.To reproduce the problem we:
github.com/operator-framework/operator-sdk/commands/operator-sdk
package as a required package in the Gopkg.toml of the projectgo run ./vendor/github.com/operator-framework/operator-sdk/commands/operator-sdk build myoperator:latest
When executing the previous command the output we obtain is:
Thank you.