Module: DockerSwarm::Concerns::Updatable

Extended by:
ActiveSupport::Concern
Included in:
Network, Node, Service
Defined in:
lib/docker_swarm/concerns/updatable.rb

Instance Method Summary collapse

Instance Method Details

#update(new_attributes = {}, **opts) ⇒ Object

Parameters:

  • new_attributes (Hash) (defaults to: {})

    atributos Docker (hash posicional braceado)

  • opts (Hash)

    keywords: atributos sueltos históricos + opciones reservadas registry_auth (header X-Registry-Auth) / registry_auth_from (query registryAuthFrom, excluyente con registry_auth). El resto se pliega como atributos.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/docker_swarm/concerns/updatable.rb', line 12

def update(new_attributes = {}, **opts)
  registry_auth = opts.delete(:registry_auth)
  registry_auth_from = opts.delete(:registry_auth_from)
  # Valida (excluyente + enum) y resuelve los canales ANTES de mutar el objeto.
  headers, auth_query = RegistryAuth.resolve(registry_auth: registry_auth, registry_auth_from: registry_auth_from)

  current_version = self.Version&.dig("Index")
  attributes = new_attributes.merge(opts)
  assign_attributes(attributes) if attributes.present?
  return false unless valid?

  Api.request(
    action: self.class.routes[:update],
    arguments: { id: self.ID },
    query_params: { version: current_version }.merge(auth_query),
    payload: payload_for_docker,
    headers: headers
  )

  true
end