/*
 * Copyright 2012 the original author or authors.
 *
 * 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.
 */

import org.opencord.gradle.rules.*
import org.yaml.snakeyaml.Yaml

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "gradle.plugin.com.dorongold.plugins:task-tree:1.2.1"
  }
}

apply plugin: "com.dorongold.task-tree"

evaluationDependsOn(':maas')
evaluationDependsOn(':platform-install')
evaluationDependsOn(':onos-apps')

allprojects {
    apply plugin: 'base'
    apply plugin: 'de.gesellix.docker'
    //apply plugin: 'com.tmiyamon.config'

    docker {
        // dockerHost = System.env.DOCKER_HOST ?: 'unix:///var/run/docker.sock'
        // dockerHost = System.env.DOCKER_HOST ?: 'https://192.168.99.100:2376'
        // certPath = System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default"
        // authConfigPlain = [
        //   "username"       : "joe",
        //   "password"       : "some-pw-as-needed",
        //   "email"          : "joe@acme.com",
        //   "serveraddress"  : "https://index.docker.io/v1/"
        //  ]
    }
}

ext {

    // Upstream registry to simplify filling out the comps table below
    upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'

    // Target registry to be used to publish docker images needed for deployment
    targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000'

    // The tag used to tag the docker images push to the target registry
    targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate'

    // Component table
    comps = [
            'onosproject/onos': [
                    'type':     'image',
                    'upstream': upstreamReg,
                    'name':     'onosproject/onos',
                    'digest':   'sha256:6c310b6bc798f745977973c8c883d3dd1eb250fd124ae4d627fd98a69efb5afc'
            ],
            'nginx': [
                    'type':     'image',
                    'upstream': upstreamReg,
                    'name':     'nginx',
                    'digest':   'sha256:b555f8c64ab4e85405e0d8b03f759b73ce88deb802892a3b155ef55e3e832806'
            ],
            'swarm': [
                    'type':     'image',
                    'upstream': upstreamReg,
                    'name':     'swarm',
                    'digest':   'sha256:6ca9b40980e2fcdcd229900ec8933f3e92c14ead22c9404cb09736cb4f3a9248'
            ],
            'xosproject/vsg': [
                    'type':     'image',
                    'upstream': upstreamReg,
                    'name':     'xosproject/vsg',
                    'digest':   'sha256:18d1c6ef9767d8a41c9b51948776052d024d4e3294e5d1d6dde1a49112175d91'
            ],
            'xosproject/xos-postgres': [
                    'type':     'image',
                    'upstream': upstreamReg,
                    'name':     'xosproject/xos-postgres',
                    'digest':   'sha256:f2d31a50b8af7434ab07b1e54e99c1ff1e10d77d16a46e5d6933d3c0528f4820'
            ],
            'xosproject/cord-app-build': [
                    'type':     'image',
                    'upstream': upstreamReg,
                    'name':     'xosproject/cord-app-build',
                    'digest':   'sha256:528c6ac3a87609779035857a7b1cf9fab8e046e7ac259d72cf275f1c46d7416e'
            ],
            'redis': [
                    'type':     'image',
                    'upstream': upstreamReg,
                    'name':     'redis',
                    'digest':   'sha256:0fe5a7afa2c2154f37c8ab56a9a6c5023cb0405cc0e85b34d8dcc1de6c3f143e'
            ],
    ]

    // Deployment target config file (yaml format); this can be overwritten from the command line
    // using the -PdeployConfig=<file-path> syntax.
    deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'

}

// ---------------- Useful tasks ----------------

task fetchUpstreamImages {
    comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } }
}


task fetch  {
    dependsOn fetchUpstreamImages
}

task buildImages  {
    logger.info "Root project has nothing to build"
}

task publishImages {
    comps.each { name, spec -> if (spec.type == 'image') { 
            dependsOn "publish" + name 
          } 
    }
}

task publish {
    dependsOn publishImages
}

tasks.addRule(new DockerFetchRule(project))
tasks.addRule(new DockerPublishRule(project, project(':maas').prime))
tasks.addRule(new DockerTagRule(project))

project('platform-install').deployPlatform.dependsOn project(':maas').deployBase
project('onos-apps').publishMavenRepoImage.dependsOn project(':maas').prime
project('platform-install').deployPlatform.dependsOn project(':onos-apps').deploy
project(':onos-apps').deploy.dependsOn project(':maas').deployBase


task deploy  {
    dependsOn << project(':platform-install').deployPlatform
}

