Skip to content

Commit

Permalink
Merge pull request #257 from cedarm/immutable-secret3
Browse files Browse the repository at this point in the history
Add immutable to Secret
  • Loading branch information
hagay3 authored Dec 22, 2022
2 parents 97bca64 + b0eb1cc commit 721007b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions client/src/main/scala/skuber/Secret.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ case class Secret(val kind: String = "Secret",
override val apiVersion: String = v1,
val metadata: ObjectMeta,
data: Map[String, Array[Byte]] = Map(),
val immutable: Boolean = false,
val `type`: String = "")
extends ObjectResource {

Expand Down
3 changes: 2 additions & 1 deletion client/src/main/scala/skuber/json/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,8 @@ package object format {

implicit val secretFmt: Format[skuber.Secret] = (objFormat and
(JsPath \ "data").formatMaybeEmptyByteArrayMap and
(JsPath \ "type").formatMaybeEmptyString()) (skuber.Secret.apply, s => (s.kind, s.apiVersion, s.metadata, s.data, s.`type`))
(JsPath \ "immutable").formatMaybeEmptyBoolean() and
(JsPath \ "type").formatMaybeEmptyString()) (skuber.Secret.apply, s => (s.kind, s.apiVersion, s.metadata, s.data, s.immutable, s.`type`))

implicit val limitRangeItemTypeFmt: Format[LimitRange.ItemType.Type] = Json.formatEnum(LimitRange.ItemType)

Expand Down
12 changes: 12 additions & 0 deletions client/src/test/scala/skuber/json/SecretSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 721007b

Please sign in to comment.