示例#1
0
文件: cli.py 项目: humilis/humilis
def update(environment, stage, output, pretend, parameters):
    """Updates (or creates) an environment."""
    if parameters:
        with open(parameters, "r") as f:
            parameters = yaml.load(f.read())
    env = Environment(environment, stage=stage, parameters=parameters)
    if not pretend:
        env.create(output_file=output, update=True)
示例#2
0
文件: cli.py 项目: humilis/humilis
def create(environment, stage, output, pretend, parameters):
    """Creates an environment."""
    if parameters:
        with open(parameters, "r") as f:
            parameters = _ensure_defaults(yaml.load(f.read()))

    env = Environment(environment, stage=stage, parameters=parameters)
    if not pretend:
        env.create(output_file=output, update=False)
示例#3
0
文件: cli.py 项目: humilis/humilis
def delete(environment, stage, pretend, parameters):
    """Deletes an environment that has been deployed to CF."""
    if parameters:
        with open(parameters, "r") as f:
            parameters = yaml.load(f.read())

    env = Environment(environment, stage=stage, parameters=parameters)
    if not pretend:
        env.delete()
示例#4
0
文件: cli.py 项目: waldt/humilis
def delete(environment, stage, pretend, parameters):
    """Deletes an environment that has been deployed to CF."""
    if parameters:
        with open(parameters, "r") as f:
            parameters = yaml.load(f.read())

    env = Environment(environment, stage=stage, parameters=parameters)
    if not pretend:
        env.delete()
示例#5
0
文件: cli.py 项目: waldt/humilis
def create(environment, stage, output, pretend, parameters):
    """Creates an environment."""
    if parameters:
        with open(parameters, "r") as f:
            parameters = _ensure_defaults(yaml.load(f.read()))
        parameters = parameters.get(stage, parameters.get("_default"))

    env = Environment(environment, stage=stage, parameters=parameters)
    if not pretend:
        env.create(output_file=output, update=False)
示例#6
0
文件: cli.py 项目: waldt/humilis
def update(environment, stage, output, pretend, parameters):
    """Updates (or creates) an environment."""
    if parameters:
        with open(parameters, "r") as f:
            parameters = yaml.load(f.read())
        parameters = parameters.get(stage, parameters.get("_default"))

    env = Environment(environment, stage=stage, parameters=parameters)
    if not pretend:
        env.create(output_file=output, update=True)
def deploy_secrets(environment_file, stage="dev"):
    """Deploy secrets to the secrets vault."""
    env = Environment(environment_file, stage=stage)

    print("Deploying secrets to environment vault ...")
    for local_key, vault_key in SECRETS.items():
        value = keyring.get_password(NAMESPACE, local_key)
        resp = env.set_secret(vault_key, value)
        status = resp['ResponseMetadata']['HTTPStatusCode']
        print("Setting secret '{}': [{}]".format(vault_key, status))
def deploy_secrets(environment_file, stage="dev"):
    """Deploy secrets to the secrets vault."""
    env = Environment(environment_file, stage=stage)

    print("Deploying secrets to environment vault ...")
    for local_key, vault_key in SECRETS.items():
        value = keyring.get_password(NAMESPACE, local_key)
        resp = env.set_secret(vault_key, value)
        status = resp['ResponseMetadata']['HTTPStatusCode']
        print("Setting secret '{}': [{}]".format(vault_key, status))
def deploy_secrets(environment_file, stage="dev"):
    """Deploy secrets to the secrets vault."""
    env = Environment(environment_file, stage=stage)

    print("Deploying secrets to environment vault ...")
    for local_key, vault_key in SECRETS.items():
        keychain_namespace = NAMESPACE.format(stage=stage.lower())
        value = keyring.get_password(keychain_namespace, local_key) or \
            os.environ.get(local_key.replace(".", "_").upper())

        if value is None:
            print("Secret {}/{} not found in local keychain nor SENTRY_DSN "
                  "environment variable: skipping".format(keychain_namespace,
                                                          local_key))
        else:
            resp = env.set_secret(vault_key, value)
            status = resp['ResponseMetadata']['HTTPStatusCode']
            print("Setting secret '{}': [{}]".format(vault_key, status))
