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

Cobra pull a lot of dependencies through viper #1138

Closed
MichaelMure opened this issue Jun 15, 2020 · 4 comments · Fixed by #1139
Closed

Cobra pull a lot of dependencies through viper #1138

MichaelMure opened this issue Jun 15, 2020 · 4 comments · Fixed by #1139

Comments

@MichaelMure
Copy link
Contributor

When using Cobra in a project, a lot of dependencies are added that are not actually useful for that project. Those comes through viper, which is used in cobra/cmd, that is a CLI tool only useful occasionally for the developer.

github.com/spf13/viper@v1.4.0 github.com/armon/consul-api@v0.0.0-20180202201655-eb2c6b5be1b6
github.com/spf13/viper@v1.4.0 github.com/coreos/bbolt@v1.3.2
github.com/spf13/viper@v1.4.0 github.com/coreos/etcd@v3.3.10+incompatible
github.com/spf13/viper@v1.4.0 github.com/coreos/go-semver@v0.2.0
github.com/spf13/viper@v1.4.0 github.com/coreos/go-systemd@v0.0.0-20190321100706-95778dfbb74e
github.com/spf13/viper@v1.4.0 github.com/coreos/pkg@v0.0.0-20180928190104-399ea9e2e55f
github.com/spf13/viper@v1.4.0 github.com/dgrijalva/jwt-go@v3.2.0+incompatible
github.com/spf13/viper@v1.4.0 github.com/fsnotify/fsnotify@v1.4.7
github.com/spf13/viper@v1.4.0 github.com/gogo/protobuf@v1.2.1
github.com/spf13/viper@v1.4.0 github.com/golang/groupcache@v0.0.0-20190129154638-5b532d6fd5ef
github.com/spf13/viper@v1.4.0 github.com/google/btree@v1.0.0
github.com/spf13/viper@v1.4.0 github.com/gorilla/websocket@v1.4.0
github.com/spf13/viper@v1.4.0 github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0
github.com/spf13/viper@v1.4.0 github.com/grpc-ecosystem/go-grpc-prometheus@v1.2.0
github.com/spf13/viper@v1.4.0 github.com/grpc-ecosystem/grpc-gateway@v1.9.0
github.com/spf13/viper@v1.4.0 github.com/hashicorp/hcl@v1.0.0
github.com/spf13/viper@v1.4.0 github.com/jonboulle/clockwork@v0.1.0
github.com/spf13/viper@v1.4.0 github.com/magiconair/properties@v1.8.0
github.com/spf13/viper@v1.4.0 github.com/mitchellh/mapstructure@v1.1.2
github.com/spf13/viper@v1.4.0 github.com/pelletier/go-toml@v1.2.0
github.com/spf13/viper@v1.4.0 github.com/prometheus/client_golang@v0.9.3
github.com/spf13/viper@v1.4.0 github.com/soheilhy/cmux@v0.1.4
github.com/spf13/viper@v1.4.0 github.com/spf13/afero@v1.1.2
github.com/spf13/viper@v1.4.0 github.com/spf13/cast@v1.3.0
github.com/spf13/viper@v1.4.0 github.com/spf13/jwalterweatherman@v1.0.0
github.com/spf13/viper@v1.4.0 github.com/spf13/pflag@v1.0.3
github.com/spf13/viper@v1.4.0 github.com/stretchr/testify@v1.2.2
github.com/spf13/viper@v1.4.0 github.com/tmc/grpc-websocket-proxy@v0.0.0-20190109142713-0ad062ec5ee5
github.com/spf13/viper@v1.4.0 github.com/ugorji/go@v1.1.4
github.com/spf13/viper@v1.4.0 github.com/xiang90/probing@v0.0.0-20190116061207-43a291ad63a2
github.com/spf13/viper@v1.4.0 github.com/xordataexchange/crypt@v0.0.3-0.20170626215501-b2862e3d0a77
github.com/spf13/viper@v1.4.0 go.etcd.io/bbolt@v1.3.2
github.com/spf13/viper@v1.4.0 go.uber.org/atomic@v1.4.0
github.com/spf13/viper@v1.4.0 go.uber.org/multierr@v1.1.0
github.com/spf13/viper@v1.4.0 go.uber.org/zap@v1.10.0
github.com/spf13/viper@v1.4.0 golang.org/x/net@v0.0.0-20190522155817-f3200d17e092
github.com/spf13/viper@v1.4.0 golang.org/x/time@v0.0.0-20190308202827-9d24e82272b4
github.com/spf13/viper@v1.4.0 google.golang.org/grpc@v1.21.0
github.com/spf13/viper@v1.4.0 gopkg.in/yaml.v2@v2.2.2

Those are quite heavy dependencies: Etcd, systemd, protobuf, prometheus, websocket, GRPC ...

Could you add a secondary go.mod file in the /cobra folder ? This would segregate those deps into the CLI tool and avoid having all that in a project using Cobra without Viper.

@MichaelMure
Copy link
Contributor Author

I went ahead and did that: #1139

It reduced the dependency count in my project from 313 to 148.

@github-actions
Copy link

This issue is being marked as stale due to a long period of inactivity

@MichaelMure
Copy link
Contributor Author

Can someone merge #1139 ?

@liggitt
Copy link
Contributor

liggitt commented Feb 8, 2022

I opened #1597 as a proposal for splitting the modules again in a way that avoids the problems of #1139

jen20 added a commit to jen20/pulumi that referenced this issue Mar 27, 2022
This commit upgrades the usage of Cobra to [v1.4.0][1], which reduces
the dependency set by removing the dependency on Viper. The upgrade
happens across both `sdk` and `pkg`.

Full details on the upgrades upstream in Cobra are available via the
release notes, but [2] contains further motivating examples of reduced
dependencies via separation of the (rarely used) Cobra bootstrapping CLI
and the library itself.

[1]: https://github.com/spf13/cobra/releases/tag/v1.4.0

[2]: spf13/cobra#1138
Frassle added a commit to pulumi/pulumi that referenced this issue Mar 28, 2022
* deps: Upgrade to Cobra v1.4.0

This commit upgrades the usage of Cobra to [v1.4.0][1], which reduces
the dependency set by removing the dependency on Viper. The upgrade
happens across both `sdk` and `pkg`.

Full details on the upgrades upstream in Cobra are available via the
release notes, but [2] contains further motivating examples of reduced
dependencies via separation of the (rarely used) Cobra bootstrapping CLI
and the library itself.

[1]: https://github.com/spf13/cobra/releases/tag/v1.4.0

[2]: spf13/cobra#1138

* Update tests/go.mod

Co-authored-by: Fraser Waters <fraser@pulumi.com>
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

Successfully merging a pull request may close this issue.

2 participants