trixie 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9fb9e4a817416d5df9d692a6da48f03afc54c429b1956e6b74724739253776e
4
- data.tar.gz: f0cbfc84bccc590573c633fe8a36ee00762fd4d6a94748c928ebb55668730d64
3
+ metadata.gz: fe98b3f0bf37304b30f8128a4d9de6c42db4bbdae41054f1fd4f135003337a64
4
+ data.tar.gz: 4970d509ce2c73acaf0be36d7401179bc5a56461507306bd4789317ada2841e7
5
5
  SHA512:
6
- metadata.gz: d897d133563fc5ce764cb7dda155f58b9822191ae74d24113736626cab6a172acbc15cd316d18d9c43cc2b473a7d1dbf93c0b655acfb7373bf09ec6d67120eda
7
- data.tar.gz: 41c803e3e23ba1a91d2c523b98e95e053ef8a5a00c72f4cbfee3427aa73f7e8a577c57ac5abc72fcc4ca3e9836069c8479a3da016305fe98276a6520f559dd9f
6
+ metadata.gz: 0a1cdb36ed57e082a2bec90c58e0f85d49a84a8ea0a926c0ca90b80e4a71c5b5a4e08431aa2b2c1ed98579b606960543a5d94ee3a2f2255404e7b6436bf68ab6
7
+ data.tar.gz: f65d4e4c2cd6aff21bb9fb4f0a049825ddc5dd148666769c3b4b0107513c08da4817ec232b6074e25cc7315bc36defc30646c14ec85f49b60a95a25366c77294
@@ -0,0 +1,2 @@
1
+ # This owner will be the default owner of everything in the repo.
2
+ * @toptal/devx
data/Gemfile.lock CHANGED
@@ -1,8 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trixie (0.1.1)
4
+ trixie (0.1.3)
5
5
  dry-cli (~> 0.7.0)
6
+ dry-schema (~> 1.10.0)
7
+ dry-validation (~> 1.8.0)
6
8
 
7
9
  GEM
8
10
  remote: https://rubygems.org/
@@ -10,8 +12,43 @@ GEM
10
12
  ast (2.4.2)
11
13
  byebug (11.1.3)
12
14
  coderay (1.1.3)
15
+ concurrent-ruby (1.1.10)
13
16
  diff-lcs (1.5.0)
14
17
  dry-cli (0.7.0)
18
+ dry-configurable (0.16.1)
19
+ dry-core (~> 0.6)
20
+ zeitwerk (~> 2.6)
21
+ dry-container (0.11.0)
22
+ concurrent-ruby (~> 1.0)
23
+ dry-core (0.9.1)
24
+ concurrent-ruby (~> 1.0)
25
+ zeitwerk (~> 2.6)
26
+ dry-inflector (0.3.0)
27
+ dry-initializer (3.1.1)
28
+ dry-logic (1.3.0)
29
+ concurrent-ruby (~> 1.0)
30
+ dry-core (~> 0.9, >= 0.9)
31
+ zeitwerk (~> 2.6)
32
+ dry-schema (1.10.6)
33
+ concurrent-ruby (~> 1.0)
34
+ dry-configurable (~> 0.13, >= 0.13.0)
35
+ dry-core (~> 0.5, >= 0.5)
36
+ dry-initializer (~> 3.0)
37
+ dry-logic (~> 1.2)
38
+ dry-types (~> 1.5)
39
+ dry-types (1.6.1)
40
+ concurrent-ruby (~> 1.0)
41
+ dry-container (~> 0.3)
42
+ dry-core (~> 0.9, >= 0.9)
43
+ dry-inflector (~> 0.1, >= 0.1.2)
44
+ dry-logic (~> 1.3, >= 1.3)
45
+ zeitwerk (~> 2.6)
46
+ dry-validation (1.8.1)
47
+ concurrent-ruby (~> 1.0)
48
+ dry-container (~> 0.7, >= 0.7.1)
49
+ dry-core (~> 0.5, >= 0.5)
50
+ dry-initializer (~> 3.0)
51
+ dry-schema (~> 1.8, >= 1.8.0)
15
52
  json (2.6.2)
16
53
  method_source (1.0.0)
17
54
  parallel (1.22.1)
@@ -54,6 +91,7 @@ GEM
54
91
  parser (>= 3.1.1.0)
55
92
  ruby-progressbar (1.11.0)
56
93
  unicode-display_width (2.2.0)
94
+ zeitwerk (2.6.6)
57
95
 
58
96
  PLATFORMS
59
97
  x86_64-linux
data/README.md CHANGED
@@ -71,8 +71,7 @@ Or install it yourself as:
71
71
 
72
72
  1. Support Multiple Backends/Password Managers, Trixie::Loader can be refactored to be an adapter for the op CLI
