From 52628e7751f907deb25649a1f65a5e5c9e230b7d Mon Sep 17 00:00:00 2001 From: Cedar Myers Date: Mon, 12 Dec 2022 17:13:28 -0500 Subject: [PATCH] Add immutable to Secret --- client/src/main/scala/skuber/Secret.scala | 1 + client/src/main/scala/skuber/json/package.scala | 1 + client/src/test/scala/skuber/json/SecretSpec.scala | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/client/src/main/scala/skuber/Secret.scala b/client/src/main/scala/skuber/Secret.scala index c28c9a35..c670855e 100644 --- a/client/src/main/scala/skuber/Secret.scala +++ b/client/src/main/scala/skuber/Secret.scala @@ -11,6 +11,7 @@ case class Secret( apiVersion: String = v1, metadata: ObjectMeta, data: Map[String, Array[Byte]] = Map(), + immutable: Boolean = false, `type`: String = "") extends ObjectResource { diff --git a/client/src/main/scala/skuber/json/package.scala b/client/src/main/scala/skuber/json/package.scala index 4e2baf14..5baf1e78 100644 --- a/client/src/main/scala/skuber/json/package.scala +++ b/client/src/main/scala/skuber/json/package.scala @@ -1079,6 +1079,7 @@ package object format { implicit val secretFmt: Format[skuber.Secret] = ( objFormat and (JsPath \ "data").formatMaybeEmptyByteArrayMap and + (JsPath \ "immutable").formatMaybeEmptyBoolean() and (JsPath \ "type").formatMaybeEmptyString() )(skuber.Secret.apply _, unlift(skuber.Secret.unapply)) diff --git a/client/src/test/scala/skuber/json/SecretSpec.scala b/client/src/test/scala/skuber/json/SecretSpec.scala index 37eb0980..d0e2d043 100644 --- a/client/src/test/scala/skuber/json/SecretSpec.scala +++ b/client/src/test/scala/skuber/json/SecretSpec.scala @@ -23,6 +23,18 @@ class SecretSpec extends Specification { val readSecret = Json.fromJson[Secret](Json.toJson(mySecret)).get mySecret mustEqual readSecret } + "this can be done with immutable defined" >> { + val mySecret = Secret(metadata = ObjectMeta("mySecret"), immutable = true) + val readSecret = Json.fromJson[Secret](Json.toJson(mySecret)).get + mySecret mustEqual readSecret + readSecret.immutable mustEqual true + } + "this can be done without immutable defined" >> { + val mySecret = Secret(metadata = ObjectMeta("mySecret")) + val readSecret = Json.fromJson[Secret](Json.toJson(mySecret)).get + mySecret mustEqual readSecret + readSecret.immutable mustEqual false + } "this can be done with the type member defined" >> { val mySecret = Secret(metadata = ObjectMeta("mySecret"), `type` = "myType") val readSecret = Json.fromJson[Secret](Json.toJson(mySecret)).get