-
Notifications
You must be signed in to change notification settings - Fork 28
Some refactoring on leo subcommands #664
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
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
480f559
Rename leo commands.
tasdomas 4284235
Refactor common options for leo commands.
tasdomas 408dd90
No need for separate packages for subcommands.
tasdomas 767095e
Move all subcommands into a common package.
tasdomas 35e27b5
Fix lint issue.
tasdomas 1a4924d
Merge remote-tracking branch 'origin/master' into d016-leo-cmd-rename
tasdomas 065e8f2
Update dependencies.
tasdomas ff9c6a0
Rename name to other name.
tasdomas d06b82e
Merge branch 'master' into d016-leo-cmd-rename
tasdomas a6f6c2e
Merge remote-tracking branch 'origin/master' into d016-leo-cmd-rename
tasdomas 2c9909e
Merge branch 'master' into d016-leo-cmd-rename
0x2b3bfa0 926d8fa
Merge branch 'master' into d016-leo-cmd-rename
tasdomas 390d913
Merge branch 'master' into d016-leo-cmd-rename
0x2b3bfa0 4693aa8
Merge branch 'master' into d016-leo-cmd-rename
0x2b3bfa0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package cmd | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
|
||
"terraform-provider-iterative/task/common" | ||
) | ||
|
||
// BaseOptions specify base flags for commands that interact with | ||
// cloud deployments. | ||
type BaseOptions struct { | ||
Region string | ||
Provider string | ||
Verbose bool | ||
} | ||
|
||
// defaultCloud specifies default timeouts. | ||
var defaultCloud = common.Cloud{ | ||
Timeouts: common.Timeouts{ | ||
Create: 15 * time.Minute, | ||
Read: 3 * time.Minute, | ||
Update: 3 * time.Minute, | ||
Delete: 15 * time.Minute, | ||
}, | ||
} | ||
|
||
// SetFlags sets base option flags on the provided flagset. | ||
func (o *BaseOptions) SetFlags(f *pflag.FlagSet) { | ||
f.StringVar(&o.Provider, "cloud", "", "cloud provider") | ||
f.StringVar(&o.Region, "region", "us-east", "cloud region") | ||
f.BoolVar(&o.Verbose, "verbose", false, "verbose output") | ||
cobra.CheckErr(cobra.MarkFlagRequired(f, "cloud")) | ||
} | ||
|
||
// GetCloud parses cloud-specific options and returns a cloud structure. | ||
func (o *BaseOptions) GetCloud() *common.Cloud { | ||
cloud := defaultCloud | ||
cloud.Provider = common.Provider(o.Provider) | ||
cloud.Region = common.Region(o.Region) | ||
return &cloud | ||
} | ||
|
||
// ConfigureLogging configures logging and sets the log level. | ||
func (o *BaseOptions) ConfigureLogging() { | ||
logrus.SetLevel(logrus.InfoLevel) | ||
if o.Verbose { | ||
logrus.SetLevel(logrus.DebugLevel) | ||
} | ||
|
||
logrus.SetFormatter(&logrus.TextFormatter{ | ||
ForceColors: true, | ||
DisableTimestamp: true, | ||
}) | ||
} | ||
|
||
// Initialize processes the options, the function can be used with `cobra.OnInitialize`. | ||
func (o *BaseOptions) Initialize() { | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Message in a botte for myself: lots of good stuff here, don't let them disappear forever