-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalize Configuration and CLI (#37)
* Add missing CLI flags and ENV variables to configuration * Restructure CLI layout. Add 'branch' and 'domain' sub commands * Refactor: Separate Config sources from Settings-Value MiqFlow::Config now does the config processing and presents the update_* methods to the rest of the program MiqFlow::Settings implements the update_* methods * FIX wrong boolean for clear_tmp * Add support for /etc/miqflow.yaml * Remove support for configuration files in the current working directory * Add support for configurable branch naming conventions * Removes unnecessary restriction for branch names * Replace invalid charachters in MIQ domain names * Shorten domain prefix to 'feat' (prev 'feature') * Refactor Travis build
- Loading branch information
1 parent
8db97f0
commit 408be68
Showing
21 changed files
with
340 additions
and
188 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'cli/cli.rb' | ||
require_relative 'cli/main.rb' |
This file contains 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,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'thor' | ||
|
||
module MiqFlow | ||
module Cli | ||
# Implements list subcommand | ||
class BranchCli < Thor | ||
include MiqFlow::Cli | ||
|
||
desc 'list', 'List avaliable Feature Branches' | ||
def list | ||
cli_setup(options, %i[git]) | ||
branches = MiqFlow::GitMethods.get_remote_branches() | ||
text = branches.map{ |b| MiqFlow::Feature.new(b.name, {}).show_summary() } | ||
puts text | ||
MiqFlow.tear_down() | ||
end | ||
|
||
desc 'inspect BRANCH', 'Show detailed information about this Feature-Branch' | ||
option :short, type: :boolean, default: false, desc: 'Same as list' | ||
def inspect(name) | ||
cli_setup(options, %i[git]) | ||
feature = MiqFlow::Feature.new(name, {}) | ||
text = options[:short] ? feature.show_summary() : feature.show_details() | ||
puts text | ||
MiqFlow.tear_down() | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains 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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'thor' | ||
|
||
module MiqFlow | ||
module Cli | ||
# Implements list subcommand | ||
class DomainCli < Thor | ||
include MiqFlow::Cli | ||
|
||
desc 'list', 'List existing Automate Domains in ManageIQ' | ||
def list | ||
cli_setup(options, %i[api]) | ||
api = MiqFlow::ManageIQ.new | ||
puts api.list_domains | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains 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,73 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'thor' | ||
require_relative 'branch.rb' | ||
require_relative 'domain.rb' | ||
|
||
module MiqFlow | ||
# Implements common CLI methods | ||
module Cli | ||
def cli_setup(options={}, mode=[]) | ||
MiqFlow::Config.process_cli_flags(options) # Set log level first | ||
MiqFlow::Config.search_config_files() | ||
MiqFlow::Config.process_environment_variables() | ||
MiqFlow::Config.process_config_file(options['config']) | ||
MiqFlow::Config.process_cli_flags(options) # And again for precedence | ||
|
||
MiqFlow.validate(mode) | ||
MiqFlow.init() | ||
MiqFlow.prepare_repo() | ||
end | ||
|
||
# Implements CLI | ||
class MainCli < Thor | ||
include MiqFlow::Cli | ||
|
||
def self.exit_on_failure? | ||
true | ||
end | ||
|
||
class_option :verbose, type: :boolean, default: false, desc: 'Turn on verbose logging' | ||
class_option :quiet, type: :boolean, default: false, desc: 'Only show errors and warnings' | ||
class_option :silent, type: :boolean, default: false, desc: 'Do not output anything' | ||
class_option :cleanup, type: :boolean, desc: 'Clean up the working dir before exiting' | ||
class_option :workdir, type: :string, desc: 'Override the working directory' | ||
class_option :config, type: :string, alias: '-c', desc: 'Specify config file to load' | ||
|
||
class_option :git_url, type: :string, desc: 'Git clone URL for remote repositories' | ||
class_option :git_path, type: :string, desc: 'path to a local git repositories' | ||
class_option :git_user, type: :string, desc: 'Username for remote repositories' | ||
class_option :git_password, type: :string, desc: 'Password/token for remote repositories' | ||
class_option :git_separator, type: :string, desc: 'List of characters separating part of your ' \ | ||
'branch naming convention' | ||
class_option :git_index, type: :numeric, desc: 'Index the NAME par of your branch naming convenion' | ||
|
||
class_option :miq_url, type: :string, desc: 'ManageIQ API URL. (e.g. https://localhost/api)' | ||
class_option :miq_user, type: :string, desc: 'ManageIQ API User. (default: admin)' | ||
class_option :miq_password, type: :string, desc: 'Passwork/login-token for the ManageIQ API User' | ||
|
||
desc 'branch', 'Branch commands' | ||
subcommand 'branch', MiqFlow::Cli::BranchCli | ||
|
||
desc 'domain', 'Domain commands' | ||
subcommand 'domain', MiqFlow::Cli::DomainCli | ||
|
||
desc 'deploy BRANCH', 'Deploy a Feature Branch' | ||
option :name, desc: 'specify domain identifier (default: 3rd segment of NAME, separated by \'-\')' | ||
option :priority, type: :numeric, desc: 'Not-yet-implemented' | ||
option :provider, desc: 'How to talk to ManageIQ (default: noop)' | ||
def deploy(branch) | ||
cli_setup(options, %i[git miq]) | ||
miq_domain = options[:name] | ||
provider = options.fetch(:provider, 'default') | ||
prio = options[:miq_priority] | ||
|
||
opts = { feature_name: miq_domain, provider: provider } | ||
opts[:miq_priotiry] = prio | ||
feature = MiqFlow::Feature.new(branch, opts) | ||
feature.deploy() | ||
MiqFlow.tear_down() | ||
end | ||
end | ||
end | ||
end |
This file contains 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 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 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.