conjur-asset-environment-api 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3ef433aab03a250b06d20fcb589b130a207fab6b
4
+ data.tar.gz: 23f308b7c7b68c14c5048941ed2f617299fba703
5
+ SHA512:
6
+ metadata.gz: e4e27b6fee4f09d9bce303b808aaac543f8fd7bf58ec9e030f7d1ece3078691ed8741ec3f6092fbfea66242eade57f6a4dc243972767dd6e8824c3482129b3ab
7
+ data.tar.gz: 252b16f16e292cbfdc27353c522e67b2c4deb4601d52d373924f460188452c33fb7f7850dcb19b833c2825da38826eadd4c4a03080aa1e8a08bae1bceb32035a
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ spec/dummy/log
16
+ spec/dummy/tmp
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in conjur-asset-environment.gemspec
4
+ gemspec
5
+
6
+ gem 'rails-api'
7
+ gem 'webmock'
8
+ gem 'rspec-rails'
9
+ gem 'selenium-webdriver'
10
+
11
+ gem 'authable', git: 'https://inscitiv-ops-dev:Me5aswes@github.com/inscitiv/authable.git', branch: 'master'
12
+ gem 'conjur-api', git: 'https://github.com/inscitiv/api-ruby.git', branch: 'master'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Kevin Gilpin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Conjur::Asset::Environment
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'conjur-asset-environment'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install conjur-asset-environment
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,51 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'conjur-asset-environment-version'
5
+
6
+ files = if ENV['API_ONLY']
7
+ exclude_dirs = [ ".project", ".rvmrc", "lib/conjur/asset", "config", "db", "features", "spec", "app" ]
8
+ `git ls-files`.split("\n").select do |f|
9
+ exclude_dirs.find{|d| f.index(d) == 0}.nil?
10
+ end.tap do |files|
11
+ puts "Packaging #{files.join(" ")}"
12
+ end
13
+ else
14
+ `git ls-files`.split($/)
15
+ end
16
+
17
+ name = if ENV['API_ONLY']
18
+ "conjur-asset-environment-api"
19
+ else
20
+ "conjur-asset-environment"
21
+ end
22
+
23
+ Gem::Specification.new do |gem|
24
+ gem.name = name
25
+ gem.version = Conjur::Asset::Environment::VERSION
26
+ gem.authors = ["Kevin Gilpin"]
27
+ gem.email = ["kgilpin@gmail.com"]
28
+ gem.summary = %q{Conjur asset plugin describing environments and variables}
29
+ gem.homepage = ""
30
+
31
+ gem.files = files
32
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
33
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
34
+ gem.require_paths = ["lib"]
35
+
36
+ gem.add_dependency "conjur-api"
37
+
38
+ gem.add_development_dependency "authable"
39
+ gem.add_development_dependency "rails-api"
40
+ gem.add_development_dependency "talentbox-sequel-rails"
41
+ gem.add_development_dependency "pg"
42
+ gem.add_development_dependency "pg_random_id"
43
+ gem.add_development_dependency "sequel-attribute_callbacks"
44
+ gem.add_development_dependency "rspec-rails"
45
+ gem.add_development_dependency "cucumber-rails"
46
+ gem.add_development_dependency "spork"
47
+ gem.add_development_dependency "simplecov"
48
+ gem.add_development_dependency "webmock"
49
+ gem.add_development_dependency "json_spec"
50
+ gem.add_development_dependency "ci_reporter"
51
+ end
@@ -0,0 +1,7 @@
1
+ module Conjur
2
+ module Asset
3
+ module Environment
4
+ VERSION = "0.2.3"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ require "conjur-asset-environment-version"
2
+ require "conjur/api"
3
+ require "conjur/environment-api"
4
+
5
+ require "conjur/asset/environment/cucumber/environment_steps" if defined?(Cucumber)
6
+ require "conjur/asset/environment/engine" if defined?(Rails) && ENV['CONJUR_ASSET_SERVICE']
@@ -0,0 +1,17 @@
1
+ require 'conjur/environment'
2
+
3
+ module Conjur
4
+ class API
5
+ def create_environment(id, options = {})
6
+ standard_create Conjur::Env::API.host, :environment, id, options
7
+ end
8
+
9
+ def environments(options = {})
10
+ standard_list Conjur::Env::API.host, :environment, options
11
+ end
12
+
13
+ def environment id
14
+ standard_show Conjur::Env::API.host, :environment, id
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,83 @@
1
+ require 'conjur/command'
2
+
3
+ class Conjur::Command::Environments < Conjur::Command
4
+ self.prefix = :environment
5
+
6
+ desc "Add a variable to an environment"
7
+ arg_name "environment variable-name variable-id"
8
+ command :"variables:add" do |c|
9
+ c.action do |global_options, options, args|
10
+ id = require_arg(args, 'environment')
11
+ name = require_arg(args, 'variable name')
12
+ variableid = require_arg(args, 'variable id')
13
+
14
+ api.environment(id).add_variable name, variableid
15
+
16
+ puts "Variable added"
17
+ end
18
+ end
19
+
20
+ desc "Creates and adds a variable to an environment"
21
+ arg_name "environment variable-name variable-kind variable-mime-type ( value | STDIN )"
22
+ command :"variables:create" do |c|
23
+ acting_as_option(c)
24
+
25
+ c.action do |global_options, options, args|
26
+ id = require_arg(args, 'environment')
27
+ name = require_arg(args, 'variable name')
28
+ kind = require_arg(args, 'kind')
29
+ mime_type = require_arg(args, 'mime_type')
30
+ value = args.shift || STDIN.read
31
+
32
+ environment = api.environment(id)
33
+ variable = api.create_variable(mime_type, kind, {ownerid: environment.ownerid}.merge(options))
34
+ variable.add_value value
35
+ environment.add_variable name, variable.id
36
+
37
+ puts "Variable created"
38
+ end
39
+ end
40
+
41
+ desc "Adds a value to an environment variable"
42
+ arg_name "environment variable-name ( value | STDIN )"
43
+ command :"variables:update" do |c|
44
+ acting_as_option(c)
45
+
46
+ c.action do |global_options, options, args|
47
+ id = require_arg(args, 'environment')
48
+ name = require_arg(args, 'variable name')
49
+ value = args.shift || STDIN.read
50
+
51
+ api.environment(id).variable(name).add_value value
52
+
53
+ puts "Value updated"
54
+ end
55
+ end
56
+
57
+ desc "Remove a variable from an environment"
58
+ arg_name "environment variable-name"
59
+ command :"variables:remove" do |c|
60
+ c.action do |global_options, options, args|
61
+ id = require_arg(args, 'environment')
62
+ name = require_arg(args, 'variable name')
63
+
64
+ api.environment(id).remove_variable name
65
+
66
+ puts "Variable removed"
67
+ end
68
+ end
69
+
70
+ desc "Show an environment variable value"
71
+ arg_name "environment variable-name"
72
+ command :value do |c|
73
+ c.desc "Version number"
74
+ c.flag [:v, :version]
75
+
76
+ c.action do |global_options, options, args|
77
+ id = require_arg(args, 'environment')
78
+ name = require_arg(args, 'variable name')
79
+
80
+ $stdout.write api.environment(id).variable(name).value(options[:version])
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,13 @@
1
+ module Conjur
2
+ module Env
3
+ class API < Conjur::API
4
+ class << self
5
+ def host
6
+ ENV['CONJUR_ENVIRONMENT_URL'] || Conjur::Core::API.host
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+ require 'conjur/api/environments'
@@ -0,0 +1,38 @@
1
+ module Conjur
2
+ class Environment < RestClient::Resource
3
+ include ActsAsAsset
4
+
5
+ def add_variable(name, variableid)
6
+ log do |logger|
7
+ logger << "Adding variable #{name} = #{variableid} to environment #{id}"
8
+ end
9
+ invalidate do
10
+ RestClient::Resource.new(self['variables'].url, options).post(name: name, variableid: variableid)
11
+ end
12
+ end
13
+
14
+ def remove_variable(name)
15
+ log do |logger|
16
+ logger << "Removing variable #{name} from enviroment #{id}"
17
+ end
18
+ invalidate do
19
+ RestClient::Resource.new(self["variables/#{path_escape name}"].url, self.options).delete
20
+ end
21
+ end
22
+
23
+ def variable(name)
24
+ variableid = attributes['variables'][name]
25
+ raise ArgumentError, "No variable '#{name}' for environment '#{id}'" unless variableid
26
+ Conjur::Variable.new(Conjur::Core::API.host, self.options)["variables/#{variableid}"]
27
+ end
28
+
29
+ def variables
30
+ {}.tap do |result|
31
+ attributes['variables'].inject(result) do |memo,v|
32
+ memo[v[0]] = Conjur::Variable.new(Conjur::Core::API.host, self.options)["variables/#{path_escape v[1]}"]
33
+ memo
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,251 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: conjur-asset-environment-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.3
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Gilpin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: conjur-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: authable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails-api
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: talentbox-sequel-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pg
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pg_random_id
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sequel-attribute_callbacks
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: cucumber-rails
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: spork
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: webmock
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: json_spec
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '>='
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: ci_reporter
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '>='
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '>='
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ description:
210
+ email:
211
+ - kgilpin@gmail.com
212
+ executables: []
213
+ extensions: []
214
+ extra_rdoc_files: []
215
+ files:
216
+ - .gitignore
217
+ - Gemfile
218
+ - LICENSE.txt
219
+ - README.md
220
+ - Rakefile
221
+ - conjur-asset-environment.gemspec
222
+ - lib/conjur-asset-environment-version.rb
223
+ - lib/conjur-asset-environment.rb
224
+ - lib/conjur/api/environments.rb
225
+ - lib/conjur/command/environments.rb
226
+ - lib/conjur/environment-api.rb
227
+ - lib/conjur/environment.rb
228
+ homepage: ''
229
+ licenses: []
230
+ metadata: {}
231
+ post_install_message:
232
+ rdoc_options: []
233
+ require_paths:
234
+ - lib
235
+ required_ruby_version: !ruby/object:Gem::Requirement
236
+ requirements:
237
+ - - '>='
238
+ - !ruby/object:Gem::Version
239
+ version: '0'
240
+ required_rubygems_version: !ruby/object:Gem::Requirement
241
+ requirements:
242
+ - - '>='
243
+ - !ruby/object:Gem::Version
244
+ version: '0'
245
+ requirements: []
246
+ rubyforge_project:
247
+ rubygems_version: 2.0.3
248
+ signing_key:
249
+ specification_version: 4
250
+ summary: Conjur asset plugin describing environments and variables
251
+ test_files: []