Class: CapsuleCD::ValidationUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/capsulecd/base/common/validation_utils.rb

Class Method Summary collapse

Class Method Details

.validate_repo_payload(repo_payload) ⇒ Object

TODO: validation almost needs to be source specific (or inherit from this base function), because source methods may require additional attributes, while these base payload keys are required for general step functions.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/capsulecd/base/common/validation_utils.rb', line 6

def self.validate_repo_payload(repo_payload)
  unless repo_payload['sha']
    fail CapsuleCD::Error::SourcePayloadFormatError, 'Incorrectly formatted payload, missing "sha" key'
  end
  unless repo_payload['ref']
    fail CapsuleCD::Error::SourcePayloadFormatError, 'Incorrectly formatted payload, missing "ref" key'
  end
  unless repo_payload['repo']
    fail CapsuleCD::Error::SourcePayloadFormatError, 'Incorrectly formatted payload, missing "repo" key'
  end
  unless repo_payload['repo']['clone_url']
    fail CapsuleCD::Error::SourcePayloadFormatError, 'Incorrectly formatted payload, missing "clone_url" key'
  end
  unless repo_payload['repo']['name']
    fail CapsuleCD::Error::SourcePayloadFormatError, 'Incorrectly formatted payload, missing "name" key'
  end
end