ops_team 1.6.2 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/action.rb +17 -12
- data/lib/action_list.rb +1 -1
- data/lib/dependencies/custom.rb +32 -4
- data/lib/dependencies/sshkey.rb +2 -2
- data/lib/ops.rb +1 -1
- data/lib/runner.rb +17 -2
- data/ops_team.gemspec +1 -1
- metadata +8 -8
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5fd6e0089c344fed6c8996c7621409e15a9be58f8ea6230d42d9e9e2512caf0c
         | 
| 4 | 
            +
              data.tar.gz: 2d5cf64ee8a5f76f1657b41721602c8df92d157a22d10a38bce4abc6b3777714
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4af29af996f97cc07379cecc16a0a97f9ca4f656330d58242071cbda2221c5d7c6f94e3d28b465ff127ab478dab250b4eaec2384c1baa519918ec5ecdc3a6340
         | 
| 7 | 
            +
              data.tar.gz: b33dc122c430a3fe53de740f1dd7b3df9a0cd908cecaf707d1d6d5ee080531e3301ed0cc7128a5a04bae39a6165face8871afb795ddf9784bc2b052af91f7dc3
         | 
    
        data/lib/action.rb
    CHANGED
    
    | @@ -5,18 +5,15 @@ require 'secrets' | |
| 5 5 | 
             
            # represents one action to be performed in the shell
         | 
| 6 6 | 
             
            # can assemble a command line from a command and args
         | 
| 7 7 | 
             
            class Action
         | 
| 8 | 
            -
            	 | 
| 8 | 
            +
            	attr_reader :name
         | 
| 9 9 |  | 
| 10 | 
            -
            	def initialize(config, args)
         | 
| 10 | 
            +
            	def initialize(name, config, args)
         | 
| 11 | 
            +
            		@name = name
         | 
| 11 12 | 
             
            		@config = config
         | 
| 12 13 | 
             
            		@args = args
         | 
| 13 14 | 
             
            	end
         | 
| 14 15 |  | 
| 15 16 | 
             
            	def run
         | 
| 16 | 
            -
            		unless allowed_in_current_env?
         | 
| 17 | 
            -
            			raise NotAllowedInEnvError, "Action not allowed in #{Environment.environment} environment."
         | 
| 18 | 
            -
            		end
         | 
| 19 | 
            -
             | 
| 20 17 | 
             
            		if perform_shell_expansion?
         | 
| 21 18 | 
             
            			Kernel.exec(to_s)
         | 
| 22 19 | 
             
            		else
         | 
| @@ -62,6 +59,18 @@ class Action | |
| 62 59 | 
             
            		@config["load_secrets"].nil? ? false : @config["load_secrets"]
         | 
| 63 60 | 
             
            	end
         | 
| 64 61 |  | 
| 62 | 
            +
            	def execute_in_env?(env)
         | 
| 63 | 
            +
            		!skip_in_envs.include?(env)
         | 
| 64 | 
            +
            	end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
            	def allowed_in_env?(env)
         | 
| 67 | 
            +
            		return false if not_in_envs.include?(env)
         | 
| 68 | 
            +
             | 
| 69 | 
            +
            		return false if in_envs.any? && !in_envs.include?(env)
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            		true
         | 
| 72 | 
            +
            	end
         | 
| 73 | 
            +
             | 
| 65 74 | 
             
            	private
         | 
| 66 75 |  | 
| 67 76 | 
             
            	def to_a
         | 
| @@ -76,12 +85,8 @@ class Action | |
| 76 85 | 
             
            		@config["in_envs"] || []
         | 
| 77 86 | 
             
            	end
         | 
| 78 87 |  | 
| 79 | 
            -
            	def  | 
| 80 | 
            -
            		 | 
| 81 | 
            -
             | 
| 82 | 
            -
            		return false if in_envs.any? && !in_envs.include?(Environment.environment)
         | 
| 83 | 
            -
             | 
| 84 | 
            -
            		true
         | 
| 88 | 
            +
            	def skip_in_envs
         | 
| 89 | 
            +
            		@config["skip_in_envs"] || []
         | 
| 85 90 | 
             
            	end
         | 
| 86 91 |  | 
| 87 92 | 
             
            	def perform_shell_expansion?
         | 
    
        data/lib/action_list.rb
    CHANGED
    
    
    
        data/lib/dependencies/custom.rb
    CHANGED
    
    | @@ -4,18 +4,46 @@ require 'dependency' | |
| 4 4 |  | 
| 5 5 | 
             
            module Dependencies
         | 
