Esempio n. 1
0
def gitlog():
    ecr = ECR()

    staging_deployment = Deployment('staging')
    staging_tag = staging_deployment.current_tag
    if staging_tag is None:
        raise HokusaiError("Could not find a tag 'staging'.  Aborting.")
    if staging_tag == 'staging':
        staging_tag = ecr.find_git_sha1_image_tag('staging')
        if staging_tag is None:
            print_red(
                "Could not find a git SHA1 tag for 'staging'.  Aborting.")
            return -1

    production_deployment = Deployment('production')
    production_tag = production_deployment.current_tag
    if production_tag is None:
        raise HokusaiError("Could not find a tag 'production'.  Aborting.")
    if production_tag == 'production':
        production_tag = ecr.find_git_sha1_image_tag('production')
        if production_tag is None:
            print_red(
                "Could not find a git SHA1 tag for 'production'.  Aborting.")
            return -1

    print_green("Comparing %s to %s" % (production_tag, staging_tag))
    shout("git log --right-only %s..%s" % (production_tag, staging_tag),
          print_output=True)
Esempio n. 2
0
def promote(migration, constraint, git_remote, timeout):
    ecr = ECR()

    deploy_from = Deployment('staging')
    tag = deploy_from.current_tag
    if tag is None:
        raise HokusaiError("Could not find a tag for staging.  Aborting.")
    tag = ecr.find_git_sha1_image_tag(tag)
    if tag is None:
        print_red("Could not find a git SHA1 for tag %s.  Aborting." % tag)
        return 1

    if migration is not None:
        print_green("Running migration '%s' on production..." % migration,
                    newline_after=True)
        return_code = CommandRunner('production').run(tag,
                                                      migration,
                                                      constraint=constraint,
                                                      tty=False)
        if return_code:
            raise HokusaiError("Migration failed with return code %s" %
                               return_code,
                               return_code=return_code)

    deploy_to = Deployment('production').update(tag, constraint, git_remote,
                                                timeout)
    print_green("Promoted staging to production at %s" % tag)
Esempio n. 3
0
def gitdiff():
    ecr = ECR()

    staging_deployment = Deployment('staging')
    staging_tag = staging_deployment.current_tag
    if staging_tag is None:
        raise HokusaiError("Could not find a tag for staging.  Aborting.")
    staging_tag = ecr.find_git_sha1_image_tag(staging_tag)
    if staging_tag is None:
        raise HokusaiError(
            "Could not find a git SHA1 tag for tag %s.  Aborting." %
            staging_tag)

    production_deployment = Deployment('production')
    production_tag = production_deployment.current_tag
    if production_tag is None:
        raise HokusaiError("Could not find a tag for production.  Aborting.")
    production_tag = ecr.find_git_sha1_image_tag(production_tag)
    if production_tag is None:
        raise HokusaiError("Could not find a git SHA1 for tag %s.  Aborting." %
                           production_tag)

    print_green("Comparing %s to %s" % (production_tag, staging_tag))
    for remote in shout('git remote').splitlines():
        shout("git fetch %s" % remote)
    shout("git diff %s %s" % (production_tag, staging_tag), print_output=True)
Esempio n. 4
0
def gitlog():
    ecr = ECR()

    staging_deployment = Deployment('staging')
    staging_tag = staging_deployment.current_tag
    if staging_tag is None:
        raise HokusaiError("Could not find a tag for staging.  Aborting.")
    staging_tag = ecr.find_git_sha1_image_tag(staging_tag)
    if staging_tag is None:
        raise HokusaiError(
            "Could not find a git SHA1 tag for tag %s.  Aborting." %
            staging_tag)

    production_deployment = Deployment('production')
    production_tag = production_deployment.current_tag
    if production_tag is None:
        raise HokusaiError("Could not find a tag for production.  Aborting.")
    production_tag = ecr.find_git_sha1_image_tag(production_tag)
    if production_tag is None:
        raise HokusaiError("Could not find a git SHA1 for tag %s.  Aborting." %
                           production_tag)

    print_green("Comparing %s to %s" % (production_tag, staging_tag))
    shout("git log --right-only %s..%s" % (production_tag, staging_tag),
          print_output=True)
Esempio n. 5
0
def update(context,
           tag,
           migration,
           constraint,
           git_remote,
           timeout,
           namespace=None,
           resolve_tag_sha1=True,
           update_config=False,
           filename=None):
    if migration is not None:
        print_green("Running migration '%s' on %s..." % (migration, context),
                    newline_after=True)
        return_code = CommandRunner(context, namespace=namespace).run(
            tag, migration, constraint=constraint, tty=False)
        if return_code:
            raise HokusaiError("Migration failed with return code %s" %
                               return_code,
                               return_code=return_code)
    Deployment(context,
               namespace=namespace).update(tag,
                                           constraint,
                                           git_remote,
                                           timeout,
                                           resolve_tag_sha1=resolve_tag_sha1,
                                           update_config=update_config,
                                           filename=filename)
    print_green("Deployment updated to %s" % tag)
Esempio n. 6
0
def promote(migration,
            constraint,
            git_remote,
            timeout,
            update_config=False,
            filename=None):
    if migration is not None:
        print_green("Running migration '%s' on production..." % migration,
                    newline_after=True)
        return_code = CommandRunner('production').run('staging',
                                                      migration,
                                                      constraint=constraint,
                                                      tty=False)
        if return_code:
            raise HokusaiError("Migration failed with return code %s" %
                               return_code,
                               return_code=return_code)

    Deployment('production').update('staging',
                                    constraint,
                                    git_remote,
                                    timeout,
                                    update_config=update_config,
                                    filename=filename)
    print_green("Promoted staging to production")
Esempio n. 7
0
def update(context, tag, migration, constraint, git_remote, namespace=None, resolve_tag_sha1=True):
  if migration is not None:
    print_green("Running migration '%s' on %s..." % (migration, context))
    return_code = CommandRunner(context, namespace=namespace).run(tag, migration, constraint=constraint)
    if return_code:
      raise HokusaiError("Migration failed with return code %s" % return_code, return_code=return_code)
  Deployment(context, namespace=namespace).update(tag, constraint, git_remote, resolve_tag_sha1=resolve_tag_sha1)
  print_green("Deployment updated to %s" % tag)
Esempio n. 8
0
def gitcompare(org_name, git_compare_link):
    ecr = ECR()

    staging_deployment = Deployment('staging')
    staging_tag = staging_deployment.current_tag
    if staging_tag is None:
        raise HokusaiError("Could not find a tag for staging.  Aborting.")
    staging_tag = ecr.find_git_sha1_image_tag(staging_tag)
    if staging_tag is None:
        raise HokusaiError(
            "Could not find a git SHA1 tag for tag %s.  Aborting." %
            staging_tag)

    production_deployment = Deployment('production')
    production_tag = production_deployment.current_tag
    if production_tag is None:
        raise HokusaiError("Could not find a tag for production.  Aborting.")
    production_tag = ecr.find_git_sha1_image_tag(production_tag)
    if production_tag is None:
        raise HokusaiError("Could not find a git SHA1 for tag %s.  Aborting." %
                           production_tag)

    print_green(git_compare_link %
                (org_name, config.project_name, production_tag, staging_tag))
Esempio n. 9
0
def refresh(context, deployment_name, namespace=None):
  deployment = Deployment(context, deployment_name=deployment_name, namespace=namespace)
  deployment.refresh()
Esempio n. 10
0
 def test_04_deployment_refresh(self, mocked_sys_exit):
     deployment = Deployment(TEST_KUBE_CONTEXT)
     deployment.refresh()