Class: HammerCLIKatello::Repository::UpdateCommand

Inherits:
UpdateCommand
  • Object
show all
Extended by:
HammerCLIKatello::RepositoryScopedToProduct
Includes:
OrganizationOptions, AnsibleCollectionRequirementsHelper
Defined in:
lib/hammer_cli_katello/repository.rb

Instance Method Summary collapse

Methods included from HammerCLIKatello::RepositoryScopedToProduct

validate_repo_name_requires_product_options

Methods included from OrganizationOptions

included, #org_options

Methods included from AnsibleCollectionRequirementsHelper

included, #request_params

Methods included from HammerCLIKatello::ResolverCommons

included

Instance Method Details

#content_upload_resourceObject



319
320
321
# File 'lib/hammer_cli_katello/repository.rb', line 319

def content_upload_resource
  ::HammerCLIForeman.foreman_resource(:content_uploads)
end

#create_content_uploadObject



341
342
343
344
345
346
347
348
# File 'lib/hammer_cli_katello/repository.rb', line 341

def create_content_upload
  response = content_upload_resource.call(:create,
                                          :repository_id => get_identifier,
                                          :size => 0
                                         )

  response["upload_id"]
end

#executeObject



307
308
309
310
311
312
313
314
315
316
317
# File 'lib/hammer_cli_katello/repository.rb', line 307

def execute
  @failure = false

  if option_docker_tag
    upload_tag(option_docker_tag, option_docker_digest)
  else
    super
  end

  @failure ? HammerCLI::EX_DATAERR : HammerCLI::EX_OK
end

#import_uploads(uploads, opts = {}) ⇒ Object



350
351
352
353
354
355
356
357
358
359
360
# File 'lib/hammer_cli_katello/repository.rb', line 350

def import_uploads(uploads, opts = {})
  publish_repository = opts.fetch(:last_file, false)
  sync_capsule = opts.fetch(:last_file, false)
  params = {:id => get_identifier,
            :uploads => uploads,
            publish_repository: publish_repository,
            sync_capsule: sync_capsule,
            content_type: "docker_tag"
  }
  resource.call(:import_uploads, params)
end

#upload_tag(tag, digest) ⇒ Object



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/hammer_cli_katello/repository.rb', line 323

def upload_tag(tag, digest)
  upload_id = create_content_upload
  import_uploads([
    {
      id: upload_id,
      name: tag,
      digest: digest
    }
  ], last_file: true)
  print_message _("Repository updated")
rescue => e
  @failure = true
  logger.error e
  output.print_error _("Failed to upload tag '%s' to repository.") % tag
ensure
  content_upload_resource.call(:destroy, :repository_id => get_identifier, :id => upload_id)
end