Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add immutable to Secret #348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
{
Expand Down
1 change: 1 addition & 0 deletions client/src/main/scala/skuber/json/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))

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