Class: Sem::CLI::Secrets

Inherits:
Dracula
  • Object
show all
Defined in:
lib/sem/cli/secrets.rb

Defined Under Namespace

Classes: EnvVars, Files

Instance Method Summary collapse

Instance Method Details

#create(secret_name) ⇒ Object



52
53
54
55
56
# File 'lib/sem/cli/secrets.rb', line 52

def create(secret_name)
  secret = Sem::API::Secret.create!(secret_name)

  Sem::Views::Secrets.info(secret)
end

#delete(secrets_name) ⇒ Object



89
90
91
92
93
94
# File 'lib/sem/cli/secrets.rb', line 89

def delete(secrets_name)
  secret = Sem::API::Secret.find!(secrets_name)
  secret.delete!

  puts "Deleted secret #{secrets_name}."
end

#info(secret_name) ⇒ Object



34
35
36
37
38
# File 'lib/sem/cli/secrets.rb', line 34

def info(secret_name)
  secret = Sem::API::Secret.find!(secret_name)

  Sem::Views::Secrets.info(secret)
end

#listObject



12
13
14
15
16
17
18
19
20
# File 'lib/sem/cli/secrets.rb', line 12

def list
  secrets = Sem::API::Secret.all

  if !secrets.empty?
    Sem::Views::Secrets.list(secrets)
  else
    Sem::Views::Secrets.setup_first_secrets
  end
end

#rename(old_secrets_name, new_secrets_name) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/sem/cli/secrets.rb', line 70

def rename(old_secrets_name, new_secrets_name)
  old_org_name, _old_name = Sem::SRN.parse_secret(old_secrets_name)
  new_org_name, new_name = Sem::SRN.parse_secret(new_secrets_name)

  abort "Secrets can't change their organization" unless new_org_name == old_org_name

  secret = Sem::API::Secret.find!(old_secrets_name)
  secret = secret.update!(:name => new_name)

  Sem::Views::Secrets.info(secret)
end