示例#10
0
def environment(settings):
    """The test environment: this fixtures creates it and takes care of
    removing it after tests have run."""
    env = Environment(settings.environment_path, stage=settings.stage)
    if os.environ.get("UPDATE", "yes") == "yes":
        env.create(update=True, output_file=settings.output_path)
    else:
        env.create(output_file=settings.output_path)

    val = keyring.get_password(
        "humilis-kinesis-processor/{}".format(settings.stage), "sentry/dsn")
    env.set_secret("sentry.dsn", val)
    yield env
    if os.environ.get("DESTROY", "yes") == "yes":
        # Empty the S3 bucket
        bucket = env.outputs["storage"]["BucketName"]
        os.system("aws s3 rm s3://{} --recursive".format(bucket))
        env.delete()
示例#11
0
def test_environment_params(environment_definition_j2_path,
                            environment_params_path, test_environment):
    """Tests using a params file in combination with an env def file."""
    with open(environment_params_path, "r") as f:
        params = yaml.load(f.read())
    env = Environment(environment_definition_j2_path, parameters=params)

    layer_params = env.layers[0].meta["parameters"]
    assert layer_params["vpc_cidr"]["value"] == params["vpc_cidr"]
示例#12
0
def deploy_secrets(environment_file, stage="dev"):
    """Deploy secrets to the secrets vault."""
    env = Environment(environment_file, stage=stage)

    print("Deploying secrets to environment vault ...")
    for local_key, vault_key in SECRETS.items():
        keychain_namespace = NAMESPACE.format(stage=stage.lower())
        value = keyring.get_password(keychain_namespace, local_key) or \
            os.environ.get(local_key.replace(".", "_").upper())

        if value is None:
            print("Secret {}/{} not found in local keychain nor SENTRY_DSN "
                  "environment variable: skipping".format(
                      keychain_namespace, local_key))
        else:
            resp = env.set_secret(vault_key, value)
            status = resp['ResponseMetadata']['HTTPStatusCode']
            print("Setting secret '{}': [{}]".format(vault_key, status))
示例#13
0
def environment(settings):
    """The test environment: this fixture creates it and takes care of
    removing it after tests have run."""
    env = Environment(settings.environment_path, stage=settings.stage)
    if settings.update == "yes":
        env.create(update=True)
    else:
        env.create()
    yield env
    if settings.destroy == "yes":
        env.delete()
示例#14
0
def environment(settings):
    """The test environment: this fixtures creates it and takes care of
    removing it after tests have run."""
    env = Environment(settings.environment_path, stage=settings.stage)
    if os.environ.get("UPDATE", "yes") == "yes":
        env.create(update=True, output_file=settings.output_path)
    else:
        env.create(output_file=settings.output_path)
    yield env
    if os.environ.get("DESTROY", "yes") == "yes":
        env.delete()
示例#15
0
def environment(settings):
    """The test environment: this fixtures creates it and takes care of
    removing it after tests have run."""
    env = Environment(settings.environment_path, stage=settings.stage)

    if os.environ.get("UPDATE", "yes") == "yes":
        env.create(update=True, output_file=settings.output_path)
    else:
        env.create(output_file=settings.output_path)
    yield env
    if os.environ.get("DESTROY", "no").lower() == "yes":
        bucket = env.outputs["asg"]["BucketName"]
        empty_bucket(bucket)
        try:
            env.delete()
        except AwsError as err:
            # Some files may have arrived to the bucket after the bucket was
            # emptied for the first time.
            empty_bucket(bucket)
            env.delete()
示例#16
0
def produce_environment(envpath, stage, parameters=None):
    """Produce humilis environment object."""
    if parameters:
        with open(parameters, "r") as f:
            parameters = yaml.load(f.read())
            stage_params = parameters.get(stage, {})
            stage_params["_default"] = parameters.get("_default", {})
    else:
        stage_params = {}

    return Environment(envpath, stage=stage, parameters=stage_params)
示例#17
0
def environment():
    """The test environment: this fixtures creates it and takes care of
    removing it after tests have run."""
    env = Environment("tests/integration/secrets-vault.yaml")
    env.create()
    yield env
    env.delete()
def environment(settings):
    """The test environment: this fixtures creates it and takes care of
    removing it after tests have run."""
    env = Environment(settings.environment_path, stage=settings.stage)
    if os.environ.get("UPDATE", "yes") == "yes":
        env.create(update=True, output_file=settings.output_path)
    else:
        env.create(output_file=settings.output_path)

    val = keyring.get_password(
        "humilis-kinesis-processor/{}".format(settings.stage), "sentry/dsn")
    env.set_secret("sentry.dsn", val)
    yield env
    if os.environ.get("DESTROY", "yes") == "yes":
        # Empty the S3 bucket
        bucket = env.outputs["storage"]["BucketName"]
        os.system("aws s3 rm s3://{} --recursive".format(bucket))
        env.delete()
