def test_check_application_version(): check_application_version('1.0') check_application_version('MyVersion') with pytest.raises(click.UsageError): check_application_id('.1') with pytest.raises(click.UsageError): check_application_id('1.')
def test_check_application_version(): check_application_version('1.0') check_application_version('MyVersion') with pytest.raises(click.UsageError): check_application_id('.1') with pytest.raises(click.UsageError): check_application_id('1.')
def extract_user_data(configuration, elastigroup_config, info: dict, force, account_info): """ This function converts a classic TaupageConfig into a base64 encoded value for the compute.launchSpecification.userData See https://api.spotinst.com/elastigroup/amazon-web-services/create/#compute.launchSpecification.userData Any existing TaupageConfig will _always_ overwrite the userData for the Elastigroup """ elastigroup_config = ensure_keys(elastigroup_config, "compute", "launchSpecification") taupage_config = configuration.get("TaupageConfig", None) if taupage_config: if 'notify_cfn' not in taupage_config: taupage_config['notify_cfn'] = { 'stack': '{}-{}'.format(info["StackName"], info["StackVersion"]), 'resource': configuration['Name'] } if 'application_id' not in taupage_config: taupage_config['application_id'] = info['StackName'] if 'application_version' not in taupage_config: taupage_config['application_version'] = info['StackVersion'] check_application_id(taupage_config['application_id']) check_application_version(taupage_config['application_version']) runtime = taupage_config.get('runtime') if runtime != 'Docker': raise click.UsageError( 'Taupage only supports the "Docker" runtime currently') source = taupage_config.get('source') if not source: raise click.UsageError( 'The "source" property of TaupageConfig must be specified') docker_image = pierone.api.DockerImage.parse(source) if not force and docker_image.registry: check_docker_image_exists(docker_image) user_data = base64.urlsafe_b64encode( generate_user_data(taupage_config, account_info.Region).encode('utf-8')) elastigroup_config["compute"]["launchSpecification"][ "userData"] = user_data.decode('utf-8')
def extract_user_data(configuration, elastigroup_config, info: dict, force, account_info): """ This function converts a classic TaupageConfig into a base64 encoded value for the compute.launchSpecification.userData See https://api.spotinst.com/elastigroup/amazon-web-services/create/#compute.launchSpecification.userData Any existing TaupageConfig will _always_ overwrite the userData for the Elastigroup """ elastigroup_config = ensure_keys(elastigroup_config, "compute", "launchSpecification") taupage_config = configuration.get("TaupageConfig", None) if taupage_config: if 'notify_cfn' not in taupage_config: taupage_config['notify_cfn'] = {'stack': '{}-{}'.format(info["StackName"], info["StackVersion"]), 'resource': configuration['Name']} if 'application_id' not in taupage_config: taupage_config['application_id'] = info['StackName'] if 'application_version' not in taupage_config: taupage_config['application_version'] = info['StackVersion'] check_application_id(taupage_config['application_id']) check_application_version(taupage_config['application_version']) runtime = taupage_config.get('runtime') if runtime != 'Docker': raise click.UsageError('Taupage only supports the "Docker" runtime currently') source = taupage_config.get('source') if not source: raise click.UsageError('The "source" property of TaupageConfig must be specified') docker_image = pierone.api.DockerImage.parse(source) if not force and docker_image.registry: check_docker_image_exists(docker_image) user_data = base64.urlsafe_b64encode(generate_user_data(taupage_config, account_info.Region).encode('utf-8')) elastigroup_config["compute"]["launchSpecification"]["userData"] = user_data.decode('utf-8')