Class: Gitlab::Ci::Pipeline::Seed::Deployment
- Defined in:
- lib/gitlab/ci/pipeline/seed/deployment.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#job ⇒ Object
readonly
Returns the value of attribute job.
Instance Method Summary collapse
-
#initialize(job, environment) ⇒ Deployment
constructor
A new instance of Deployment.
- #to_resource ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(job, environment) ⇒ Deployment
Returns a new instance of Deployment.
10 11 12 13 |
# File 'lib/gitlab/ci/pipeline/seed/deployment.rb', line 10 def initialize(job, environment) @job = job @environment = environment end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment
8 9 10 |
# File 'lib/gitlab/ci/pipeline/seed/deployment.rb', line 8 def environment @environment end |
#job ⇒ Object (readonly)
Returns the value of attribute job
8 9 10 |
# File 'lib/gitlab/ci/pipeline/seed/deployment.rb', line 8 def job @job end |
Instance Method Details
#to_resource ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gitlab/ci/pipeline/seed/deployment.rb', line 15 def to_resource return job.deployment if job.deployment return unless job.starts_environment? deployment = ::Deployment.new(attributes) # If there is a validation error on environment creation, such as # the name contains invalid character, the job will fall back to a # non-environment job. return unless deployment.valid? && deployment.environment.persisted? if cluster = deployment.environment.deployment_platform&.cluster # double write cluster_id until 12.9: https://gitlab.com/gitlab-org/gitlab/issues/202628 deployment.cluster_id = cluster.id deployment.deployment_cluster = ::DeploymentCluster.new( cluster_id: cluster.id, kubernetes_namespace: cluster.kubernetes_namespace_for(deployment.environment, deployable: job) ) end # Allocate IID for deployments. # This operation must be outside of transactions of pipeline creations. deployment.ensure_project_iid! deployment end |