Skip to content

[AIA-126] Refactor chef-load to have sub-commands#20

Merged
afiune merged 21 commits intomasterfrom
afiune/AIA-126/Sub-Commands
Mar 7, 2018
Merged

[AIA-126] Refactor chef-load to have sub-commands#20
afiune merged 21 commits intomasterfrom
afiune/AIA-126/Sub-Commands

Conversation

@afiune
Copy link
Copy Markdown

@afiune afiune commented Feb 28, 2018

This PR 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.

kmacgugan and others added 9 commits February 20, 2018 16:49
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>
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
@afiune afiune force-pushed the afiune/AIA-126/Sub-Commands branch from 008f4cd to ab2379d Compare March 5, 2018 17:39
Salim Afiune added 2 commits March 5, 2018 17:03
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
Salim Afiune added 2 commits March 5, 2018 17:06
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
@afiune afiune changed the title Refactor chef-load to have sub-commands [AIA-126] Refactor chef-load to have sub-commands Mar 5, 2018
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?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That was a nice clean up!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a little confusing having the type amountOfRequests and the variable amountOfRequests have the same name.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yeah agree


for {
select {
case req := <-requests:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are there two goroutine listening to the requests channel here? I see the other at generator.go. Could that be a problem?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No, but I can clean it. They are called by separate commands. 🤔 I wonder if that could be done in next PR?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This might be a hard thing but I feel weird not doing it, I guess.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done 6e91c88

Copy link
Copy Markdown
Contributor

@lancewf lancewf left a comment

Choose a reason for hiding this comment

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

Nice Clean up. I have a few questions inline.

Copy link
Copy Markdown
Contributor

@rmoshier rmoshier left a comment

Choose a reason for hiding this comment

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

I suggest we update the README now that we have new subcommands.

Salim Afiune added 3 commits March 6, 2018 16:40
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
Signed-off-by: Salim Afiune <afiune@chef.io>
@afiune afiune force-pushed the afiune/AIA-126/Sub-Commands branch from 31f8756 to 6e91c88 Compare March 7, 2018 00:08
@afiune
Copy link
Copy Markdown
Author

afiune commented Mar 7, 2018

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>
@afiune afiune force-pushed the afiune/AIA-126/Sub-Commands branch 2 times, most recently from cb8167f to c05e86f Compare March 7, 2018 19:12
Salim Afiune added 4 commits March 7, 2018 14:39
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>
@afiune afiune force-pushed the afiune/AIA-126/Sub-Commands branch from c05e86f to 7d79a67 Compare March 7, 2018 19:39
Copy link
Copy Markdown
Contributor

@lancewf lancewf left a comment

Choose a reason for hiding this comment

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

Ship it!
image

@afiune
Copy link
Copy Markdown
Author

afiune commented Mar 7, 2018

tenor-37737782

@afiune afiune merged commit 2ed2f9d into master Mar 7, 2018
@afiune afiune deleted the afiune/AIA-126/Sub-Commands branch March 7, 2018 19:52
@afiune
Copy link
Copy Markdown
Author

afiune commented Mar 7, 2018

Hab package uploaded to:

✓ Uploaded chef/chef-load/4.0.0/20180307195344
★ Upload of chef/chef-load/4.0.0/20180307195344 complete.

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 this pull request may close these issues.

3 participants