Class: Kitchen::Driver::VmpoolStores::GitlabCommitStore

Inherits:
BaseStore
  • Object
show all
Defined in:
lib/kitchen/driver/vmpool_stores/gitlab_commit_store.rb

Instance Attribute Summary collapse

Attributes inherited from BaseStore

#pool_data

Instance Method Summary collapse

Methods inherited from BaseStore

#read, #reread

Constructor Details

#initialize(options = nil) ⇒ GitlabCommitStore

Returns a new instance of GitlabCommitStore.

Parameters:

  • project_id (Hash)

    a customizable set of options

  • commit_id (Hash)

    a customizable set of options

  • pool_file (Hash)

    a customizable set of options

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
# File 'lib/kitchen/driver/vmpool_stores/gitlab_commit_store.rb', line 16

def initialize(options = nil)
  options ||= { project_id: nil, pool_file: 'vmpool.yaml'}
  raise ArgumentError.new("You must pass the project_id option") unless options['project_id'].to_i > 0
  @project_id = options['project_id']  #ie. 89
  @pool_file = options['pool_file'] || 'vmpool.yaml'
  @branch = 'master'
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



11
12
13
# File 'lib/kitchen/driver/vmpool_stores/gitlab_commit_store.rb', line 11

def branch
  @branch
end

#pool_fileObject (readonly)

Returns the value of attribute pool_file.



11
12
13
# File 'lib/kitchen/driver/vmpool_stores/gitlab_commit_store.rb', line 11

def pool_file
  @pool_file
end

#project_idObject

Returns the value of attribute project_id.



10
11
12
# File 'lib/kitchen/driver/vmpool_stores/gitlab_commit_store.rb', line 10

def project_id
  @project_id
end

Instance Method Details

#createObject



30
31
32
33
34
# File 'lib/kitchen/driver/vmpool_stores/gitlab_commit_store.rb', line 30

def create
  #info("Creating new vmpool data commit")
  create_file unless file_exists?
  read
end

#file_exists?(project = project_id, file = pool_file) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/kitchen/driver/vmpool_stores/gitlab_commit_store.rb', line 42

def file_exists?(project = project_id, file = pool_file)
  read_content(project, file)
end

#saveObject



36
37
38
39
40
# File 'lib/kitchen/driver/vmpool_stores/gitlab_commit_store.rb', line 36

def save
 # info("Saving vmpool data")
  update_file
  read
end

#update(content = nil) ⇒ Object



24
25
26
27
28
# File 'lib/kitchen/driver/vmpool_stores/gitlab_commit_store.rb', line 24

def update(content = nil)
  #info("Updating vmpool data")
  update_file
  read
end