How to use the hokusai.lib.common.clean_string 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 / 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]
    else:
github artsy / hokusai / hokusai / commands / namespace.py View on Github external
def create_new_app_yaml(source_file, app_name):
  with open(source_file, 'r') as stream:
    try:
      yaml_content = list(yaml.load_all(stream))
    except yaml.YAMLError as exc:
      raise HokusaiError("Cannot read source yaml file %s." % source_file)

  for c in yaml_content: update_namespace(c, clean_string(app_name))

  new_namespace = OrderedDict([
      ('apiVersion', 'v1'),
      ('kind', 'Namespace'),
      ('metadata', {
        'name': clean_string(app_name)
      })
    ])
  yaml_content = [new_namespace] + yaml_content

  with open(os.path.join(CWD, HOKUSAI_CONFIG_DIR, "%s.yml" % app_name), 'w') as output:
    output.write(YAML_HEADER)
    yaml.safe_dump_all(yaml_content, output, default_flow_style=False)

  print_green("Created %s/%s.yml" % (HOKUSAI_CONFIG_DIR, app_name))
github artsy / hokusai / hokusai / cli / review_app.py View on Github external
def run(app_name, command, tty, tag, env, constraint, verbose):
  """Launch a new container and run a command"""
  set_verbosity(verbose)
  if tag is None:
    tag = clean_string(app_name)
  hokusai.run(KUBE_CONTEXT, command, tty, tag, env, constraint, namespace=clean_string(app_name))
github artsy / hokusai / hokusai / cli / review_app.py View on Github external
def status(app_name, resources, pods, describe, top, verbose):
  """Print the Kubernetes resources status defined in the staging context / {APP_NAME} namespace"""
  set_verbosity(verbose)
  hokusai.k8s_status(KUBE_CONTEXT, resources, pods, describe, top, namespace=clean_string(app_name), filename=os.path.join(CWD, HOKUSAI_CONFIG_DIR, "%s.yml" % app_name))
github artsy / hokusai / hokusai / cli / review_app.py View on Github external
def update(app_name, verbose):
  """Updates the Kubernetes based resources defined in ./hokusai/{APP_NAME}.yml"""
  set_verbosity(verbose)
  hokusai.k8s_update(KUBE_CONTEXT, namespace=clean_string(app_name), filename=os.path.join(CWD, HOKUSAI_CONFIG_DIR, "%s.yml" % app_name), skip_checks=True)
github artsy / hokusai / hokusai / cli / review_app.py View on Github external
def run(app_name, command, tty, tag, env, constraint, verbose):
  """Launch a new container and run a command"""
  set_verbosity(verbose)
  if tag is None:
    tag = clean_string(app_name)
  hokusai.run(KUBE_CONTEXT, command, tty, tag, env, constraint, namespace=clean_string(app_name))
github artsy / hokusai / hokusai / cli / review_app.py View on Github external
def get(app_name, env_vars, verbose):
  """Print environment variables stored on the Kubernetes server"""
  set_verbosity(verbose)
  hokusai.get_env(KUBE_CONTEXT, env_vars, namespace=clean_string(app_name))
github artsy / hokusai / hokusai / cli / review_app.py View on Github external
def unset(app_name, env_vars, verbose):
  """Unset environment variables - each of {ENV_VARS} must be of the form 'KEY'"""
  set_verbosity(verbose)
  hokusai.unset_env(KUBE_CONTEXT, env_vars, namespace=clean_string(app_name))