
io.k8s.api.apps.v1.DeploymentStrategy.scala Maven / Gradle / Ivy
package io.k8s.api.apps.v1
import dev.hnaderi.k8s.utils._
/** DeploymentStrategy describes how to replace existing pods with new ones. */
final case class DeploymentStrategy(
rollingUpdate : Option[io.k8s.api.apps.v1.RollingUpdateDeployment] = None,
`type` : Option[String] = None
) {
/** Returns a new data with rollingUpdate set to new value */
def withRollingUpdate(value: io.k8s.api.apps.v1.RollingUpdateDeployment) : DeploymentStrategy = copy(rollingUpdate = Some(value))
/** if rollingUpdate has a value, transforms to the result of function*/
def mapRollingUpdate(f: io.k8s.api.apps.v1.RollingUpdateDeployment => io.k8s.api.apps.v1.RollingUpdateDeployment) : DeploymentStrategy = copy(rollingUpdate = rollingUpdate.map(f))
/** Returns a new data with `type` set to new value */
def withType(value: String) : DeploymentStrategy = copy(`type` = Some(value))
/** if `type` has a value, transforms to the result of function*/
def mapType(f: String => String) : DeploymentStrategy = copy(`type` = `type`.map(f))
}
object DeploymentStrategy {
implicit val encoder : Encoder[io.k8s.api.apps.v1.DeploymentStrategy] = new Encoder[io.k8s.api.apps.v1.DeploymentStrategy] {
def apply[T : Builder](o: io.k8s.api.apps.v1.DeploymentStrategy) : T = {
val obj = ObjectWriter[T]()
obj
.write("rollingUpdate", o.rollingUpdate)
.write("type", o.`type`)
.build
}
}
implicit val decoder: Decoder[DeploymentStrategy] = new Decoder[DeploymentStrategy] {
def apply[T : Reader](t: T): Either[String, DeploymentStrategy] = for {
obj <- ObjectReader(t)
rollingUpdate <- obj.readOpt[io.k8s.api.apps.v1.RollingUpdateDeployment]("rollingUpdate")
`type` <- obj.readOpt[String]("type")
} yield DeploymentStrategy (
rollingUpdate = rollingUpdate,
`type` = `type`
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy