Skip to content

Commit

Permalink
Merge pull request awslabs#79 from govau/snakesonaplane
Browse files Browse the repository at this point in the history
Add `OutputsAsIs` optional field to metadata for a service
  • Loading branch information
jaymccon authored Dec 14, 2018
2 parents 02a57c2 + 2c10f6d commit 4158206
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/broker/awsbroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ func (db Db) ServiceDefinitionToOsb(sd CfnTemplate) osb.Service {
"documentationUrl": sd.Metadata.Spec.DocumentationUrl,
"imageUrl": sd.Metadata.Spec.ImageUrl,
"longDescription": sd.Metadata.Spec.LongDescription,
"outputsAsIs": sd.Metadata.Spec.OutputsAsIs,
},
PlanUpdatable: aws.Bool(false),
}
Expand Down
1 change: 1 addition & 0 deletions pkg/broker/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ type CfnTemplate struct {
ImageUrl string `yaml:"ImageUrl,omitempty"`
DocumentationUrl string `yaml:"DocumentationUrl,omitempty"`
ProviderDisplayName string `yaml:"ProviderDisplayName,omitempty"`
OutputsAsIs bool `yaml:"OutputsAsIs,omitempty"`
Bindings struct {
IAM struct {
AddKeypair bool `yaml:"AddKeypair,omitempty"`
Expand Down
24 changes: 23 additions & 1 deletion pkg/broker/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,28 @@ func paramValue(v interface{}) string {
return fmt.Sprintf("%v", v)
}

func leaveOutputsAsIs(service *osb.Service) bool {
if service.Metadata == nil {
return false
}
v, found := service.Metadata["outputsAsIs"]
if !found {
return false
}
b, ok := v.(bool)
if !ok {
return false
}
return b
}

func toScreamingSnakeCaseIfAppropriate(service *osb.Service, s string) string {
if leaveOutputsAsIs(service) {
return s
}
return toScreamingSnakeCase(s)
}

func getCredentials(service *osb.Service, outputs []*cloudformation.Output, ssmSvc ssmiface.SSMAPI) (map[string]interface{}, error) {
credentials := make(map[string]interface{})
var ssmValues []string
Expand All @@ -410,7 +432,7 @@ func getCredentials(service *osb.Service, outputs []*cloudformation.Output, ssmS
credentials[k] = aws.StringValue(o.OutputValue)
ssmValues = append(ssmValues, aws.StringValue(o.OutputValue))
} else {
credentials[toScreamingSnakeCase(aws.StringValue(o.OutputKey))] = aws.StringValue(o.OutputValue)
credentials[toScreamingSnakeCaseIfAppropriate(service, aws.StringValue(o.OutputKey))] = aws.StringValue(o.OutputValue)
// If the output value starts with "ssm:", we'll get the actual value from SSM
if strings.HasPrefix(aws.StringValue(o.OutputValue), cfnOutputSSMValuePrefix) {
ssmValues = append(ssmValues, strings.TrimPrefix(aws.StringValue(o.OutputValue), cfnOutputSSMValuePrefix))
Expand Down

0 comments on commit 4158206

Please sign in to comment.