Sha256: ab4758bc97118878610fad83ecfae8091162d92ba029d8532e119443358afbcb

Contents?: true

Size: 1006 Bytes

Versions: 12

Compression:

Stored size: 1006 Bytes

Contents

# frozen_string_literal: true

module Scripts
  module_function

  def assert_replicas(gvc:, workload:, location:)
    <<~SHELL
      REPLICAS_QTY=$( \
        curl ${CPLN_ENDPOINT}/org/shakacode-staging/gvc/#{gvc}/workload/#{workload}/deployment/#{location} \
        -H "Authorization: ${CONTROLPLANE_TOKEN}" -s | grep -o '"replicas":[0-9]*' | grep -o '[0-9]*')

      if [ "$REPLICAS_QTY" -gt 0 ]; then
        echo "-- MULTIPLE REPLICAS ATTEMPT: $REPLICAS_QTY --"
        exit -1
      fi
    SHELL
  end

  def helpers_cleanup
    <<~SHELL
      unset CONTROLPLANE_RUNNER
    SHELL
  end

  # NOTE: please escape all '/' as '//' (as it is ruby interpolation here as well)
  def http_dummy_server_ruby
    'require "socket";s=TCPServer.new(ENV["PORT"] || 80);' \
      'loop do c=s.accept;c.puts("HTTP/1.1 200 OK\\nContent-Length: 2\\n\\nOk");c.close end'
  end

  def http_ping_ruby
    'require "net/http";uri=URI(ENV["CPLN_GLOBAL_ENDPOINT"]);loop do puts(Net::HTTP.get(uri));sleep(5);end'
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cpl-1.4.0 lib/core/scripts.rb
cpl-1.3.0 lib/core/scripts.rb
cpl-1.2.0 lib/core/scripts.rb
cpl-1.1.2 lib/core/scripts.rb
cpl-1.1.2.rc.0 lib/core/scripts.rb
cpl-1.1.1 lib/core/scripts.rb
cpl-1.1.0 lib/core/scripts.rb
cpl-1.0.4 lib/core/scripts.rb
cpl-1.0.3 lib/core/scripts.rb
cpl-1.0.2 lib/core/scripts.rb
cpl-1.0.1 lib/core/scripts.rb
cpl-1.0.0 lib/core/scripts.rb