github.com/yrj2011/jx-test-infra@v0.0.0-20190529031832-7a2065ee98eb/image.bzl (about)

     1  # Copyright 2018 The Kubernetes Authors.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #     http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  
    15  # tags appends default tags to name
    16  #
    17  # In particular, names is a {image_prefix: image_target} mapping, which gets
    18  # expanded into three full image paths:
    19  #   image_prefix:latest
    20  #   image_prefix:latest-{BUILD_USER}
    21  #   image_prefix:{DOCKER_TAG}
    22  # (See hack/print-workspace-status.sh for how BUILD_USER and DOCKER_TAG are created.
    23  #
    24  # Concretely, tags(this=":that-image", foo="//bar") will return:
    25  #   {
    26  #     "this:latest": ":that-image",
    27  #     "this:latest-fejta": ":that-image",
    28  #     "this:20180203-deadbeef": ":that-image",
    29  #     "foo:latest": "//bar",
    30  #     "foo:latest-fejta": "//bar",
    31  #     "foo:20180203-deadbeef", "//bar",
    32  #   }
    33  def tags(**names):
    34    outs = {}
    35    for img, target in names.items():
    36      outs['%s:{DOCKER_TAG}' % img] = target
    37      outs['%s:latest-{BUILD_USER}' % img] = target
    38      outs['%s:latest' % img] = target
    39    return outs