Skip to content

Commit

Permalink
Add form field for new field. XLarge not Xlarge
Browse files Browse the repository at this point in the history
  • Loading branch information
philmcmahon committed Jan 17, 2025
1 parent f7c0d32 commit aed5082
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 deletions.
18 changes: 9 additions & 9 deletions app/controllers/BaseImageController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class BaseImageController(
image.amiId,
image.linuxDist.getOrElse(Ubuntu),
image.eolDate.getOrElse(DateTime.now).toLocalDate.toDate,
image.requiresXlargeBuilder
image.requiresXLargeBuilder
)
)
Ok(views.html.editBaseImage(image, form, Roles.listIds))
Expand All @@ -80,7 +80,7 @@ class BaseImageController(
amiId,
linuxDist,
eolDate,
requiresXlargeBuilder
requiresXLargeBuilder
) =>
val customisedRoles = parseEnabledRoles(request.body)
customisedRoles.fold(
Expand All @@ -94,7 +94,7 @@ class BaseImageController(
roles,
modifiedBy = request.user.fullName,
new DateTime(eolDate),
requiresXlargeBuilder
requiresXLargeBuilder
)
Redirect(routes.BaseImageController.showBaseImage(id))
.flashing("info" -> "Successfully updated base image")
Expand Down Expand Up @@ -123,7 +123,7 @@ class BaseImageController(
amiId,
linuxDist,
eolDate,
requiresXlargeBuilder
requiresXLargeBuilder
) =>
BaseImages.findById(id) match {
case Some(existingImage) =>
Expand All @@ -135,7 +135,7 @@ class BaseImageController(
amiId,
linuxDist,
eolDate,
requiresXlargeBuilder
requiresXLargeBuilder
)
)
.withError("id", "This base image ID is already in use")
Expand All @@ -153,7 +153,7 @@ class BaseImageController(
createdBy = request.user.fullName,
linuxDist,
Some(new DateTime(eolDate)),
requiresXlargeBuilder
requiresXLargeBuilder
)
Redirect(routes.BaseImageController.showBaseImage(id))
.flashing("info" -> "Successfully created base image")
Expand Down Expand Up @@ -188,7 +188,7 @@ class BaseImageController(
createdBy = request.user.fullName,
linuxDist = linuxDist,
eolDate = baseImage.eolDate,
requiresXlargeBuilder = baseImage.requiresXlargeBuilder
requiresXLargeBuilder = baseImage.requiresXLargeBuilder
)
Redirect(routes.BaseImageController.showBaseImage(newId))
.flashing("info" -> "Successfully cloned base image")
Expand Down Expand Up @@ -248,7 +248,7 @@ object BaseImageController {
"amiId" -> amiId,
"linuxDist" -> linuxDist,
"eolDate" -> date("yyyy-MM-dd"),
"requiresXlargeBuilder" -> boolean
"requiresXLargeBuilder" -> boolean
)
)

Expand All @@ -260,7 +260,7 @@ object BaseImageController {
"amiId" -> amiId,
"linuxDist" -> linuxDist,
"eolDate" -> date("yyyy-MM-dd"),
"requiresXlargeBuilder" -> boolean
"requiresXLargeBuilder" -> boolean
)
)

Expand Down
8 changes: 4 additions & 4 deletions app/data/BaseImages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object BaseImages {
createdBy: String,
linuxDist: LinuxDist,
eolDate: Option[DateTime],
requiresXlargeBuilder: Boolean
requiresXLargeBuilder: Boolean
)(implicit dynamo: Dynamo): BaseImage = {
val now = DateTime.now()
val baseImage = BaseImage(
Expand All @@ -29,7 +29,7 @@ object BaseImages {
modifiedAt = now,
Some(linuxDist),
eolDate,
requiresXlargeBuilder
requiresXLargeBuilder
)

table.put(baseImage).exec()
Expand All @@ -44,7 +44,7 @@ object BaseImages {
builtinRoles: List[CustomisedRole],
modifiedBy: String,
eolDate: DateTime,
requiresXlargeBuilder: Boolean
requiresXLargeBuilder: Boolean
)(implicit dynamo: Dynamo): Unit = {
val updated = baseImage.copy(
description = description,
Expand All @@ -54,7 +54,7 @@ object BaseImages {
modifiedBy = modifiedBy,
modifiedAt = DateTime.now(),
eolDate = Some(eolDate),
requiresXlargeBuilder = requiresXlargeBuilder
requiresXLargeBuilder = requiresXLargeBuilder
)
table.put(updated).exec()
}
Expand Down
2 changes: 1 addition & 1 deletion app/models/BaseImage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ case class BaseImage(
modifiedAt: DateTime,
linuxDist: Option[LinuxDist] = None,
eolDate: Option[DateTime] = None,
requiresXlargeBuilder: Boolean = false
requiresXLargeBuilder: Boolean = false
)

sealed trait EolStatus
Expand Down
2 changes: 1 addition & 1 deletion app/packer/PackerRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PackerRunner(maxInstances: Int) extends Loggable {
awsAccountNumbers,
amiMetadata,
amigoDataBucket,
bake.recipe.baseImage.requiresXlargeBuilder
bake.recipe.baseImage.requiresXLargeBuilder
)
val packerJson = Json.prettyPrint(Json.toJson(packerBuildConfig))
val packerConfigFile =
Expand Down
9 changes: 9 additions & 0 deletions app/views/editBaseImage.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
<p>(Find Ubuntu support info <a href="https://wiki.ubuntu.com/Releases" target="_blank">here</a>)</p>
</div>
</div>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-6">
@b3.checkbox(form("requiresXLargeBuilder"), Symbol("_label") -> "Requires XLarge builder instance")
</div>
<div class="col-md-3">
<p>Note - XLarge instances are 8x more expensive than normal AMIgo builders. Avoid where possible.</p>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2" for="builtin-roles">Builtin roles</label>
<div class="col-md-10" id="builtin-roles">
Expand Down
2 changes: 2 additions & 0 deletions app/views/newBaseImage.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@b3.textarea( form("description"), Symbol("_label") -> "Description" )
@b3.date(form("eolDate"), Symbol("_label")-> "End of Life Date")
<p>(Find Ubuntu support info <a href="https://wiki.ubuntu.com/Releases">here</a></p>
@b3.checkbox(form("requiresXLargeBuilder"), Symbol("_label") -> "Requires XLarge builder instance")
<p>Note - XLarge instances are 8x more expensive than normal AMIgo builders. Avoid where possible.</p>

<div class="form-group">
<label class="control-label col-md-2" for="builtin-roles">Builtin roles</label>
Expand Down
9 changes: 8 additions & 1 deletion app/views/showBaseImage.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ <h1>@image.id.value</h1>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">Requires XLarge builder instance</div>
<div class="panel-body">
@image.requiresXLargeBuilder
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">Builtin roles</div>
<div class="panel-body">
Expand All @@ -64,4 +71,4 @@ <h1>@image.id.value</h1>
</div>
</div>

}
}

0 comments on commit aed5082

Please sign in to comment.