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
@@ -0,0 +1,51 @@
|
|
1
|
+
class Sem::Views::Secrets < Sem::Views::Base
|
2
|
+
|
3
|
+
def self.setup_first_secrets
|
4
|
+
puts "You don't have any secrets on Semaphore."
|
5
|
+
puts ""
|
6
|
+
puts "Create your first secrets:"
|
7
|
+
puts ""
|
8
|
+
puts " sem secrets:create SECRETS_NAME"
|
9
|
+
puts ""
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.list(secrets)
|
13
|
+
header = ["ID", "NAME", "CONFIG FILES", "ENV VARS"]
|
14
|
+
|
15
|
+
body = secrets.map do |secret|
|
16
|
+
[secret.id, secret.full_name, secret.files.count, secret.env_vars.count]
|
17
|
+
end
|
18
|
+
|
19
|
+
print_table [header, *body]
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.info(secret)
|
23
|
+
print_table [
|
24
|
+
["ID", secret.id],
|
25
|
+
["Name", secret.full_name],
|
26
|
+
["Config Files", secret.files.count.to_s],
|
27
|
+
["Environment Variables", secret.env_vars.count.to_s],
|
28
|
+
["Created", secret.created_at],
|
29
|
+
["Updated", secret.updated_at]
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.add_first_file(secret)
|
34
|
+
puts "You don't have any files in these secrets"
|
35
|
+
puts ""
|
36
|
+
puts "Add your first file:"
|
37
|
+
puts ""
|
38
|
+
puts " sem secrets:files:add #{secret.full_name} --local-path <file> --path-on-semaphore <path>"
|
39
|
+
puts ""
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.add_first_env_var(secret)
|
43
|
+
puts "You don't have any environment variable in these secrets"
|
44
|
+
puts ""
|
45
|
+
puts "Add your first environment variable:"
|
46
|
+
puts ""
|
47
|
+
puts " sem secrets:env-vars:add #{secret.full_name} --local-path <file> --path-on-semaphore <path>"
|
48
|
+
puts ""
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/lib/sem/views/teams.rb
CHANGED
@@ -47,12 +47,12 @@ class Sem::Views::Teams < Sem::Views::Base
|
|
47
47
|
puts ""
|
48
48
|
end
|
49
49
|
|
50
|
-
def self.
|
51
|
-
puts "You don't have any
|
50
|
+
def self.add_first_secrets(team)
|
51
|
+
puts "You don't have any secrets in this team."
|
52
52
|
puts ""
|
53
|
-
puts "Add your first
|
53
|
+
puts "Add your first secrets:"
|
54
54
|
puts ""
|
55
|
-
puts " sem teams:
|
55
|
+
puts " sem teams:secrets:add #{team.full_name} SECRET_NAME"
|
56
56
|
puts ""
|
57
57
|
end
|
58
58
|
end
|
data/lib/sem/views.rb
CHANGED
data/sem.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "semaphore_client", "
|
24
|
+
spec.add_dependency "semaphore_client", "3.0.2"
|
25
25
|
spec.add_dependency "dracula", "~> 0.6.0"
|
26
26
|
spec.add_dependency "pmap", "~> 1.1.1"
|
27
27
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Šarčević
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semaphore_client
|
@@ -16,96 +16,96 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dracula
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.6.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.6.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pmap
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 1.1.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.1.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.14'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.14'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '10.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '10.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '3.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rubocop
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 0.47.1
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.47.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
@@ -126,56 +126,56 @@ dependencies:
|
|
126
126
|
name: simplecov
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0.13'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - ~>
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0.13'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: byebug
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - ~>
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: 9.0.0
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - ~>
|
150
|
+
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 9.0.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: public_suffix
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - ~>
|
157
|
+
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: 2.0.5
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - ~>
|
164
|
+
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 2.0.5
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: webmock
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- - ~>
|
171
|
+
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: 3.0.1
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- - ~>
|
178
|
+
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: 3.0.1
|
181
181
|
description: Semaphore CLI
|
@@ -186,9 +186,9 @@ executables:
|
|
186
186
|
extensions: []
|
187
187
|
extra_rdoc_files: []
|
188
188
|
files:
|
189
|
-
- .gitignore
|
190
|
-
- .rspec
|
191
|
-
- .rubocop.yml
|
189
|
+
- ".gitignore"
|
190
|
+
- ".rspec"
|
191
|
+
- ".rubocop.yml"
|
192
192
|
- Gemfile
|
193
193
|
- README.md
|
194
194
|
- Rakefile
|
@@ -205,13 +205,13 @@ files:
|
|
205
205
|
- lib/sem/api/file.rb
|
206
206
|
- lib/sem/api/org.rb
|
207
207
|
- lib/sem/api/project.rb
|
208
|
-
- lib/sem/api/
|
208
|
+
- lib/sem/api/secret.rb
|
209
209
|
- lib/sem/api/team.rb
|
210
210
|
- lib/sem/api/user.rb
|
211
211
|
- lib/sem/cli.rb
|
212
212
|
- lib/sem/cli/orgs.rb
|
213
213
|
- lib/sem/cli/projects.rb
|
214
|
-
- lib/sem/cli/
|
214
|
+
- lib/sem/cli/secrets.rb
|
215
215
|
- lib/sem/cli/teams.rb
|
216
216
|
- lib/sem/configuration.rb
|
217
217
|
- lib/sem/errors.rb
|
@@ -225,7 +225,7 @@ files:
|
|
225
225
|
- lib/sem/views/files.rb
|
226
226
|
- lib/sem/views/orgs.rb
|
227
227
|
- lib/sem/views/projects.rb
|
228
|
-
- lib/sem/views/
|
228
|
+
- lib/sem/views/secrets.rb
|
229
229
|
- lib/sem/views/teams.rb
|
230
230
|
- lib/sem/views/users.rb
|
231
231
|
- sem.gemspec
|
@@ -239,17 +239,17 @@ require_paths:
|
|
239
239
|
- lib
|
240
240
|
required_ruby_version: !ruby/object:Gem::Requirement
|
241
241
|
requirements:
|
242
|
-
- -
|
242
|
+
- - ">="
|
243
243
|
- !ruby/object:Gem::Version
|
244
244
|
version: '0'
|
245
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
246
246
|
requirements:
|
247
|
-
- -
|
247
|
+
- - ">="
|
248
248
|
- !ruby/object:Gem::Version
|
249
249
|
version: '0'
|
250
250
|
requirements: []
|
251
251
|
rubyforge_project:
|
252
|
-
rubygems_version: 2.
|
252
|
+
rubygems_version: 2.5.2
|
253
253
|
signing_key:
|
254
254
|
specification_version: 4
|
255
255
|
summary: Semaphore CLI
|
@@ -1,109 +0,0 @@
|
|
1
|
-
class Sem::API::SharedConfig < SimpleDelegator
|
2
|
-
extend Sem::API::Base
|
3
|
-
|
4
|
-
def self.all
|
5
|
-
Sem::API::Org.all.pmap(&:shared_configs).flatten
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.find!(shared_config_srn)
|
9
|
-
org_name, shared_config_name = Sem::SRN.parse_shared_config(shared_config_srn)
|
10
|
-
|
11
|
-
configs = client.shared_configs.list_for_org!(org_name)
|
12
|
-
config = configs.find { |c| c.name == shared_config_name }
|
13
|
-
|
14
|
-
if config.nil?
|
15
|
-
raise Sem::Errors::ResourceNotFound.new("Shared Configuration", [org_name, shared_config_name])
|
16
|
-
end
|
17
|
-
|
18
|
-
new(org_name, config)
|
19
|
-
rescue SemaphoreClient::Exceptions::NotFound
|
20
|
-
raise Sem::Errors::ResourceNotFound.new("Shared Configuration", [org_name, shared_config_name])
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.create!(shared_config_srn, args = {})
|
24
|
-
org_name, shared_config_name = Sem::SRN.parse_shared_config(shared_config_srn)
|
25
|
-
|
26
|
-
shared_config = client.shared_configs.create_for_org!(org_name, args.merge(:name => shared_config_name))
|
27
|
-
|
28
|
-
if shared_config.nil?
|
29
|
-
raise Sem::Errors::ResourceNotCreated.new("Shared Configuration", [org_name, shared_config_name])
|
30
|
-
end
|
31
|
-
|
32
|
-
new(org_name, shared_config)
|
33
|
-
end
|
34
|
-
|
35
|
-
attr_reader :org_name
|
36
|
-
|
37
|
-
def initialize(org_name, shared_config)
|
38
|
-
@org_name = org_name
|
39
|
-
|
40
|
-
super(shared_config)
|
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_shared_config!(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_shared_config!(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
|
-
shared_config = Sem::API::Base.client.shared_configs.update!(id, args)
|
89
|
-
|
90
|
-
if shared_config.nil?
|
91
|
-
raise Sem::Errors::ResourceNotUpdated.new("Shared Configuration", [org_name, name])
|
92
|
-
end
|
93
|
-
|
94
|
-
self.class.new(org_name, shared_config)
|
95
|
-
end
|
96
|
-
|
97
|
-
def delete!
|
98
|
-
Sem::API::Base.client.shared_configs.delete!(id)
|
99
|
-
end
|
100
|
-
|
101
|
-
def files
|
102
|
-
Sem::API::Base.client.config_files.list_for_shared_config!(id).map { |file| Sem::API::File.new(file) }
|
103
|
-
end
|
104
|
-
|
105
|
-
def env_vars
|
106
|
-
Sem::API::Base.client.env_vars.list_for_shared_config!(id).map { |env_var| Sem::API::EnvVar.new(env_var) }
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
@@ -1,220 +0,0 @@
|
|
1
|
-
class Sem::CLI::SharedConfigs < Dracula
|
2
|
-
|
3
|
-
desc "list", "list shared cofigurations"
|
4
|
-
long_desc <<-DESC
|
5
|
-
Examples:
|
6
|
-
|
7
|
-
$ sem shared-configs: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
|
-
shared_configs = Sem::API::SharedConfig.all
|
14
|
-
|
15
|
-
if !shared_configs.empty?
|
16
|
-
Sem::Views::SharedConfigs.list(shared_configs)
|
17
|
-
else
|
18
|
-
Sem::Views::SharedConfigs.setup_first_shared_config
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
desc "info", "show information about a shared configuration"
|
23
|
-
long_desc <<-DESC
|
24
|
-
Examples:
|
25
|
-
|
26
|
-
$ sem shared-configs:info renderedtext/secrets
|
27
|
-
ID 99c7ed43-ac8a-487e-b488-c38bc757a034
|
28
|
-
Name renderedtext/secrets
|
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(shared_config_name)
|
35
|
-
shared_config = Sem::API::SharedConfig.find!(shared_config_name)
|
36
|
-
|
37
|
-
Sem::Views::SharedConfigs.info(shared_config)
|
38
|
-
end
|
39
|
-
|
40
|
-
desc "create", "create a new shared configuration"
|
41
|
-
long_desc <<-DESC
|
42
|
-
Examples:
|
43
|
-
|
44
|
-
$ sem shared-configs:create renderedtext/secrets
|
45
|
-
ID 99c7ed43-ac8a-487e-b488-c38bc757a034
|
46
|
-
Name renderedtext/secrets
|
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(shared_config_name)
|
53
|
-
shared_config = Sem::API::SharedConfig.create!(shared_config_name)
|
54
|
-
|
55
|
-
Sem::Views::SharedConfigs.info(shared_config)
|
56
|
-
end
|
57
|
-
|
58
|
-
desc "rename", "rename a shared configuration"
|
59
|
-
long_desc <<-DESC
|
60
|
-
Examples:
|
61
|
-
|
62
|
-
$ sem shared-configs:create renderedtext/secrets 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_shared_config_name, new_shared_config_name)
|
71
|
-
old_org_name, _old_name = Sem::SRN.parse_shared_config(old_shared_config_name)
|
72
|
-
new_org_name, new_name = Sem::SRN.parse_shared_config(new_shared_config_name)
|
73
|
-
|
74
|
-
abort "Shared Configuration can't change its organization" unless new_org_name == old_org_name
|
75
|
-
|
76
|
-
shared_config = Sem::API::SharedConfig.find!(old_shared_config_name)
|
77
|
-
shared_config = shared_config.update!(:name => new_name)
|
78
|
-
|
79
|
-
Sem::Views::SharedConfigs.info(shared_config)
|
80
|
-
end
|
81
|
-
|
82
|
-
desc "delete", "removes a shared configuration from your organization"
|
83
|
-
long_desc <<-DESC
|
84
|
-
Examples:
|
85
|
-
|
86
|
-
$ sem shared-configs:delete renderedtext/secrets
|
87
|
-
Deleted shared configuration renderedtext/secrets.
|
88
|
-
DESC
|
89
|
-
def delete(shared_config_name)
|
90
|
-
shared_config = Sem::API::SharedConfig.find!(shared_config_name)
|
91
|
-
shared_config.delete!
|
92
|
-
|
93
|
-
puts "Deleted shared configuration #{shared_config_name}."
|
94
|
-
end
|
95
|
-
|
96
|
-
class Files < Dracula
|
97
|
-
|
98
|
-
desc "list", "list files in a shared configuration"
|
99
|
-
long_desc <<-DESC
|
100
|
-
Examples:
|
101
|
-
|
102
|
-
$ sem shared-configs:files:list renderedtext/secrets
|
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(shared_config_name)
|
108
|
-
shared_config = Sem::API::SharedConfig.find!(shared_config_name)
|
109
|
-
files = shared_config.files
|
110
|
-
|
111
|
-
if !files.empty?
|
112
|
-
Sem::Views::Files.list(files)
|
113
|
-
else
|
114
|
-
Sem::Views::SharedConfigs.add_first_file(shared_config)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
desc "add", "add a file to the shared configuration"
|
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 shared-configs:files:add renderedtext/secrets --local-path /tmp/secrets.json --path-on-semaphore secrets.json
|
125
|
-
Added /home/runner/secrets.txt to renderedtext/secrets.
|
126
|
-
DESC
|
127
|
-
def add(shared_config_name)
|
128
|
-
shared_config = Sem::API::SharedConfig.find!(shared_config_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
|
-
shared_config.add_config_file(:path => path, :content => content, :encrypted => true)
|
138
|
-
|
139
|
-
puts "Added /home/runner/#{path} to #{shared_config_name}."
|
140
|
-
end
|
141
|
-
|
142
|
-
desc "remove", "remove a file from the shared configuration"
|
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 shared-configs:files:remove renderedtext/secrets --path secrets.json
|
148
|
-
Removed /home/runner/secrets.txt from renderedtext/secrets.
|
149
|
-
DESC
|
150
|
-
def remove(shared_config_name)
|
151
|
-
shared_config = Sem::API::SharedConfig.find!(shared_config_name)
|
152
|
-
|
153
|
-
shared_config.remove_config_file(options[:path])
|
154
|
-
|
155
|
-
puts "Removed /home/runner/#{options[:path]} from #{shared_config_name}."
|
156
|
-
end
|
157
|
-
|
158
|
-
end
|
159
|
-
|
160
|
-
class EnvVars < Dracula
|
161
|
-
|
162
|
-
desc "list", "list environment variables in the shared configuration"
|
163
|
-
long_desc <<-DESC
|
164
|
-
Examples:
|
165
|
-
|
166
|
-
$ sem shared-configs:files:list renderedtext/secrets
|
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(shared_config_name)
|
172
|
-
shared_config = Sem::API::SharedConfig.find!(shared_config_name)
|
173
|
-
env_vars = shared_config.env_vars
|
174
|
-
|
175
|
-
if !env_vars.empty?
|
176
|
-
Sem::Views::EnvVars.list(env_vars)
|
177
|
-
else
|
178
|
-
Sem::Views::SharedConfigs.add_first_env_var(shared_config)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
desc "add", "add an environment variable to the shared configuration"
|
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 shared-configs:env-vars:add renderedtext/secrets --name TOKEN --content "s3cr3t"
|
189
|
-
Added TOKEN to renderedtext/secrets.
|
190
|
-
DESC
|
191
|
-
def add(shared_config_name)
|
192
|
-
shared_config = Sem::API::SharedConfig.find!(shared_config_name)
|
193
|
-
|
194
|
-
shared_config.add_env_var(:name => options[:name], :content => options[:content], :encrypted => true)
|
195
|
-
|
196
|
-
puts "Added #{options[:name]} to #{shared_config_name}."
|
197
|
-
end
|
198
|
-
|
199
|
-
desc "remove", "remove an environment variable from the shared configuration"
|
200
|
-
option :name, :aliases => "n", :desc => "Name of the variable", :required => true
|
201
|
-
long_desc <<-DESC
|
202
|
-
Examples:
|
203
|
-
|
204
|
-
$ sem shared-configs:env-vars:remove renderedtext/secrets --name TOKEN
|
205
|
-
Removed TOKEN from renderedtext/secrets.
|
206
|
-
DESC
|
207
|
-
def remove(shared_config_name)
|
208
|
-
shared_config = Sem::API::SharedConfig.find!(shared_config_name)
|
209
|
-
name = options[:name]
|
210
|
-
|
211
|
-
shared_config.remove_env_var(name)
|
212
|
-
|
213
|
-
puts "Removed #{name} from #{shared_config_name}"
|
214
|
-
end
|
215
|
-
|
216
|
-
end
|
217
|
-
|
218
|
-
register "files", "manage files", Files
|
219
|
-
register "env-vars", "manage environment variables", EnvVars
|
220
|
-
end
|