Class: BrainzLab::Signal::Provisioner

Inherits:
Object
  • Object
show all
Defined in:
lib/brainzlab/signal/provisioner.rb

Constant Summary collapse

CACHE_DIR =
ENV.fetch('BRAINZLAB_CACHE_DIR') { File.join(Dir.home, '.brainzlab') }

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Provisioner

Returns a new instance of Provisioner.



13
14
15
# File 'lib/brainzlab/signal/provisioner.rb', line 13

def initialize(config)
  @config = config
end

Instance Method Details

#ensure_project!Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/brainzlab/signal/provisioner.rb', line 17

def ensure_project!
  return unless should_provision?

  # Try cached credentials first
  if (cached = load_cached_credentials)
    apply_credentials(cached)
    return cached
  end

  # Provision new project
  project = provision_project
  return unless project

  # Cache and apply credentials
  cache_credentials(project)
  apply_credentials(project)

  project
end