Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
Update PR #132 for new resource types and resolve branch conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Henroid committed Jan 20, 2017
1 parent eb0d5a1 commit e177daf
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 70 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/type/cloudwatch_alarm.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:cloudwatch_alarm) do
@doc = 'Type representing an AWS CloudWatch Alarm.'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/type/ec2_autoscalinggroup.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/region.rb'
require 'puppet/property/boolean'

Puppet::Type.newtype(:ec2_autoscalinggroup) do
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/type/ec2_elastic_ip.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_elastic_ip) do
@doc = "Type representing an Elastic IP and it's association."
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/type/ec2_instance.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_instance) do
@doc = 'Type representing an EC2 instance.'
Expand Down Expand Up @@ -93,12 +94,8 @@ def insync?(is)
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the instance.'
validate do |value|
fail 'region should not contain spaces' if value =~ /\s/
fail 'region should be a String' unless value.is_a?(String)
end
end

newproperty(:image_id) do
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/type/ec2_launchconfiguration.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_launchconfiguration) do
@doc = 'Type representing an EC2 launch configuration.'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/type/ec2_scalingpolicy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_scalingpolicy) do
@doc = 'Type representing an EC2 scaling policy.'
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/ec2_securitygroup.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag'
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'
require_relative '../../puppet_x/puppetlabs/aws_ingress_rules_parser'

Puppet::Type.newtype(:ec2_securitygroup) do
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/ec2_vpc.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag'
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_vpc) do
@doc = 'A type representing an AWS VPC.'
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/ec2_vpc_customer_gateway.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag'
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_vpc_customer_gateway) do
@doc = 'Type representing an AWS VPC customer gateways.'
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/ec2_vpc_dhcp_options.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag'
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_vpc_dhcp_options) do
@doc = 'Type representing a DHCP option set for AWS VPC.'
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/ec2_vpc_internet_gateway.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag'
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_vpc_internet_gateway) do
@doc = 'Type representing an EC2 VPC Internet Gateway.'
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/ec2_vpc_routetable.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag'
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_vpc_routetable) do
@doc = 'Type representing a VPC route table.'
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/ec2_vpc_subnet.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag'
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_vpc_subnet) do
@doc = 'Type representing a VPC Subnet.'
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/ec2_vpc_vpn.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag'
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_vpc_vpn) do
@doc = 'Type representing an AWS Virtual Private Networks.'
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/ec2_vpc_vpn_gateway.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag'
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:ec2_vpc_vpn_gateway) do
@doc = 'A type representing a VPN gateway.'
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/elb_loadbalancer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/tag'
require_relative '../../puppet_x/puppetlabs/property/region'
require_relative '../../puppet_x/puppetlabs/property/tag.rb'
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:elb_loadbalancer) do
@doc = 'Type representing an ELB load balancer.'
Expand Down
8 changes: 3 additions & 5 deletions lib/puppet/type/rds_db_parameter_group.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:rds_db_parameter_group) do
@doc = 'Type representing an RDS DB Parameter group.'

Expand All @@ -22,12 +24,8 @@
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to create the db_parameter_group.'
validate do |value|
fail 'region should be a String' unless value.is_a?(String)
fail 'region should not contain spaces' if value =~ /\s/
end
end

end
8 changes: 3 additions & 5 deletions lib/puppet/type/rds_db_securitygroup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:rds_db_securitygroup) do
@doc = 'Type representing an RDS instance.'

Expand Down Expand Up @@ -32,12 +34,8 @@
end
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to create the db_securitygroup.'
validate do |value|
fail 'region should be a String' unless value.is_a?(String)
fail 'region should not contain spaces' if value =~ /\s/
end
end

newproperty(:ip_ranges, :array_matching => :all) do
Expand Down
8 changes: 3 additions & 5 deletions lib/puppet/type/rds_instance.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:rds_instance) do
@doc = 'Type representing an RDS instance.'

Expand Down Expand Up @@ -49,12 +51,8 @@
Not applicable. Must be null.'
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The region in which to launch the instance.'
validate do |value|
fail 'region should be a String' unless value.is_a?(String)
fail 'region should not contain spaces' if value =~ /\s/
end
end

newproperty(:db_instance_class) do
Expand Down
9 changes: 3 additions & 6 deletions lib/puppet/type/sqs_queue.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_relative '../../puppet_x/puppetlabs/property/region.rb'

Puppet::Type.newtype(:sqs_queue) do
@doc = "Type representing a SQS Queue"
ensurable
Expand Down Expand Up @@ -43,13 +45,8 @@
munge(&:to_s)
end