73
73
  2. Allow specific Backend options, eg: trixie load --backend op --backend-options '{ "email": "bar@foo.com", "address": "foo.1password.com"}'
74
- 3. Validate the `.trixie.yml`, check if we have the required values for trixie to run
75
- 4. Add a load --cache option, so fetched secrets could be retained for a while without using the Password Manager Backend
74
+ 3. Add a load --cache option, so fetched secrets could be retained for a while without using the Password Manager Backend
76
75
 
77
76
  ## Development
78
77
 
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trixie
4
+ module Contracts
5
+ # class to validate .trixie.yml files
6
+ # Usage:
7
+ # config_contract = Trixie::Contracts::TrixieYml.new
8
+ # result = config_contract.call(config_options)
9
+ # result.sucess?
10
+ # result.errors.to_h
11
+ class TrixieYml < Dry::Validation::Contract
12
+ params do
13
+ required(:secrets).array(:hash) do
14
+ required(:env).filled(:string)
15
+ required(:value).filled(Types::Strict::String | Types::Strict::Bool | Types::Strict::Integer)
16
+ required(:groups).array(:string)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trixie
4
+ module Contracts
5
+ module Types
6
+ include Dry.Types
7
+ end
8
+ end
9
+ end
data/lib/trixie/load.rb CHANGED
@@ -13,6 +13,7 @@ module Trixie
13
13
 
14
14
  def call
15
15
  verify_op_installed!
16
+ verify_secrets_config!
16
17
 
17
18
  create_account unless account_is_configured?
18
19
 
@@ -20,7 +21,13 @@ module Trixie
20
21
  end
21
22
 
22
23
  def verify_op_installed!
23
- raise Trixie::OpCLINotInstalled, OP_NOT_INSTALLED unless system("which op > /dev/null")
24
+ raise Trixie::OpCLINotInstalledError, OP_NOT_INSTALLED unless system("which op > /dev/null")
25
+ end
26
+
27
+ def verify_secrets_config!
28
+ result = Trixie::Contracts::TrixieYml.new.call(secrets_config)
29
+
30
+ raise Trixie::InvalidConfigError, "Invalid .trixie.yml: #{result.errors.to_h}" if result.errors.any?
24
31
  end
25
32
 
26
33
  def account_is_configured?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Trixie
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/trixie.rb CHANGED
@@ -5,16 +5,20 @@ require "yaml"
5
5
  require "json"
6
6
  require "pathname"
7
7
  require "dry/cli"
8
+ require "dry/validation"
8
9
 
9
10
  require_relative "trixie/version"
10
11
  require_relative "trixie/template"
11
12
  require_relative "trixie/formatter"
13
+ require_relative "trixie/contracts/types"
14
+ require_relative "trixie/contracts/trixie_yml"
12
15
  require_relative "trixie/load"
13
16
  require_relative "trixie/cli"
14
17
 
15
18
  module Trixie # rubocop:disable Style/Documentation
16
19
  class Error < StandardError; end
17
- class OpCLINotInstalled < Error; end
20
+ class OpCLINotInstalledError < Error; end
21
+ class InvalidConfigError < Error; end
18
22
 
19
23
  class << self
20
24
  def root_path
data/trixie.gemspec CHANGED
@@ -32,4 +32,6 @@ Gem::Specification.new do |spec|
32
32
  # For more information and examples about making a new gem, checkout our
33
33
  # guide at: https://bundler.io/guides/creating_gem.html
34
34
  spec.add_dependency "dry-cli", "~> 0.7.0"
35
+ spec.add_dependency "dry-schema", "~> 1.10.0"
36
+ spec.add_dependency "dry-validation", "~> 1.8.0"
35
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trixie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toptal, LLC
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-22 00:00:00.000000000 Z
11
+ date: 2022-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.7.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: dry-schema
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.10.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.10.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: dry-validation
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.0
27
55
  description:
28
56
  email:
29
57
  - open-source@toptal.com
@@ -35,6 +63,7 @@ executables:
35
63
  extensions: []
36
64
  extra_rdoc_files: []
37
65
  files:
66
+ - ".github/CODEOWNERS"
38
67
  - ".github/workflows/main.yml"
39
68
  - ".gitignore"
40
69
  - ".rspec"
@@ -50,6 +79,8 @@ files:
50
79
  - exe/trixie
51
80
  - lib/trixie.rb
52
81
  - lib/trixie/cli.rb
82
+ - lib/trixie/contracts/trixie_yml.rb
83
+ - lib/trixie/contracts/types.rb
53
84
  - lib/trixie/formatter.rb
54
85
  - lib/trixie/load.rb
55
86
  - lib/trixie/template.rb