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
Config impl #567
Config impl #567
Conversation
2c87ec0
to
10f60ec
Compare
|
@eriknelson @jmrodri @rthallisey @djzager Some testing help would be nice, this touches so much stuff, that I will forget something during my testing. Things that I am most worried about
|
|
Changes Unknown when pulling 10f60ec on shawn-hurley:config-impl into ** on openshift:master**. |
|
Changes Unknown when pulling 3694e65 on shawn-hurley:config-impl into ** on openshift:master**. |
pkg/apb/svc_acct.go
Outdated
| @@ -124,7 +124,7 @@ func (s *ServiceAccountManager) CreateApbSandbox( | |||
|
|
|||
| func (s *ServiceAccountManager) createResources(rFilePath string, namespace string) error { | |||
| s.log.Debug("Creating resources from file at path: %s", rFilePath) | |||
| output, err := runtime.RunCommand("oc", "create", "-f", rFilePath) | |||
| output, err := runtime.RunCommand("oc", "create", "--namespace", namespace, "-f", rFilePath) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this namespace meant to be here or is it from another commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another commit, I can remove.
pkg/apb/svc_acct.go
Outdated
| @@ -221,7 +221,7 @@ func (s *ServiceAccountManager) createFile(handle string) (string, error) { | |||
| } | |||
|
|
|||
| // DestroyApbSandbox - Destroys the apb sandbox | |||
| func (s *ServiceAccountManager) DestroyApbSandbox(executionContext ExecutionContext, clusterConfig ClusterConfig) { | |||
| func (s *ServiceAccountManager) DestroyApbSandbox(executionContext ExecutionContext) { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the removal of the clusterConfig ClusterConfig parameters.
| CertFile: config.Broker.SSLCert, | ||
| KeyFile: config.Broker.SSLCertKey, | ||
| CertFile: config.GetString("broker.ssl_cert"), | ||
| KeyFile: config.GetString("broker.ssl_cert_key"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So config.Broker.SSLCert gave us the compile time benefit. But it was also the source of what made adding stuff to the config painful. I would have to go update the struct vs just adding values to the config. Most projects I've worked with I've used the GetString type methods.
| @@ -199,11 +201,11 @@ func CreateApp() App { | |||
| } | |||
|
|
|||
| app.log.Debug("Connecting Registry") | |||
| for _, r := range app.config.Registry { | |||
| reg, err := registries.NewRegistry(r, app.log.Logger) | |||
| for name := range app.config.GetSubConfig("registry").ToMap() { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GetSubConfig is also acceptable.
3694e65
to
da4aaaa
Compare
|
Changes Unknown when pulling f2ec97f on shawn-hurley:config-impl into ** on openshift:master**. |
|
Changes Unknown when pulling f2ec97f on shawn-hurley:config-impl into ** on openshift:master**. |
| WhiteList: con.GetSliceOfStrings("white_list"), | ||
| BlackList: con.GetSliceOfStrings("black_list"), | ||
| AuthType: con.GetString("auth_type"), | ||
| AuthName: con.GetString("auth_name"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the thing you mentioned to me where we can have the config struct which gives me compile time validation while using the config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONDACK pending answers to my questions.
pkg/apb/secrets.go
Outdated
| @@ -103,27 +104,29 @@ func match(spec *Spec, rule AssociationRule) bool { | |||
|
|
|||
| // InitializeSecretsCache - Generates AssociationRules from config and | |||
| // initializes the global secrets cache | |||
| func InitializeSecretsCache(config []SecretsConfig, log *logging.Logger) { | |||
| func InitializeSecretsCache(con *config.Config, log *logging.Logger) { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about conf instead of con
| var ( | ||
| log = logging.MustGetLogger("config") | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be an easier way to share the config data.
// pkg/config/broker.go
client.NewConfig(...)
// pkg/config/config.go
var configFile map[string]interface{}
func NewConfig(conf map[string]interface{}) error {
...
configFile = conf
return nil
}
func GetConfigValue(value string) (string, error) {
....
return configFile[value], nil
}Then every pkg can have access to the var through the GetConfigValue function. If there's nested config values we could also add a GetNestedConfigValue.
config.GetConfigValue(configValue)|
Changes Unknown when pulling 6540b2c on shawn-hurley:config-impl into ** on openshift:master**. |
6540b2c
to
81c30a6
Compare
|
Changes Unknown when pulling 81c30a6 on shawn-hurley:config-impl into ** on openshift:master**. |
81c30a6
to
af9d7e0
Compare
|
Changes Unknown when pulling af9d7e0 on shawn-hurley:config-impl into ** on openshift:master**. |
|
Changes Unknown when pulling 9bb233d on shawn-hurley:config-impl into ** on openshift:master**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONDACK
Few questions just curious about, otherwise I think this is a big improvement. Especially happy to get rid of config references in every fn sig 👍
One thought that comes to mind is that it will be very easy to fat finger a config value lookup string. It's maybe less of a problem with some types, but often we may take two very different behavioral branches depending on a config value. I can see us taking a falsy branch here unintentionally with just a debug log to indicate what actually happened.
Maybe we want to kick those up to warning level logs? Not sure I have a better option to offer here, but kind of curious what other people think.
Overall, nice job @shawn-hurley !
| } | ||
|
|
||
| err := broker.Login() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we able to get rid of all of this? Looking this over again, I'm not a fan of this being in a New* method, so I'm a proponent of pulling it out, but I want to make sure this isn't a regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are able to get rid of this because the initialization of the clients does the things that we need. I think this code has not been needed for a long time. I can add it back if people don't want it removed in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to add it back and remove in an explicit PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eriknelson I just realized while adding it back why I removed it. I removed the clusterConfig from the broker object causing this to be a problem where it is with this PR.
I did not add it back because this will just initialize the OC client, while everything should no longer be using the local oc client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been commenting this out locally for a few days now because it messes up the local k8s deployment. I don't think we need it anymore. Removing it will also be one less thing we need to add to the runtime pkg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also be removing the Config Values as well (Host and BearerTokenFile)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know of folks wanting to use their own bearer tokens instead of using auth that k8s provides? To me, I think it would be safe to remove it. We could always add it back in later if that is a valid use case.
| } | ||
|
|
||
| // GetEtcdVersion - Connects to ETCD cluster and retrieves server/version info | ||
| func GetEtcdVersion(ec EtcdConfig) (string, string, error) { | ||
| // The next etcd release (1.4) will have client.GetVersion() | ||
| // We'll use this to test our etcd connection for now | ||
| etcdURL := fmt.Sprintf("http://%s:%s/version", ec.EtcdHost, ec.EtcdPort) | ||
| etcdURL := fmt.Sprintf("http://%s:%v/version", ec.EtcdHost, ec.EtcdPort) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own edification, what's the purpose of this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EtcdPort was changed to an int, %s assumes a string, %v is just the value of the thing so works for everything. https://golang.org/pkg/fmt/ if you want to see all the options that fmt gives you.
9bb233d
to
8c27f14
Compare
|
Changes Unknown when pulling 8c27f14 on shawn-hurley:config-impl into ** on openshift:master**. |
|
Changes Unknown when pulling 31e9156 on shawn-hurley:config-impl into ** on openshift:master**. |
31e9156
to
08dc5a8
Compare
|
Changes Unknown when pulling 08dc5a8 on shawn-hurley:config-impl into ** on openshift:master**. |
* adding configuration package * changing everyting for configuration changes * fixing test handler. * rebase changes. * fixing tests * fixing variable name from review comments * fixing logging debug statements that were left over. * removing Host, CAFILE, and BearerToken as they are no longer used. * fixing rebase of app.go
Describe what this PR does and why we need it:
Implementation of the config proposal
Changes proposed in this pull request