| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| """Recipe for pushing goma docker images and deploying them to k8s.""" |
| |
| from recipe_engine.recipe_api import Property |
| |
| DEPS = [ |
| "fuchsia/docker", |
| "fuchsia/gcloud", |
| "recipe_engine/buildbucket", |
| "recipe_engine/properties", |
| "recipe_engine/time", |
| "recipe_engine/url", |
| ] |
| |
| PROPERTIES = { |
| "domain": Property( |
| kind=str, help="domain name of container registry", default="gcr.io" |
| ), |
| "project": Property( |
| kind=str, help="name of goma cloud project", default="goma-fuchsia" |
| ), |
| "upstream_tag": Property( |
| kind=str, |
| help="container tag used to pull images from upstream", |
| default="latest", |
| ), |
| } |
| |
| SERVER_IMAGES = [ |
| "auth-server", |
| "cache-server", |
| "cmd-server", |
| "exec-server", |
| "execlog-server", |
| "file-server", |
| "frontend", |
| "gomatools", |
| ] |
| |
| UPSTREAM_PROJECT_ID = "cxx-compiler-service" |
| |
| |
| def generate_time_stamp(api): |
| return "{:%Y%m%d_%H%M%S}".format(api.time.utcnow()) |
| |
| |
| def RunSteps(api, domain, project, upstream_tag): |
| timestamp = generate_time_stamp(api) |
| api.gcloud("config", "set", "project", project) |
| |
| # Pull prebuilts from goma-teams' container registry and push them to |
| # project's container registry. |
| for item in SERVER_IMAGES: |
| upstream_container_tag = api.url.join(domain, UPSTREAM_PROJECT_ID, item) |
| container_tag = api.url.join(domain, project, item) |
| api.docker( |
| "pull", upstream_container_tag, step_name="pull %s from upstream" % item |
| ) |
| api.docker( |
| "tag", upstream_container_tag, container_tag, step_name="tag %s" % item |
| ) |
| api.docker( |
| "tag", |
| upstream_container_tag + ":" + upstream_tag, |
| container_tag + ":" + timestamp, |
| step_name="tag %s with timestamp" % item, |
| ) |
| api.docker("push", container_tag, step_name="push %s" % item) |
| api.docker( |
| "push", |
| container_tag + ":" + timestamp, |
| step_name="push %s with timestamp" % item, |
| ) |
| |
| |
| def GenTests(api): |
| default_properties = api.properties( |
| domain="gcr.io", |
| cluster="rbe-dev", |
| project="goma-fuchsia", |
| upstream_tag="latest", |
| ) |
| |
| yield api.test("default") + default_properties + api.buildbucket.try_build( |
| git_repo="https://fuchsia.googlesource.com/integration" |
| ) |