| 6 6 | 
             
            	class Custom < Dependency
         | 
| 7 | 
            +
            		class CustomConfigError < StandardError; end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            		def initialize(definition)
         | 
| 10 | 
            +
            			super
         | 
| 11 | 
            +
            			@definition = definition
         | 
| 12 | 
            +
            			@name, @config = parse_definition
         | 
| 13 | 
            +
            		end
         | 
| 14 | 
            +
             | 
| 7 15 | 
             
            		def met?
         | 
| 8 | 
            -
            			# we always want to try to meet this dependency
         | 
| 9 16 | 
             
            			false
         | 
| 10 17 | 
             
            		end
         | 
| 11 18 |  | 
| 19 | 
            +
            		def always_act?
         | 
| 20 | 
            +
            			true
         | 
| 21 | 
            +
            		end
         | 
| 22 | 
            +
             | 
| 12 23 | 
             
            		def meet
         | 
| 13 | 
            -
            			 | 
| 14 | 
            -
            			execute(name)
         | 
| 24 | 
            +
            			execute(up_command) if up_command
         | 
| 15 25 | 
             
            		end
         | 
| 16 26 |  | 
| 17 27 | 
             
            		def unmeet
         | 
| 18 | 
            -
            			 | 
| 28 | 
            +
            			execute(down_command) if down_command
         | 
| 29 | 
            +
            		end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            		private
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            		def up_command
         | 
| 34 | 
            +
            			@up_command ||= @definition.is_a?(Hash) ? @config&.dig("up") : name
         | 
| 35 | 
            +
            		end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            		def down_command
         | 
| 38 | 
            +
            			@down_command ||= @config && @config&.dig("down") || nil
         | 
| 39 | 
            +
            		end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            		def parse_definition
         | 
| 42 | 
            +
            			return @definition, {} if @definition.is_a?(String)
         | 
| 43 | 
            +
            			return @definition.first if @definition.is_a?(Hash)
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            			raise CustomConfigError, "Expected custom dependency @definition '#{@definition}' " \
         | 
| 46 | 
            +
            				"to be a String or a Hash; received #{@definition.class}."
         | 
| 19 47 | 
             
            		end
         | 
| 20 48 | 
             
            	end
         | 
| 21 49 | 
             
            end
         | 
    
        data/lib/dependencies/sshkey.rb
    CHANGED
    
    | @@ -6,7 +6,7 @@ require 'dependency' | |
| 6 6 |  | 
| 7 7 | 
             
            module Dependencies
         | 
| 8 8 | 
             
            	class Sshkey < Dependency
         | 
| 9 | 
            -
            		DEFAULT_KEY_SIZE =  | 
| 9 | 
            +
            		DEFAULT_KEY_SIZE = 4096
         | 
| 10 10 | 
             
            		DEFAULT_KEY_ALGO = "rsa"
         | 
| 11 11 | 
             
            		DEFAULT_KEY_LIFETIME_S = 3600
         | 
| 12 12 | 
             
            		DEFAULT_KEY_FILE_COMMENT_COMMAND = "$USER@`hostname -s`"
         | 
| @@ -83,7 +83,7 @@ module Dependencies | |
| 83 83 | 
             
            		end
         | 
| 84 84 |  | 
| 85 85 | 
             
            		def opt_key_algo
         | 
| 86 | 
            -
            			DEFAULT_KEY_ALGO
         | 
| 86 | 
            +
            			Options.get("sshkey.key_algo") || DEFAULT_KEY_ALGO
         | 
| 87 87 | 
             
            		end
         | 
| 88 88 |  | 
| 89 89 | 
             
            		def passphrase
         | 
    
        data/lib/ops.rb
    CHANGED
    
    | @@ -59,7 +59,7 @@ class Ops | |
| 59 59 | 
             
            	rescue AppConfig::ParsingError => e
         | 
| 60 60 | 
             
            		Output.error("Error parsing app config: #{e}")
         | 
| 61 61 | 
             
            		exit(ERROR_LOADING_APP_CONFIG_EXIT_CODE)
         | 
| 62 | 
            -
            	rescue  | 
| 62 | 
            +
            	rescue Runner::NotAllowedInEnvError => e
         | 
| 63 63 | 
             
            		Output.error("Error running action #{@action_name}: #{e}")
         | 
| 64 64 | 
             
            		exit(ACTION_NOT_ALLOWED_IN_ENV_EXIT_CODE)
         | 
