Skip to content

Commit

Permalink
PC-22556 | Update for Ruby 3.3.4 (#312)
Browse files Browse the repository at this point in the history
* PC-22556 | Update for Ruby 3.3.4
  • Loading branch information
nalakafernando authored Oct 7, 2024
1 parent 5484cf3 commit 6741c75
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
AllCops:
TargetRubyVersion: 3.1.3
TargetRubyVersion: 3.3.4
Exclude:
- '.gemspec'
- 'vendor/**/*'
Expand Down Expand Up @@ -40,5 +40,7 @@ Metrics/PerceivedComplexity:
Enabled: false
Style/OptionalBooleanParameter:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
Lint/EmptyFile:
Enabled: false
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.3
3.3.4
2 changes: 2 additions & 0 deletions lib/moonshot/commands/tag_arguments.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Moonshot
module Commands
module TagArguments
Expand Down
4 changes: 2 additions & 2 deletions lib/moonshot/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def generate_name(config)
def make_tags(config)
default_tags = [
{ key: 'moonshot_application', value: config.app_name },
{ key: 'moonshot_environment', value: config.environment_name },
{ key: 'moonshot_environment', value: config.environment_name }
]
name = generate_name(config)

Expand Down Expand Up @@ -253,7 +253,7 @@ def new_change_set
change_set_name:,
description: "Moonshot update command for application '#{Moonshot.config.app_name}'",
stack_name: @name,
capabilities: %w(CAPABILITY_IAM CAPABILITY_NAMED_IAM),
capabilities: %w(CAPABILITY_IAM CAPABILITY_NAMED_IAM), # rubocop:disable Layout/HashAlignment,Style/PercentLiteralDelimiters
parameters: @config.parameters.values.map(&:to_cf),
tags: make_tags
}
Expand Down
6 changes: 4 additions & 2 deletions lib/moonshot/unicode_table.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'colorize'

module Moonshot
Expand Down Expand Up @@ -39,10 +41,10 @@ def draw(depth = 1, first = true)
pipe = '|'
print first ? '┌' : '├'
print '─' * depth
puts "#{space}" << @name.light_black
puts "#{space}" << @name.light_black # rubocop:disable Style/RedundantInterpolation
@lines = [''] + @lines + ['']
@lines.each do |line|
puts "#{pipe}" << (' ' * depth) << line
puts "#{pipe}" << (' ' * depth) << line # rubocop:disable Style/RedundantInterpolation
end
@children.each do |child|
child.draw(depth + 1, false)
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def define_bucket
# single bucket for all accounts
return @bucket if @bucket
# calculating bucket based on account name
return bucket_by_account(iam_account) if @buckets
return bucket_by_account(iam_account) if @buckets # rubocop:disable Style/RedundantReturn
end

def bucket_by_account(account)
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/encrypted_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def find_or_create_kms_key
Moonshot.config.parameters[@kms_key_parameter_name].set(key_arn)
s.success "Created a new KMS Key for #{@kms_key_parameter_name.blue}!"
else
kms=KmsKey.new(Moonshot.config.parameters[@kms_key_parameter_name].value)
kms=KmsKey.new(Moonshot.config.parameters[@kms_key_parameter_name].value) # rubocop:disable Style/SpaceAroundOperators
key_arn = kms.arn
kms.update
s.success "Using existing KMS Key for #{@kms_key_parameter_name.blue}!"
Expand Down
16 changes: 9 additions & 7 deletions lib/plugins/encrypted_parameters/kms_key.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# frozen_string_literal: true
require_relative '../../moonshot/stack.rb'

require_relative '../../moonshot/stack'

module Moonshot
module Plugins
class EncryptedParameters
# Class that manages KMS keys in AWS.
class KmsKey
attr_reader :arn

class << self
def create
standard_tags = stack_tags
resp = Aws::KMS::Client.new.create_key({
tags: standard_tags, # An array of tags.
})
tags: standard_tags # An array of tags.
})
arn = resp.key_metadata.arn
new(arn)
end

def stack_tags
tags = Moonshot::Stack.make_tags(Moonshot.config)
tags.map { |tag| { tag_key: tag[:key], tag_value: tag[:value] } }
tags.map { |tag| { tag_key: tag[:key], tag_value: tag[:value] } }
end
end

Expand All @@ -31,9 +33,9 @@ def initialize(arn)
def update
standard_tags = self.class.stack_tags
@kms_client.tag_resource({
key_id: @arn, # arn of the CMK being tagged
tags: standard_tags, # An array of tags.
})
key_id: @arn, # arn of the CMK being tagged
tags: standard_tags # An array of tags.
})
end

def delete
Expand Down
10 changes: 7 additions & 3 deletions moonshot.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,32 @@ Gem::Specification.new do |s|
s.executables = ['moonshot']
s.homepage = 'https://github.com/acquia/moonshot'

s.required_ruby_version = '>= 3.1.2'
s.required_ruby_version = '>= 3.3.4'

s.add_dependency('aws-sdk-autoscaling', '~> 1.5')
s.add_dependency('aws-sdk-cloudformation', '~> 1.4')
s.add_dependency('aws-sdk-codedeploy', '~> 1.5')
s.add_dependency('aws-sdk-elasticloadbalancing', '~> 1.3')
s.add_dependency('aws-sdk-ec2', '~> 1.34')
s.add_dependency('aws-sdk-elasticloadbalancing', '~> 1.3')
s.add_dependency('aws-sdk-iam', '~> 1.4')
s.add_dependency('aws-sdk-s3', '~> 1.12')

s.add_dependency('activesupport')
s.add_dependency('colorize')
s.add_dependency('faraday', '~> 1.0')
s.add_dependency('faraday-rack', '~> 1.0.0')
s.add_dependency('faraday-retry', '~> 1.0')
s.add_dependency('highline')
s.add_dependency('interactive-logger')
s.add_dependency('pry')
s.add_dependency('require_all')
s.add_dependency('retriable')
s.add_dependency('rexml')
s.add_dependency('rotp')
s.add_dependency('ruby-duration')
s.add_dependency('semantic')
s.add_dependency('thor')
s.add_dependency('travis')
s.add_dependency('travis', '~> 1.11.1')
s.add_dependency('vandamme')

s.add_development_dependency('fakefs')
Expand Down
2 changes: 2 additions & 0 deletions sample/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'moonshot', '~> 0.7.0'

0 comments on commit 6741c75

Please sign in to comment.