sem 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sem/api/org.rb +2 -2
- data/lib/sem/api/project.rb +8 -8
- data/lib/sem/api/secret.rb +109 -0
- data/lib/sem/api/team.rb +8 -8
- data/lib/sem/api.rb +1 -1
- data/lib/sem/cli/projects.rb +22 -25
- data/lib/sem/cli/secrets.rb +220 -0
- data/lib/sem/cli/teams.rb +21 -21
- data/lib/sem/cli.rb +2 -2
- data/lib/sem/srn.rb +2 -2
- data/lib/sem/version.rb +1 -1
- data/lib/sem/views/projects.rb +4 -4
- data/lib/sem/views/secrets.rb +51 -0
- data/lib/sem/views/teams.rb +4 -4
- data/lib/sem/views.rb +1 -1
- data/sem.gemspec +1 -1
- metadata +33 -33
- data/lib/sem/api/shared_config.rb +0 -109
- data/lib/sem/cli/shared_configs.rb +0 -220
- data/lib/sem/views/shared_configs.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcf97334c5552314453331d55eff0abdf5dcb0a7
|
4
|
+
data.tar.gz: c53b9c7001b91e8bd888e77d88759b5627afde8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c706b748e6920848e71318d3ae91f009eec005d6fb9fefa24a5a9621908ad7d6e798a29dda0417c5461652f7ff56234ca213dc6622e24cd4b01d3d963dc57c8a
|
7
|
+
data.tar.gz: 9a705290418c713cee873bf311c932ade36afb76af077cda2f0c36df666cf111359162e304adb720b683a7a326ce2821b5901bd52ef5f73a6ddbc462da7f1bb9
|
data/lib/sem/api/org.rb
CHANGED
@@ -23,8 +23,8 @@ class Sem::API::Org < SimpleDelegator
|
|
23
23
|
Sem::API::Base.client.projects.list_for_org!(username).map { |project| Sem::API::Project.new(username, project) }
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
Sem::API::Base.client.
|
26
|
+
def secrets
|
27
|
+
Sem::API::Base.client.secrets.list_for_org!(username).map { |secret| Sem::API::Secret.new(username, secret) }
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
data/lib/sem/api/project.rb
CHANGED
@@ -42,20 +42,20 @@ class Sem::API::Project < SimpleDelegator
|
|
42
42
|
"#{@org_name}/#{name}"
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
Sem::API::Base.client.
|
45
|
+
def secrets
|
46
|
+
Sem::API::Base.client.secrets.list_for_project!(id).map { |secret| Sem::API::Secret.new(org_name, secret) }
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
50
|
-
Sem::API::Base.client.
|
49
|
+
def add_secret(secret)
|
50
|
+
Sem::API::Base.client.secrets.attach_to_project!(secret.id, id)
|
51
51
|
rescue SemaphoreClient::Exceptions::NotFound
|
52
|
-
raise Sem::Errors::ResourceNotFound.new("
|
52
|
+
raise Sem::Errors::ResourceNotFound.new("Secret", [secret.full_name])
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
Sem::API::Base.client.
|
55
|
+
def remove_secret(secret)
|
56
|
+
Sem::API::Base.client.secrets.detach_from_project!(secret.id, id)
|
57
57
|
rescue SemaphoreClient::Exceptions::NotFound
|
58
|
-
raise Sem::Errors::ResourceNotFound.new("
|
58
|
+
raise Sem::Errors::ResourceNotFound.new("Secret", [secret.full_name])
|
59
59
|
end
|
60
60
|
|
61
61
|
def config_files
|
@@ -0,0 +1,109 @@
|
|
1
|
+
class Sem::API::Secret < SimpleDelegator
|
2
|
+
extend Sem::API::Base
|
3
|
+
|
4
|
+
def self.all
|
5
|
+
Sem::API::Org.all.pmap(&:secrets).flatten
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.find!(secrets_srn)
|
9
|
+
org_name, secret_name = Sem::SRN.parse_secret(secrets_srn)
|
10
|
+
|
11
|
+
secrets = client.secrets.list_for_org!(org_name)
|
12
|
+
secret = secrets.find { |c| c.name == secret_name }
|
13
|
+
|
14
|
+
if secret.nil?
|
15
|
+
raise Sem::Errors::ResourceNotFound.new("Secret", [org_name, secret_name])
|
16
|
+
end
|
17
|
+
|
18
|
+
new(org_name, secret)
|
19
|
+
rescue SemaphoreClient::Exceptions::NotFound
|
20
|
+
raise Sem::Errors::ResourceNotFound.new("Secret", [org_name, secret_name])
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.create!(secret_srn, args = {})
|
24
|
+
org_name, secret_name = Sem::SRN.parse_secret(secret_srn)
|
25
|
+
|
26
|
+
secret = client.secrets.create_for_org!(org_name, args.merge(:name => secret_name))
|
27
|
+
|
28
|
+
if secret.nil?
|
29
|
+
raise Sem::Errors::ResourceNotCreated.new("Secret", [org_name, secret_name])
|
30
|
+
end
|
31
|
+
|
32
|
+
new(org_name, secret)
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_reader :org_name
|
36
|
+
|
37
|
+
def initialize(org_name, secret)
|
38
|
+
@org_name = org_name
|
39
|
+
|
40
|
+
super(secret)
|
41
|
+
end
|
42
|
+
|
43
|
+
def full_name
|
44
|
+
"#{org_name}/#{name}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_config_file(args)
|
48
|
+
file = Sem::API::Base.client.config_files.create_for_secret!(id, args)
|
49
|
+
|
50
|
+
if file.nil?
|
51
|
+
raise Sem::Errors::ResourceNotCreated.new("Configuration File", [org_name, path])
|
52
|
+
end
|
53
|
+
|
54
|
+
Sem::API::File.new(file)
|
55
|
+
end
|
56
|
+
|
57
|
+
def remove_config_file(path)
|
58
|
+
file = files.find { |f| f.path == path }
|
59
|
+
|
60
|
+
if file.nil?
|
61
|
+
raise Sem::Errors::ResourceNotCreated.new("Configuration File", [org_name, path])
|
62
|
+
end
|
63
|
+
|
64
|
+
Sem::API::Base.client.config_files.delete!(file.id)
|
65
|
+
end
|
66
|
+
|
67
|
+
def add_env_var(args)
|
68
|
+
env_var = Sem::API::Base.client.env_vars.create_for_secret!(id, args)
|
69
|
+
|
70
|
+
if env_var.nil?
|
71
|
+
raise Sem::Errors::ResourceNotCreated.new("Environment Variable", [org_name, args[:name]])
|
72
|
+
end
|
73
|
+
|
74
|
+
Sem::API::EnvVar.new(env_var)
|
75
|
+
end
|
76
|
+
|
77
|
+
def remove_env_var(name)
|
78
|
+
env_var = env_vars.find { |var| var.name == name }
|
79
|
+
|
80
|
+
if env_var.nil?
|
81
|
+
raise Sem::Errors::ResourceNotFound.new("Environment Variable", [org_name, name])
|
82
|
+
end
|
83
|
+
|
84
|
+
Sem::API::Base.client.env_vars.delete!(env_var.id)
|
85
|
+
end
|
86
|
+
|
87
|
+
def update!(args)
|
88
|
+
secret = Sem::API::Base.client.secrets.update!(id, args)
|
89
|
+
|
90
|
+
if secret.nil?
|
91
|
+
raise Sem::Errors::ResourceNotUpdated.new("Secret", [org_name, name])
|
92
|
+
end
|
93
|
+
|
94
|
+
self.class.new(org_name, secret)
|
95
|
+
end
|
96
|
+
|
97
|
+
def delete!
|
98
|
+
Sem::API::Base.client.secrets.delete!(id)
|
99
|
+
end
|
100
|
+
|
101
|
+
def files
|
102
|
+
Sem::API::Base.client.config_files.list_for_secret!(id).map { |file| Sem::API::File.new(file) }
|
103
|
+
end
|
104
|
+
|
105
|
+
def env_vars
|
106
|
+
Sem::API::Base.client.env_vars.list_for_secret!(id).map { |env_var| Sem::API::EnvVar.new(env_var) }
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
data/lib/sem/api/team.rb
CHANGED
@@ -71,16 +71,16 @@ class Sem::API::Team < SimpleDelegator
|
|
71
71
|
raise Sem::Errors::ResourceNotFound.new("Project", [project.full_name])
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
75
|
-
Sem::API::Base.client.
|
74
|
+
def add_secret(secret)
|
75
|
+
Sem::API::Base.client.secrets.attach_to_team!(secret.id, id)
|
76
76
|
rescue SemaphoreClient::Exceptions::NotFound
|
77
|
-
raise Sem::Errors::ResourceNotFound.new("
|
77
|
+
raise Sem::Errors::ResourceNotFound.new("Secret", [secret.full_name])
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
81
|
-
Sem::API::Base.client.
|
80
|
+
def remove_secret(secret)
|
81
|
+
Sem::API::Base.client.secrets.detach_from_team!(secret.id, id)
|
82
82
|
rescue SemaphoreClient::Exceptions::NotFound
|
83
|
-
raise Sem::Errors::ResourceNotFound.new("
|
83
|
+
raise Sem::Errors::ResourceNotFound.new("Secret", [secret.full_name])
|
84
84
|
end
|
85
85
|
|
86
86
|
def delete!
|
@@ -95,8 +95,8 @@ class Sem::API::Team < SimpleDelegator
|
|
95
95
|
Sem::API::Base.client.projects.list_for_team!(id).map { |project| Sem::API::Project.new(org_name, project) }
|
96
96
|
end
|
97
97
|
|
98
|
-
def
|
99
|
-
Sem::API::Base.client.
|
98
|
+
def secrets
|
99
|
+
Sem::API::Base.client.secrets.list_for_team!(id).map { |secret| Sem::API::Secret.new(org_name, secret) }
|
100
100
|
end
|
101
101
|
|
102
102
|
end
|
data/lib/sem/api.rb
CHANGED
data/lib/sem/cli/projects.rb
CHANGED
@@ -113,66 +113,63 @@ DESC
|
|
113
113
|
|
114
114
|
end
|
115
115
|
|
116
|
-
class
|
116
|
+
class Secrets < Dracula
|
117
117
|
|
118
|
-
desc "list", "list
|
118
|
+
desc "list", "list secrets on a project"
|
119
119
|
long_desc <<-DESC
|
120
120
|
Examples:
|
121
121
|
|
122
|
-
$ sem projects:
|
122
|
+
$ sem projects:secrets:list renderedtext/cli
|
123
123
|
ID NAME CONFIG FILES ENV VARS
|
124
124
|
99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/tokens 1 0
|
125
125
|
99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/secrets 0 1
|
126
126
|
DESC
|
127
127
|
def list(project_name)
|
128
128
|
project = Sem::API::Project.find!(project_name)
|
129
|
-
|
129
|
+
secrets = project.secrets
|
130
130
|
|
131
|
-
if !
|
132
|
-
Sem::Views::
|
131
|
+
if !secrets.empty?
|
132
|
+
Sem::Views::Secrets.list(secrets)
|
133
133
|
else
|
134
|
-
Sem::Views::Projects.
|
134
|
+
Sem::Views::Projects.attach_first_secret(project)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
-
desc "add", "attach a
|
138
|
+
desc "add", "attach a secret to a project"
|
139
139
|
long_desc <<-DESC
|
140
140
|
Examples:
|
141
141
|
|
142
|
-
$ sem projects:
|
143
|
-
|
142
|
+
$ sem projects:secrets:add renderedtext/cli renderedtext/secrets
|
143
|
+
Secret renderedtext/secrets added to the project.
|
144
144
|
DESC
|
145
|
-
def add(project_name,
|
145
|
+
def add(project_name, secret_name)
|
146
146
|
project = Sem::API::Project.find!(project_name)
|
147
|
-
|
147
|
+
secret = Sem::API::Secret.find!(secret_name)
|
148
148
|
|
149
|
-
project.
|
149
|
+
project.add_secret(secret)
|
150
150
|
|
151
|
-
|
152
|
-
shared_config.files.each { |file| project.add_config_file(file) }
|
153
|
-
|
154
|
-
puts "Shared Configuration #{shared_config_name} added to the project."
|
151
|
+
puts "Secret #{secret_name} added to the project."
|
155
152
|
end
|
156
153
|
|
157
|
-
desc "remove", "removes a
|
154
|
+
desc "remove", "removes a secret from the project"
|
158
155
|
long_desc <<-DESC
|
159
156
|
Examples:
|
160
157
|
|
161
|
-
$ sem projects:
|
162
|
-
|
158
|
+
$ sem projects:secrets:remove renderedtext/cli renderedtext/secrets
|
159
|
+
Secret renderedtext/secrets removed from the project.
|
163
160
|
DESC
|
164
|
-
def remove(project_name,
|
161
|
+
def remove(project_name, secret_name)
|
165
162
|
project = Sem::API::Project.find!(project_name)
|
166
|
-
|
163
|
+
secret = Sem::API::Secret.find!(secret_name)
|
167
164
|
|
168
|
-
project.
|
165
|
+
project.remove_secret(secret)
|
169
166
|
|
170
|
-
puts "
|
167
|
+
puts "Secret #{secret_name} removed from the project."
|
171
168
|
end
|
172
169
|
|
173
170
|
end
|
174
171
|
|
175
|
-
register "
|
172
|
+
register "secrets", "manage secrets", Secrets
|
176
173
|
register "files", "manage projects' config files", Files
|
177
174
|
register "env-vars", "manage projects' environment variables", EnvVars
|
178
175
|
end
|
@@ -0,0 +1,220 @@
|
|
1
|
+
class Sem::CLI::Secrets < Dracula
|
2
|
+
|
3
|
+
desc "list", "list secrets"
|
4
|
+
long_desc <<-DESC
|
5
|
+
Examples:
|
6
|
+
|
7
|
+
$ sem secrets:list
|
8
|
+
ID NAME CONFIG FILES ENV VARS
|
9
|
+
99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/tokens 1 0
|
10
|
+
1133ed43-ac8a-487e-b488-c38bc757a044 renderedtext/secrets 0 1
|
11
|
+
DESC
|
12
|
+
def list
|
13
|
+
secrets = Sem::API::Secret.all
|
14
|
+
|
15
|
+
if !secrets.empty?
|
16
|
+
Sem::Views::Secrets.list(secrets)
|
17
|
+
else
|
18
|
+
Sem::Views::Secrets.setup_first_secrets
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "info", "show information about secrets"
|
23
|
+
long_desc <<-DESC
|
24
|
+
Examples:
|
25
|
+
|
26
|
+
$ sem secrets:info renderedtext/tokens
|
27
|
+
ID 99c7ed43-ac8a-487e-b488-c38bc757a034
|
28
|
+
Name renderedtext/tokens
|
29
|
+
Config Files 1
|
30
|
+
Environment Variables 0
|
31
|
+
Created 2017-08-01 13:14:40 +0200
|
32
|
+
Updated 2017-08-02 13:14:40 +0200
|
33
|
+
DESC
|
34
|
+
def info(secret_name)
|
35
|
+
secret = Sem::API::Secret.find!(secret_name)
|
36
|
+
|
37
|
+
Sem::Views::Secrets.info(secret)
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "create", "create new secrets"
|
41
|
+
long_desc <<-DESC
|
42
|
+
Examples:
|
43
|
+
|
44
|
+
$ sem secrets:create renderedtext/tokens
|
45
|
+
ID 99c7ed43-ac8a-487e-b488-c38bc757a034
|
46
|
+
Name renderedtext/tokens
|
47
|
+
Config Files 1
|
48
|
+
Environment Variables 0
|
49
|
+
Created 2017-08-01 13:14:40 +0200
|
50
|
+
Updated 2017-08-02 13:14:40 +0200
|
51
|
+
DESC
|
52
|
+
def create(secret_name)
|
53
|
+
secret = Sem::API::Secret.create!(secret_name)
|
54
|
+
|
55
|
+
Sem::Views::Secrets.info(secret)
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "rename", "rename secrets"
|
59
|
+
long_desc <<-DESC
|
60
|
+
Examples:
|
61
|
+
|
62
|
+
$ sem secrets:create renderedtext/tokens renderedtext/psst
|
63
|
+
ID 99c7ed43-ac8a-487e-b488-c38bc757a034
|
64
|
+
Name renderedtext/psst
|
65
|
+
Config Files 1
|
66
|
+
Environment Variables 0
|
67
|
+
Created 2017-08-01 13:14:40 +0200
|
68
|
+
Updated 2017-08-02 13:14:40 +0200
|
69
|
+
DESC
|
70
|
+
def rename(old_secrets_name, new_secrets_name)
|
71
|
+
old_org_name, _old_name = Sem::SRN.parse_secret(old_secrets_name)
|
72
|
+
new_org_name, new_name = Sem::SRN.parse_secret(new_secrets_name)
|
73
|
+
|
74
|
+
abort "Secrets can't change their organization" unless new_org_name == old_org_name
|
75
|
+
|
76
|
+
secret = Sem::API::Secret.find!(old_secrets_name)
|
77
|
+
secret = secret.update!(:name => new_name)
|
78
|
+
|
79
|
+
Sem::Views::Secrets.info(secret)
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "delete", "removes secrets from your organization"
|
83
|
+
long_desc <<-DESC
|
84
|
+
Examples:
|
85
|
+
|
86
|
+
$ sem secrets:delete renderedtext/tokens
|
87
|
+
Deleted secret renderedtext/tokens.
|
88
|
+
DESC
|
89
|
+
def delete(secrets_name)
|
90
|
+
secret = Sem::API::Secret.find!(secrets_name)
|
91
|
+
secret.delete!
|
92
|
+
|
93
|
+
puts "Deleted secret #{secrets_name}."
|
94
|
+
end
|
95
|
+
|
96
|
+
class Files < Dracula
|
97
|
+
|
98
|
+
desc "list", "list files in secrets"
|
99
|
+
long_desc <<-DESC
|
100
|
+
Examples:
|
101
|
+
|
102
|
+
$ sem secrets:files:list renderedtext/tokens
|
103
|
+
ID PATH ENCRYPTED?
|
104
|
+
77c7ed43-ac8a-487e-b488-c38bc757a034 /home/runner/a true
|
105
|
+
11c7ed43-bc8a-a87e-ba88-a38ba757a034 /home/runner/secrets.txt true
|
106
|
+
DESC
|
107
|
+
def list(secret_name)
|
108
|
+
secret = Sem::API::Secret.find!(secret_name)
|
109
|
+
files = secret.files
|
110
|
+
|
111
|
+
if !files.empty?
|
112
|
+
Sem::Views::Files.list(files)
|
113
|
+
else
|
114
|
+
Sem::Views::Secrets.add_first_file(secret)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
desc "add", "add a file to secrets"
|
119
|
+
option "path-on-semaphore", :aliases => "p", :desc => "Path of the file in builds relative to /home/runner directory", :required => true
|
120
|
+
option "local-path", :aliases => "l", :desc => "Location of the file on the local machine", :required => true
|
121
|
+
long_desc <<-DESC
|
122
|
+
Examples:
|
123
|
+
|
124
|
+
$ sem secrets:files:add renderedtext/tokens --local-path /tmp/secrets.json --path-on-semaphore secrets.json
|
125
|
+
Added /home/runner/secrets.txt to renderedtext/secrets.
|
126
|
+
DESC
|
127
|
+
def add(secrets_name)
|
128
|
+
secret = Sem::API::Secret.find!(secrets_name)
|
129
|
+
|
130
|
+
local_path = options["local-path"]
|
131
|
+
|
132
|
+
abort "File #{local_path} not found" unless File.exist?(local_path)
|
133
|
+
|
134
|
+
path = options["path-on-semaphore"]
|
135
|
+
content = File.read(local_path)
|
136
|
+
|
137
|
+
secret.add_config_file(:path => path, :content => content, :encrypted => true)
|
138
|
+
|
139
|
+
puts "Added /home/runner/#{path} to #{secrets_name}."
|
140
|
+
end
|
141
|
+
|
142
|
+
desc "remove", "remove a file from secrets"
|
143
|
+
option :path, :aliases => "p", :desc => "Path of the file in builds relative to /home/runner directory", :required => true
|
144
|
+
long_desc <<-DESC
|
145
|
+
Examples:
|
146
|
+
|
147
|
+
$ sem secrets:files:remove renderedtext/secrets --path secrets.json
|
148
|
+
Removed /home/runner/secrets.txt from renderedtext/secrets.
|
149
|
+
DESC
|
150
|
+
def remove(secrets_name)
|
151
|
+
secret = Sem::API::Secret.find!(secrets_name)
|
152
|
+
|
153
|
+
secret.remove_config_file(options[:path])
|
154
|
+
|
155
|
+
puts "Removed /home/runner/#{options[:path]} from #{secrets_name}."
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
class EnvVars < Dracula
|
161
|
+
|
162
|
+
desc "list", "list environment variables in secrets"
|
163
|
+
long_desc <<-DESC
|
164
|
+
Examples:
|
165
|
+
|
166
|
+
$ sem secrets:files:list renderedtext/tokens
|
167
|
+
ID NAME ENCRYPTED? CONTENT
|
168
|
+
9997ed43-ac8a-487e-b488-c38bc757a034 SECRET true aaa
|
169
|
+
1117ed43-tc8a-387e-6488-838bc757a034 TOKEN true *encrypted*
|
170
|
+
DESC
|
171
|
+
def list(secret_name)
|
172
|
+
secret = Sem::API::Secret.find!(secret_name)
|
173
|
+
env_vars = secret.env_vars
|
174
|
+
|
175
|
+
if !env_vars.empty?
|
176
|
+
Sem::Views::EnvVars.list(env_vars)
|
177
|
+
else
|
178
|
+
Sem::Views::Secrets.add_first_env_var(secret)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
desc "add", "add an environment variable to secrets"
|
183
|
+
option :name, :aliases => "n", :desc => "Name of the variable", :required => true
|
184
|
+
option :content, :aliases => "c", :desc => "Content of the variable", :required => true
|
185
|
+
long_desc <<-DESC
|
186
|
+
Examples:
|
187
|
+
|
188
|
+
$ sem secrets:env-vars:add renderedtext/secrets --name TOKEN --content "s3cr3t"
|
189
|
+
Added TOKEN to renderedtext/secrets.
|
190
|
+
DESC
|
191
|
+
def add(secret_name)
|
192
|
+
secret = Sem::API::Secret.find!(secret_name)
|
193
|
+
|
194
|
+
secret.add_env_var(:name => options[:name], :content => options[:content], :encrypted => true)
|
195
|
+
|
196
|
+
puts "Added #{options[:name]} to #{secret_name}."
|
197
|
+
end
|
198
|
+
|
199
|
+
desc "remove", "remove an environment variable from secrets"
|
200
|
+
option :name, :aliases => "n", :desc => "Name of the variable", :required => true
|
201
|
+
long_desc <<-DESC
|
202
|
+
Examples:
|
203
|
+
|
204
|
+
$ sem secrets:env-vars:remove renderedtext/secrets --name TOKEN
|
205
|
+
Removed TOKEN from renderedtext/secrets.
|
206
|
+
DESC
|
207
|
+
def remove(secrets_name)
|
208
|
+
secret = Sem::API::Secret.find!(secrets_name)
|
209
|
+
name = options[:name]
|
210
|
+
|
211
|
+
secret.remove_env_var(name)
|
212
|
+
|
213
|
+
puts "Removed #{name} from #{secrets_name}"
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
|
218
|
+
register "files", "manage files", Files
|
219
|
+
register "env-vars", "manage environment variables", EnvVars
|
220
|
+
end
|
data/lib/sem/cli/teams.rb
CHANGED
@@ -255,61 +255,61 @@ DESC
|
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
258
|
-
class
|
259
|
-
desc "list", "list
|
258
|
+
class Secrets < Dracula
|
259
|
+
desc "list", "list secrets in a team"
|
260
260
|
long_desc <<-DESC
|
261
261
|
Examples:
|
262
262
|
|
263
|
-
$ sem team:
|
263
|
+
$ sem team:secrets:list renderedtext/devs
|
264
264
|
ID NAME CONFIG FILES ENV VARS
|
265
265
|
99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/tokens 1 0
|
266
266
|
1133ed43-ac8a-487e-b488-c38bc757a044 renderedtext/secrets 0 1
|
267
267
|
DESC
|
268
268
|
def list(team_name)
|
269
269
|
team = Sem::API::Team.find!(team_name)
|
270
|
-
configs = team.
|
270
|
+
configs = team.secrets
|
271
271
|
|
272
272
|
if !configs.empty?
|
273
|
-
Sem::Views::
|
273
|
+
Sem::Views::Secrets.list(configs)
|
274
274
|
else
|
275
|
-
Sem::Views::Teams.
|
275
|
+
Sem::Views::Teams.add_first_secrets(team)
|
276
276
|
end
|
277
277
|
end
|
278
278
|
|
279
|
-
desc "add", "add
|
279
|
+
desc "add", "add secrets to a team"
|
280
280
|
long_desc <<-DESC
|
281
281
|
Examples:
|
282
282
|
|
283
|
-
$ sem team:
|
284
|
-
|
283
|
+
$ sem team:secrets:add renderedtext/devs renderedtext/tokens
|
284
|
+
Secrets renderedtext/token added to the team.
|
285
285
|
DESC
|
286
|
-
def add(team_name,
|
286
|
+
def add(team_name, secret_name)
|
287
287
|
team = Sem::API::Team.find!(team_name)
|
288
|
-
|
288
|
+
secret = Sem::API::Secret.find!(secret_name)
|
289
289
|
|
290
|
-
team.
|
290
|
+
team.add_secret(secret)
|
291
291
|
|
292
|
-
puts "
|
292
|
+
puts "Secrets #{secret_name} added to the team."
|
293
293
|
end
|
294
294
|
|
295
|
-
desc "remove", "removes
|
295
|
+
desc "remove", "removes secrets from the team"
|
296
296
|
long_desc <<-DESC
|
297
297
|
Examples:
|
298
298
|
|
299
|
-
$ sem team:
|
300
|
-
|
299
|
+
$ sem team:secrets:remove renderedtext/devs renderedtext/secrets
|
300
|
+
Secrets renderedtext/secrets removed from the team.
|
301
301
|
DESC
|
302
|
-
def remove(team_name,
|
302
|
+
def remove(team_name, secret_name)
|
303
303
|
team = Sem::API::Team.find!(team_name)
|
304
|
-
|
304
|
+
secret = Sem::API::Secret.find!(secret_name)
|
305
305
|
|
306
|
-
team.
|
306
|
+
team.remove_secret(secret)
|
307
307
|
|
308
|
-
puts "
|
308
|
+
puts "Secrets #{secret_name} removed from the team."
|
309
309
|
end
|
310
310
|
end
|
311
311
|
|
312
312
|
register "members", "manage team members", Members
|
313
313
|
register "projects", "manage team members", Projects
|
314
|
-
register "
|
314
|
+
register "secrets", "manage secrets", Secrets
|
315
315
|
end
|
data/lib/sem/cli.rb
CHANGED
@@ -5,7 +5,7 @@ module Sem
|
|
5
5
|
require_relative "cli/orgs"
|
6
6
|
require_relative "cli/projects"
|
7
7
|
require_relative "cli/teams"
|
8
|
-
require_relative "cli/
|
8
|
+
require_relative "cli/secrets"
|
9
9
|
|
10
10
|
desc "version", "Display CLI version"
|
11
11
|
def version
|
@@ -49,7 +49,7 @@ DESC
|
|
49
49
|
|
50
50
|
register "orgs", "manage organizations", Sem::CLI::Orgs
|
51
51
|
register "teams", "manage teams and team membership", Sem::CLI::Teams
|
52
|
-
register "
|
52
|
+
register "secrets", "manage secrets", Sem::CLI::Secrets
|
53
53
|
register "projects", "manage projects", Sem::CLI::Projects
|
54
54
|
end
|
55
55
|
end
|
data/lib/sem/srn.rb
CHANGED
@@ -14,8 +14,8 @@ class Sem::SRN
|
|
14
14
|
parse_srn(semaphore_resource_name, "org_name/project_name")
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
parse_srn(semaphore_resource_name, "org_name/
|
17
|
+
def parse_secret(semaphore_resource_name)
|
18
|
+
parse_srn(semaphore_resource_name, "org_name/secret_name")
|
19
19
|
end
|
20
20
|
|
21
21
|
def parse_user(semaphore_resource_name)
|
data/lib/sem/version.rb
CHANGED
data/lib/sem/views/projects.rb
CHANGED
@@ -26,12 +26,12 @@ class Sem::Views::Projects < Sem::Views::Base
|
|
26
26
|
]
|
27
27
|
end
|
28
28
|
|
29
|
-
def self.
|
30
|
-
puts "You don't have any
|
29
|
+
def self.attach_first_secret(project)
|
30
|
+
puts "You don't have any secrets on this project."
|
31
31
|
puts ""
|
32
|
-
puts "Add your first
|
32
|
+
puts "Add your first secret:"
|
33
33
|
puts ""
|
34
|
-
puts " sem projects:
|
34
|
+
puts " sem projects:secrets:add #{project.full_name} SECRETS_NAME"
|
35
35
|
puts ""
|
36
36
|
end
|
37
37
|
|