Module: Scripts

Defined in:
lib/core/scripts.rb

Class Method Summary collapse

Class Method Details

.assert_replicas(gvc:, workload:, location:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/core/scripts.rb', line 6

def assert_replicas(gvc:, workload:, location:)
  "    REPLICAS_QTY=$( \\\n      curl ${CPLN_ENDPOINT}/org/shakacode-staging/gvc/\#{gvc}/workload/\#{workload}/deployment/\#{location} \\\n      -H \"Authorization: ${CONTROLPLANE_TOKEN}\" -s | grep -o '\"replicas\":[0-9]*' | grep -o '[0-9]*')\n\n    if [ \"$REPLICAS_QTY\" -gt 0 ]; then\n      echo \"-- MULTIPLE REPLICAS ATTEMPT: $REPLICAS_QTY --\"\n      exit -1\n    fi\n  SHELL\nend\n"

.helpers_cleanupObject



19
20
21
22
23
# File 'lib/core/scripts.rb', line 19

def helpers_cleanup
  "    unset CONTROLPLANE_RUNNER\n  SHELL\nend\n"

.http_dummy_server_rubyObject

NOTE: please escape all ‘/’ as ‘//’ (as it is ruby interpolation here as well)



26
27
28
29
# File 'lib/core/scripts.rb', line 26

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

.http_ping_rubyObject



31
32
33
# File 'lib/core/scripts.rb', line 31

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