blob: b48cfb52e8c86445a11d16b9e5e0fa98d399eaa8 [file] [log] [blame]
Zsolt Harasztiec7df102016-05-05 13:34:18 -07001/*
2 * Copyright 2012 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.opencord.build.rules
18
19import org.gradle.api.Rule
20import de.gesellix.gradle.docker.tasks.DockerTagTask
21
22
23/**
24 * Gradle Rule class to tag a docker image
25 */
26class DockerTagRule implements Rule {
27
28 def project
29
30 DockerTagRule(project) {
31 this.project = project
32 }
33
34 String getDescription() {
Zsolt Haraszti3dbe6162016-05-12 12:25:56 -070035 'Rule Usage: tag<component-name>'
Zsolt Harasztiec7df102016-05-05 13:34:18 -070036 }
37
38 void apply(String taskName) {
39 if (taskName.startsWith('tag')) {
40 project.task(taskName, type: DockerTagTask) {
41 ext.compName = taskName - 'tag'
42 dependsOn "fetch" + compName
43 def spec = project.comps[ext.compName]
44 imageId = spec.name + '@' + spec.digest
45 tag = compName + ':' + project.targetTag
46 }
47 }
48 }
49}