How to use the hokusai.lib.config.config.project_name 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 / services / command_runner.py View on Github external
def run(self, image_tag, cmd, tty=False, env=(), constraint=()):
    if not self.ecr.project_repo_exists():
      raise HokusaiError("Project repo does not exist.  Aborting.")

    if os.environ.get('USER') is not None:
      uuid = "%s-%s" % (os.environ.get('USER'), k8s_uuid())
    else:
      uuid = k8s_uuid()

    name = "%s-hokusai-run-%s" % (config.project_name, uuid)
    image_name = "%s:%s" % (self.ecr.project_repo, image_tag)
    container = {
      "args": cmd.split(' '),
      "name": name,
      "image": image_name,
      "imagePullPolicy": "Always",
      'envFrom': [{'configMapRef': {'name': "%s-environment" % config.project_name}}]
    }

    run_tty = tty or config.run_tty
    if run_tty:
      container.update({
        "stdin": True,
        "stdinOnce": True,
        "tty": True
      })
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
def __init__(self, context, deployment_name=None, namespace=None):
    self.context = context
    self.namespace = namespace
    self.kctl = Kubectl(self.context, namespace=namespace)
    self.ecr = ECR()
    if deployment_name:
      self.cache = [self.kctl.get_object("deployment %s" % deployment_name)]
    else:
      self.cache = self.kctl.get_objects('deployment', selector="app=%s,layer=application" % config.project_name)
github artsy / hokusai / hokusai / commands / pull.py View on Github external
def pull(tag, local_tag):
  ecr = ECR()
  if not ecr.project_repo_exists():
    raise HokusaiError("ECR repo %s does not exist... did you run `hokusai setup` for this project?" % config.project_name)

  shout(ecr.get_login(), mask=(r'^(docker login -u) .+ (-p) .+ (.+)$', r'\1 ****** \2 ***** \3'))

  shout("docker pull %s:%s" % (ecr.project_repo, tag))

  shout("docker tag %s:%s hokusai_%s:%s" % (ecr.project_repo, tag, config.project_name, local_tag))
  
  print_green("Pulled %s:%s to hokusai_%s:%s" % (ecr.project_repo, tag, config.project_name, local_tag), newline_after=True)
github artsy / hokusai / hokusai / commands / check.py View on Github external
def check():
  return_code = 0

  def check_ok(check_item):
    print_green(u'\u2714 ' + check_item + ' found')

  def check_err(check_item):
    print_red(u'\u2718 ' + check_item + ' not found')

  config.check()

  try:
    config.project_name
    check_ok('Config project-name')
  except HokusaiError:
    check_err('Config project-name')

  try:
    shout('docker --version')
    check_ok('docker')
  except CalledProcessError:
    check_err('docker')
    return_code += 1

  try:
    shout('docker-compose --version')
    check_ok('docker-compose')
  except CalledProcessError:
    check_err('docker-compose')
github artsy / hokusai / hokusai / services / configmap.py View on Github external
def __init__(self, context, namespace='default', name=None):
    self.context = context
    self.kctl = Kubectl(context, namespace=namespace)
    self.name = name or "%s-environment" % config.project_name
    self.metadata = {
      'name': self.name,
      'namespace': namespace
    }
    if name is None:
      self.metadata['labels'] = { 'app': config.project_name }
    self.struct = {
      'apiVersion': 'v1',
      'kind': 'ConfigMap',
      'metadata': self.metadata,
      'data': {}
    }
github artsy / hokusai / hokusai / services / ecr.py View on Github external
  @property
  def images(self):
    if self.__images is None:
      images = []
      res = self.client.describe_images(registryId=self.aws_account_id,
                                    repositoryName=config.project_name)
      images += res['imageDetails']
      while 'nextToken' in res:
        res = self.client.describe_images(registryId=self.aws_account_id,
                                      repositoryName=config.project_name,
                                      nextToken=res['nextToken'])
        images += res['imageDetails']
      self.__images = images
    return self.__images
github artsy / hokusai / hokusai / services / service.py View on Github external
def __init__(self, context, application_only=True):
    self.context = context
    self.kctl = Kubectl(self.context)

    if application_only:
      selector = "app=%s,layer=application" % config.project_name
    else:
      selector = "app=%s" % config.project_name

    self.cache = self.kctl.get_object('service', selector=selector)
github artsy / hokusai / hokusai / services / deployment.py View on Github external
def __init__(self, context):
    self.context = context
    self.kctl = Kubectl(self.context)
    self.cache = self.kctl.get_object('deployment', selector="app=%s,layer=application" % config.project_name)
github artsy / hokusai / hokusai / services / service.py View on Github external
def __init__(self, context):
    self.context = context
    self.kctl = Kubectl(self.context)
    self.cache = self.kctl.get_object('service', selector="app=%s,layer=application" % config.project_name)