lib/core/controlplane.rb in cpl-1.3.0 vs lib/core/controlplane.rb in cpl-1.4.0

- old
+ new

@@ -298,10 +298,28 @@ def log_get(workload:, from:, to:) api.log_get(org: org, gvc: gvc, workload: workload, from: from, to: to) end + # identities + + def fetch_identity(identity, a_gvc = gvc) + api.fetch_identity(org: org, gvc: a_gvc, identity: identity) + end + + # policies + + def fetch_policy(policy) + api.fetch_policy(org: org, policy: policy) + end + + def bind_identity_to_policy(identity_link, policy) + cmd = "cpln policy add-binding #{policy} --org #{org} --identity #{identity_link} --permission reveal" + cmd += " > /dev/null" if Shell.should_hide_output? + perform!(cmd) + end + # apply def apply_template(data) # rubocop:disable Metrics/MethodLength Tempfile.create do |f| f.write(data) f.rewind @@ -315,11 +333,11 @@ $CHILD_STATUS.success? ? parse_apply_result(result) : false else Shell.debug("CMD", cmd) result = `#{cmd}` - $CHILD_STATUS.success? ? parse_apply_result(result) : exit(false) + $CHILD_STATUS.success? ? parse_apply_result(result) : exit(1) end end end def apply_hash(data) @@ -368,17 +386,17 @@ end def perform!(cmd, sensitive_data_pattern: nil) Shell.debug("CMD", cmd, sensitive_data_pattern: sensitive_data_pattern) - system(cmd) || exit(false) + system(cmd) || exit(1) end def perform_yaml(cmd) Shell.debug("CMD", cmd) result = `#{cmd}` - $CHILD_STATUS.success? ? YAML.safe_load(result) : exit(false) + $CHILD_STATUS.success? ? YAML.safe_load(result) : exit(1) end def gvc_org "--gvc #{gvc} --org #{org}" end