Class: UffizziCore::Api::Cli::V1::Projects::DeploymentSerializer

Inherits:
BaseSerializer
  • Object
show all
Defined in:
app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb

Instance Method Summary collapse

Instance Method Details

#branchObject



41
42
43
# File 'app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb', line 41

def branch
  object.ingress_container&.repo&.branch
end

#commitObject



45
46
47
# File 'app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb', line 45

def commit
  object.ingress_container&.repo&.builds&.deployed&.last&.commit.to_s.slice(0..5)
end

#containersObject



29
30
31
# File 'app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb', line 29

def containers
  object.containers.active
end

#deployed_byObject



25
26
27
# File 'app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb', line 25

def deployed_by
  object.deployed_by
end

#image_idObject



49
50
51
# File 'app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb', line 49

def image_id
  object.ingress_container&.repo&.name
end

#ingress_container_readyObject



53
54
55
# File 'app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb', line 53

def ingress_container_ready
  !!object.ingress_container&.activity_items&.last&.events&.last&.deployed?
end

#ingress_container_stateObject



57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb', line 57

def ingress_container_state
  last_event = object.ingress_container&.activity_items&.last&.events&.last

  case last_event&.state
  when UffizziCore::Event.state.deployed
    :deployed
  when UffizziCore::Event.state.failed, UffizziCore::Event.state.timeout, UffizziCore::Event.state.cancelled
    :failed
  else
    state_from_activity_items
  end
end

#preview_urlObject



33
34
35
# File 'app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb', line 33

def preview_url
  UffizziCore::DeploymentService.build_preview_url(object)
end

#state_from_activity_itemsObject



70
71
72
73
# File 'app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb', line 70

def state_from_activity_items
  activity_items_count = object.ingress_container&.activity_items&.count
  activity_items_count.to_i > 1 ? :updating : :pending
end

#tagObject



37
38
39
# File 'app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb', line 37

def tag
  object.ingress_container&.tag
end