Method: Controlplane#parse_apply_result
- Defined in:
- lib/core/controlplane.rb
#parse_apply_result(result) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
# File 'lib/core/controlplane.rb', line 436 def parse_apply_result(result) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity items = [] lines = result.split("\n") lines.each do |line| # The line can be in one of these formats: # - "Created /org/shakacode-open-source-examples/gvc/my-app-staging" # - "Created /org/shakacode-open-source-examples/gvc/my-app-staging/workload/redis" # - "Updated gvc 'tutorial-app-test-1'" # - "Updated workload 'redis'" if line.start_with?("Created") matches = line.match(%r{Created\s/org/[^/]+/gvc/([^/]+)($|(/([^/]+)/([^/]+)$))})&.captures next unless matches app, _, __, kind, name = matches if kind items.push({ kind: kind, name: name }) else items.push({ kind: "app", name: app }) end else matches = line.match(/Updated\s([^\s]+)\s'([^\s]+)'$/)&.captures next unless matches kind, name = matches kind = "app" if kind == "gvc" items.push({ kind: kind, name: name }) end end items end |