morpheus-cli 6.2.3 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/README.md +6 -0
- data/lib/morpheus/cli/commands/clusters.rb +1 -2
- data/lib/morpheus/cli/commands/policies_command.rb +112 -128
- data/lib/morpheus/cli/commands/roles.rb +3 -0
- data/lib/morpheus/cli/mixins/accounts_helper.rb +2 -0
- data/lib/morpheus/cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02effa7bdd51120b68b2253e21f9be4df3a3388424975e21ec4add33a6ad516e
|
4
|
+
data.tar.gz: 55ce2d5a93cce0ac5aa77ed3d993af5daa41fd3473bddeae773e6d18ac324442
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8a17ab56472e03157c1e9d2fd2cbaf36dd98dbc4c0d06270b84dfd8b0064d93f2259206a0f6623dc2a51995cd0888ba7ea3785cbcf43936fe7998f4f54577b7
|
7
|
+
data.tar.gz: 3086104a09b6739bab99d963937dec66d8f1de208270aae3a7bb23374c3c848e1636e6bd7086f37dee0e259f6dc718e57b7a15213b615d37a985805fcc620f43
|
data/Dockerfile
CHANGED
data/README.md
CHANGED
@@ -58,6 +58,12 @@ While developing, you can quickly reload your code changes in a morpheus shell w
|
|
58
58
|
morpheus shell
|
59
59
|
```
|
60
60
|
|
61
|
+
or
|
62
|
+
|
63
|
+
```shell
|
64
|
+
bundle exec morpheus shell —debug
|
65
|
+
```
|
66
|
+
|
61
67
|
Then to reload changes without restarting the morpheus shell (and the ruby process), use:
|
62
68
|
|
63
69
|
```shell
|
@@ -730,14 +730,13 @@ class Morpheus::Cli::Clusters
|
|
730
730
|
server_payload['hostname'] = options[:hostname] || Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'hostname', 'fieldLabel' => 'Hostname', 'type' => 'text', 'required' => true, 'description' => 'Hostname', 'defaultValue' => resourceName}], options[:options], @api_client, api_params)['hostname']
|
731
731
|
|
732
732
|
# Kube Default Repo
|
733
|
-
if cluster_payload['type'] == 'kubernetes-cluster'
|
733
|
+
if cluster_payload['type'] == 'kubernetes-cluster'
|
734
734
|
default_repo = options[:default_repo] || Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'defaultRepoAccount', 'fieldLabel' => 'Cluster Repo Account', 'type' => 'select', 'required' => false, 'optionSource' => 'dockerHubRegistries'}], options[:options], @api_client, api_params)['defaultRepoAccount']
|
735
735
|
if default_repo != ""
|
736
736
|
server_payload['config']['defaultRepoAccount'] = default_repo
|
737
737
|
end
|
738
738
|
end
|
739
739
|
|
740
|
-
|
741
740
|
# Workflow / Automation
|
742
741
|
if provision_type['code'] != 'manual' && controller_type && controller_type['hasAutomation']
|
743
742
|
task_set_id = options[:taskSetId] || Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'taskSet', 'fieldLabel' => 'Workflow', 'type' => 'select', 'required' => false, 'optionSource' => 'taskSets'}], options[:options], @api_client, api_params.merge({'phase' => 'postProvision'}))['taskSet']
|
@@ -763,61 +763,49 @@ class Morpheus::Cli::PoliciesCommand
|
|
763
763
|
params = {}
|
764
764
|
options = {}
|
765
765
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
766
|
-
opts.banner = subcommand_usage()
|
767
|
-
|
766
|
+
opts.banner = subcommand_usage("[search]")
|
767
|
+
build_standard_list_options(opts, options, [], [:search])
|
768
|
+
opts.footer = <<-EOT
|
769
|
+
Get details about a policy type.
|
770
|
+
[policy-type] is required. This is Name or ID of a policy type.
|
771
|
+
EOT
|
768
772
|
opts.footer = "List policy types."
|
769
773
|
end
|
770
774
|
optparse.parse!(args)
|
771
|
-
|
772
|
-
if args.count
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
end
|
777
|
-
|
775
|
+
verify_args!(args:args, optparse:optparse, count:0)
|
776
|
+
# if args.count > 0
|
777
|
+
# options[:phrase] = args.join(" ")
|
778
|
+
# end
|
779
|
+
params.merge!(parse_list_options(options))
|
778
780
|
connect(options)
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
781
|
+
@policies_interface.setopts(options)
|
782
|
+
if options[:dry_run]
|
783
|
+
print_dry_run @policies_interface.dry.list_policy_types(params)
|
784
|
+
return 0
|
785
|
+
end
|
786
|
+
json_response = @policies_interface.list_policy_types(params)
|
787
|
+
render_response(json_response, options, 'policyTypes') do
|
786
788
|
policy_types = json_response['policyTypes']
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
puts records_as_csv(policy_types, options)
|
795
|
-
return 0
|
796
|
-
else
|
797
|
-
print_h1 "Morpheus Policy Types"
|
798
|
-
rows = policy_types.collect {|policy_type|
|
799
|
-
row = {
|
800
|
-
id: policy_type['id'],
|
801
|
-
name: policy_type['name'],
|
802
|
-
code: policy_type['code'],
|
803
|
-
description: policy_type['description']
|
804
|
-
}
|
805
|
-
row
|
789
|
+
print_h1 "Morpheus Policy Types"
|
790
|
+
rows = policy_types.collect {|policy_type|
|
791
|
+
row = {
|
792
|
+
id: policy_type['id'],
|
793
|
+
name: policy_type['name'],
|
794
|
+
code: policy_type['code'],
|
795
|
+
description: policy_type['description']
|
806
796
|
}
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
print as_pretty_table(rows, columns, options)
|
813
|
-
print_results_pagination(json_response, {:label => "policy type", :n_label => "policy types"})
|
814
|
-
print reset, "\n"
|
797
|
+
row
|
798
|
+
}
|
799
|
+
columns = [:id, :name]
|
800
|
+
if options[:include_fields]
|
801
|
+
columns = options[:include_fields]
|
815
802
|
end
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
803
|
+
print cyan
|
804
|
+
print as_pretty_table(rows, columns, options)
|
805
|
+
print_results_pagination(json_response)
|
806
|
+
print reset, "\n"
|
820
807
|
end
|
808
|
+
return 0
|
821
809
|
end
|
822
810
|
|
823
811
|
def get_type(args)
|
@@ -825,91 +813,54 @@ class Morpheus::Cli::PoliciesCommand
|
|
825
813
|
options = {}
|
826
814
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
827
815
|
opts.banner = subcommand_usage("[policy-type]")
|
828
|
-
|
829
|
-
opts.footer =
|
830
|
-
|
816
|
+
build_standard_get_options(opts, options)
|
817
|
+
opts.footer = <<-EOT
|
818
|
+
Get details about a policy type.
|
819
|
+
[policy-type] is required. This is Name or ID of a policy type.
|
820
|
+
EOT
|
831
821
|
end
|
832
822
|
optparse.parse!(args)
|
833
|
-
|
834
|
-
if args.count != 1
|
835
|
-
print_error Morpheus::Terminal.angry_prompt
|
836
|
-
puts_error "wrong number of arguments, expected 1 and got #{args.count}\n#{optparse}"
|
837
|
-
return 1
|
838
|
-
end
|
839
|
-
|
823
|
+
verify_args!(args:args, optparse:optparse, count: 1)
|
840
824
|
connect(options)
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
puts as_json(json_response)
|
852
|
-
else
|
853
|
-
print_h1 "Policy Type Details"
|
854
|
-
print cyan
|
855
|
-
description_cols = {
|
856
|
-
"ID" => 'id',
|
857
|
-
"Name" => 'name',
|
858
|
-
# "Description" => 'description',
|
859
|
-
"Code" => 'code',
|
860
|
-
"Category" => 'category',
|
861
|
-
# "Load Method" => 'loadMethod',
|
862
|
-
# "Enforce Method" => 'enforceMethod',
|
863
|
-
# "Prepare Method" => 'prepareMethod',
|
864
|
-
# "Validate Method" => 'validateMethod',
|
865
|
-
"Provision Enforced" => lambda {|it| it['enforceOnProvision'] ? 'Yes' : 'No' },
|
866
|
-
"Managed Enforced" => lambda {|it| it['enforceOnManaged'] ? 'Yes' : 'No' },
|
867
|
-
}
|
868
|
-
print_description_list(description_cols, policy_type)
|
869
|
-
print reset,"\n"
|
870
|
-
|
871
|
-
# show option types
|
872
|
-
print_h2 "Policy Type Options"
|
873
|
-
policy_type_option_types = policy_type['optionTypes']
|
874
|
-
if !policy_type_option_types || policy_type_option_types.size() == 0
|
875
|
-
puts "No options found for policy type"
|
876
|
-
else
|
877
|
-
rows = policy_type_option_types.collect {|option_type|
|
878
|
-
field_str = option_type['fieldName'].to_s
|
879
|
-
if !option_type['fieldContext'].to_s.empty?
|
880
|
-
field_str = option_type['fieldContext'] + "." + field_str
|
881
|
-
end
|
882
|
-
description_str = option_type['description'].to_s
|
883
|
-
if option_type['helpBlock']
|
884
|
-
if description_str.empty?
|
885
|
-
description_str = option_type['helpBlock']
|
886
|
-
else
|
887
|
-
description_str += " " + option_type['helpBlock']
|
888
|
-
end
|
889
|
-
end
|
890
|
-
row = {
|
891
|
-
#code: option_type['code'],
|
892
|
-
field: field_str,
|
893
|
-
type: option_type['type'],
|
894
|
-
description: description_str,
|
895
|
-
default: option_type['defaultValue'],
|
896
|
-
required: option_type['required'] ? 'Yes' : 'No'
|
897
|
-
}
|
898
|
-
row
|
899
|
-
}
|
900
|
-
columns = [:field, :type, :description, :default, :required]
|
901
|
-
print cyan
|
902
|
-
print as_pretty_table(rows, columns)
|
903
|
-
print reset,"\n"
|
904
|
-
end
|
905
|
-
return 0
|
906
|
-
end
|
825
|
+
params.merge!(parse_query_options(options))
|
826
|
+
policy_type_id = args[0]
|
827
|
+
if policy_type_id.to_s !~ /\A\d{1,}\Z/
|
828
|
+
policy_type = find_policy_type_by_name_or_id(args[0])
|
829
|
+
return [1, "Policy Type not found for #{args[0]}"] if policy_type.nil?
|
830
|
+
policy_type_id = policy_type['id']
|
831
|
+
end
|
832
|
+
@policies_interface.setopts(options)
|
833
|
+
if options[:dry_run]
|
834
|
+
print_dry_run @policies_interface.dry.get_policy_type(policy_type_id, params)
|
907
835
|
return 0
|
908
|
-
rescue RestClient::Exception => e
|
909
|
-
print_rest_exception(e, options)
|
910
|
-
return 1
|
911
836
|
end
|
912
|
-
@policies_interface.
|
837
|
+
json_response = @policies_interface.get_policy_type(policy_type_id, params)
|
838
|
+
render_response(json_response, options, 'policyType') do
|
839
|
+
policy_type = json_response['policyType']
|
840
|
+
print_h1 "Policy Type Details"
|
841
|
+
print cyan
|
842
|
+
description_cols = {
|
843
|
+
"ID" => 'id',
|
844
|
+
"Name" => 'name',
|
845
|
+
# "Description" => 'description',
|
846
|
+
"Code" => 'code',
|
847
|
+
"Category" => 'category',
|
848
|
+
# "Load Method" => 'loadMethod',
|
849
|
+
# "Enforce Method" => 'enforceMethod',
|
850
|
+
# "Prepare Method" => 'prepareMethod',
|
851
|
+
# "Validate Method" => 'validateMethod',
|
852
|
+
"Provision Enforced" => lambda {|it| it['enforceOnProvision'] ? 'Yes' : 'No' },
|
853
|
+
"Managed Enforced" => lambda {|it| it['enforceOnManaged'] ? 'Yes' : 'No' },
|
854
|
+
}
|
855
|
+
print_description_list(description_cols, policy_type)
|
856
|
+
print reset,"\n"
|
857
|
+
|
858
|
+
# show option types
|
859
|
+
print_h2 "Policy Type Options"
|
860
|
+
print format_option_types_table(policy_type['optionTypes'], options, 'policy')
|
861
|
+
print reset,"\n"
|
862
|
+
end
|
863
|
+
return 0
|
913
864
|
end
|
914
865
|
|
915
866
|
private
|
@@ -978,9 +929,42 @@ class Morpheus::Cli::PoliciesCommand
|
|
978
929
|
end
|
979
930
|
end
|
980
931
|
|
932
|
+
def find_policy_type_by_name_or_id(val)
|
933
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
934
|
+
return find_policy_type_by_id(val)
|
935
|
+
else
|
936
|
+
return find_policy_type_by_name(val)
|
937
|
+
end
|
938
|
+
end
|
939
|
+
|
940
|
+
def find_policy_type_by_name(name)
|
941
|
+
json_response = nil
|
942
|
+
|
943
|
+
# json_response = @policies_interface.list_policy_types({name: name.to_s})
|
944
|
+
json_response = @policies_interface.list_policy_types({max: 10000})
|
945
|
+
policy_types = json_response['policyTypes']
|
946
|
+
match_value = name.to_s.downcase
|
947
|
+
policy_types = policy_types.select {|it| it['name'].to_s.downcase == match_value || it['code'].to_s.downcase == match_value }
|
948
|
+
if policy_types.empty?
|
949
|
+
print_red_alert "Policy not found by name #{name}"
|
950
|
+
return nil
|
951
|
+
elsif policy_types.size > 1
|
952
|
+
print_red_alert "#{policy_types.size} policy types found by name or code #{name}"
|
953
|
+
# print_policies_table(policy_types, {color: red})
|
954
|
+
rows = policy_types.collect do |it|
|
955
|
+
{id: it['id'], name: it['name'], code: it['code']}
|
956
|
+
end
|
957
|
+
puts as_pretty_table(rows, [:id, :name], {color:red})
|
958
|
+
return nil
|
959
|
+
else
|
960
|
+
policy_type = policy_types[0]
|
961
|
+
return policy_type
|
962
|
+
end
|
963
|
+
end
|
964
|
+
|
981
965
|
def find_policy_type_by_id(id)
|
982
966
|
begin
|
983
|
-
json_response = @policies_interface.
|
967
|
+
json_response = @policies_interface.get_policy_type(id.to_s)
|
984
968
|
return json_response['policyType']
|
985
969
|
rescue RestClient::Exception => e
|
986
970
|
if e.response && e.response.code == 404
|
@@ -631,6 +631,8 @@ EOT
|
|
631
631
|
params['authority'] = v_prompt['authority']
|
632
632
|
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'displayOrder' => 2}], options[:options])
|
633
633
|
params['description'] = v_prompt['description']
|
634
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'landingUrl', 'fieldLabel' => 'landingUrl', 'type' => 'text', 'displayOrder' => 3, 'description' => 'An optional override for the default landing page after login for a user.'}], options[:options])
|
635
|
+
params['landingUrl'] = v_prompt['landingUrl']
|
634
636
|
|
635
637
|
if params['owner']
|
636
638
|
if @is_master_account && has_complete_access
|
@@ -2479,6 +2481,7 @@ Update default workflow access for a role.
|
|
2479
2481
|
[
|
2480
2482
|
{'fieldName' => 'authority', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true},
|
2481
2483
|
{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text'},
|
2484
|
+
{'fieldName' => 'landingUrl', 'fieldLabel' => 'Landing URL', 'type' => 'text', 'description' => 'An optional override for the default landing page after login for a user.'},
|
2482
2485
|
{'fieldName' => 'roleType', 'fieldLabel' => 'Role Type', 'type' => 'select', 'selectOptions' => [{'name' => 'User Role', 'value' => 'user'}, {'name' => 'Account Role', 'value' => 'account'}], 'defaultValue' => 'user'},
|
2483
2486
|
{'fieldName' => 'baseRole', 'fieldLabel' => 'Copy From Role', 'type' => 'text'},
|
2484
2487
|
{'fieldName' => 'multitenant', 'fieldLabel' => 'Multitenant', 'type' => 'checkbox', 'defaultValue' => 'off', 'description' => 'A Multitenant role is automatically copied into all existing subaccounts as well as placed into a subaccount when created. Useful for providing a set of predefined roles a Customer can use'},
|
@@ -131,6 +131,7 @@ module Morpheus::Cli::AccountsHelper
|
|
131
131
|
"ID" => 'id',
|
132
132
|
"Name" => 'authority',
|
133
133
|
"Description" => 'description',
|
134
|
+
"Landing URL" => 'landingUrl',
|
134
135
|
#"Scope" => lambda {|it| it['scope'] },
|
135
136
|
"Type" => lambda {|it| format_role_type(it) },
|
136
137
|
"Multitenant" => lambda {|it|
|
@@ -149,6 +150,7 @@ module Morpheus::Cli::AccountsHelper
|
|
149
150
|
"ID" => 'id',
|
150
151
|
"Name" => 'authority',
|
151
152
|
"Description" => 'description',
|
153
|
+
"Landing URL" => 'landingUrl',
|
152
154
|
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
153
155
|
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
154
156
|
}
|
data/lib/morpheus/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morpheus-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Estes
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2023-10-
|
14
|
+
date: 2023-10-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|