lib/core/controlplane.rb in cpl-1.2.0 vs lib/core/controlplane.rb in cpl-1.3.0
- old
+ new
@@ -42,16 +42,17 @@
gvc_op = partial_gvc_match ? "~" : "="
api.query_images(org: a_org, gvc: a_gvc, gvc_op_type: gvc_op)
end
- def image_build(image, dockerfile:, build_args: [], push: true)
+ def image_build(image, dockerfile:, docker_args: [], build_args: [], push: true)
# https://docs.controlplane.com/guides/push-image#step-2
# Might need to use `docker buildx build` if compatiblitity issues arise
cmd = "docker build --platform=linux/amd64 -t #{image} -f #{dockerfile}"
cmd += " --progress=plain" if ControlplaneApiDirect.trace
+ cmd += " #{docker_args.join(' ')}" if docker_args.any?
build_args.each { |build_arg| cmd += " --build-arg #{build_arg}" }
cmd += " #{config.app_dir}"
perform!(cmd)
image_push(image) if push
@@ -262,16 +263,24 @@
domains = api.list_domains(org: org)["items"]
domains.find do |domain_data|
route = find_domain_route(domain_data)
next false if route.nil?
- workloads.any? { |workload| route["workloadLink"].split("/").last == workload }
+ workloads.any? { |workload| route["workloadLink"].match?(%r{/org/#{org}/gvc/#{gvc}/workload/#{workload}}) }
end
end
- def get_domain_workload(data)
+ def fetch_domain(domain)
+ domain_data = api.fetch_domain(org: org, domain: domain)
+ route = find_domain_route(domain_data)
+ return nil if route.nil?
+
+ domain_data
+ end
+
+ def domain_workload_matches?(data, workload)
route = find_domain_route(data)
- route["workloadLink"].split("/").last
+ route["workloadLink"].match?(%r{/org/#{org}/gvc/#{gvc}/workload/#{workload}})
end
def set_domain_workload(data, workload)
route = find_domain_route(data)
route["workloadLink"] = "/org/#{org}/gvc/#{gvc}/workload/#{workload}"