[AIA-126] Refactor chef-load to have sub-commands#20
Conversation
TODO: -handle viper config -utilize flags -random data command?
This commit is refactoring a bunch of files, it is creating two main directories, `commands/` and `lib/`. The `commands/` directory will host all the commands that chef-load will provide. The `lib/` directory is meant to be the libraries that chef-load will use to do specific tasks like generate nodes and start the continuous load of nodes, actions, reports, etc. The `lib/` directory will be able to be imported as an external library to provide load functionality to other go applications. Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
…e/AIA-126/Sub-Commands
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
008f4cd to
ab2379d
Compare
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
commands/root.go
Outdated
| func init() { | ||
| cobra.OnInitialize(initConfig) | ||
| rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.chef-load.toml)") | ||
| // TODO: Should we add data_collector_url and chef_server_url to run the tool without the config? |
There was a problem hiding this comment.
It would be nice to add the 'data_collector_url' and 'chef_server_url' to the command line also.
| ckbk.Files, | ||
| ckbk.Libraries, | ||
| ckbk.Recipes, | ||
| ckbk.Providers, |
lib/generator.go
Outdated
| func generateRandomData(chefClient chef.Client, requests amountOfRequests) (err error) { | ||
| channels := make([]<-chan error, config.NumNodes) | ||
| func GenerateData(config *Config) error { | ||
| var amountOfRequests = make(amountOfRequests) |
There was a problem hiding this comment.
This is a little confusing having the type amountOfRequests and the variable amountOfRequests have the same name.
|
|
||
| for { | ||
| select { | ||
| case req := <-requests: |
There was a problem hiding this comment.
Are there two goroutine listening to the requests channel here? I see the other at generator.go. Could that be a problem?
There was a problem hiding this comment.
No, but I can clean it. They are called by separate commands. 🤔 I wonder if that could be done in next PR?
There was a problem hiding this comment.
This might be a hard thing but I feel weird not doing it, I guess.
lancewf
left a comment
There was a problem hiding this comment.
Nice Clean up. I have a few questions inline.
rmoshier
left a comment
There was a problem hiding this comment.
I suggest we update the README now that we have new subcommands.
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
31f8756 to
6e91c88
Compare
|
Lastly, I'll modify the README as per @rmoshier comment. Maybe tomorrow morning it is 15 pass 7pm here. 😭 |
Signed-off-by: Salim Afiune <afiune@chef.io>
cb8167f to
c05e86f
Compare
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
c05e86f to
7d79a67
Compare
|
Hab package uploaded to: |


This PR is refactoring a bunch of files, it is creating two main
directories,
commands/andlib/.The
commands/directory will host all the commands that chef-loadwill provide.
The
lib/directory is meant to be the libraries that chef-load willuse to do specific tasks like generate nodes and start the continuous
load of nodes, actions, reports, etc.
The
lib/directory will be able to be imported as an external libraryto provide load functionality to other go applications.