Skip to content

Commit

Permalink
fix(artifacts): remove hard coded artifact types (#1966)
Browse files Browse the repository at this point in the history
* fix(artifacts): remove hard coded artifact types

* rename method and argument

Co-authored-by: Lorin Hochstein <[email protected]>
Co-authored-by: Luis Pollo <[email protected]>
  • Loading branch information
3 people authored Aug 11, 2021
1 parent 9a5ae27 commit 88629af
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ abstract class DeliveryArtifact {
@get:ExcludedFromDiff
abstract val deliveryConfigName: String?

abstract fun withDeliveryConfigName(deliveryConfigName: String): DeliveryArtifact

/** A set of release statuses to filter by. Mutually exclusive with [from] filters. */
open val statuses: Set<ArtifactStatus> = emptySet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ data class DebianArtifact(
DebianVersionSortingStrategy
}

override fun withDeliveryConfigName(deliveryConfigName: String): DeliveryArtifact {
return this.copy(deliveryConfigName = deliveryConfigName)
}

override fun toString(): String = super.toString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ data class DockerArtifact(
} else throw ValidationException(
listOf("Unable to determine sorting strategy for $this. You must specify either `tagVersionStrategy` or `from` in your delivery config."))

override fun withDeliveryConfigName(deliveryConfigName: String): DeliveryArtifact {
return this.copy(deliveryConfigName = deliveryConfigName)
}

override fun toString(): String = super.toString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ data class NpmArtifact(
NpmVersionSortingStrategy
}

override fun withDeliveryConfigName(deliveryConfigName: String): DeliveryArtifact {
return this.copy(deliveryConfigName = deliveryConfigName)
}

override fun toString(): String = super.toString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import com.netflix.spinnaker.keel.api.Verification
import com.netflix.spinnaker.keel.api.artifacts.DeliveryArtifact
import com.netflix.spinnaker.keel.api.postdeploy.PostDeployAction
import com.netflix.spinnaker.keel.api.schema.Description
import com.netflix.spinnaker.keel.artifacts.DebianArtifact
import com.netflix.spinnaker.keel.artifacts.DockerArtifact
import com.netflix.spinnaker.keel.artifacts.NpmArtifact
import com.netflix.spinnaker.keel.serialization.SubmittedEnvironmentDeserializer
import com.netflix.spinnaker.kork.exceptions.UserException

const val DEFAULT_SERVICE_ACCOUNT = "[email protected]"

Expand All @@ -42,12 +38,7 @@ data class SubmittedDeliveryConfig(
serviceAccount = serviceAccount
?: error("No service account specified, and no default applied"),
artifacts = artifacts.mapTo(mutableSetOf()) { artifact ->
when (artifact) {
is DebianArtifact -> artifact.copy(deliveryConfigName = safeName)
is DockerArtifact -> artifact.copy(deliveryConfigName = safeName)
is NpmArtifact -> artifact.copy(deliveryConfigName = safeName)
else -> throw UserException("Unrecognized artifact sub-type: ${artifact.type} (${artifact.javaClass.name})")
}
artifact.withDeliveryConfigName(safeName)
},
environments = environments.mapTo(mutableSetOf()) { env ->
env.toEnvironment()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class DummyArtifact(
) : DeliveryArtifact() {
override val type: ArtifactType = "dummy"
override val sortingStrategy = DummySortingStrategy
override fun withDeliveryConfigName(deliveryConfigName: String): DeliveryArtifact {
return this
}
}

object DummySortingStrategy : SortingStrategy {
Expand Down

0 comments on commit 88629af

Please sign in to comment.