blob: 474e16dc02ab0cdc606afa509c23b649d940b34f [file] [log] [blame]
Andy Bavieradea0fd2016-07-06 05:26:26 -04001/*
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.gradle.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() {
35 'Rule Usage: tag<component-name>'
36 }
37
38 void apply(String taskName) {
39 if (taskName.startsWith('tag') && !taskName.equals('tag')) {
40 project.task(taskName, type: DockerTagTask) {
41 ext.compName = taskName - 'tag'
42 def spec = project.comps[compName]
43 imageId = spec.name + '@' + spec.digest
44 tag = compName + ':' + project.targetTag
45 }
46 }
47 }
48}