How to use the hokusai.lib.common.print_yellow function in hokusai

To help you get started, we’ve selected a few hokusai examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github artsy / hokusai / hokusai / commands / images.py View on Github external
print_green('----------------------------------------------------------')

  for image in filtered_images[:limit]:
    image_tags = ', '.join(image['imageTags'])
    if digests:
      line = "%s | %s | %s" % (image['imagePushedAt'], image['imageDigest'], image_tags)
    else:
      line = "%s | %s" % (image['imagePushedAt'], image_tags)
    if 'production' in image['imageTags']:
      print_green(line)
    elif 'staging' in image['imageTags']:
      print_yellow(line)
    else:
      print_smart(line)

  print_yellow("%d more images available" % (len(filtered_images) - len(filtered_images[:limit])),
                newline_before=True, newline_after=True)
github artsy / hokusai / hokusai / services / deployment.py View on Github external
rollout_commands = [self.kctl.command("rollout status deployment/%s" % deployment['metadata']['name']) for deployment in self.cache]
    return_codes = shout_concurrent(rollout_commands, print_output=True)
    if any(return_codes):
      print_red("One or more deployment rollouts failed!  Rolling back...", newline_before=True, newline_after=True)
      rollback_commands = [self.kctl.command("rollout undo deployment/%s" % deployment['metadata']['name']) for deployment in self.cache]
      shout_concurrent(rollback_commands, print_output=True)
      raise HokusaiError("Deployment failed!")

    post_deploy_success = True

    # Run the post-deploy hook for the canonical app or a review app
    if config.post_deploy and (filename is None or (filename and self.namespace)):
      print_green("Running post-deploy hook '%s'..." % config.post_deploy, newline_after=True)
      return_code = CommandRunner(self.context, namespace=self.namespace).run(tag, config.post_deploy, constraint=constraint, tty=False)
      if return_code:
        print_yellow("WARNING: Running the post-deploy hook failed with return code %s" % return_code, newline_before=True, newline_after=True)
        print_yellow("The image digest %s has been rolled out.  However, you should run the post-deploy hook '%s' manually, or re-run this deployment." % (digest, config.post_deploy), newline_after=True)
        post_deploy_success = False

    # For the canonical app, create tags
    if filename is None:
      deployment_tag = "%s--%s" % (self.context, datetime.datetime.utcnow().strftime("%Y-%m-%d--%H-%M-%S"))
      print_green("Updating ECR deployment tags in %s..." % self.ecr.project_repo, newline_after=True)
      try:
        self.ecr.retag(tag, self.context)
        print_green("Updated ECR tag %s -> %s" % (tag, self.context))

        self.ecr.retag(tag, deployment_tag)
        print_green("Updated ECR tag %s -> %s" % (tag, deployment_tag), newline_after=True)
      except (ValueError, ClientError) as e:
        print_yellow("WARNING: Updating ECR deployment tags failed due to the error: '%s'" % str(e), newline_before=True, newline_after=True)
        print_yellow("The tag %s has been rolled out.  However, you should create the ECR tags '%s' and '%s' manually, or re-run this deployment." % (tag, deployment_tag, self.context), newline_after=True)
