49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/pangea/entities/namespace.rb', line 49
def self.new(attributes)
attrs = attributes.is_a?(Hash) ? attributes : {}
state_type = attrs[:type]
config_attrs = attrs[:config] || {}
if state_type == :s3
required_fields = [:bucket, :key]
missing_fields = required_fields.select { |field| config_attrs[field].nil? || config_attrs[field].empty? }
unless missing_fields.empty?
raise ::Pangea::Entities::ValidationError, "S3 backend requires: #{missing_fields.join(', ')}"
end
elsif state_type == :local
config_attrs[:path] ||= "./terraform.tfstate"
end
super(attrs)
end
|