Skip to content

Commit

Permalink
no more default annotation in code
Browse files Browse the repository at this point in the history
  • Loading branch information
leviramsey committed Jul 31, 2024
1 parent c1380d1 commit bee11a8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class KubernetesApiIntegrationTest
crName = None,
cleanupAfter = 60.seconds
),
revisionAnnotation = KubernetesJsonSupport.defaultRevisionAnnotation.revisionAnnotation
revisionAnnotation = "deployment.kubernetes.io/revision"
)

private val underTest =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import scala.util.control.NonFatal

import system.dispatcher

override val _revisionAnnotation: HasRevisionAnnotation = settings
override val revisionAnnotation = settings.revisionAnnotation

private implicit val sys: ActorSystem = system
private val log = Logging(system, classOf[KubernetesApiImpl])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ case class Spec(pods: immutable.Seq[PodCost])
*/
@InternalApi
trait KubernetesJsonSupport extends SprayJsonSupport with DefaultJsonProtocol {
val _revisionAnnotation: HasRevisionAnnotation = KubernetesJsonSupport.defaultRevisionAnnotation
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)
Expand All @@ -102,10 +102,9 @@ trait KubernetesJsonSupport extends SprayJsonSupport with DefaultJsonProtocol {
def read(json: JsValue): ReplicaAnnotation = {
json match {
case JsObject(fields) =>
val annotation = _revisionAnnotation.revisionAnnotation
fields.get(annotation) match {
fields.get(revisionAnnotation) match {
case Some(JsString(foundRevision)) =>
ReplicaAnnotation(foundRevision, annotation, fields - annotation)
ReplicaAnnotation(foundRevision, revisionAnnotation, fields - revisionAnnotation)

case _ =>
ReplicaAnnotation("", "", fields)
Expand All @@ -119,9 +118,3 @@ trait KubernetesJsonSupport extends SprayJsonSupport with DefaultJsonProtocol {
implicit val replicaSetMedatataFormat: JsonFormat[ReplicaSetMetadata] = jsonFormat1(ReplicaSetMetadata.apply)
implicit val podReplicaSetFormat: RootJsonFormat[ReplicaSet] = jsonFormat1(ReplicaSet.apply)
}

private[kubernetes] object KubernetesJsonSupport {
val defaultRevisionAnnotation: HasRevisionAnnotation = new HasRevisionAnnotation {
val revisionAnnotation = "deployment.kubernetes.io/revision"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,7 @@ private[kubernetes] class KubernetesSettings(
val customResourceSettings: CustomResourceSettings,
val revisionAnnotation: String,
val bodyReadTimeout: FiniteDuration = 1.second
) extends HasRevisionAnnotation

/**
* INTERNAL API
*/
@InternalApi
private[kubernetes] trait HasRevisionAnnotation {
def revisionAnnotation: String
}
)

/**
* INTERNAL API
Expand Down

0 comments on commit bee11a8

Please sign in to comment.