/*
 * Copyright (c) 2019 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at:
 *
 *     https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
plugins {
    id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}"
    id 'org.eclipse.jkube.openshift' version "${jKubeVersion}"
    id 'java'
}

group = 'org.eclipse.jkube.integration.tests.gradle'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

def allProperties = new Properties()
allProperties.put("team","via-resource-groovy-dsl-labels-all")
allProperties.put("language", "via-resource-groovy-dsl-labels-all")
allProperties.put("provider", "via-resource-groovy-dsl-labels-all")
allProperties.put("app", "via-resource-groovy-dsl-labels-all")
allProperties.put("version", "via-resource-groovy-dsl-labels-all")
allProperties.put("group", "via-resource-groovy-dsl-labels-all")
allProperties.put("app.kubernetes.io/name", "via-resource-groovy-dsl-labels-all")
allProperties.put("app.kubernetes.io/version", "via-resource-groovy-dsl-labels-all")
allProperties.put("app.kubernetes.io/component", "via-resource-groovy-dsl-labels-all")
allProperties.put("app.kubernetes.io/managed-by", "via-resource-groovy-dsl-labels-all")
allProperties.put("app.kubernetes.io/part-of", "via-resource-groovy-dsl-labels-all")

def serviceProperties = new Properties();
serviceProperties.put("team", "via-resource-groovy-dsl-labels-service")
serviceProperties.put("language", "via-resource-groovy-dsl-labels-service")
serviceProperties.put("provider", "via-resource-groovy-dsl-labels-service")
serviceProperties.put("app", "via-resource-groovy-dsl-labels-service")
serviceProperties.put("version", "via-resource-groovy-dsl-labels-service")
serviceProperties.put("group", "via-resource-groovy-dsl-labels-service")
serviceProperties.put("app.kubernetes.io/name", "via-resource-groovy-dsl-labels-service")
serviceProperties.put("app.kubernetes.io/version", "via-resource-groovy-dsl-labels-service")
serviceProperties.put("app.kubernetes.io/component", "via-resource-groovy-dsl-labels-service")
serviceProperties.put("app.kubernetes.io/managed-by", "via-resource-groovy-dsl-labels-service")
serviceProperties.put("app.kubernetes.io/part-of", "via-resource-groovy-dsl-labels-service")

def extensionConfig = {
    offline = true
    images {
        image {
            name = 'repository/well-known-labels:latest'
            build {
                from = 'quay.io/jkube/jkube-java-11'
                ports = ['8080']
            }
        }
    }
if (project.hasProperty('labelsViaResourceConfig')) {
    resources {
        labels {
            all = allProperties
            service = serviceProperties
        }
    }
}
}

kubernetes(extensionConfig)
openshift(extensionConfig)
