Skip to content

Commit

Permalink
Only skip deploy validation if resource is not imported
Browse files Browse the repository at this point in the history
  • Loading branch information
gordon-klotho committed Feb 21, 2024
1 parent 352a41d commit f06bc0f
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 9 deletions.
60 changes: 60 additions & 0 deletions pkg/engine/testdata/vpc_import.err.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,65 @@
"resource": "aws:vpc:vpc",
"validation_error": "required property CidrBlock is not set on resource aws:vpc:vpc",
"value": null
},
{
"error": {
"chain": [
"required property Id is not set on resource aws:subnet:vpc:subnet1"
]
},
"error_code": "config_invalid",
"property": "Id",
"resource": "aws:subnet:vpc:subnet1",
"validation_error": "required property Id is not set on resource aws:subnet:vpc:subnet1",
"value": null
},
{
"error": {
"chain": [
"required property Id is not set on resource aws:subnet:vpc:subnet2"
]
},
"error_code": "config_invalid",
"property": "Id",
"resource": "aws:subnet:vpc:subnet2",
"validation_error": "required property Id is not set on resource aws:subnet:vpc:subnet2",
"value": null
},
{
"error": {
"chain": [
"required property Id is not set on resource aws:subnet:vpc:subnet3"
]
},
"error_code": "config_invalid",
"property": "Id",
"resource": "aws:subnet:vpc:subnet3",
"validation_error": "required property Id is not set on resource aws:subnet:vpc:subnet3",
"value": null
},
{
"error": {
"chain": [
"required property Id is not set on resource aws:subnet:vpc:subnet4"
]
},
"error_code": "config_invalid",
"property": "Id",
"resource": "aws:subnet:vpc:subnet4",
"validation_error": "required property Id is not set on resource aws:subnet:vpc:subnet4",
"value": null
},
{
"error": {
"chain": [
"required property Arn is not set on resource aws:vpc:vpc"
]
},
"error_code": "config_invalid",
"property": "Arn",
"resource": "aws:vpc:vpc",
"validation_error": "required property Arn is not set on resource aws:vpc:vpc",
"value": null
}
]
60 changes: 60 additions & 0 deletions pkg/engine/testdata/vpc_import_to_lambda.err.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,65 @@
"resource": "aws:ecr_image:lambda_function-image",
"validation_error": "required property BaseImage is not set on resource aws:ecr_image:lambda_function-image",
"value": null
},
{
"error": {
"chain": [
"required property Id is not set on resource aws:subnet:subnet3"
]
},
"error_code": "config_invalid",
"property": "Id",
"resource": "aws:subnet:subnet3",
"validation_error": "required property Id is not set on resource aws:subnet:subnet3",
"value": null
},
{
"error": {
"chain": [
"required property Id is not set on resource aws:subnet:subnet4"
]
},
"error_code": "config_invalid",
"property": "Id",
"resource": "aws:subnet:subnet4",
"validation_error": "required property Id is not set on resource aws:subnet:subnet4",
"value": null
},
{
"error": {
"chain": [
"required property Id is not set on resource aws:subnet:vpc:subnet1"
]
},
"error_code": "config_invalid",
"property": "Id",
"resource": "aws:subnet:vpc:subnet1",
"validation_error": "required property Id is not set on resource aws:subnet:vpc:subnet1",
"value": null
},
{
"error": {
"chain": [
"required property Id is not set on resource aws:subnet:vpc:subnet2"
]
},
"error_code": "config_invalid",
"property": "Id",
"resource": "aws:subnet:vpc:subnet2",
"validation_error": "required property Id is not set on resource aws:subnet:vpc:subnet2",
"value": null
},
{
"error": {
"chain": [
"required property Arn is not set on resource aws:vpc:vpc"
]
},
"error_code": "config_invalid",
"property": "Arn",
"resource": "aws:vpc:vpc",
"validation_error": "required property Arn is not set on resource aws:vpc:vpc",
"value": null
}
]
12 changes: 12 additions & 0 deletions pkg/engine/testdata/vpc_import_wo_subnets_to_lambda.err.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,17 @@
"resource": "aws:ecr_image:lambda_function-image",
"validation_error": "required property BaseImage is not set on resource aws:ecr_image:lambda_function-image",
"value": null
},
{
"error": {
"chain": [
"required property Arn is not set on resource aws:vpc:vpc"
]
},
"error_code": "config_invalid",
"property": "Arn",
"resource": "aws:vpc:vpc",
"validation_error": "required property Arn is not set on resource aws:vpc:vpc",
"value": null
}
]
2 changes: 1 addition & 1 deletion pkg/knowledgebase/properties/any_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (a *AnyProperty) Type() string {
}

func (a *AnyProperty) Validate(resource *construct.Resource, value any, ctx knowledgebase.DynamicContext) error {
if a.DeployTime && value == nil {
if a.DeployTime && value == nil && !resource.Imported {
return nil
}
if a.Required && value == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/knowledgebase/properties/bool_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (b *BoolProperty) Type() string {
}

func (b *BoolProperty) Validate(resource *construct.Resource, value any, ctx knowledgebase.DynamicContext) error {
if b.DeployTime && value == nil {
if b.DeployTime && value == nil && !resource.Imported {
return nil
}
if value == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/knowledgebase/properties/float_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (f *FloatProperty) Type() string {
}

func (f *FloatProperty) Validate(resource *construct.Resource, value any, ctx knowledgebase.DynamicContext) error {
if f.DeployTime && value == nil {
if f.DeployTime && value == nil && !resource.Imported {
return nil
}
if value == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/knowledgebase/properties/int_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (i *IntProperty) Type() string {
}

func (i *IntProperty) Validate(resource *construct.Resource, value any, ctx knowledgebase.DynamicContext) error {
if i.DeployTime && value == nil {
if i.DeployTime && value == nil && !resource.Imported {
return nil
}
if value == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/knowledgebase/properties/list_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (l *ListProperty) Type() string {
}

func (l *ListProperty) Validate(resource *construct.Resource, value any, ctx knowledgebase.DynamicContext) error {
if l.DeployTime && value == nil {
if l.DeployTime && value == nil && !resource.Imported {
return nil
}
if value == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/knowledgebase/properties/map_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (m *MapProperty) Type() string {
}

func (m *MapProperty) Validate(resource *construct.Resource, value any, ctx knowledgebase.DynamicContext) error {
if m.DeployTime && value == nil {
if m.DeployTime && value == nil && !resource.Imported {
return nil
}
if value == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/knowledgebase/properties/resource_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (r *ResourceProperty) Type() string {
}

func (r *ResourceProperty) Validate(resource *construct.Resource, value any, ctx knowledgebase.DynamicContext) error {
if r.DeployTime && value == nil {
if r.DeployTime && value == nil && !resource.Imported {
return nil
}
if value == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/knowledgebase/properties/set_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (s *SetProperty) Type() string {
}

func (s *SetProperty) Validate(resource *construct.Resource, value any, ctx knowledgebase.DynamicContext) error {
if s.DeployTime && value == nil {
if s.DeployTime && value == nil && !resource.Imported {
return nil
}
if value == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/knowledgebase/properties/string_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *StringProperty) Type() string {
}

func (s *StringProperty) Validate(resource *construct.Resource, value any, ctx knowledgebase.DynamicContext) error {
if s.DeployTime && value == nil {
if s.DeployTime && value == nil && !resource.Imported {
return nil
}
if value == nil {
Expand Down

0 comments on commit f06bc0f

Please sign in to comment.