-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce ability to create invalid RDS template
Implement a complex mechanism for reducing the chance of creating JSON for an RDS DBInstance that is invalid. My hope is that the complexity equals and is not greater than the complexity inherent in the restrictions around RDS creation. There is still one run-time check around storage encryption since specifying it is only valid on new instances created within VPCs. There are restrictions on the values of AllocatedStorage when using Iops but often these values are given as parameter and therefore must accept Token[Int]. I currently used Either to take Int or Token[Int] but at some point it would be good to allow one to reach through the Token to see if the Int is there too test. Tests were added to cover all of the above. A couple other minor changes: - Clean up build.sbt - Implement and use EnumFormat for all enumerations JSON serialization
- Loading branch information
Showing
8 changed files
with
958 additions
and
194 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
15 changes: 15 additions & 0 deletions
15
src/main/scala/com/monsanto/arch/cloudformation/model/EnumFormat.scala
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,15 @@ | ||
package com.monsanto.arch.cloudformation.model | ||
|
||
import spray.json._ | ||
import scala.reflect.runtime.universe._ | ||
|
||
class EnumFormat[T](values: Seq[T], stringifier: T => String = (x: T) => x.toString) | ||
(implicit tag: TypeTag[T]) extends JsonFormat[T] { | ||
override def read(json: JsValue): T = | ||
json match { | ||
case s: JsString => | ||
values.find(x => stringifier(x) == s.value).getOrElse(deserializationError(s.toString + " is not a valid " + tag.tpe)) | ||
case x => deserializationError(x.toString + " is not a String") | ||
} | ||
override def write(obj: T) = JsString(stringifier(obj)) | ||
} |
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
Oops, something went wrong.