-
Notifications
You must be signed in to change notification settings - Fork 160
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
feat: configurable choice of annotations for rolling update revision #1303
Changes from all commits
1837af8
6eb7b8a
8c7e7d1
23f54e6
220d106
c1380d1
bee11a8
2917be4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,13 +10,16 @@ import akka.annotation.InternalApi | |
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport | ||
import spray.json.DefaultJsonProtocol | ||
import spray.json.JsonFormat | ||
import spray.json.JsObject | ||
import spray.json.RootJsonFormat | ||
import spray.json.JsString | ||
import spray.json.JsValue | ||
|
||
/** | ||
* INTERNAL API | ||
*/ | ||
@InternalApi | ||
case class ReplicaAnnotation(`deployment.kubernetes.io/revision`: String) | ||
case class ReplicaAnnotation(revision: String, source: String, otherAnnotations: Map[String, JsValue]) | ||
|
||
/** | ||
* INTERNAL API | ||
|
@@ -75,6 +78,8 @@ case class Spec(pods: immutable.Seq[PodCost]) | |
*/ | ||
@InternalApi | ||
trait KubernetesJsonSupport extends SprayJsonSupport with DefaultJsonProtocol { | ||
val revisionAnnotation: String | ||
|
||
// If adding more formats here, remember to also add in META-INF/native-image reflect config | ||
implicit val metadataFormat: JsonFormat[Metadata] = jsonFormat2(Metadata.apply) | ||
implicit val podCostFormat: JsonFormat[PodCost] = jsonFormat5(PodCost.apply) | ||
|
@@ -86,7 +91,30 @@ trait KubernetesJsonSupport extends SprayJsonSupport with DefaultJsonProtocol { | |
implicit val podMetadataFormat: JsonFormat[PodMetadata] = jsonFormat1(PodMetadata.apply) | ||
implicit val podFormat: RootJsonFormat[Pod] = jsonFormat1(Pod.apply) | ||
|
||
implicit val replicaAnnotationFormat: JsonFormat[ReplicaAnnotation] = jsonFormat1(ReplicaAnnotation.apply) | ||
implicit val replicaAnnotationFormat: RootJsonFormat[ReplicaAnnotation] = | ||
new RootJsonFormat[ReplicaAnnotation] { | ||
// Not sure if we ever write this out, but if we do, this will let us write out exactly what we took in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we add the "writes" part only then if really need? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then we can even further simplify the case class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a |
||
def write(ra: ReplicaAnnotation): JsValue = | ||
if (ra.revision.nonEmpty && ra.source.nonEmpty) { | ||
JsObject(ra.otherAnnotations + (ra.source -> JsString(ra.revision))) | ||
} else JsObject(ra.otherAnnotations) | ||
|
||
def read(json: JsValue): ReplicaAnnotation = { | ||
json match { | ||
case JsObject(fields) => | ||
fields.get(revisionAnnotation) match { | ||
case Some(JsString(foundRevision)) => | ||
ReplicaAnnotation(foundRevision, revisionAnnotation, fields - revisionAnnotation) | ||
|
||
case _ => | ||
ReplicaAnnotation("", "", fields) | ||
} | ||
|
||
case _ => spray.json.deserializationError("expected an object") | ||
} | ||
} | ||
} | ||
|
||
implicit val replicaSetMedatataFormat: JsonFormat[ReplicaSetMetadata] = jsonFormat1(ReplicaSetMetadata.apply) | ||
implicit val podReplicaSetFormat: RootJsonFormat[ReplicaSet] = jsonFormat1(ReplicaSet.apply) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how long the typo has been there...
I think the comment in
reference.conf
is sufficient documentation for a niche feature.