forked from awslabs/goformation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(parser): Select the correct AWS CloudFormation resource type base…
…d on similarity (awslabs#183) * [Fix] Select the correct polymorphic type
- Loading branch information
1 parent
776555d
commit 5749b23
Showing
8 changed files
with
139 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package resources | ||
|
||
import ( | ||
"encoding/json" | ||
) | ||
|
||
type byJSONLength []interface{} | ||
|
||
func (s byJSONLength) Len() int { | ||
return len(s) | ||
} | ||
|
||
func (s byJSONLength) Swap(i, j int) { | ||
s[i], s[j] = s[j], s[i] | ||
} | ||
|
||
func (s byJSONLength) Less(i, j int) bool { | ||
// Nil is always at the end | ||
if s[i] == nil { | ||
return false | ||
} | ||
if s[j] == nil { | ||
return true | ||
} | ||
jsoni, _ := json.Marshal(s[i]) | ||
jsonj, _ := json.Marshal(s[j]) | ||
|
||
if jsoni == nil { | ||
return false | ||
} | ||
if jsonj == nil { | ||
return true | ||
} | ||
|
||
return len(jsoni) > len(jsonj) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters