Sha256: be16cf933123bda9d2e8afa000c8afa1d118d601a3b086f572b9fe644ca30c40

Contents?: true

Size: 677 Bytes

Versions: 1

Compression:

Stored size: 677 Bytes

Contents

require 'singleton'
require 'pathname'

class GitlabClusterHelper
  class Config
    include Singleton

    class Error < StandardError; end

    attr_reader :gcp_project, :gcp_zone, :cluster_prefix

    DEFAULT_PATH = Pathname.new('~').join('.gitlab-cluster-helper-config.json').expand_path

    def initialize
      path = ENV["GITLAB_CLUSTER_HELPER_CONFIG"] || DEFAULT_PATH

      raise Error, "Config file does not exist at path: #{path}" unless Pathname.new(path).file?

      json = File.read(path)
      data = JSON.parse(json)

      @gcp_project = data['gcp_project']
      @gcp_zone = data['gcp_zone']
      @cluster_prefix = data['cluster_prefix']
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitlab-cluster-helper-0.1.0 lib/gitlab_cluster_helper/config.rb