Class: Ci::Slsa::ProvenanceStatement::BuildDefinition

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/ci/slsa/provenance_statement.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#build_typeObject

Returns the value of attribute build_type.



58
59
60
# File 'app/models/ci/slsa/provenance_statement.rb', line 58

def build_type
  @build_type
end

#external_parametersObject

Returns the value of attribute external_parameters.



58
59
60
# File 'app/models/ci/slsa/provenance_statement.rb', line 58

def external_parameters
  @external_parameters
end

#internal_parametersObject

Returns the value of attribute internal_parameters.



58
59
60
# File 'app/models/ci/slsa/provenance_statement.rb', line 58

def internal_parameters
  @internal_parameters
end

#resolved_dependenciesObject

Returns the value of attribute resolved_dependencies.



58
59
60
# File 'app/models/ci/slsa/provenance_statement.rb', line 58

def resolved_dependencies
  @resolved_dependencies
end

Class Method Details

.from_build(build) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'app/models/ci/slsa/provenance_statement.rb', line 60

def self.from_build(build)
  # TODO: update buildType as part of https://gitlab.com/gitlab-org/gitlab/-/issues/426764
  build_type = "https://gitlab.com/gitlab-org/gitlab/-/issues/546150"
  external_parameters = ExternalParameters.from_build(build)
  internal_parameters = {
    architecture: build.runner_manager.architecture,
    executor: build.runner_manager.executor_type,
    job: build.id,
    name: build.runner.display_name
  }

  build_resource = ResourceDescriptor.new(uri: Gitlab::Routing.url_helpers.project_url(build.project),
    digest: { gitCommit: build.sha })
  resolved_dependencies = [build_resource]

  BuildDefinition.new(build_type: build_type, external_parameters: external_parameters,
    internal_parameters: internal_parameters,
    resolved_dependencies: resolved_dependencies)
end