示例#19
0
def environment(settings):
    """The test environment: this fixtures creates it and takes care of
    removing it after tests have run."""
    env = Environment(settings.environment_path, stage=settings.stage)
    if settings.update == "yes":
        env.create(update=True)
    else:
        env.create()
    yield env
    if settings.destroy == "yes":
        env.delete()
示例#20
0
def test_plugin(envfile):
    """Create and destroy the test environment of a humilis plugin."""
    envfile_path = os.path.join(EXAMPLES_DIR, envfile)
    env = Environment(envfile_path, stage="TEST")
    try:
        env.create(update=True)
    finally:
        env.delete()
示例#21
0
def environment(settings):
    """The test environment: this fixtures creates it and takes care of
    removing it after tests have run."""
    env = Environment(settings.environment_path, stage=settings.stage)
    env.create(update=True)
    yield env
    if os.environ.get("DESTROY", "yes").lower() == "yes":
        env.delete()
示例#22
0
def environment(settings):
    """The test environment: this fixtures creates it and takes care of
    removing it after tests have run."""
    env = Environment(settings.environment_path, stage=settings.stage)
    if os.environ.get("UPDATE", "yes") == "yes":
        env.create(update=True, output_file=settings.output_path)
    else:
        env.create(output_file=settings.output_path)
    yield env
    if os.environ.get("DESTROY", "yes") == "yes":
        # Empty the S3 bucket
        bucket = env.outputs["storage"]["BucketName"]
        os.system("aws s3 rm s3://{} --recursive".format(bucket))
        env.delete()
示例#23
0
def main(ctx, envpath, stage, parameters):
    """Polku sample app: deployment CLI."""
    ctx.obj = {"env": Environment(envpath, stage=stage, parameters=parameters)}
    config.context = ctx.obj
示例#24
0
文件: cli.py 项目: humilis/humilis
def delete(environment, stage, pretend, parameters):
    """Deletes an environment that has been deployed to CF."""
    env = Environment(environment, stage=stage, parameters=parameters)
    if not pretend:
        env.delete()
示例#25
0
文件: conftest.py 项目: waldt/humilis
def test_environment(environment_definition_path, test_config):
    """A humilis environment based on the sample environment definition."""
    return Environment(environment_definition_path)
示例#26
0
文件: cli.py 项目: humilis/humilis
def get_secret(environment, key, stage, pretend):
    """Gets a secret from the vault."""
    env = Environment(environment, stage=stage)
    if not pretend:
        resp = env.get_secret(key)
        print(resp)
示例#27
0
文件: cli.py 项目: humilis/humilis
def update(environment, stage, output, pretend, parameters):
    """Updates (or creates) an environment."""
    env = Environment(environment, stage=stage, parameters=parameters)
    if not pretend:
        env.create(output_file=output, update=True)
示例#28
0
文件: cli.py 项目: humilis/humilis
def set_secret(environment, key, value, stage, pretend):
    """Stores a secret in the vault."""
    env = Environment(environment, stage=stage)
    if not pretend:
        env.set_secret(key, value)
示例#29
0
文件: cli.py 项目: humilis/humilis
def create(environment, stage, output, pretend, parameters, debug):
    """Creates an environment."""
    env = Environment(environment, stage=stage, parameters=parameters)
    if not pretend:
        env.create(output_file=output, update=False, debug=debug)
示例#30
0
文件: cli.py 项目: humilis/humilis
def set_secret(environment, key, value, stage, pretend):
    """Stores a secret in the vault."""
    env = Environment(environment, stage=stage)
    if not pretend:
        env.set_secret(key, value)
示例#31
0
文件: cli.py 项目: humilis/humilis
def get_secret(environment, key, stage, pretend):
    """Gets a secret from the vault."""
    env = Environment(environment, stage=stage)
    if not pretend:
        resp = env.get_secret(key)
        print(resp)
示例#32
0
def environment(settings):
    """The io-streams-test humilis environment."""
    env = Environment(settings.environment_path, stage=settings.stage)
    env.create()
    return env