summaryrefslogtreecommitdiff
path: root/lib/gitlab/kubernetes/helm/parsers/list_v2.rb
blob: daa716cdef78756b35bfbc056e5330772f9bc5d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Gitlab
  module Kubernetes
    module Helm
      module Parsers
        # Parses Helm v2 list (JSON) output
        class ListV2
          ParserError = Class.new(StandardError)

          attr_reader :contents, :json

          def initialize(contents)
            @contents = contents
            @json = Gitlab::Json.parse(contents)
          rescue JSON::ParserError => e
            raise ParserError, e.message
          end

          def releases
            @releases ||= json["Releases"] || []
          end
        end
      end
    end
  end
end