Puppet Function: docker_swarm_join_flags

Defined in:
lib/puppet/parser/functions/docker_swarm_join_flags.rb
Function type:
Ruby 3.x API

Overview

docker_swarm_join_flags()Any

Transforms a hash into a string of docker swarm init flags

Returns:

  • (Any)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/puppet/parser/functions/docker_swarm_join_flags.rb', line 5

newfunction(:docker_swarm_join_flags, :type => :rvalue) do |args|
  opts = args[0] || {}
  flags = []

  if opts['join'].to_s != 'false'
    flags << 'join'
  end

  if opts['advertise_addr'].to_s != 'undef'
    flags << "--advertise-addr '#{opts['advertise_addr']}'"
  end
   
  if opts['listen_addr'].to_s != 'undef'
    flags << "--listen-addr '#{opts['listen_addr']}'"
  end
  
  if opts['token'].to_s != 'undef'
    flags << "--token '#{opts['token']}'"
  end

  flags.flatten.join(" ")
end