github artsy / hokusai / hokusai / services / deployment.py View on Github external
return_codes = shout_concurrent(rollout_commands, print_output=True)
    if any(return_codes):
      print_red("One or more deployment rollouts failed!  Rolling back...", newline_before=True, newline_after=True)
      rollback_commands = [self.kctl.command("rollout undo deployment/%s" % deployment['metadata']['name']) for deployment in self.cache]
      shout_concurrent(rollback_commands, print_output=True)
      raise HokusaiError("Deployment failed!")

    post_deploy_success = True

    # Run the post-deploy hook for the canonical app or a review app
    if config.post_deploy and (filename is None or (filename and self.namespace)):
      print_green("Running post-deploy hook '%s'..." % config.post_deploy, newline_after=True)
      return_code = CommandRunner(self.context, namespace=self.namespace).run(tag, config.post_deploy, constraint=constraint, tty=False)
      if return_code:
        print_yellow("WARNING: Running the post-deploy hook failed with return code %s" % return_code, newline_before=True, newline_after=True)
        print_yellow("The image digest %s has been rolled out.  However, you should run the post-deploy hook '%s' manually, or re-run this deployment." % (digest, config.post_deploy), newline_after=True)
        post_deploy_success = False

    # For the canonical app, create tags
    if filename is None:
      deployment_tag = "%s--%s" % (self.context, datetime.datetime.utcnow().strftime("%Y-%m-%d--%H-%M-%S"))
      print_green("Updating ECR deployment tags in %s..." % self.ecr.project_repo, newline_after=True)
      try:
        self.ecr.retag(tag, self.context)
        print_green("Updated ECR tag %s -> %s" % (tag, self.context))

        self.ecr.retag(tag, deployment_tag)
        print_green("Updated ECR tag %s -> %s" % (tag, deployment_tag), newline_after=True)
      except (ValueError, ClientError) as e:
        print_yellow("WARNING: Updating ECR deployment tags failed due to the error: '%s'" % str(e), newline_before=True, newline_after=True)
        print_yellow("The tag %s has been rolled out.  However, you should create the ECR tags '%s' and '%s' manually, or re-run this deployment." % (tag, deployment_tag, self.context), newline_after=True)
        post_deploy_success = False
github artsy / hokusai / hokusai / services / yaml_spec.py View on Github external
template_config = {
      "project_name": config.project_name
    }

    try:
      template_config["project_repo"] = self.ecr.project_repo
    except NoCredentialsError:
      print_yellow("WARNING: Could not get template variable project_repo")

    if config.template_config_files:
      for template_config_file in config.template_config_files:
        try:
          config_loader = ConfigLoader(template_config_file)
          template_config.update(config_loader.load())
        except NoCredentialsError:
          print_yellow("WARNING: Could not get template config file %s" % template_config_file)

    return TemplateRenderer(self.kubernetes_yaml, template_config).render()
github artsy / hokusai / hokusai / services / yaml_spec.py View on Github external
def to_string(self):
    template_config = {
      "project_name": config.project_name
    }

    try:
      template_config["project_repo"] = self.ecr.project_repo
    except NoCredentialsError:
      print_yellow("WARNING: Could not get template variable project_repo")

    if config.template_config_files:
      for template_config_file in config.template_config_files:
        try:
          config_loader = ConfigLoader(template_config_file)
          template_config.update(config_loader.load())
        except NoCredentialsError:
          print_yellow("WARNING: Could not get template config file %s" % template_config_file)

    return TemplateRenderer(self.kubernetes_yaml, template_config).render()
github artsy / hokusai / hokusai / services / deployment.py View on Github external
shout("git fetch -f %s --tags" % remote)
            shout("git tag -f %s %s" % (self.context, tag), print_output=True)
            shout("git tag -f %s %s" % (deployment_tag, tag), print_output=True)
            shout("git push -f --no-verify %s refs/tags/%s" % (remote, self.context), print_output=True)
            print_green("Updated Git tag %s -> %s" % (tag, self.context))
            shout("git push -f --no-verify %s refs/tags/%s" % (remote, deployment_tag), print_output=True)
            print_green("Updated Git tag %s -> %s" % (tag, deployment_tag), newline_after=True)
            git_tag_sucess = True
          except CalledProcessError as e:
            # If subprocess.check_output() was called, the actual error is in CalledProcessError's 'output' attribute.
            print_yellow("WARNING: Creating Git deployment tags failed due to the error:", newline_before=True, newline_after=True)
            print_yellow(e.output)
            time.sleep(3)

        if (not git_tag_sucess):
            print_yellow("Failed all attempts at pushing Git deployment tags! Please do it manually.", newline_after=True)

    if post_deploy_success:
      print_green("Deployment succeeded!")
    else:
      raise HokusaiError("One or more post-deploy steps failed!")