Skip to content

Commit

Permalink
Do not require a VPC as parent of security groups nor route table. Cl…
Browse files Browse the repository at this point in the history
…oses #56.
  • Loading branch information
fxaguessy committed Feb 21, 2017
1 parent 958d97b commit bacfbc1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@

- [#44](https://github.com/wallix/awless/issues/44): Fetch only the S3 buckets and related objects of the current region.
- [#52](https://github.com/wallix/awless/issues/52), [#34](https://github.com/wallix/awless/issues/34): Properly fetch route tables, even if a route contains several destinations.
- [#37](https://github.com/wallix/awless/issues/37): Load the region from database when initializing cloud services rather than `awless` environment.
- [#37](https://github.com/wallix/awless/issues/37): Load the region from database when initializing cloud services rather than `awless` environment.
- [#56](https://github.com/wallix/awless/issues/56): Do not require a VPC as parent of security groups nor route table.
13 changes: 3 additions & 10 deletions cloud/aws/parents.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type funcBuilder struct {
parent graph.ResourceType
fieldName, listName string
relation int
must bool
}

type addParentFn func(*graph.Graph, interface{}) error
Expand All @@ -51,15 +50,15 @@ var addParentsFns = map[string][]addParentFn{
funcBuilder{parent: graph.Keypair, fieldName: "KeyName", relation: APPLIES_ON}.build(),
},
graph.SecurityGroup.String(): {
funcBuilder{parent: graph.Vpc, fieldName: "VpcId", must: true}.build(),
funcBuilder{parent: graph.Vpc, fieldName: "VpcId"}.build(),
},
graph.InternetGateway.String(): {
addRegionParent,
funcBuilder{parent: graph.Vpc, fieldName: "VpcId", listName: "Attachments"}.build(),
},
graph.RouteTable.String(): {
funcBuilder{parent: graph.Subnet, fieldName: "SubnetId", listName: "Associations"}.build(),
funcBuilder{parent: graph.Vpc, fieldName: "VpcId", must: true}.build(),
funcBuilder{parent: graph.Vpc, fieldName: "VpcId"}.build(),
},
graph.Vpc.String(): {addRegionParent},
graph.Keypair.String(): {addRegionParent},
Expand All @@ -70,8 +69,6 @@ var addParentsFns = map[string][]addParentFn{
graph.Bucket.String(): {addRegionParent},
}

var ParentNotFound = errors.New("empty field to add parent")

func (fb funcBuilder) build() addParentFn {
if fb.listName != "" {
return fb.addRelationListWithField()
Expand All @@ -98,11 +95,7 @@ func (fb funcBuilder) addRelationWithField() addParentFn {
}

if awssdk.StringValue(str) == "" {
if fb.must {
return ParentNotFound
} else {
return nil
}
return nil
}

parent, err := g.GetResource(fb.parent, awssdk.StringValue(str))
Expand Down

0 comments on commit bacfbc1

Please sign in to comment.