Sha256: dbdcfb7fc2ae746037cb8ea90d10c71840056efd08279461dd91d4a9fb7f2901

Contents?: true

Size: 1.56 KB

Versions: 11

Compression:

Stored size: 1.56 KB

Contents

module Ridley
  # @author Jamie Winsor <reset@riotgames.com>
  class SandboxObject < ChefObject
    set_chef_id "sandbox_id"

    attribute :sandbox_id,
      type: String

    attribute :uri,
      type: String

    attribute :checksums,
      type: Hash

    attribute :is_completed,
      type: Boolean,
      default: false

    # Return information about the given checksum
    #
    # @example
    #   sandbox.checksum("e5a0f6b48d0712382295ff30bec1f9cc") => {
    #     needs_upload: true,
    #     url: "https://s3.amazonaws.com/opscode-platform-production-data/organization"
    #   }
    #
    # @param [#to_sym] chk_id
    #   checksum to retrieve information about
    #
    # @return [Hash]
    #   a hash containing the checksum information
    def checksum(chk_id)
      checksums[chk_id.to_sym]
    end

    # Concurrently upload all of this sandboxes files into the checksum containers of the sandbox
    #
    # @param [Hash] checksums
    #   a hash of file checksums and file paths
    #
    # @example
    #   sandbox.upload(
    #     "e5a0f6b48d0712382295ff30bec1f9cc" => "/Users/reset/code/rbenv-cookbook/recipes/default.rb",
    #     "de6532a7fbe717d52020dc9f3ae47dbe" => "/Users/reset/code/rbenv-cookbook/recipes/ohai_plugin.rb"
    #   )
    def upload(checksums)
      resource.upload(self, checksums)
    end

    # Notify the Chef Server that uploading to this sandbox has completed
    #
    # @raise [Ridley::Errors::SandboxCommitError]
    def commit
      response = resource.commit(self)
      set_attribute(:is_completed, response[:is_completed])
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ridley-1.0.0.rc2 lib/ridley/chef_objects/sandbox_object.rb
ridley-1.0.0.rc1 lib/ridley/chef_objects/sandbox_object.rb
ridley-0.12.4 lib/ridley/chef_objects/sandbox_object.rb
ridley-0.12.3 lib/ridley/chef_objects/sandbox_object.rb
ridley-0.12.2 lib/ridley/chef_objects/sandbox_object.rb
ridley-0.12.1 lib/ridley/chef_objects/sandbox_object.rb
ridley-0.12.0 lib/ridley/chef_objects/sandbox_object.rb
ridley-0.11.2 lib/ridley/chef_objects/sandbox_object.rb
ridley-0.12.0.rc1 lib/ridley/chef_objects/sandbox_object.rb
ridley-0.11.1 lib/ridley/chef_objects/sandbox_object.rb
ridley-0.11.0.rc1 lib/ridley/chef_objects/sandbox_object.rb