How to use the hokusai.CWD 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 / test / unit / test_config_loader.py View on Github external
def test_load_config(self):
    _config_file = os.path.join(CWD, 'test/fixtures/template_config.yml')
    config_loader = ConfigLoader(_config_file)
    template_config = config_loader.load()
    self.assertEqual("eggs", template_config["vars"]["imageTag"])
github artsy / hokusai / test / unit / test_docker_compose_helpers.py View on Github external
def test_follows_extends(self):
    httpretty.register_uri(httpretty.POST, "https://sts.amazonaws.com/",
                            body=open(os.path.join(os.getcwd(), 'test', 'fixtures', 'sts-get-caller-identity-response.xml')).read(),
                            content_type="application/xml")
    httpretty.register_uri(httpretty.POST, "https://api.ecr.us-east-1.amazonaws.com/",
                            body=open(os.path.join(os.getcwd(), 'test', 'fixtures', 'ecr-repositories-response.json')).read(),
                            content_type="application/x-amz-json-1.1")
    docker_compose_yml = os.path.join(CWD, 'test/fixtures/project/hokusai/docker-compose-extends.yml.j2')
    rendered_templates = docker_compose_helpers.follow_extends(docker_compose_yml)
    self.assertEqual(len(rendered_templates), 1)

    with open(rendered_templates[0], 'r') as f:
      struct = yaml.safe_load(f.read())
      self.assertEqual(struct['services']['nancy']['build']['context'], '../')
github artsy / hokusai / test / unit / test_template_selector.py View on Github external
def setUp(self):
    self.template_path = os.path.join(CWD, 'test/fixtures/project/hokusai')
github artsy / hokusai / test / unit / test_yaml_spec.py View on Github external
def setUp(self):
    self.kubernetes_yml = os.path.join(CWD, 'test/fixtures/kubernetes-config.yml')
github artsy / hokusai / hokusai / commands / setup.py View on Github external
def setup(project_name, template_remote, template_dir, template_vars, allow_missing_vars):
  mkpath(os.path.join(CWD, HOKUSAI_CONFIG_DIR))
  config.create(clean_string(project_name))

  ecr = ECR()
  if ecr.project_repo_exists():
    print_green("Project repo %s already exists.  Skipping create." % ecr.project_repo)
  else:
    ecr.create_project_repo()
    print_green("Created project repo %s" % ecr.project_repo)

  scratch_dir = None
  if template_remote:
    scratch_dir = tempfile.mkdtemp()
    git_repo_and_branch = template_remote.split('#', 1)
    git_repo = git_repo_and_branch[0]
    if len(git_repo_and_branch) == 2:
      git_branch = git_repo_and_branch[1]
github artsy / hokusai / hokusai / cli / base.py View on Github external
@click.option('--project-name', type=click.STRING, default=os.path.basename(hokusai.CWD), help='The project name (default: name of current directory)')
@click.option('--template-remote', type=click.STRING, help='Git remote of templates to use - you can specify a branch via #')
@click.option('--template-dir', type=click.STRING, help='Directory of templates to use - can be used with --template-remote')
@click.option('--var', type=click.STRING, multiple=True, help='Extra variables to render Jinja templates in the form of key=value')
@click.option('--allow-missing-vars', is_flag=True, help='Do not fail on undefined template vars')
@click.option('-v', '--verbose', type=click.BOOL, is_flag=True, help='Verbose output')
def setup(project_name, template_remote, template_dir, var, allow_missing_vars, verbose):
  """Set up Hokusai for the current project"""
  set_verbosity(verbose)
  hokusai.setup(project_name, template_remote, template_dir, var, allow_missing_vars)
github artsy / hokusai / hokusai / cli / review_app.py View on Github external
def delete(app_name, verbose):
  """Deletes the Kubernetes based resources defined in ./hokusai/{APP_NAME}.yml"""
  set_verbosity(verbose)
  hokusai.k8s_delete(KUBE_CONTEXT, namespace=clean_string(app_name), filename=os.path.join(CWD, HOKUSAI_CONFIG_DIR, "%s.yml" % app_name))
github artsy / hokusai / hokusai / commands / kubernetes.py View on Github external
def k8s_create(context, tag='latest', namespace=None, filename=None, environment=()):
  if filename is None:
    kubernetes_yml = os.path.join(CWD, HOKUSAI_CONFIG_DIR, "%s.yml" % context)
  else:
    kubernetes_yml = filename

  if not os.path.isfile(kubernetes_yml):
    raise HokusaiError("Yaml file %s does not exist." % kubernetes_yml)

  ecr = ECR()
  if not ecr.project_repo_exists():
    raise HokusaiError("ECR repository %s does not exist... did you run `hokusai setup` for this project?" % config.project_name)

  if not ecr.tag_exists(tag):
    raise HokusaiError("Image tag %s does not exist... did you run `hokusai registry push`?" % tag)

  if tag is 'latest' and not ecr.tag_exists(context):
    ecr.retag(tag, context)
    print_green("Updated tag 'latest' -> %s" % context)