Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
*
* Copyright 2019 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.netflix.spinnaker.keel.sql
import com.fasterxml.jackson.databind.JsonMappingException
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import com.netflix.spinnaker.exceptions.ArtifactParsingException
import com.netflix.spinnaker.keel.api.artifacts.ArtifactStatus
import com.netflix.spinnaker.keel.api.artifacts.ArtifactType
import com.netflix.spinnaker.keel.api.artifacts.BuildMetadata
import com.netflix.spinnaker.keel.api.artifacts.DeliveryArtifact
import com.netflix.spinnaker.keel.api.artifacts.GitMetadata
import com.netflix.spinnaker.keel.api.artifacts.PublishedArtifact
import com.netflix.spinnaker.keel.api.plugins.ArtifactSupplier
import com.netflix.spinnaker.keel.artifacts.DockerArtifact
import com.netflix.spinnaker.keel.artifacts.TagComparator
import com.netflix.spinnaker.keel.exceptions.InvalidRegexException
import com.netflix.spinnaker.keel.persistence.metamodel.Tables.ARTIFACT_VERSIONS
import com.netflix.spinnaker.keel.serialization.configuredObjectMapper
import org.jooq.Record7
import org.jooq.ResultQuery
import org.jooq.SelectConditionStep
import org.slf4j.LoggerFactory
import java.time.Instant
private val objectMapper: ObjectMapper = configuredObjectMapper()
private val log by lazy { LoggerFactory.getLogger("ArtifactUtils") }
internal val ARTIFACT_VERSIONS_BRANCH =
field("json_unquote(keel.artifact_versions.git_metadata->'$.branch')")
internal val ARTIFACT_VERSIONS_PR_NUMBER =
field("json_unquote(keel.artifact_versions.git_metadata->'$.pullRequest.number')")
internal const val EMPTY_PR_NUMBER = "\"\""
/**
* A helper function to construct the proper artifact type from the serialized JSON.
*/
fun mapToArtifact(
artifactSupplier: ArtifactSupplier<*, *>,
name: String,
type: ArtifactType,
json: String,
reference: String,
deliveryConfigName: String
): DeliveryArtifact {
try {
val artifactAsMap = objectMapper.readValue