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

refactor: migrate to viper configure manage #1946

Merged
merged 3 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
)

var (
configFile string
forceStart bool
)

Expand All @@ -52,7 +51,7 @@ func init() {
}
})

rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "./conf/conf.yml", "config file")
rootCmd.PersistentFlags().StringVarP(&conf.ConfigFile, "config", "c", "", "config file")
rootCmd.PersistentFlags().StringVarP(&conf.WorkDir, "work-dir", "p", ".", "current work directory")
rootCmd.PersistentFlags().BoolVarP(&forceStart, "force", "f", false, "force start manager-api")

Expand Down
10 changes: 2 additions & 8 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ replace github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.5
require (
github.com/coreos/bbolt v1.3.2 // indirect
github.com/coreos/etcd v3.3.25+incompatible // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
Expand All @@ -19,32 +18,27 @@ require (
github.com/gin-contrib/pprof v1.3.0
github.com/gin-contrib/static v0.0.0-20200916080430-d45d9a37d28e
github.com/gin-gonic/gin v1.6.3
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/prometheus/client_golang v1.8.0 // indirect
github.com/satori/go.uuid v1.2.0
github.com/shiningrush/droplet v0.2.6-0.20210127040147-53817015cd1b
github.com/shiningrush/droplet/wrapper/gin v0.2.1
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/sony/sonyflake v1.0.0
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.8.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember that the license of a dependency of viper was not compatible with Apache 2.0, please confirm.

Copy link
Contributor Author

@bzp2010 bzp2010 Jul 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @nic-chen. I'm sorry for the slow response.

I used google/go-licenses to generate a list of the spf13/viper's dependencies and licenses.

library URL license
github.com/mitchellh/mapstructure https://github.com/mitchellh/mapstructure/blob/master/LICENSE MIT
github.com/magiconair/properties https://github.com/magiconair/properties/blob/master/LICENSE.md BSD-2-Clause
github.com/spf13/afero https://github.com/spf13/afero/blob/master/LICENSE.txt Apache-2.0
github.com/spf13/pflag https://github.com/spf13/pflag/blob/master/LICENSE BSD-3-Clause
github.com/hashicorp/hcl https://github.com/hashicorp/hcl/blob/master/LICENSE MPL-2.0
github.com/pelletier/go-toml https://github.com/pelletier/go-toml/blob/master/LICENSE Apache-2.0
github.com/spf13/viper https://github.com/spf13/viper/blob/master/LICENSE MIT
github.com/spf13/cast https://github.com/spf13/cast/blob/master/LICENSE MIT
github.com/spf13/jwalterweatherman https://github.com/spf13/jwalterweatherman/blob/master/LICENSE MIT
github.com/subosito/gotenv https://github.com/subosito/gotenv/blob/master/LICENSE MIT
github.com/fsnotify/fsnotify https://github.com/fsnotify/fsnotify/blob/master/LICENSE BSD-3-Clause
gopkg.in/yaml.v2 https://github.com/go-yaml/yaml Apahce-2.0
golang.org/x/text https://golang.org/x/text BSD-3-Clause
gopkg.in/ini.v1 https://gopkg.in/ini.v1 Apache-2.0

Include Apache-2.0, MIT, MPL-2.0, BSD-2-Clause and BSD-3-Clause.

And these licenses are also used in current Manager API dependencies.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about MPL-2.0, @moonming please have a look, thanks.

Copy link
Contributor Author

@bzp2010 bzp2010 Jul 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description

Viper library uses the API of hashicorp/hcl open source repository using MPL-2.0 license, but does not use its code directly.

Solution

If importing a library using MPL-2.0 license is not feasible, I will consider implementing a shim code and replacing it with go mod replace. It emulates the API of that library and provides empty results.

It's like the following image.
image

So is such a solution feasible?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I searched the go project under apache, and many projects also use viper
for example:

https://github.com/apache/skywalking-banyandb

https://github.com/apache/camel-k

I have no problem here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MPL-2.0 maybe can NOT in apache projects: https://www.apache.org/legal/resolved.html

Copy link
Contributor Author

@bzp2010 bzp2010 Jul 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @moonming. Sorry to bother you again.

🤔 What do you think of this? Thx.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @moonming Any changes here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a dependency with a Category B license is fine

github.com/stretchr/testify v1.7.0
github.com/takama/daemon v1.0.0
github.com/tidwall/gjson v1.6.7
github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966 // indirect
github.com/xeipuuv/gojsonschema v1.2.0
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
go.etcd.io/etcd v3.3.25+incompatible
go.uber.org/zap v1.16.0
go.uber.org/zap v1.17.0
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
gopkg.in/yaml.v2 v2.4.0
sigs.k8s.io/yaml v1.2.0 // indirect
)
Loading