| 65 65 | 
             
            	end
         | 
    
        data/lib/runner.rb
    CHANGED
    
    | @@ -10,6 +10,7 @@ require 'environment' | |
| 10 10 | 
             
            class Runner
         | 
| 11 11 | 
             
            	class UnknownActionError < StandardError; end
         | 
| 12 12 | 
             
            	class ActionConfigError < StandardError; end
         | 
| 13 | 
            +
            	class NotAllowedInEnvError < StandardError; end
         | 
| 13 14 |  | 
| 14 15 | 
             
            	def initialize(action_name, args, config, config_path)
         | 
| 15 16 | 
             
            		@action_name = action_name
         | 
| @@ -29,8 +30,8 @@ class Runner | |
| 29 30 | 
             
            		raise ActionConfigError, action.config_errors.join("; ") unless action.config_valid?
         | 
| 30 31 |  | 
| 31 32 | 
             
            		do_before_action
         | 
| 32 | 
            -
             | 
| 33 | 
            -
            		 | 
| 33 | 
            +
             | 
| 34 | 
            +
            		run_action
         | 
| 34 35 | 
             
            	end
         | 
| 35 36 |  | 
| 36 37 | 
             
            	def suggestions
         | 
| @@ -72,6 +73,20 @@ class Runner | |
| 72 73 | 
             
            		@forward ||= Forwards.new(@config, @args).get(@action_name)
         | 
| 73 74 | 
             
            	end
         | 
| 74 75 |  | 
| 76 | 
            +
            	def run_action
         | 
| 77 | 
            +
            		unless action.allowed_in_env?(Environment.environment)
         | 
| 78 | 
            +
            			raise NotAllowedInEnvError, "Action not allowed in #{Environment.environment} environment."
         | 
| 79 | 
            +
            		end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            		unless action.execute_in_env?(Environment.environment)
         | 
| 82 | 
            +
            			Output.warn("Skipping action '#{action.name}' in environment #{Environment.environment}.")
         | 
| 83 | 
            +
            			return true
         | 
| 84 | 
            +
            		end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            		Output.notice("Running '#{action}' in environment '#{ENV['environment']}'...")
         | 
| 87 | 
            +
            		action.run
         | 
| 88 | 
            +
            	end
         | 
| 89 | 
            +
             | 
| 75 90 | 
             
            	def action
         | 
| 76 91 | 
             
            		return action_list.get(@action_name) if action_list.get(@action_name)
         | 
| 77 92 | 
             
            		return action_list.get_by_alias(@action_name) if action_list.get_by_alias(@action_name)
         | 
    
        data/ops_team.gemspec
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: ops_team
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.9.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - nickthecook@gmail.com
         | 
| @@ -114,22 +114,22 @@ dependencies: | |
| 114 114 | 
             
              name: net-ssh
         | 
| 115 115 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 116 116 | 
             
                requirements:
         | 
| 117 | 
            -
                - - "~>"
         | 
| 118 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 119 | 
            -
                    version: '6.1'
         | 
| 120 117 | 
             
                - - ">="
         | 
| 121 118 | 
             
                  - !ruby/object:Gem::Version
         | 
| 122 119 | 
             
                    version: 6.1.0
         | 
| 120 | 
            +
                - - "~>"
         | 
| 121 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 122 | 
            +
                    version: '6.1'
         | 
| 123 123 | 
             
              type: :runtime
         | 
| 124 124 | 
             
              prerelease: false
         | 
| 125 125 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 126 126 | 
             
                requirements:
         | 
| 127 | 
            -
                - - "~>"
         | 
| 128 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 129 | 
            -
                    version: '6.1'
         | 
| 130 127 | 
             
                - - ">="
         | 
| 131 128 | 
             
                  - !ruby/object:Gem::Version
         | 
| 132 129 | 
             
                    version: 6.1.0
         | 
| 130 | 
            +
                - - "~>"
         | 
| 131 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 132 | 
            +
                    version: '6.1'
         | 
| 133 133 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 134 134 | 
             
              name: require_all
         | 
| 135 135 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 227 227 | 
             
                - !ruby/object:Gem::Version
         | 
| 228 228 | 
             
                  version: '0'
         | 
| 229 229 | 
             
            requirements: []
         | 
| 230 | 
            -
            rubygems_version: 3. | 
| 230 | 
            +
            rubygems_version: 3.0.3.1
         | 
| 231 231 | 
             
            signing_key:
         | 
| 232 232 | 
             
            specification_version: 4
         | 
| 233 233 | 
             
            summary: ops_team handles basic automation for your project, driven by self-documenting
         |