lib/core/controlplane.rb in cpl-1.0.2 vs lib/core/controlplane.rb in cpl-1.0.3
- old
+ new
@@ -43,11 +43,15 @@
image_push(image) if push
end
def image_query(app_name = config.app, org_name = config.org)
- cmd = "cpln image query --org #{org_name} -o yaml --max -1 --prop repository=#{app_name}"
+ # When `match_if_app_name_starts_with` is `true`, we query for images from any gvc containing the name,
+ # otherwise we query for images from a gvc with the exact name.
+ op = config.should_app_start_with?(app_name) ? "~" : "="
+
+ cmd = "cpln image query --org #{org_name} -o yaml --max -1 --prop repository#{op}#{app_name}"
perform_yaml(cmd)
end
def image_delete(image)
api.image_delete(org: org, image: image)
@@ -84,11 +88,11 @@
end
def gvc_query(app_name = config.app)
# When `match_if_app_name_starts_with` is `true`, we query for any gvc containing the name,
# otherwise we query for a gvc with the exact name.
- op = config.current[:match_if_app_name_starts_with] ? "~" : "="
+ op = config.should_app_start_with?(app_name) ? "~" : "="
cmd = "cpln gvc query --org #{org} -o yaml --prop name#{op}#{app_name}"
perform_yaml(cmd)
end
@@ -126,14 +130,15 @@
return workload_data if workload_data
raise "Can't find workload '#{workload}', please create it with 'cpl apply-template #{workload} -a #{config.app}'."
end
- def query_workloads(workload, partial_match: false)
- op = partial_match ? "~" : "="
+ def query_workloads(workload, partial_gvc_match: false, partial_workload_match: false)
+ gvc_op = partial_gvc_match ? "~" : "="
+ workload_op = partial_workload_match ? "~" : "="
- api.query_workloads(org: org, gvc: gvc, workload: workload, op_type: op)
+ api.query_workloads(org: org, gvc: gvc, workload: workload, gvc_op_type: gvc_op, workload_op_type: workload_op)
end
def workload_get_replicas(workload, location:)
cmd = "cpln workload get-replicas #{workload} #{gvc_org} --location #{location} -o yaml"
perform_yaml(cmd)
@@ -202,11 +207,11 @@
cmd = "cpln workload force-redeployment #{workload} #{gvc_org}"
cmd += " > /dev/null" if Shell.tmp_stderr
perform!(cmd)
end
- def delete_workload(workload)
- api.delete_workload(org: org, gvc: gvc, workload: workload)
+ def delete_workload(workload, a_gvc = gvc)
+ api.delete_workload(org: org, gvc: a_gvc, workload: workload)
end
def workload_connect(workload, location:, container: nil, shell: nil)
cmd = "cpln workload connect #{workload} #{gvc_org} --location #{location}"
cmd += " --container #{container}" if container