newproperty(:region) do
newproperty(:region, :parent => PuppetX::Property::AwsRegion) do
desc 'The name of the region in which the SQS queue is located'
validate do |value|
fail 'region should be a String' unless value.is_a?(String)
fail 'You must provide a non-blank region name for SQS Queues' if value.nil? || value.empty?
fail 'The name of a region should contain only alphanumeric characters or dashes' unless value =~ /^([a-zA-Z]+-+)+\d$/
end
end

newproperty(:visibility_timeout) do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/provider/rds_instance/v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Puppet::Type.type(:rds_instance).new(
ensure: 'present',
name: 'awesome-db-5',
region: 'us-west-1',
region: 'sa-east-1',
db_name: 'mysqldbname3',
engine: 'mysql',
engine_version: '5.6.19a',
Expand Down
33 changes: 15 additions & 18 deletions spec/unit/type/sqs_queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,46 @@
end

it 'should create a valid instance' do
type_class.new({name: 'name', region: 'us-east-1'})
type_class.new({name: 'name', region: 'sa-east-1'})
end

it 'should set delay seconds should get set with a valid value' do
queue = type_class.new({name: 'queue', region: 'us-east-1', delay_seconds: 450})
queue = type_class.new({name: 'queue', region: 'sa-east-1', delay_seconds: 450})
expect(queue[:delay_seconds]).to eq("450")
end

it 'delay seconds should default to 0' do
queue = type_class.new({name: 'queue', region: 'us-east-1'})
queue = type_class.new({name: 'queue', region: 'sa-east-1'})
expect(queue[:delay_seconds]).to eq("0")
end

it 'visibility_timeout should default to 30' do
queue = type_class.new({name: 'queue', region: 'us-east-1'})
queue = type_class.new({name: 'queue', region: 'sa-east-1'})
expect(queue[:visibility_timeout]).to eq('30')
end

it 'should set visibility_timeout with a valid value' do
queue = type_class.new({name: 'queue', region: 'us-east-1', visibility_timeout: 123})
queue = type_class.new({name: 'queue', region: 'sa-east-1', visibility_timeout: 123})
expect(queue[:visibility_timeout]).to eq("123")
end

it 'should set message_retention_period should get set with a valid value' do
queue = type_class.new({name: 'queue', region: 'us-east-1', message_retention_period: 360})
queue = type_class.new({name: 'queue', region: 'sa-east-1', message_retention_period: 360})
expect(queue[:message_retention_period]).to eq("360")
end

it 'should set message_retention_period to default to 345600' do
queue = type_class.new({name: 'queue', region: 'us-east-1'})
queue = type_class.new({name: 'queue', region: 'sa-east-1'})
expect(queue[:message_retention_period]).to eq("345600")
end

it 'should set maximum_message_size should get set with a valid value' do
queue = type_class.new({name: 'queue', region: 'us-east-1', maximum_message_size: 2048})
queue = type_class.new({name: 'queue', region: 'sa-east-1', maximum_message_size: 2048})
expect(queue[:maximum_message_size]).to eq("2048")
end

it 'should set maximum_message_size to default to 262144' do
queue = type_class.new({name: 'queue', region: 'us-east-1'})
queue = type_class.new({name: 'queue', region: 'sa-east-1'})
expect(queue[:maximum_message_size]).to eq("262144")
end

Expand All @@ -81,26 +81,23 @@
context 'erroring values' do
it 'should error with incorrect range value for delay seconds' do
expect do
type_class.new({name: 'queue', region: 'us-east-1', delay_seconds: 1024})
type_class.new({name: 'queue', region: 'sa-east-1', delay_seconds: 1024})
end.to raise_error(Puppet::Error, /delay_seconds must be an integer between 0 and 900/)
end

it 'should require something that looks like a region' do
expect do
type_class.new ({name: 'somename', :region => 'us_east_1'})
end.to raise_error(Puppet::Error, /The name of a region should contain only alphanumeric characters or dashes/)
type_class.new ({name: 'somename', :region => 'sa-east-1 '})
end.to raise_error(Puppet::Error, /region should not contain spaces/)
expect do
type_class.new ({name: 'somename', :region => '123'})
end.to raise_error(Puppet::Error, /The name of a region should contain only alphanumeric characters or dashes/)
expect do
type_class.new ({name: 'somename', :region => 'europe'})
end.to raise_error(Puppet::Error, /The name of a region should contain only alphanumeric characters or dashes/)
type_class.new ({name: 'somename', :region => 1})
end.to raise_error(Puppet::Error, /region should be a String/)
end

it 'should require a non-blank region' do
expect do
type_class.new ({name: 'somename', region: ''})
end.to raise_error(Puppet::Error, /You must provide a non-blank region name for SQS Queues/)
end.to raise_error(Puppet::Error, /region should not be blank/)
end
it 'should require a name' do
expect do
Expand Down

0 comments on commit e177daf

Please sign in to comment.