repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
ECRL/ecabc | ecabc/abc.py | ABC.save_settings | def save_settings(self, filename):
'''Save settings to a JSON file
Arge:
filename (string): name of the file to save to
'''
data = dict()
data['valueRanges'] = self._value_ranges
data['best_values'] = [str(value) for value in self._best_values]
data[... | python | def save_settings(self, filename):
'''Save settings to a JSON file
Arge:
filename (string): name of the file to save to
'''
data = dict()
data['valueRanges'] = self._value_ranges
data['best_values'] = [str(value) for value in self._best_values]
data[... | [
"def",
"save_settings",
"(",
"self",
",",
"filename",
")",
":",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"'valueRanges'",
"]",
"=",
"self",
".",
"_value_ranges",
"data",
"[",
"'best_values'",
"]",
"=",
"[",
"str",
"(",
"value",
")",
"for",
"value",
... | Save settings to a JSON file
Arge:
filename (string): name of the file to save to | [
"Save",
"settings",
"to",
"a",
"JSON",
"file"
] | train | https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L620-L636 |
ECRL/ecabc | ecabc/bees.py | EmployerBee.get_score | def get_score(self, error=None):
'''Calculate bee's fitness score given a value returned by the fitness
function
Args:
error (float): value returned by the fitness function
Returns:
float: derived fitness score
'''
if error is not None:
... | python | def get_score(self, error=None):
'''Calculate bee's fitness score given a value returned by the fitness
function
Args:
error (float): value returned by the fitness function
Returns:
float: derived fitness score
'''
if error is not None:
... | [
"def",
"get_score",
"(",
"self",
",",
"error",
"=",
"None",
")",
":",
"if",
"error",
"is",
"not",
"None",
":",
"self",
".",
"error",
"=",
"error",
"if",
"self",
".",
"error",
">=",
"0",
":",
"return",
"1",
"/",
"(",
"self",
".",
"error",
"+",
"... | Calculate bee's fitness score given a value returned by the fitness
function
Args:
error (float): value returned by the fitness function
Returns:
float: derived fitness score | [
"Calculate",
"bee",
"s",
"fitness",
"score",
"given",
"a",
"value",
"returned",
"by",
"the",
"fitness",
"function"
] | train | https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/bees.py#L40-L56 |
ECRL/ecabc | ecabc/bees.py | OnlookerBee.calculate_positions | def calculate_positions(self, first_bee_val, second_bee_val, value_range):
'''Calculate the new value/position for two given bee values
Args:
first_bee_val (int or float): value from the first bee
second_bee_val (int or float): value from the second bee
value_ranges ... | python | def calculate_positions(self, first_bee_val, second_bee_val, value_range):
'''Calculate the new value/position for two given bee values
Args:
first_bee_val (int or float): value from the first bee
second_bee_val (int or float): value from the second bee
value_ranges ... | [
"def",
"calculate_positions",
"(",
"self",
",",
"first_bee_val",
",",
"second_bee_val",
",",
"value_range",
")",
":",
"value",
"=",
"first_bee_val",
"+",
"np",
".",
"random",
".",
"uniform",
"(",
"-",
"1",
",",
"1",
")",
"*",
"(",
"first_bee_val",
"-",
"... | Calculate the new value/position for two given bee values
Args:
first_bee_val (int or float): value from the first bee
second_bee_val (int or float): value from the second bee
value_ranges (tuple): "(value type, (min_val, max_val))" for the
given value
... | [
"Calculate",
"the",
"new",
"value",
"/",
"position",
"for",
"two",
"given",
"bee",
"values"
] | train | https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/bees.py#L78-L100 |
foremast/foremast | src/foremast/dns/create_dns.py | SpinnakerDns.create_elb_dns | def create_elb_dns(self, regionspecific=False):
"""Create dns entries in route53.
Args:
regionspecific (bool): The DNS entry should have region on it
Returns:
str: Auto-generated DNS name for the Elastic Load Balancer.
"""
if regionspecific:
... | python | def create_elb_dns(self, regionspecific=False):
"""Create dns entries in route53.
Args:
regionspecific (bool): The DNS entry should have region on it
Returns:
str: Auto-generated DNS name for the Elastic Load Balancer.
"""
if regionspecific:
... | [
"def",
"create_elb_dns",
"(",
"self",
",",
"regionspecific",
"=",
"False",
")",
":",
"if",
"regionspecific",
":",
"dns_elb",
"=",
"self",
".",
"generated",
".",
"dns",
"(",
")",
"[",
"'elb_region'",
"]",
"else",
":",
"dns_elb",
"=",
"self",
".",
"generat... | Create dns entries in route53.
Args:
regionspecific (bool): The DNS entry should have region on it
Returns:
str: Auto-generated DNS name for the Elastic Load Balancer. | [
"Create",
"dns",
"entries",
"in",
"route53",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/dns/create_dns.py#L55-L85 |
foremast/foremast | src/foremast/dns/create_dns.py | SpinnakerDns.create_failover_dns | def create_failover_dns(self, primary_region='us-east-1'):
"""Create dns entries in route53 for multiregion failover setups.
Args:
primary_region (str): primary AWS region for failover
Returns:
Auto-generated DNS name.
"""
dns_record = self.generated.dns(... | python | def create_failover_dns(self, primary_region='us-east-1'):
"""Create dns entries in route53 for multiregion failover setups.
Args:
primary_region (str): primary AWS region for failover
Returns:
Auto-generated DNS name.
"""
dns_record = self.generated.dns(... | [
"def",
"create_failover_dns",
"(",
"self",
",",
"primary_region",
"=",
"'us-east-1'",
")",
":",
"dns_record",
"=",
"self",
".",
"generated",
".",
"dns",
"(",
")",
"[",
"'global'",
"]",
"zone_ids",
"=",
"get_dns_zone_ids",
"(",
"env",
"=",
"self",
".",
"env... | Create dns entries in route53 for multiregion failover setups.
Args:
primary_region (str): primary AWS region for failover
Returns:
Auto-generated DNS name. | [
"Create",
"dns",
"entries",
"in",
"route53",
"for",
"multiregion",
"failover",
"setups",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/dns/create_dns.py#L87-L121 |
foremast/foremast | src/foremast/elb/format_listeners.py | format_listeners | def format_listeners(elb_settings=None, env='dev', region='us-east-1'):
"""Format ELB Listeners into standard list.
Args:
elb_settings (dict): ELB settings including ELB Listeners to add,
e.g.::
# old
{
"certificate": null,
... | python | def format_listeners(elb_settings=None, env='dev', region='us-east-1'):
"""Format ELB Listeners into standard list.
Args:
elb_settings (dict): ELB settings including ELB Listeners to add,
e.g.::
# old
{
"certificate": null,
... | [
"def",
"format_listeners",
"(",
"elb_settings",
"=",
"None",
",",
"env",
"=",
"'dev'",
",",
"region",
"=",
"'us-east-1'",
")",
":",
"LOG",
".",
"debug",
"(",
"'ELB settings:\\n%s'",
",",
"elb_settings",
")",
"credential",
"=",
"get_env_credential",
"(",
"env",... | Format ELB Listeners into standard list.
Args:
elb_settings (dict): ELB settings including ELB Listeners to add,
e.g.::
# old
{
"certificate": null,
"i_port": 8080,
"lb_port": 80,
"s... | [
"Format",
"ELB",
"Listeners",
"into",
"standard",
"list",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/elb/format_listeners.py#L26-L128 |
foremast/foremast | src/foremast/elb/format_listeners.py | format_cert_name | def format_cert_name(env='', account='', region='', certificate=None):
"""Format the SSL certificate name into ARN for ELB.
Args:
env (str): Account environment name
account (str): Account number for ARN
region (str): AWS Region.
certificate (str): Name of SSL certificate
R... | python | def format_cert_name(env='', account='', region='', certificate=None):
"""Format the SSL certificate name into ARN for ELB.
Args:
env (str): Account environment name
account (str): Account number for ARN
region (str): AWS Region.
certificate (str): Name of SSL certificate
R... | [
"def",
"format_cert_name",
"(",
"env",
"=",
"''",
",",
"account",
"=",
"''",
",",
"region",
"=",
"''",
",",
"certificate",
"=",
"None",
")",
":",
"cert_name",
"=",
"None",
"if",
"certificate",
":",
"if",
"certificate",
".",
"startswith",
"(",
"'arn'",
... | Format the SSL certificate name into ARN for ELB.
Args:
env (str): Account environment name
account (str): Account number for ARN
region (str): AWS Region.
certificate (str): Name of SSL certificate
Returns:
str: Fully qualified ARN for SSL certificate
None: Cer... | [
"Format",
"the",
"SSL",
"certificate",
"name",
"into",
"ARN",
"for",
"ELB",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/elb/format_listeners.py#L131-L161 |
foremast/foremast | src/foremast/elb/format_listeners.py | generate_custom_cert_name | def generate_custom_cert_name(env='', region='', account='', certificate=None):
"""Generate a custom TLS Cert name based on a template.
Args:
env (str): Account environment name
region (str): AWS Region.
account (str): Account number for ARN.
certificate (str): Name of SSL certi... | python | def generate_custom_cert_name(env='', region='', account='', certificate=None):
"""Generate a custom TLS Cert name based on a template.
Args:
env (str): Account environment name
region (str): AWS Region.
account (str): Account number for ARN.
certificate (str): Name of SSL certi... | [
"def",
"generate_custom_cert_name",
"(",
"env",
"=",
"''",
",",
"region",
"=",
"''",
",",
"account",
"=",
"''",
",",
"certificate",
"=",
"None",
")",
":",
"cert_name",
"=",
"None",
"template_kwargs",
"=",
"{",
"'account'",
":",
"account",
",",
"'name'",
... | Generate a custom TLS Cert name based on a template.
Args:
env (str): Account environment name
region (str): AWS Region.
account (str): Account number for ARN.
certificate (str): Name of SSL certificate.
Returns:
str: Fully qualified ARN for SSL certificate.
Non... | [
"Generate",
"a",
"custom",
"TLS",
"Cert",
"name",
"based",
"on",
"a",
"template",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/elb/format_listeners.py#L164-L213 |
foremast/foremast | src/foremast/slacknotify/__main__.py | main | def main():
"""Send Slack notification to a configured channel."""
logging.basicConfig(format=LOGGING_FORMAT)
log = logging.getLogger(__name__)
parser = argparse.ArgumentParser()
add_debug(parser)
add_app(parser)
add_env(parser)
add_properties(parser)
args = parser.parse_args()
... | python | def main():
"""Send Slack notification to a configured channel."""
logging.basicConfig(format=LOGGING_FORMAT)
log = logging.getLogger(__name__)
parser = argparse.ArgumentParser()
add_debug(parser)
add_app(parser)
add_env(parser)
add_properties(parser)
args = parser.parse_args()
... | [
"def",
"main",
"(",
")",
":",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"LOGGING_FORMAT",
")",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"add_debug",
"(",
"parser",
... | Send Slack notification to a configured channel. | [
"Send",
"Slack",
"notification",
"to",
"a",
"configured",
"channel",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/slacknotify/__main__.py#L28-L49 |
foremast/foremast | src/foremast/destroyer.py | main | def main(): # noqa
"""Attempt to fully destroy AWS Resources for a Spinnaker Application."""
logging.basicConfig(format=LOGGING_FORMAT)
parser = argparse.ArgumentParser(description=main.__doc__)
add_debug(parser)
add_app(parser)
args = parser.parse_args()
if args.debug == logging.DEBUG:
... | python | def main(): # noqa
"""Attempt to fully destroy AWS Resources for a Spinnaker Application."""
logging.basicConfig(format=LOGGING_FORMAT)
parser = argparse.ArgumentParser(description=main.__doc__)
add_debug(parser)
add_app(parser)
args = parser.parse_args()
if args.debug == logging.DEBUG:
... | [
"def",
"main",
"(",
")",
":",
"# noqa",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"LOGGING_FORMAT",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"main",
".",
"__doc__",
")",
"add_debug",
"(",
"parser",
")",
"add_... | Attempt to fully destroy AWS Resources for a Spinnaker Application. | [
"Attempt",
"to",
"fully",
"destroy",
"AWS",
"Resources",
"for",
"a",
"Spinnaker",
"Application",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/destroyer.py#L34-L79 |
foremast/foremast | src/foremast/pipeline/construct_pipeline_block.py | check_provider_healthcheck | def check_provider_healthcheck(settings, default_provider='Discovery'):
"""Set Provider Health Check when specified.
Returns:
collections.namedtuple: **ProviderHealthCheck** with attributes:
* providers (list): Providers set to use native Health Check.
* has_healthcheck (bool):... | python | def check_provider_healthcheck(settings, default_provider='Discovery'):
"""Set Provider Health Check when specified.
Returns:
collections.namedtuple: **ProviderHealthCheck** with attributes:
* providers (list): Providers set to use native Health Check.
* has_healthcheck (bool):... | [
"def",
"check_provider_healthcheck",
"(",
"settings",
",",
"default_provider",
"=",
"'Discovery'",
")",
":",
"ProviderHealthCheck",
"=",
"collections",
".",
"namedtuple",
"(",
"'ProviderHealthCheck'",
",",
"[",
"'providers'",
",",
"'has_healthcheck'",
"]",
")",
"eurek... | Set Provider Health Check when specified.
Returns:
collections.namedtuple: **ProviderHealthCheck** with attributes:
* providers (list): Providers set to use native Health Check.
* has_healthcheck (bool): If any native Health Checks requested. | [
"Set",
"Provider",
"Health",
"Check",
"when",
"specified",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/construct_pipeline_block.py#L29-L70 |
foremast/foremast | src/foremast/pipeline/construct_pipeline_block.py | get_template_name | def get_template_name(env, pipeline_type):
"""Generates the correct template name based on pipeline type
Args:
env (str): environment to generate templates for
pipeline_type (str): Type of pipeline like ec2 or lambda
Returns:
str: Name of template
"""
pipeline_base = 'pipel... | python | def get_template_name(env, pipeline_type):
"""Generates the correct template name based on pipeline type
Args:
env (str): environment to generate templates for
pipeline_type (str): Type of pipeline like ec2 or lambda
Returns:
str: Name of template
"""
pipeline_base = 'pipel... | [
"def",
"get_template_name",
"(",
"env",
",",
"pipeline_type",
")",
":",
"pipeline_base",
"=",
"'pipeline/pipeline'",
"template_name_format",
"=",
"'{pipeline_base}'",
"if",
"env",
".",
"startswith",
"(",
"'prod'",
")",
":",
"template_name_format",
"=",
"template_name_... | Generates the correct template name based on pipeline type
Args:
env (str): environment to generate templates for
pipeline_type (str): Type of pipeline like ec2 or lambda
Returns:
str: Name of template | [
"Generates",
"the",
"correct",
"template",
"name",
"based",
"on",
"pipeline",
"type"
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/construct_pipeline_block.py#L73-L96 |
foremast/foremast | src/foremast/pipeline/construct_pipeline_block.py | construct_pipeline_block | def construct_pipeline_block(env='',
generated=None,
previous_env='',
region='us-east-1',
settings=None,
pipeline_data=None,
region_subnets=None,
... | python | def construct_pipeline_block(env='',
generated=None,
previous_env='',
region='us-east-1',
settings=None,
pipeline_data=None,
region_subnets=None,
... | [
"def",
"construct_pipeline_block",
"(",
"env",
"=",
"''",
",",
"generated",
"=",
"None",
",",
"previous_env",
"=",
"''",
",",
"region",
"=",
"'us-east-1'",
",",
"settings",
"=",
"None",
",",
"pipeline_data",
"=",
"None",
",",
"region_subnets",
"=",
"None",
... | Create the Pipeline JSON from template.
This handles the common repeatable patterns in a pipeline, such as
judgement, infrastructure, tagger and qe.
Note:
ASG Health Check type is overridden to `EC2` when deploying to **dev** or
using :ref:`eureka_enabled`.
Args:
env (str): Depl... | [
"Create",
"the",
"Pipeline",
"JSON",
"from",
"template",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/construct_pipeline_block.py#L99-L166 |
foremast/foremast | src/foremast/pipeline/construct_pipeline_block.py | ec2_pipeline_setup | def ec2_pipeline_setup(
generated=None,
project='',
settings=None,
env='',
pipeline_type='',
region='',
region_subnets=None,
):
"""Handles ec2 pipeline data setup
Args:
generated (gogoutils.Generator): Generated naming formats.
project (st... | python | def ec2_pipeline_setup(
generated=None,
project='',
settings=None,
env='',
pipeline_type='',
region='',
region_subnets=None,
):
"""Handles ec2 pipeline data setup
Args:
generated (gogoutils.Generator): Generated naming formats.
project (st... | [
"def",
"ec2_pipeline_setup",
"(",
"generated",
"=",
"None",
",",
"project",
"=",
"''",
",",
"settings",
"=",
"None",
",",
"env",
"=",
"''",
",",
"pipeline_type",
"=",
"''",
",",
"region",
"=",
"''",
",",
"region_subnets",
"=",
"None",
",",
")",
":",
... | Handles ec2 pipeline data setup
Args:
generated (gogoutils.Generator): Generated naming formats.
project (str): Group name of application
settings (dict): Environment settings from configurations.
env (str): Deploy environment name, e.g. dev, stage, prod.
pipeline_type (str)... | [
"Handles",
"ec2",
"pipeline",
"data",
"setup"
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/construct_pipeline_block.py#L169-L275 |
foremast/foremast | src/foremast/pipeline/create_pipeline_manual.py | SpinnakerPipelineManual.create_pipeline | def create_pipeline(self):
"""Use JSON files to create Pipelines."""
pipelines = self.settings['pipeline']['pipeline_files']
self.log.info('Uploading manual Pipelines: %s', pipelines)
lookup = FileLookup(git_short=self.generated.gitlab()['main'], runway_dir=self.runway_dir)
for... | python | def create_pipeline(self):
"""Use JSON files to create Pipelines."""
pipelines = self.settings['pipeline']['pipeline_files']
self.log.info('Uploading manual Pipelines: %s', pipelines)
lookup = FileLookup(git_short=self.generated.gitlab()['main'], runway_dir=self.runway_dir)
for... | [
"def",
"create_pipeline",
"(",
"self",
")",
":",
"pipelines",
"=",
"self",
".",
"settings",
"[",
"'pipeline'",
"]",
"[",
"'pipeline_files'",
"]",
"self",
".",
"log",
".",
"info",
"(",
"'Uploading manual Pipelines: %s'",
",",
"pipelines",
")",
"lookup",
"=",
... | Use JSON files to create Pipelines. | [
"Use",
"JSON",
"files",
"to",
"create",
"Pipelines",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/create_pipeline_manual.py#L25-L42 |
foremast/foremast | src/foremast/pipeline/__main__.py | main | def main():
"""Creates a pipeline in Spinnaker"""
logging.basicConfig(format=LOGGING_FORMAT)
log = logging.getLogger(__name__)
parser = argparse.ArgumentParser()
add_debug(parser)
add_app(parser)
add_properties(parser)
parser.add_argument('-b', '--base', help='Base AMI name to use, e.g.... | python | def main():
"""Creates a pipeline in Spinnaker"""
logging.basicConfig(format=LOGGING_FORMAT)
log = logging.getLogger(__name__)
parser = argparse.ArgumentParser()
add_debug(parser)
add_app(parser)
add_properties(parser)
parser.add_argument('-b', '--base', help='Base AMI name to use, e.g.... | [
"def",
"main",
"(",
")",
":",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"LOGGING_FORMAT",
")",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"add_debug",
"(",
"parser",
... | Creates a pipeline in Spinnaker | [
"Creates",
"a",
"pipeline",
"in",
"Spinnaker"
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/__main__.py#L31-L71 |
foremast/foremast | src/foremast/configs/outputs.py | convert_ini | def convert_ini(config_dict):
"""Convert _config_dict_ into a list of INI formatted strings.
Args:
config_dict (dict): Configuration dictionary to be flattened.
Returns:
(list) Lines to be written to a file in the format of KEY1_KEY2=value.
"""
config_lines = []
for env, confi... | python | def convert_ini(config_dict):
"""Convert _config_dict_ into a list of INI formatted strings.
Args:
config_dict (dict): Configuration dictionary to be flattened.
Returns:
(list) Lines to be written to a file in the format of KEY1_KEY2=value.
"""
config_lines = []
for env, confi... | [
"def",
"convert_ini",
"(",
"config_dict",
")",
":",
"config_lines",
"=",
"[",
"]",
"for",
"env",
",",
"configs",
"in",
"sorted",
"(",
"config_dict",
".",
"items",
"(",
")",
")",
":",
"for",
"resource",
",",
"app_properties",
"in",
"sorted",
"(",
"configs... | Convert _config_dict_ into a list of INI formatted strings.
Args:
config_dict (dict): Configuration dictionary to be flattened.
Returns:
(list) Lines to be written to a file in the format of KEY1_KEY2=value. | [
"Convert",
"_config_dict_",
"into",
"a",
"list",
"of",
"INI",
"formatted",
"strings",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/configs/outputs.py#L29-L63 |
foremast/foremast | src/foremast/configs/outputs.py | write_variables | def write_variables(app_configs=None, out_file='', git_short=''):
"""Append _application.json_ configs to _out_file_, .exports, and .json.
Variables are written in INI style, e.g. UPPER_CASE=value. The .exports file
contains 'export' prepended to each line for easy sourcing. The .json file
is a minifie... | python | def write_variables(app_configs=None, out_file='', git_short=''):
"""Append _application.json_ configs to _out_file_, .exports, and .json.
Variables are written in INI style, e.g. UPPER_CASE=value. The .exports file
contains 'export' prepended to each line for easy sourcing. The .json file
is a minifie... | [
"def",
"write_variables",
"(",
"app_configs",
"=",
"None",
",",
"out_file",
"=",
"''",
",",
"git_short",
"=",
"''",
")",
":",
"generated",
"=",
"gogoutils",
".",
"Generator",
"(",
"*",
"gogoutils",
".",
"Parser",
"(",
"git_short",
")",
".",
"parse_url",
... | Append _application.json_ configs to _out_file_, .exports, and .json.
Variables are written in INI style, e.g. UPPER_CASE=value. The .exports file
contains 'export' prepended to each line for easy sourcing. The .json file
is a minified representation of the combined configurations.
Args:
app_c... | [
"Append",
"_application",
".",
"json_",
"configs",
"to",
"_out_file_",
".",
"exports",
"and",
".",
"json",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/configs/outputs.py#L66-L122 |
foremast/foremast | src/foremast/utils/get_sns_subscriptions.py | get_sns_subscriptions | def get_sns_subscriptions(app_name, env, region):
"""List SNS lambda subscriptions.
Returns:
list: List of Lambda subscribed SNS ARNs.
"""
session = boto3.Session(profile_name=env, region_name=region)
sns_client = session.client('sns')
lambda_alias_arn = get_lambda_alias_arn(app=app_n... | python | def get_sns_subscriptions(app_name, env, region):
"""List SNS lambda subscriptions.
Returns:
list: List of Lambda subscribed SNS ARNs.
"""
session = boto3.Session(profile_name=env, region_name=region)
sns_client = session.client('sns')
lambda_alias_arn = get_lambda_alias_arn(app=app_n... | [
"def",
"get_sns_subscriptions",
"(",
"app_name",
",",
"env",
",",
"region",
")",
":",
"session",
"=",
"boto3",
".",
"Session",
"(",
"profile_name",
"=",
"env",
",",
"region_name",
"=",
"region",
")",
"sns_client",
"=",
"session",
".",
"client",
"(",
"'sns'... | List SNS lambda subscriptions.
Returns:
list: List of Lambda subscribed SNS ARNs. | [
"List",
"SNS",
"lambda",
"subscriptions",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/get_sns_subscriptions.py#L11-L33 |
foremast/foremast | src/foremast/awslambda/cloudwatch_log_event/destroy_cloudwatch_log_event/destroy_cloudwatch_log_event.py | destroy_cloudwatch_log_event | def destroy_cloudwatch_log_event(app='', env='dev', region=''):
"""Destroy Cloudwatch log event.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment.
region (str): AWS region.
Returns:
bool: True upon successful completion.
"""
session = b... | python | def destroy_cloudwatch_log_event(app='', env='dev', region=''):
"""Destroy Cloudwatch log event.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment.
region (str): AWS region.
Returns:
bool: True upon successful completion.
"""
session = b... | [
"def",
"destroy_cloudwatch_log_event",
"(",
"app",
"=",
"''",
",",
"env",
"=",
"'dev'",
",",
"region",
"=",
"''",
")",
":",
"session",
"=",
"boto3",
".",
"Session",
"(",
"profile_name",
"=",
"env",
",",
"region_name",
"=",
"region",
")",
"cloudwatch_client... | Destroy Cloudwatch log event.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment.
region (str): AWS region.
Returns:
bool: True upon successful completion. | [
"Destroy",
"Cloudwatch",
"log",
"event",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/cloudwatch_log_event/destroy_cloudwatch_log_event/destroy_cloudwatch_log_event.py#L24-L42 |
foremast/foremast | src/foremast/app/create_app.py | SpinnakerApp.get_accounts | def get_accounts(self, provider='aws'):
"""Get Accounts added to Spinnaker.
Args:
provider (str): What provider to find accounts for.
Returns:
list: list of dicts of Spinnaker credentials matching _provider_.
Raises:
AssertionError: Failure getting ... | python | def get_accounts(self, provider='aws'):
"""Get Accounts added to Spinnaker.
Args:
provider (str): What provider to find accounts for.
Returns:
list: list of dicts of Spinnaker credentials matching _provider_.
Raises:
AssertionError: Failure getting ... | [
"def",
"get_accounts",
"(",
"self",
",",
"provider",
"=",
"'aws'",
")",
":",
"url",
"=",
"'{gate}/credentials'",
".",
"format",
"(",
"gate",
"=",
"API_URL",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"verify",
"=",
"GATE_CA_BUNDLE",
"... | Get Accounts added to Spinnaker.
Args:
provider (str): What provider to find accounts for.
Returns:
list: list of dicts of Spinnaker credentials matching _provider_.
Raises:
AssertionError: Failure getting accounts from Spinnaker. | [
"Get",
"Accounts",
"added",
"to",
"Spinnaker",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/app/create_app.py#L55-L82 |
foremast/foremast | src/foremast/app/create_app.py | SpinnakerApp.create_app | def create_app(self):
"""Send a POST to spinnaker to create a new application with class variables.
Raises:
AssertionError: Application creation failed.
"""
self.appinfo['accounts'] = self.get_accounts()
self.log.debug('Pipeline Config\n%s', pformat(self.pipeline_con... | python | def create_app(self):
"""Send a POST to spinnaker to create a new application with class variables.
Raises:
AssertionError: Application creation failed.
"""
self.appinfo['accounts'] = self.get_accounts()
self.log.debug('Pipeline Config\n%s', pformat(self.pipeline_con... | [
"def",
"create_app",
"(",
"self",
")",
":",
"self",
".",
"appinfo",
"[",
"'accounts'",
"]",
"=",
"self",
".",
"get_accounts",
"(",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'Pipeline Config\\n%s'",
",",
"pformat",
"(",
"self",
".",
"pipeline_config",
... | Send a POST to spinnaker to create a new application with class variables.
Raises:
AssertionError: Application creation failed. | [
"Send",
"a",
"POST",
"to",
"spinnaker",
"to",
"create",
"a",
"new",
"application",
"with",
"class",
"variables",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/app/create_app.py#L84-L97 |
foremast/foremast | src/foremast/app/create_app.py | SpinnakerApp.retrieve_template | def retrieve_template(self):
"""Sets the instance links with pipeline_configs and then renders template files
Returns:
jsondata: A json objects containing templates
"""
links = self.retrieve_instance_links()
self.log.debug('Links is \n%s', pformat(links))
sel... | python | def retrieve_template(self):
"""Sets the instance links with pipeline_configs and then renders template files
Returns:
jsondata: A json objects containing templates
"""
links = self.retrieve_instance_links()
self.log.debug('Links is \n%s', pformat(links))
sel... | [
"def",
"retrieve_template",
"(",
"self",
")",
":",
"links",
"=",
"self",
".",
"retrieve_instance_links",
"(",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'Links is \\n%s'",
",",
"pformat",
"(",
"links",
")",
")",
"self",
".",
"pipeline_config",
"[",
"'ins... | Sets the instance links with pipeline_configs and then renders template files
Returns:
jsondata: A json objects containing templates | [
"Sets",
"the",
"instance",
"links",
"with",
"pipeline_configs",
"and",
"then",
"renders",
"template",
"files"
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/app/create_app.py#L99-L115 |
foremast/foremast | src/foremast/app/create_app.py | SpinnakerApp.retrieve_instance_links | def retrieve_instance_links(self):
"""Appends on existing instance links
Returns:
instance_links: A dictionary containing all the instance links in LINKS and not in pipeline_config
"""
instance_links = {}
self.log.debug("LINKS IS %s", LINKS)
for key, value in... | python | def retrieve_instance_links(self):
"""Appends on existing instance links
Returns:
instance_links: A dictionary containing all the instance links in LINKS and not in pipeline_config
"""
instance_links = {}
self.log.debug("LINKS IS %s", LINKS)
for key, value in... | [
"def",
"retrieve_instance_links",
"(",
"self",
")",
":",
"instance_links",
"=",
"{",
"}",
"self",
".",
"log",
".",
"debug",
"(",
"\"LINKS IS %s\"",
",",
"LINKS",
")",
"for",
"key",
",",
"value",
"in",
"LINKS",
".",
"items",
"(",
")",
":",
"if",
"value"... | Appends on existing instance links
Returns:
instance_links: A dictionary containing all the instance links in LINKS and not in pipeline_config | [
"Appends",
"on",
"existing",
"instance",
"links"
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/app/create_app.py#L117-L128 |
foremast/foremast | src/foremast/utils/get_cloudwatch_event_rule.py | get_cloudwatch_event_rule | def get_cloudwatch_event_rule(app_name, account, region):
"""Get CloudWatch Event rule names."""
session = boto3.Session(profile_name=account, region_name=region)
cloudwatch_client = session.client('events')
lambda_alias_arn = get_lambda_alias_arn(app=app_name, account=account, region=region)
rule_... | python | def get_cloudwatch_event_rule(app_name, account, region):
"""Get CloudWatch Event rule names."""
session = boto3.Session(profile_name=account, region_name=region)
cloudwatch_client = session.client('events')
lambda_alias_arn = get_lambda_alias_arn(app=app_name, account=account, region=region)
rule_... | [
"def",
"get_cloudwatch_event_rule",
"(",
"app_name",
",",
"account",
",",
"region",
")",
":",
"session",
"=",
"boto3",
".",
"Session",
"(",
"profile_name",
"=",
"account",
",",
"region_name",
"=",
"region",
")",
"cloudwatch_client",
"=",
"session",
".",
"clien... | Get CloudWatch Event rule names. | [
"Get",
"CloudWatch",
"Event",
"rule",
"names",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/get_cloudwatch_event_rule.py#L11-L24 |
foremast/foremast | src/foremast/s3/s3deploy.py | S3Deployment.setup_pathing | def setup_pathing(self):
"""Format pathing for S3 deployments."""
self.s3_version_uri = self._path_formatter(self.version)
self.s3_latest_uri = self._path_formatter("LATEST")
self.s3_canary_uri = self._path_formatter("CANARY")
self.s3_alpha_uri = self._path_formatter("ALPHA")
... | python | def setup_pathing(self):
"""Format pathing for S3 deployments."""
self.s3_version_uri = self._path_formatter(self.version)
self.s3_latest_uri = self._path_formatter("LATEST")
self.s3_canary_uri = self._path_formatter("CANARY")
self.s3_alpha_uri = self._path_formatter("ALPHA")
... | [
"def",
"setup_pathing",
"(",
"self",
")",
":",
"self",
".",
"s3_version_uri",
"=",
"self",
".",
"_path_formatter",
"(",
"self",
".",
"version",
")",
"self",
".",
"s3_latest_uri",
"=",
"self",
".",
"_path_formatter",
"(",
"\"LATEST\"",
")",
"self",
".",
"s3... | Format pathing for S3 deployments. | [
"Format",
"pathing",
"for",
"S3",
"deployments",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3deploy.py#L69-L75 |
foremast/foremast | src/foremast/s3/s3deploy.py | S3Deployment._path_formatter | def _path_formatter(self, suffix):
"""Format the s3 path properly.
Args:
suffix (str): suffix to add on to an s3 path
Returns:
str: formatted path
"""
if suffix.lower() == "mirror":
path_items = [self.bucket, self.s3path]
else:
... | python | def _path_formatter(self, suffix):
"""Format the s3 path properly.
Args:
suffix (str): suffix to add on to an s3 path
Returns:
str: formatted path
"""
if suffix.lower() == "mirror":
path_items = [self.bucket, self.s3path]
else:
... | [
"def",
"_path_formatter",
"(",
"self",
",",
"suffix",
")",
":",
"if",
"suffix",
".",
"lower",
"(",
")",
"==",
"\"mirror\"",
":",
"path_items",
"=",
"[",
"self",
".",
"bucket",
",",
"self",
".",
"s3path",
"]",
"else",
":",
"path_items",
"=",
"[",
"sel... | Format the s3 path properly.
Args:
suffix (str): suffix to add on to an s3 path
Returns:
str: formatted path | [
"Format",
"the",
"s3",
"path",
"properly",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3deploy.py#L77-L96 |
foremast/foremast | src/foremast/s3/s3deploy.py | S3Deployment.upload_artifacts | def upload_artifacts(self):
"""Upload artifacts to S3 and copy to correct path depending on strategy."""
deploy_strategy = self.properties["deploy_strategy"]
mirror = False
if deploy_strategy == "mirror":
mirror = True
self._upload_artifacts_to_path(mirror=mirror)
... | python | def upload_artifacts(self):
"""Upload artifacts to S3 and copy to correct path depending on strategy."""
deploy_strategy = self.properties["deploy_strategy"]
mirror = False
if deploy_strategy == "mirror":
mirror = True
self._upload_artifacts_to_path(mirror=mirror)
... | [
"def",
"upload_artifacts",
"(",
"self",
")",
":",
"deploy_strategy",
"=",
"self",
".",
"properties",
"[",
"\"deploy_strategy\"",
"]",
"mirror",
"=",
"False",
"if",
"deploy_strategy",
"==",
"\"mirror\"",
":",
"mirror",
"=",
"True",
"self",
".",
"_upload_artifacts... | Upload artifacts to S3 and copy to correct path depending on strategy. | [
"Upload",
"artifacts",
"to",
"S3",
"and",
"copy",
"to",
"correct",
"path",
"depending",
"on",
"strategy",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3deploy.py#L98-L116 |
foremast/foremast | src/foremast/s3/s3deploy.py | S3Deployment.promote_artifacts | def promote_artifacts(self, promote_stage='latest'):
"""Promote artifact version to dest.
Args:
promote_stage (string): Stage that is being promoted
"""
if promote_stage.lower() == 'alpha':
self._sync_to_uri(self.s3_canary_uri)
elif promote_stage.lower() ... | python | def promote_artifacts(self, promote_stage='latest'):
"""Promote artifact version to dest.
Args:
promote_stage (string): Stage that is being promoted
"""
if promote_stage.lower() == 'alpha':
self._sync_to_uri(self.s3_canary_uri)
elif promote_stage.lower() ... | [
"def",
"promote_artifacts",
"(",
"self",
",",
"promote_stage",
"=",
"'latest'",
")",
":",
"if",
"promote_stage",
".",
"lower",
"(",
")",
"==",
"'alpha'",
":",
"self",
".",
"_sync_to_uri",
"(",
"self",
".",
"s3_canary_uri",
")",
"elif",
"promote_stage",
".",
... | Promote artifact version to dest.
Args:
promote_stage (string): Stage that is being promoted | [
"Promote",
"artifact",
"version",
"to",
"dest",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3deploy.py#L118-L129 |
foremast/foremast | src/foremast/s3/s3deploy.py | S3Deployment._get_upload_cmd | def _get_upload_cmd(self, mirror=False):
"""Generate the S3 CLI upload command
Args:
mirror (bool): If true, uses a flat directory structure instead of nesting under a version.
Returns:
str: The full CLI command to run.
"""
if mirror:
dest_ur... | python | def _get_upload_cmd(self, mirror=False):
"""Generate the S3 CLI upload command
Args:
mirror (bool): If true, uses a flat directory structure instead of nesting under a version.
Returns:
str: The full CLI command to run.
"""
if mirror:
dest_ur... | [
"def",
"_get_upload_cmd",
"(",
"self",
",",
"mirror",
"=",
"False",
")",
":",
"if",
"mirror",
":",
"dest_uri",
"=",
"self",
".",
"s3_mirror_uri",
"else",
":",
"dest_uri",
"=",
"self",
".",
"s3_version_uri",
"cmd",
"=",
"'aws s3 sync {} {} --delete --exact-timest... | Generate the S3 CLI upload command
Args:
mirror (bool): If true, uses a flat directory structure instead of nesting under a version.
Returns:
str: The full CLI command to run. | [
"Generate",
"the",
"S3",
"CLI",
"upload",
"command"
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3deploy.py#L131-L147 |
foremast/foremast | src/foremast/s3/s3deploy.py | S3Deployment._upload_artifacts_to_path | def _upload_artifacts_to_path(self, mirror=False):
"""Recursively upload directory contents to S3.
Args:
mirror (bool): If true, uses a flat directory structure instead of nesting under a version.
"""
if not os.listdir(self.artifact_path) or not self.artifact_path:
... | python | def _upload_artifacts_to_path(self, mirror=False):
"""Recursively upload directory contents to S3.
Args:
mirror (bool): If true, uses a flat directory structure instead of nesting under a version.
"""
if not os.listdir(self.artifact_path) or not self.artifact_path:
... | [
"def",
"_upload_artifacts_to_path",
"(",
"self",
",",
"mirror",
"=",
"False",
")",
":",
"if",
"not",
"os",
".",
"listdir",
"(",
"self",
".",
"artifact_path",
")",
"or",
"not",
"self",
".",
"artifact_path",
":",
"raise",
"S3ArtifactNotFound",
"uploaded",
"=",... | Recursively upload directory contents to S3.
Args:
mirror (bool): If true, uses a flat directory structure instead of nesting under a version. | [
"Recursively",
"upload",
"directory",
"contents",
"to",
"S3",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3deploy.py#L149-L168 |
foremast/foremast | src/foremast/s3/s3deploy.py | S3Deployment.content_metadata_uploads | def content_metadata_uploads(self, mirror=False):
"""Finds all specified encoded directories and uploads in multiple parts,
setting metadata for objects.
Args:
mirror (bool): If true, uses a flat directory structure instead of nesting under a version.
Returns:
b... | python | def content_metadata_uploads(self, mirror=False):
"""Finds all specified encoded directories and uploads in multiple parts,
setting metadata for objects.
Args:
mirror (bool): If true, uses a flat directory structure instead of nesting under a version.
Returns:
b... | [
"def",
"content_metadata_uploads",
"(",
"self",
",",
"mirror",
"=",
"False",
")",
":",
"excludes_str",
"=",
"''",
"includes_cmds",
"=",
"[",
"]",
"cmd_base",
"=",
"self",
".",
"_get_upload_cmd",
"(",
"mirror",
"=",
"mirror",
")",
"for",
"content",
"in",
"s... | Finds all specified encoded directories and uploads in multiple parts,
setting metadata for objects.
Args:
mirror (bool): If true, uses a flat directory structure instead of nesting under a version.
Returns:
bool: True if uploaded | [
"Finds",
"all",
"specified",
"encoded",
"directories",
"and",
"uploads",
"in",
"multiple",
"parts",
"setting",
"metadata",
"for",
"objects",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3deploy.py#L170-L204 |
foremast/foremast | src/foremast/s3/s3deploy.py | S3Deployment._sync_to_uri | def _sync_to_uri(self, uri):
"""Copy and sync versioned directory to uri in S3.
Args:
uri (str): S3 URI to sync version to.
"""
cmd_cp = 'aws s3 cp {} {} --recursive --profile {}'.format(self.s3_version_uri, uri, self.env)
# AWS CLI sync does not work as expected buc... | python | def _sync_to_uri(self, uri):
"""Copy and sync versioned directory to uri in S3.
Args:
uri (str): S3 URI to sync version to.
"""
cmd_cp = 'aws s3 cp {} {} --recursive --profile {}'.format(self.s3_version_uri, uri, self.env)
# AWS CLI sync does not work as expected buc... | [
"def",
"_sync_to_uri",
"(",
"self",
",",
"uri",
")",
":",
"cmd_cp",
"=",
"'aws s3 cp {} {} --recursive --profile {}'",
".",
"format",
"(",
"self",
".",
"s3_version_uri",
",",
"uri",
",",
"self",
".",
"env",
")",
"# AWS CLI sync does not work as expected bucket to buck... | Copy and sync versioned directory to uri in S3.
Args:
uri (str): S3 URI to sync version to. | [
"Copy",
"and",
"sync",
"versioned",
"directory",
"to",
"uri",
"in",
"S3",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3deploy.py#L206-L223 |
foremast/foremast | src/foremast/utils/vpc.py | get_vpc_id | def get_vpc_id(account, region):
"""Get VPC ID configured for ``account`` in ``region``.
Args:
account (str): AWS account name.
region (str): Region name, e.g. us-east-1.
Returns:
str: VPC ID for the requested ``account`` in ``region``.
Raises:
:obj:`foremast.exception... | python | def get_vpc_id(account, region):
"""Get VPC ID configured for ``account`` in ``region``.
Args:
account (str): AWS account name.
region (str): Region name, e.g. us-east-1.
Returns:
str: VPC ID for the requested ``account`` in ``region``.
Raises:
:obj:`foremast.exception... | [
"def",
"get_vpc_id",
"(",
"account",
",",
"region",
")",
":",
"url",
"=",
"'{0}/networks/aws'",
".",
"format",
"(",
"API_URL",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"verify",
"=",
"GATE_CA_BUNDLE",
",",
"cert",
"=",
"GATE_CLIENT_CE... | Get VPC ID configured for ``account`` in ``region``.
Args:
account (str): AWS account name.
region (str): Region name, e.g. us-east-1.
Returns:
str: VPC ID for the requested ``account`` in ``region``.
Raises:
:obj:`foremast.exceptions.SpinnakerVPCIDNotFound`: VPC ID not fo... | [
"Get",
"VPC",
"ID",
"configured",
"for",
"account",
"in",
"region",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/vpc.py#L27-L62 |
foremast/foremast | src/foremast/utils/subnets.py | get_subnets | def get_subnets(
target='ec2',
purpose='internal',
env='',
region='', ):
"""Get all availability zones for a given target.
Args:
target (str): Type of subnets to look up (ec2 or elb).
env (str): Environment to look up.
region (str): AWS Region to find Sub... | python | def get_subnets(
target='ec2',
purpose='internal',
env='',
region='', ):
"""Get all availability zones for a given target.
Args:
target (str): Type of subnets to look up (ec2 or elb).
env (str): Environment to look up.
region (str): AWS Region to find Sub... | [
"def",
"get_subnets",
"(",
"target",
"=",
"'ec2'",
",",
"purpose",
"=",
"'internal'",
",",
"env",
"=",
"''",
",",
"region",
"=",
"''",
",",
")",
":",
"account_az_dict",
"=",
"defaultdict",
"(",
"defaultdict",
")",
"subnet_id_dict",
"=",
"defaultdict",
"(",... | Get all availability zones for a given target.
Args:
target (str): Type of subnets to look up (ec2 or elb).
env (str): Environment to look up.
region (str): AWS Region to find Subnets for.
Returns:
az_dict: dictionary of availbility zones, structured like
{ $region: [ ... | [
"Get",
"all",
"availability",
"zones",
"for",
"a",
"given",
"target",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/subnets.py#L32-L93 |
foremast/foremast | src/foremast/pipeline/construct_pipeline_block_datapipeline.py | construct_datapipeline | def construct_datapipeline(env='',
generated=None,
previous_env=None,
region='us-east-1',
settings=None,
pipeline_data=None):
"""Create the Pipeline JSON from template.
This ha... | python | def construct_datapipeline(env='',
generated=None,
previous_env=None,
region='us-east-1',
settings=None,
pipeline_data=None):
"""Create the Pipeline JSON from template.
This ha... | [
"def",
"construct_datapipeline",
"(",
"env",
"=",
"''",
",",
"generated",
"=",
"None",
",",
"previous_env",
"=",
"None",
",",
"region",
"=",
"'us-east-1'",
",",
"settings",
"=",
"None",
",",
"pipeline_data",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"("... | Create the Pipeline JSON from template.
This handles the common repeatable patterns in a pipeline, such as
judgement, infrastructure, tagger and qe.
Args:
env (str): Deploy environment name, e.g. dev, stage, prod.
generated (gogoutils.Generator): Gogo Application name generator.
pr... | [
"Create",
"the",
"Pipeline",
"JSON",
"from",
"template",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/construct_pipeline_block_datapipeline.py#L26-L75 |
foremast/foremast | src/foremast/awslambda/awslambdaevent.py | LambdaEvent.create_lambda_events | def create_lambda_events(self):
"""Create all defined lambda events for an lambda application."""
# Clean up lambda permissions before creating triggers
remove_all_lambda_permissions(app_name=self.app_name, env=self.env, region=self.region)
triggers = self.properties['lambda_triggers']... | python | def create_lambda_events(self):
"""Create all defined lambda events for an lambda application."""
# Clean up lambda permissions before creating triggers
remove_all_lambda_permissions(app_name=self.app_name, env=self.env, region=self.region)
triggers = self.properties['lambda_triggers']... | [
"def",
"create_lambda_events",
"(",
"self",
")",
":",
"# Clean up lambda permissions before creating triggers",
"remove_all_lambda_permissions",
"(",
"app_name",
"=",
"self",
".",
"app_name",
",",
"env",
"=",
"self",
".",
"env",
",",
"region",
"=",
"self",
".",
"reg... | Create all defined lambda events for an lambda application. | [
"Create",
"all",
"defined",
"lambda",
"events",
"for",
"an",
"lambda",
"application",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambdaevent.py#L45-L83 |
foremast/foremast | src/foremast/utils/pipelines.py | check_managed_pipeline | def check_managed_pipeline(name='', app_name=''):
"""Check a Pipeline name is a managed format **app_name [region]**.
Args:
name (str): Name of Pipeline to check.
app_name (str): Name of Application to find in Pipeline name.
Returns:
str: Region name from managed Pipeline name.
... | python | def check_managed_pipeline(name='', app_name=''):
"""Check a Pipeline name is a managed format **app_name [region]**.
Args:
name (str): Name of Pipeline to check.
app_name (str): Name of Application to find in Pipeline name.
Returns:
str: Region name from managed Pipeline name.
... | [
"def",
"check_managed_pipeline",
"(",
"name",
"=",
"''",
",",
"app_name",
"=",
"''",
")",
":",
"*",
"pipeline_name_prefix",
",",
"bracket_region",
"=",
"name",
".",
"split",
"(",
")",
"region",
"=",
"bracket_region",
".",
"strip",
"(",
"'[]'",
")",
"not_ma... | Check a Pipeline name is a managed format **app_name [region]**.
Args:
name (str): Name of Pipeline to check.
app_name (str): Name of Application to find in Pipeline name.
Returns:
str: Region name from managed Pipeline name.
Raises:
ValueError: Pipeline is not managed. | [
"Check",
"a",
"Pipeline",
"name",
"is",
"a",
"managed",
"format",
"**",
"app_name",
"[",
"region",
"]",
"**",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/pipelines.py#L26-L61 |
foremast/foremast | src/foremast/utils/pipelines.py | get_all_pipelines | def get_all_pipelines(app=''):
"""Get a list of all the Pipelines in _app_.
Args:
app (str): Name of Spinnaker Application.
Returns:
requests.models.Response: Response from Gate containing Pipelines.
"""
url = '{host}/applications/{app}/pipelineConfigs'.format(host=API_URL, app=ap... | python | def get_all_pipelines(app=''):
"""Get a list of all the Pipelines in _app_.
Args:
app (str): Name of Spinnaker Application.
Returns:
requests.models.Response: Response from Gate containing Pipelines.
"""
url = '{host}/applications/{app}/pipelineConfigs'.format(host=API_URL, app=ap... | [
"def",
"get_all_pipelines",
"(",
"app",
"=",
"''",
")",
":",
"url",
"=",
"'{host}/applications/{app}/pipelineConfigs'",
".",
"format",
"(",
"host",
"=",
"API_URL",
",",
"app",
"=",
"app",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"veri... | Get a list of all the Pipelines in _app_.
Args:
app (str): Name of Spinnaker Application.
Returns:
requests.models.Response: Response from Gate containing Pipelines. | [
"Get",
"a",
"list",
"of",
"all",
"the",
"Pipelines",
"in",
"_app_",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/pipelines.py#L64-L82 |
foremast/foremast | src/foremast/utils/pipelines.py | get_pipeline_id | def get_pipeline_id(app='', name=''):
"""Get the ID for Pipeline _name_.
Args:
app (str): Name of Spinnaker Application to search.
name (str): Name of Pipeline to get ID for.
Returns:
str: ID of specified Pipeline.
None: Pipeline or Spinnaker Appliation not found.
"""
... | python | def get_pipeline_id(app='', name=''):
"""Get the ID for Pipeline _name_.
Args:
app (str): Name of Spinnaker Application to search.
name (str): Name of Pipeline to get ID for.
Returns:
str: ID of specified Pipeline.
None: Pipeline or Spinnaker Appliation not found.
"""
... | [
"def",
"get_pipeline_id",
"(",
"app",
"=",
"''",
",",
"name",
"=",
"''",
")",
":",
"return_id",
"=",
"None",
"pipelines",
"=",
"get_all_pipelines",
"(",
"app",
"=",
"app",
")",
"for",
"pipeline",
"in",
"pipelines",
":",
"LOG",
".",
"debug",
"(",
"'ID o... | Get the ID for Pipeline _name_.
Args:
app (str): Name of Spinnaker Application to search.
name (str): Name of Pipeline to get ID for.
Returns:
str: ID of specified Pipeline.
None: Pipeline or Spinnaker Appliation not found. | [
"Get",
"the",
"ID",
"for",
"Pipeline",
"_name_",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/pipelines.py#L85-L109 |
foremast/foremast | src/foremast/utils/pipelines.py | normalize_pipeline_name | def normalize_pipeline_name(name=''):
"""Translate unsafe characters to underscores."""
normalized_name = name
for bad in '\\/?%#':
normalized_name = normalized_name.replace(bad, '_')
return normalized_name | python | def normalize_pipeline_name(name=''):
"""Translate unsafe characters to underscores."""
normalized_name = name
for bad in '\\/?%#':
normalized_name = normalized_name.replace(bad, '_')
return normalized_name | [
"def",
"normalize_pipeline_name",
"(",
"name",
"=",
"''",
")",
":",
"normalized_name",
"=",
"name",
"for",
"bad",
"in",
"'\\\\/?%#'",
":",
"normalized_name",
"=",
"normalized_name",
".",
"replace",
"(",
"bad",
",",
"'_'",
")",
"return",
"normalized_name"
] | Translate unsafe characters to underscores. | [
"Translate",
"unsafe",
"characters",
"to",
"underscores",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/pipelines.py#L112-L117 |
foremast/foremast | src/foremast/utils/apps.py | get_all_apps | def get_all_apps():
"""Get a list of all applications in Spinnaker.
Returns:
requests.models.Response: Response from Gate containing list of all apps.
"""
LOG.info('Retreiving list of all Spinnaker applications')
url = '{}/applications'.format(API_URL)
response = requests.get(url, veri... | python | def get_all_apps():
"""Get a list of all applications in Spinnaker.
Returns:
requests.models.Response: Response from Gate containing list of all apps.
"""
LOG.info('Retreiving list of all Spinnaker applications')
url = '{}/applications'.format(API_URL)
response = requests.get(url, veri... | [
"def",
"get_all_apps",
"(",
")",
":",
"LOG",
".",
"info",
"(",
"'Retreiving list of all Spinnaker applications'",
")",
"url",
"=",
"'{}/applications'",
".",
"format",
"(",
"API_URL",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"verify",
"=",... | Get a list of all applications in Spinnaker.
Returns:
requests.models.Response: Response from Gate containing list of all apps. | [
"Get",
"a",
"list",
"of",
"all",
"applications",
"in",
"Spinnaker",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/apps.py#L28-L44 |
foremast/foremast | src/foremast/utils/apps.py | get_details | def get_details(app='groupproject', env='dev', region='us-east-1'):
"""Extract details for Application.
Args:
app (str): Application Name
env (str): Environment/account to get details from
Returns:
collections.namedtuple with _group_, _policy_, _profile_, _role_,
_user_... | python | def get_details(app='groupproject', env='dev', region='us-east-1'):
"""Extract details for Application.
Args:
app (str): Application Name
env (str): Environment/account to get details from
Returns:
collections.namedtuple with _group_, _policy_, _profile_, _role_,
_user_... | [
"def",
"get_details",
"(",
"app",
"=",
"'groupproject'",
",",
"env",
"=",
"'dev'",
",",
"region",
"=",
"'us-east-1'",
")",
":",
"url",
"=",
"'{host}/applications/{app}'",
".",
"format",
"(",
"host",
"=",
"API_URL",
",",
"app",
"=",
"app",
")",
"request",
... | Extract details for Application.
Args:
app (str): Application Name
env (str): Environment/account to get details from
Returns:
collections.namedtuple with _group_, _policy_, _profile_, _role_,
_user_. | [
"Extract",
"details",
"for",
"Application",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/apps.py#L47-L74 |
foremast/foremast | src/foremast/pipeline/create_pipeline_s3.py | SpinnakerPipelineS3.render_wrapper | def render_wrapper(self, region='us-east-1'):
"""Generate the base Pipeline wrapper.
This renders the non-repeatable stages in a pipeline, like jenkins, baking, tagging and notifications.
Args:
region (str): AWS Region.
Returns:
dict: Rendered Pipeline wrapper.... | python | def render_wrapper(self, region='us-east-1'):
"""Generate the base Pipeline wrapper.
This renders the non-repeatable stages in a pipeline, like jenkins, baking, tagging and notifications.
Args:
region (str): AWS Region.
Returns:
dict: Rendered Pipeline wrapper.... | [
"def",
"render_wrapper",
"(",
"self",
",",
"region",
"=",
"'us-east-1'",
")",
":",
"base",
"=",
"self",
".",
"settings",
"[",
"'pipeline'",
"]",
"[",
"'base'",
"]",
"if",
"self",
".",
"base",
":",
"base",
"=",
"self",
".",
"base",
"email",
"=",
"self... | Generate the base Pipeline wrapper.
This renders the non-repeatable stages in a pipeline, like jenkins, baking, tagging and notifications.
Args:
region (str): AWS Region.
Returns:
dict: Rendered Pipeline wrapper. | [
"Generate",
"the",
"base",
"Pipeline",
"wrapper",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/create_pipeline_s3.py#L39-L82 |
foremast/foremast | src/foremast/pipeline/create_pipeline_s3.py | SpinnakerPipelineS3.create_pipeline | def create_pipeline(self):
"""Main wrapper for pipeline creation.
1. Runs clean_pipelines to clean up existing ones
2. determines which environments the pipeline needs
3. Renders all of the pipeline blocks as defined in configs
4. Runs post_pipeline to create pipeline
"""... | python | def create_pipeline(self):
"""Main wrapper for pipeline creation.
1. Runs clean_pipelines to clean up existing ones
2. determines which environments the pipeline needs
3. Renders all of the pipeline blocks as defined in configs
4. Runs post_pipeline to create pipeline
"""... | [
"def",
"create_pipeline",
"(",
"self",
")",
":",
"clean_pipelines",
"(",
"app",
"=",
"self",
".",
"app_name",
",",
"settings",
"=",
"self",
".",
"settings",
")",
"pipeline_envs",
"=",
"self",
".",
"environments",
"self",
".",
"log",
".",
"debug",
"(",
"'... | Main wrapper for pipeline creation.
1. Runs clean_pipelines to clean up existing ones
2. determines which environments the pipeline needs
3. Renders all of the pipeline blocks as defined in configs
4. Runs post_pipeline to create pipeline | [
"Main",
"wrapper",
"for",
"pipeline",
"creation",
".",
"1",
".",
"Runs",
"clean_pipelines",
"to",
"clean",
"up",
"existing",
"ones",
"2",
".",
"determines",
"which",
"environments",
"the",
"pipeline",
"needs",
"3",
".",
"Renders",
"all",
"of",
"the",
"pipeli... | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/create_pipeline_s3.py#L84-L129 |
foremast/foremast | src/foremast/awslambda/awslambda.py | LambdaFunction._check_lambda | def _check_lambda(self):
"""Check if lambda function exists.
Returns:
True if function does exist
False if function does not exist
"""
exists = False
try:
self.lambda_client.get_function(FunctionName=self.app_name)
exists = True
... | python | def _check_lambda(self):
"""Check if lambda function exists.
Returns:
True if function does exist
False if function does not exist
"""
exists = False
try:
self.lambda_client.get_function(FunctionName=self.app_name)
exists = True
... | [
"def",
"_check_lambda",
"(",
"self",
")",
":",
"exists",
"=",
"False",
"try",
":",
"self",
".",
"lambda_client",
".",
"get_function",
"(",
"FunctionName",
"=",
"self",
".",
"app_name",
")",
"exists",
"=",
"True",
"except",
"boto3",
".",
"exceptions",
".",
... | Check if lambda function exists.
Returns:
True if function does exist
False if function does not exist | [
"Check",
"if",
"lambda",
"function",
"exists",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambda.py#L72-L85 |
foremast/foremast | src/foremast/awslambda/awslambda.py | LambdaFunction._check_lambda_alias | def _check_lambda_alias(self):
"""Check if lambda alias exists.
Returns:
True if alias exists
False if alias does not exist
"""
aliases = self.lambda_client.list_aliases(FunctionName=self.app_name)
matched_alias = False
for alias in aliases['Alia... | python | def _check_lambda_alias(self):
"""Check if lambda alias exists.
Returns:
True if alias exists
False if alias does not exist
"""
aliases = self.lambda_client.list_aliases(FunctionName=self.app_name)
matched_alias = False
for alias in aliases['Alia... | [
"def",
"_check_lambda_alias",
"(",
"self",
")",
":",
"aliases",
"=",
"self",
".",
"lambda_client",
".",
"list_aliases",
"(",
"FunctionName",
"=",
"self",
".",
"app_name",
")",
"matched_alias",
"=",
"False",
"for",
"alias",
"in",
"aliases",
"[",
"'Aliases'",
... | Check if lambda alias exists.
Returns:
True if alias exists
False if alias does not exist | [
"Check",
"if",
"lambda",
"alias",
"exists",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambda.py#L87-L104 |
foremast/foremast | src/foremast/awslambda/awslambda.py | LambdaFunction._vpc_config | def _vpc_config(self):
"""Get VPC config."""
if self.vpc_enabled:
subnets = get_subnets(env=self.env, region=self.region, purpose='internal')['subnet_ids'][self.region]
security_groups = self._get_sg_ids()
vpc_config = {'SubnetIds': subnets, 'SecurityGroupIds': secur... | python | def _vpc_config(self):
"""Get VPC config."""
if self.vpc_enabled:
subnets = get_subnets(env=self.env, region=self.region, purpose='internal')['subnet_ids'][self.region]
security_groups = self._get_sg_ids()
vpc_config = {'SubnetIds': subnets, 'SecurityGroupIds': secur... | [
"def",
"_vpc_config",
"(",
"self",
")",
":",
"if",
"self",
".",
"vpc_enabled",
":",
"subnets",
"=",
"get_subnets",
"(",
"env",
"=",
"self",
".",
"env",
",",
"region",
"=",
"self",
".",
"region",
",",
"purpose",
"=",
"'internal'",
")",
"[",
"'subnet_ids... | Get VPC config. | [
"Get",
"VPC",
"config",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambda.py#L106-L116 |
foremast/foremast | src/foremast/awslambda/awslambda.py | LambdaFunction._get_sg_ids | def _get_sg_ids(self):
"""Get IDs for all defined security groups.
Returns:
list: security group IDs for all lambda_extras
"""
try:
lambda_extras = self.settings['security_groups']['lambda_extras']
except KeyError:
lambda_extras = []
... | python | def _get_sg_ids(self):
"""Get IDs for all defined security groups.
Returns:
list: security group IDs for all lambda_extras
"""
try:
lambda_extras = self.settings['security_groups']['lambda_extras']
except KeyError:
lambda_extras = []
... | [
"def",
"_get_sg_ids",
"(",
"self",
")",
":",
"try",
":",
"lambda_extras",
"=",
"self",
".",
"settings",
"[",
"'security_groups'",
"]",
"[",
"'lambda_extras'",
"]",
"except",
"KeyError",
":",
"lambda_extras",
"=",
"[",
"]",
"security_groups",
"=",
"[",
"self"... | Get IDs for all defined security groups.
Returns:
list: security group IDs for all lambda_extras | [
"Get",
"IDs",
"for",
"all",
"defined",
"security",
"groups",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambda.py#L118-L134 |
foremast/foremast | src/foremast/awslambda/awslambda.py | LambdaFunction.create_alias | def create_alias(self):
"""Create lambda alias with env name and points it to $LATEST."""
LOG.info('Creating alias %s', self.env)
try:
self.lambda_client.create_alias(
FunctionName=self.app_name,
Name=self.env,
FunctionVersion='$LATEST... | python | def create_alias(self):
"""Create lambda alias with env name and points it to $LATEST."""
LOG.info('Creating alias %s', self.env)
try:
self.lambda_client.create_alias(
FunctionName=self.app_name,
Name=self.env,
FunctionVersion='$LATEST... | [
"def",
"create_alias",
"(",
"self",
")",
":",
"LOG",
".",
"info",
"(",
"'Creating alias %s'",
",",
"self",
".",
"env",
")",
"try",
":",
"self",
".",
"lambda_client",
".",
"create_alias",
"(",
"FunctionName",
"=",
"self",
".",
"app_name",
",",
"Name",
"="... | Create lambda alias with env name and points it to $LATEST. | [
"Create",
"lambda",
"alias",
"with",
"env",
"name",
"and",
"points",
"it",
"to",
"$LATEST",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambda.py#L137-L150 |
foremast/foremast | src/foremast/awslambda/awslambda.py | LambdaFunction.update_alias | def update_alias(self):
"""Update lambda alias to point to $LATEST."""
LOG.info('Updating alias %s to point to $LATEST', self.env)
try:
self.lambda_client.update_alias(FunctionName=self.app_name, Name=self.env, FunctionVersion='$LATEST')
except boto3.exceptions.botocore.exce... | python | def update_alias(self):
"""Update lambda alias to point to $LATEST."""
LOG.info('Updating alias %s to point to $LATEST', self.env)
try:
self.lambda_client.update_alias(FunctionName=self.app_name, Name=self.env, FunctionVersion='$LATEST')
except boto3.exceptions.botocore.exce... | [
"def",
"update_alias",
"(",
"self",
")",
":",
"LOG",
".",
"info",
"(",
"'Updating alias %s to point to $LATEST'",
",",
"self",
".",
"env",
")",
"try",
":",
"self",
".",
"lambda_client",
".",
"update_alias",
"(",
"FunctionName",
"=",
"self",
".",
"app_name",
... | Update lambda alias to point to $LATEST. | [
"Update",
"lambda",
"alias",
"to",
"point",
"to",
"$LATEST",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambda.py#L153-L162 |
foremast/foremast | src/foremast/awslambda/awslambda.py | LambdaFunction.update_function_configuration | def update_function_configuration(self, vpc_config):
"""Update existing Lambda function configuration.
Args:
vpc_config (dict): Dictionary of SubnetIds and SecurityGroupsIds for using
a VPC in lambda
"""
LOG.info('Updating configuration for lam... | python | def update_function_configuration(self, vpc_config):
"""Update existing Lambda function configuration.
Args:
vpc_config (dict): Dictionary of SubnetIds and SecurityGroupsIds for using
a VPC in lambda
"""
LOG.info('Updating configuration for lam... | [
"def",
"update_function_configuration",
"(",
"self",
",",
"vpc_config",
")",
":",
"LOG",
".",
"info",
"(",
"'Updating configuration for lambda function: %s'",
",",
"self",
".",
"app_name",
")",
"try",
":",
"self",
".",
"lambda_client",
".",
"update_function_configurat... | Update existing Lambda function configuration.
Args:
vpc_config (dict): Dictionary of SubnetIds and SecurityGroupsIds for using
a VPC in lambda | [
"Update",
"existing",
"Lambda",
"function",
"configuration",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambda.py#L165-L206 |
foremast/foremast | src/foremast/awslambda/awslambda.py | LambdaFunction.create_function | def create_function(self, vpc_config):
"""Create lambda function, configures lambda parameters.
We need to upload non-zero zip when creating function. Uploading
hello_world python lambda function since AWS doesn't care which
executable is in ZIP.
Args:
vpc_config (d... | python | def create_function(self, vpc_config):
"""Create lambda function, configures lambda parameters.
We need to upload non-zero zip when creating function. Uploading
hello_world python lambda function since AWS doesn't care which
executable is in ZIP.
Args:
vpc_config (d... | [
"def",
"create_function",
"(",
"self",
",",
"vpc_config",
")",
":",
"zip_file",
"=",
"'lambda-holder.zip'",
"with",
"zipfile",
".",
"ZipFile",
"(",
"zip_file",
",",
"mode",
"=",
"'w'",
")",
"as",
"zipped",
":",
"zipped",
".",
"writestr",
"(",
"'index.py'",
... | Create lambda function, configures lambda parameters.
We need to upload non-zero zip when creating function. Uploading
hello_world python lambda function since AWS doesn't care which
executable is in ZIP.
Args:
vpc_config (dict): Dictionary of SubnetIds and SecurityGroupsId... | [
"Create",
"lambda",
"function",
"configures",
"lambda",
"parameters",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambda.py#L209-L253 |
foremast/foremast | src/foremast/awslambda/awslambda.py | LambdaFunction.create_lambda_function | def create_lambda_function(self):
"""Create or update Lambda function."""
vpc_config = self._vpc_config()
if self._check_lambda():
self.update_function_configuration(vpc_config)
else:
self.create_function(vpc_config)
if self._check_lambda_alias():
... | python | def create_lambda_function(self):
"""Create or update Lambda function."""
vpc_config = self._vpc_config()
if self._check_lambda():
self.update_function_configuration(vpc_config)
else:
self.create_function(vpc_config)
if self._check_lambda_alias():
... | [
"def",
"create_lambda_function",
"(",
"self",
")",
":",
"vpc_config",
"=",
"self",
".",
"_vpc_config",
"(",
")",
"if",
"self",
".",
"_check_lambda",
"(",
")",
":",
"self",
".",
"update_function_configuration",
"(",
"vpc_config",
")",
"else",
":",
"self",
"."... | Create or update Lambda function. | [
"Create",
"or",
"update",
"Lambda",
"function",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambda.py#L255-L267 |
foremast/foremast | src/foremast/securitygroup/destroy_sg/destroy_sg.py | destroy_sg | def destroy_sg(app='', env='', region='', **_):
"""Destroy Security Group.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment.
region (str): Region name, e.g. us-east-1.
Returns:
True upon successful completion.
"""
vpc = get_vpc_id(accou... | python | def destroy_sg(app='', env='', region='', **_):
"""Destroy Security Group.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment.
region (str): Region name, e.g. us-east-1.
Returns:
True upon successful completion.
"""
vpc = get_vpc_id(accou... | [
"def",
"destroy_sg",
"(",
"app",
"=",
"''",
",",
"env",
"=",
"''",
",",
"region",
"=",
"''",
",",
"*",
"*",
"_",
")",
":",
"vpc",
"=",
"get_vpc_id",
"(",
"account",
"=",
"env",
",",
"region",
"=",
"region",
")",
"url",
"=",
"'{api}/securityGroups/{... | Destroy Security Group.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment.
region (str): Region name, e.g. us-east-1.
Returns:
True upon successful completion. | [
"Destroy",
"Security",
"Group",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/securitygroup/destroy_sg/destroy_sg.py#L27-L52 |
foremast/foremast | src/foremast/s3/destroy_s3/destroy_s3.py | destroy_s3 | def destroy_s3(app='', env='dev', **_):
"""Destroy S3 Resources for _app_ in _env_.
Args:
app (str): Application name
env (str): Deployment environment/account name
Returns:
boolean: True if destroyed sucessfully
"""
session = boto3.Session(profile_name=env)
client = se... | python | def destroy_s3(app='', env='dev', **_):
"""Destroy S3 Resources for _app_ in _env_.
Args:
app (str): Application name
env (str): Deployment environment/account name
Returns:
boolean: True if destroyed sucessfully
"""
session = boto3.Session(profile_name=env)
client = se... | [
"def",
"destroy_s3",
"(",
"app",
"=",
"''",
",",
"env",
"=",
"'dev'",
",",
"*",
"*",
"_",
")",
":",
"session",
"=",
"boto3",
".",
"Session",
"(",
"profile_name",
"=",
"env",
")",
"client",
"=",
"session",
".",
"resource",
"(",
"'s3'",
")",
"generat... | Destroy S3 Resources for _app_ in _env_.
Args:
app (str): Application name
env (str): Deployment environment/account name
Returns:
boolean: True if destroyed sucessfully | [
"Destroy",
"S3",
"Resources",
"for",
"_app_",
"in",
"_env_",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/destroy_s3/destroy_s3.py#L26-L48 |
foremast/foremast | src/foremast/app/__main__.py | main | def main():
"""Entry point for creating a Spinnaker application."""
# Setup parser
parser = argparse.ArgumentParser()
add_debug(parser)
add_app(parser)
parser.add_argument(
'--email', help='Email address to associate with application', default='PS-DevOpsTooling@example.com')
parser.a... | python | def main():
"""Entry point for creating a Spinnaker application."""
# Setup parser
parser = argparse.ArgumentParser()
add_debug(parser)
add_app(parser)
parser.add_argument(
'--email', help='Email address to associate with application', default='PS-DevOpsTooling@example.com')
parser.a... | [
"def",
"main",
"(",
")",
":",
"# Setup parser",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"add_debug",
"(",
"parser",
")",
"add_app",
"(",
"parser",
")",
"parser",
".",
"add_argument",
"(",
"'--email'",
",",
"help",
"=",
"'Email address to ... | Entry point for creating a Spinnaker application. | [
"Entry",
"point",
"for",
"creating",
"a",
"Spinnaker",
"application",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/app/__main__.py#L30-L56 |
foremast/foremast | src/foremast/awslambda/s3_event/destroy_s3_event/destroy_s3_event.py | destroy_s3_event | def destroy_s3_event(app, env, region):
"""Destroy S3 event.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment.
region (str): AWS region.
Returns:
bool: True upon successful completion.
"""
# TODO: how do we know which bucket to process ... | python | def destroy_s3_event(app, env, region):
"""Destroy S3 event.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment.
region (str): AWS region.
Returns:
bool: True upon successful completion.
"""
# TODO: how do we know which bucket to process ... | [
"def",
"destroy_s3_event",
"(",
"app",
",",
"env",
",",
"region",
")",
":",
"# TODO: how do we know which bucket to process if triggers dict is empty?",
"# Maybe list buckets and see which has notification to that lambda defined?",
"# TODO: buckets should be named the same as apps, what if o... | Destroy S3 event.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment.
region (str): AWS region.
Returns:
bool: True upon successful completion. | [
"Destroy",
"S3",
"event",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/s3_event/destroy_s3_event/destroy_s3_event.py#L26-L53 |
foremast/foremast | src/foremast/iam/destroy_iam/destroy_iam.py | destroy_iam | def destroy_iam(app='', env='dev', **_):
"""Destroy IAM Resources.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment, i.e. dev, stage, prod.
Returns:
True upon successful completion.
"""
session = boto3.Session(profile_name=env)
client = ses... | python | def destroy_iam(app='', env='dev', **_):
"""Destroy IAM Resources.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment, i.e. dev, stage, prod.
Returns:
True upon successful completion.
"""
session = boto3.Session(profile_name=env)
client = ses... | [
"def",
"destroy_iam",
"(",
"app",
"=",
"''",
",",
"env",
"=",
"'dev'",
",",
"*",
"*",
"_",
")",
":",
"session",
"=",
"boto3",
".",
"Session",
"(",
"profile_name",
"=",
"env",
")",
"client",
"=",
"session",
".",
"client",
"(",
"'iam'",
")",
"generat... | Destroy IAM Resources.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment, i.e. dev, stage, prod.
Returns:
True upon successful completion. | [
"Destroy",
"IAM",
"Resources",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/iam/destroy_iam/destroy_iam.py#L28-L108 |
foremast/foremast | src/foremast/utils/roles.py | get_role_arn | def get_role_arn(role_name, env, region):
"""Get role ARN given role name.
Args:
role_name (str): Role name to lookup
env (str): Environment in which to lookup
region (str): Region
Returns:
ARN if role found
"""
session = boto3.Session(profile_name=env, region_name... | python | def get_role_arn(role_name, env, region):
"""Get role ARN given role name.
Args:
role_name (str): Role name to lookup
env (str): Environment in which to lookup
region (str): Region
Returns:
ARN if role found
"""
session = boto3.Session(profile_name=env, region_name... | [
"def",
"get_role_arn",
"(",
"role_name",
",",
"env",
",",
"region",
")",
":",
"session",
"=",
"boto3",
".",
"Session",
"(",
"profile_name",
"=",
"env",
",",
"region_name",
"=",
"region",
")",
"iam_client",
"=",
"session",
".",
"client",
"(",
"'iam'",
")"... | Get role ARN given role name.
Args:
role_name (str): Role name to lookup
env (str): Environment in which to lookup
region (str): Region
Returns:
ARN if role found | [
"Get",
"role",
"ARN",
"given",
"role",
"name",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/roles.py#L9-L31 |
foremast/foremast | src/foremast/iam/construct_policy.py | render_policy_template | def render_policy_template( # pylint: disable=too-many-arguments
account_number='',
app='coreforrest',
env='dev',
group='forrest',
items=None,
pipeline_settings=None,
region='us-east-1',
service=''):
"""Render IAM Policy template.
To support mult... | python | def render_policy_template( # pylint: disable=too-many-arguments
account_number='',
app='coreforrest',
env='dev',
group='forrest',
items=None,
pipeline_settings=None,
region='us-east-1',
service=''):
"""Render IAM Policy template.
To support mult... | [
"def",
"render_policy_template",
"(",
"# pylint: disable=too-many-arguments",
"account_number",
"=",
"''",
",",
"app",
"=",
"'coreforrest'",
",",
"env",
"=",
"'dev'",
",",
"group",
"=",
"'forrest'",
",",
"items",
"=",
"None",
",",
"pipeline_settings",
"=",
"None",... | Render IAM Policy template.
To support multiple statement blocks, JSON objects can be separated by a
comma. This function attempts to turn any invalid JSON into a valid list
based on this comma separated assumption.
Args:
account_number (str): AWS Account number.
app (str): Name of Spi... | [
"Render",
"IAM",
"Policy",
"template",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/iam/construct_policy.py#L57-L108 |
foremast/foremast | src/foremast/iam/construct_policy.py | construct_policy | def construct_policy(app='coreforrest', env='dev', group='forrest', region='us-east-1', pipeline_settings=None):
"""Assemble IAM Policy for _app_.
Args:
app (str): Name of Spinnaker Application.
env (str): Environment/Account in AWS
group (str):A Application group/namespace
regi... | python | def construct_policy(app='coreforrest', env='dev', group='forrest', region='us-east-1', pipeline_settings=None):
"""Assemble IAM Policy for _app_.
Args:
app (str): Name of Spinnaker Application.
env (str): Environment/Account in AWS
group (str):A Application group/namespace
regi... | [
"def",
"construct_policy",
"(",
"app",
"=",
"'coreforrest'",
",",
"env",
"=",
"'dev'",
",",
"group",
"=",
"'forrest'",
",",
"region",
"=",
"'us-east-1'",
",",
"pipeline_settings",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"'Create custom IAM Policy for %... | Assemble IAM Policy for _app_.
Args:
app (str): Name of Spinnaker Application.
env (str): Environment/Account in AWS
group (str):A Application group/namespace
region (str): AWS region
pipeline_settings (dict): Settings from *pipeline.json*.
Returns:
json: Custom... | [
"Assemble",
"IAM",
"Policy",
"for",
"_app_",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/iam/construct_policy.py#L111-L163 |
foremast/foremast | src/foremast/pipeline/construct_pipeline_block_lambda.py | construct_pipeline_block_lambda | def construct_pipeline_block_lambda(env='',
generated=None,
previous_env=None,
region='us-east-1',
region_subnets=None,
settings=None,
... | python | def construct_pipeline_block_lambda(env='',
generated=None,
previous_env=None,
region='us-east-1',
region_subnets=None,
settings=None,
... | [
"def",
"construct_pipeline_block_lambda",
"(",
"env",
"=",
"''",
",",
"generated",
"=",
"None",
",",
"previous_env",
"=",
"None",
",",
"region",
"=",
"'us-east-1'",
",",
"region_subnets",
"=",
"None",
",",
"settings",
"=",
"None",
",",
"pipeline_data",
"=",
... | Create the Pipeline JSON from template.
This handles the common repeatable patterns in a pipeline, such as
judgement, infrastructure, tagger and qe.
Args:
env (str): Deploy environment name, e.g. dev, stage, prod.
generated (gogoutils.Generator): Gogo Application name generator.
pr... | [
"Create",
"the",
"Pipeline",
"JSON",
"from",
"template",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/construct_pipeline_block_lambda.py#L28-L99 |
foremast/foremast | src/foremast/validate.py | validate_gate | def validate_gate():
"""Check Gate connection."""
try:
credentials = get_env_credential()
LOG.debug('Found credentials: %s', credentials)
LOG.info('Gate working.')
except TypeError:
LOG.fatal('Gate connection not valid: API_URL = %s', API_URL) | python | def validate_gate():
"""Check Gate connection."""
try:
credentials = get_env_credential()
LOG.debug('Found credentials: %s', credentials)
LOG.info('Gate working.')
except TypeError:
LOG.fatal('Gate connection not valid: API_URL = %s', API_URL) | [
"def",
"validate_gate",
"(",
")",
":",
"try",
":",
"credentials",
"=",
"get_env_credential",
"(",
")",
"LOG",
".",
"debug",
"(",
"'Found credentials: %s'",
",",
"credentials",
")",
"LOG",
".",
"info",
"(",
"'Gate working.'",
")",
"except",
"TypeError",
":",
... | Check Gate connection. | [
"Check",
"Gate",
"connection",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/validate.py#L10-L17 |
foremast/foremast | src/foremast/awslambda/s3_event/s3_event.py | create_s3_event | def create_s3_event(app_name, env, region, bucket, triggers):
"""Create S3 lambda events from triggers
Args:
app_name (str): name of the lambda function
env (str): Environment/Account for lambda function
region (str): AWS region of the lambda function
triggers (list): List of tr... | python | def create_s3_event(app_name, env, region, bucket, triggers):
"""Create S3 lambda events from triggers
Args:
app_name (str): name of the lambda function
env (str): Environment/Account for lambda function
region (str): AWS region of the lambda function
triggers (list): List of tr... | [
"def",
"create_s3_event",
"(",
"app_name",
",",
"env",
",",
"region",
",",
"bucket",
",",
"triggers",
")",
":",
"session",
"=",
"boto3",
".",
"Session",
"(",
"profile_name",
"=",
"env",
",",
"region_name",
"=",
"region",
")",
"s3_client",
"=",
"session",
... | Create S3 lambda events from triggers
Args:
app_name (str): name of the lambda function
env (str): Environment/Account for lambda function
region (str): AWS region of the lambda function
triggers (list): List of triggers from the settings | [
"Create",
"S3",
"lambda",
"events",
"from",
"triggers"
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/s3_event/s3_event.py#L28-L62 |
foremast/foremast | src/foremast/utils/generate_filename.py | generate_packer_filename | def generate_packer_filename(provider, region, builder):
"""Generate a filename to be used by packer.
Args:
provider (str): Name of Spinnaker provider.
region (str): Name of provider region to use.
builder (str): Name of builder process type.
Returns:
str: Generated filenam... | python | def generate_packer_filename(provider, region, builder):
"""Generate a filename to be used by packer.
Args:
provider (str): Name of Spinnaker provider.
region (str): Name of provider region to use.
builder (str): Name of builder process type.
Returns:
str: Generated filenam... | [
"def",
"generate_packer_filename",
"(",
"provider",
",",
"region",
",",
"builder",
")",
":",
"filename",
"=",
"'{0}_{1}_{2}.json'",
".",
"format",
"(",
"provider",
",",
"region",
",",
"builder",
")",
"return",
"filename"
] | Generate a filename to be used by packer.
Args:
provider (str): Name of Spinnaker provider.
region (str): Name of provider region to use.
builder (str): Name of builder process type.
Returns:
str: Generated filename based on parameters. | [
"Generate",
"a",
"filename",
"to",
"be",
"used",
"by",
"packer",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/generate_filename.py#L19-L32 |
foremast/foremast | src/foremast/utils/templates.py | get_template_object | def get_template_object(template_file=''):
"""Retrieve template.
Args:
template_file (str): Name of template file.
Returns:
jinja2.Template: Template ready to render.
Raises:
AssertionError: Configured path for templates does not exist.
:obj:`foremast.exceptions.Forema... | python | def get_template_object(template_file=''):
"""Retrieve template.
Args:
template_file (str): Name of template file.
Returns:
jinja2.Template: Template ready to render.
Raises:
AssertionError: Configured path for templates does not exist.
:obj:`foremast.exceptions.Forema... | [
"def",
"get_template_object",
"(",
"template_file",
"=",
"''",
")",
":",
"jinja_template_paths_obj",
"=",
"[",
"]",
"if",
"TEMPLATES_PATH",
":",
"external_templates",
"=",
"pathlib",
".",
"Path",
"(",
"TEMPLATES_PATH",
")",
".",
"expanduser",
"(",
")",
".",
"r... | Retrieve template.
Args:
template_file (str): Name of template file.
Returns:
jinja2.Template: Template ready to render.
Raises:
AssertionError: Configured path for templates does not exist.
:obj:`foremast.exceptions.ForemastTemplateNotFound`: Requested template
... | [
"Retrieve",
"template",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/templates.py#L32-L67 |
foremast/foremast | src/foremast/utils/templates.py | get_template | def get_template(template_file='', **kwargs):
"""Get the Jinja2 template and renders with dict _kwargs_.
Args:
template_file (str): name of the template file
kwargs: Keywords to use for rendering the Jinja2 template.
Returns:
String of rendered JSON template.
"""
template ... | python | def get_template(template_file='', **kwargs):
"""Get the Jinja2 template and renders with dict _kwargs_.
Args:
template_file (str): name of the template file
kwargs: Keywords to use for rendering the Jinja2 template.
Returns:
String of rendered JSON template.
"""
template ... | [
"def",
"get_template",
"(",
"template_file",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"template",
"=",
"get_template_object",
"(",
"template_file",
")",
"LOG",
".",
"info",
"(",
"'Rendering template %s'",
",",
"template",
".",
"filename",
")",
"for",
"k... | Get the Jinja2 template and renders with dict _kwargs_.
Args:
template_file (str): name of the template file
kwargs: Keywords to use for rendering the Jinja2 template.
Returns:
String of rendered JSON template. | [
"Get",
"the",
"Jinja2",
"template",
"and",
"renders",
"with",
"dict",
"_kwargs_",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/templates.py#L70-L90 |
foremast/foremast | src/foremast/pipeline/renumerate_stages.py | renumerate_stages | def renumerate_stages(pipeline):
"""Renumber Pipeline Stage reference IDs to account for dependencies.
stage order is defined in the templates. The ``refId`` field dictates
if a stage should be mainline or parallel to other stages.
* ``master`` - A mainline required stage. Other stages depend on i... | python | def renumerate_stages(pipeline):
"""Renumber Pipeline Stage reference IDs to account for dependencies.
stage order is defined in the templates. The ``refId`` field dictates
if a stage should be mainline or parallel to other stages.
* ``master`` - A mainline required stage. Other stages depend on i... | [
"def",
"renumerate_stages",
"(",
"pipeline",
")",
":",
"stages",
"=",
"pipeline",
"[",
"'stages'",
"]",
"main_index",
"=",
"0",
"branch_index",
"=",
"0",
"previous_refid",
"=",
"''",
"for",
"stage",
"in",
"stages",
":",
"current_refid",
"=",
"stage",
"[",
... | Renumber Pipeline Stage reference IDs to account for dependencies.
stage order is defined in the templates. The ``refId`` field dictates
if a stage should be mainline or parallel to other stages.
* ``master`` - A mainline required stage. Other stages depend on it
* ``branch`` - A stage that sh... | [
"Renumber",
"Pipeline",
"Stage",
"reference",
"IDs",
"to",
"account",
"for",
"dependencies",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/renumerate_stages.py#L22-L68 |
foremast/foremast | src/foremast/utils/tasks.py | post_task | def post_task(task_data, task_uri='/tasks'):
"""Create Spinnaker Task.
Args:
task_data (str): Task JSON definition.
Returns:
str: Spinnaker Task ID.
Raises:
AssertionError: Error response from Spinnaker.
"""
url = '{}/{}'.format(API_URL, task_uri.lstrip('/'))
if ... | python | def post_task(task_data, task_uri='/tasks'):
"""Create Spinnaker Task.
Args:
task_data (str): Task JSON definition.
Returns:
str: Spinnaker Task ID.
Raises:
AssertionError: Error response from Spinnaker.
"""
url = '{}/{}'.format(API_URL, task_uri.lstrip('/'))
if ... | [
"def",
"post_task",
"(",
"task_data",
",",
"task_uri",
"=",
"'/tasks'",
")",
":",
"url",
"=",
"'{}/{}'",
".",
"format",
"(",
"API_URL",
",",
"task_uri",
".",
"lstrip",
"(",
"'/'",
")",
")",
"if",
"isinstance",
"(",
"task_data",
",",
"str",
")",
":",
... | Create Spinnaker Task.
Args:
task_data (str): Task JSON definition.
Returns:
str: Spinnaker Task ID.
Raises:
AssertionError: Error response from Spinnaker. | [
"Create",
"Spinnaker",
"Task",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/tasks.py#L29-L56 |
foremast/foremast | src/foremast/utils/tasks.py | _check_task | def _check_task(taskid):
"""Check Spinnaker Task status.
Args:
taskid (str): Existing Spinnaker Task ID.
Returns:
str: Task status.
"""
try:
taskurl = taskid.get('ref', '0000')
except AttributeError:
taskurl = taskid
taskid = taskurl.split('/tasks/')[-1]
... | python | def _check_task(taskid):
"""Check Spinnaker Task status.
Args:
taskid (str): Existing Spinnaker Task ID.
Returns:
str: Task status.
"""
try:
taskurl = taskid.get('ref', '0000')
except AttributeError:
taskurl = taskid
taskid = taskurl.split('/tasks/')[-1]
... | [
"def",
"_check_task",
"(",
"taskid",
")",
":",
"try",
":",
"taskurl",
"=",
"taskid",
".",
"get",
"(",
"'ref'",
",",
"'0000'",
")",
"except",
"AttributeError",
":",
"taskurl",
"=",
"taskid",
"taskid",
"=",
"taskurl",
".",
"split",
"(",
"'/tasks/'",
")",
... | Check Spinnaker Task status.
Args:
taskid (str): Existing Spinnaker Task ID.
Returns:
str: Task status. | [
"Check",
"Spinnaker",
"Task",
"status",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/tasks.py#L59-L94 |
foremast/foremast | src/foremast/utils/tasks.py | check_task | def check_task(taskid, timeout=DEFAULT_TASK_TIMEOUT, wait=2):
"""Wrap check_task.
Args:
taskid (str): Existing Spinnaker Task ID.
timeout (int, optional): Consider Task failed after given seconds.
wait (int, optional): Seconds to pause between polling attempts.
Returns:
str... | python | def check_task(taskid, timeout=DEFAULT_TASK_TIMEOUT, wait=2):
"""Wrap check_task.
Args:
taskid (str): Existing Spinnaker Task ID.
timeout (int, optional): Consider Task failed after given seconds.
wait (int, optional): Seconds to pause between polling attempts.
Returns:
str... | [
"def",
"check_task",
"(",
"taskid",
",",
"timeout",
"=",
"DEFAULT_TASK_TIMEOUT",
",",
"wait",
"=",
"2",
")",
":",
"max_attempts",
"=",
"int",
"(",
"timeout",
"/",
"wait",
")",
"try",
":",
"return",
"retry_call",
"(",
"partial",
"(",
"_check_task",
",",
"... | Wrap check_task.
Args:
taskid (str): Existing Spinnaker Task ID.
timeout (int, optional): Consider Task failed after given seconds.
wait (int, optional): Seconds to pause between polling attempts.
Returns:
str: Task status.
Raises:
AssertionError: API did not respo... | [
"Wrap",
"check_task",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/tasks.py#L97-L122 |
foremast/foremast | src/foremast/utils/tasks.py | wait_for_task | def wait_for_task(task_data, task_uri='/tasks'):
"""Run task and check the result.
Args:
task_data (str): the task json to execute
Returns:
str: Task status.
"""
taskid = post_task(task_data, task_uri)
if isinstance(task_data, str):
json_data = json.loads(task_data)
... | python | def wait_for_task(task_data, task_uri='/tasks'):
"""Run task and check the result.
Args:
task_data (str): the task json to execute
Returns:
str: Task status.
"""
taskid = post_task(task_data, task_uri)
if isinstance(task_data, str):
json_data = json.loads(task_data)
... | [
"def",
"wait_for_task",
"(",
"task_data",
",",
"task_uri",
"=",
"'/tasks'",
")",
":",
"taskid",
"=",
"post_task",
"(",
"task_data",
",",
"task_uri",
")",
"if",
"isinstance",
"(",
"task_data",
",",
"str",
")",
":",
"json_data",
"=",
"json",
".",
"loads",
... | Run task and check the result.
Args:
task_data (str): the task json to execute
Returns:
str: Task status. | [
"Run",
"task",
"and",
"check",
"the",
"result",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/tasks.py#L125-L151 |
foremast/foremast | src/foremast/s3/__main__.py | main | def main():
"""Create application.properties for a given application."""
logging.basicConfig(format=LOGGING_FORMAT)
parser = argparse.ArgumentParser(description=main.__doc__)
add_debug(parser)
add_app(parser)
add_env(parser)
add_properties(parser)
add_region(parser)
add_artifact_pa... | python | def main():
"""Create application.properties for a given application."""
logging.basicConfig(format=LOGGING_FORMAT)
parser = argparse.ArgumentParser(description=main.__doc__)
add_debug(parser)
add_app(parser)
add_env(parser)
add_properties(parser)
add_region(parser)
add_artifact_pa... | [
"def",
"main",
"(",
")",
":",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"LOGGING_FORMAT",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"main",
".",
"__doc__",
")",
"add_debug",
"(",
"parser",
")",
"add_app",
"(",... | Create application.properties for a given application. | [
"Create",
"application",
".",
"properties",
"for",
"a",
"given",
"application",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/__main__.py#L34-L68 |
foremast/foremast | src/foremast/s3/create_archaius.py | init_properties | def init_properties(env='dev', app='unnecessary', **_):
"""Make sure _application.properties_ file exists in S3.
For Applications with Archaius support, there needs to be a file where the
cloud environment variable points to.
Args:
env (str): Deployment environment/account, i.e. dev, stage, pr... | python | def init_properties(env='dev', app='unnecessary', **_):
"""Make sure _application.properties_ file exists in S3.
For Applications with Archaius support, there needs to be a file where the
cloud environment variable points to.
Args:
env (str): Deployment environment/account, i.e. dev, stage, pr... | [
"def",
"init_properties",
"(",
"env",
"=",
"'dev'",
",",
"app",
"=",
"'unnecessary'",
",",
"*",
"*",
"_",
")",
":",
"aws_env",
"=",
"boto3",
".",
"session",
".",
"Session",
"(",
"profile_name",
"=",
"env",
")",
"s3client",
"=",
"aws_env",
".",
"resourc... | Make sure _application.properties_ file exists in S3.
For Applications with Archaius support, there needs to be a file where the
cloud environment variable points to.
Args:
env (str): Deployment environment/account, i.e. dev, stage, prod.
app (str): GitLab Project name.
Returns:
... | [
"Make",
"sure",
"_application",
".",
"properties_",
"file",
"exists",
"in",
"S3",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/create_archaius.py#L26-L55 |
foremast/foremast | src/foremast/awslambda/cloudwatch_event/cloudwatch_event.py | create_cloudwatch_event | def create_cloudwatch_event(app_name, env, region, rules):
"""Create cloudwatch event for lambda from rules.
Args:
app_name (str): name of the lambda function
env (str): Environment/Account for lambda function
region (str): AWS region of the lambda function
rules (dict): Trigger... | python | def create_cloudwatch_event(app_name, env, region, rules):
"""Create cloudwatch event for lambda from rules.
Args:
app_name (str): name of the lambda function
env (str): Environment/Account for lambda function
region (str): AWS region of the lambda function
rules (dict): Trigger... | [
"def",
"create_cloudwatch_event",
"(",
"app_name",
",",
"env",
",",
"region",
",",
"rules",
")",
":",
"session",
"=",
"boto3",
".",
"Session",
"(",
"profile_name",
"=",
"env",
",",
"region_name",
"=",
"region",
")",
"cloudwatch_client",
"=",
"session",
".",
... | Create cloudwatch event for lambda from rules.
Args:
app_name (str): name of the lambda function
env (str): Environment/Account for lambda function
region (str): AWS region of the lambda function
rules (dict): Trigger rules from the settings | [
"Create",
"cloudwatch",
"event",
"for",
"lambda",
"from",
"rules",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/cloudwatch_event/cloudwatch_event.py#L29-L98 |
foremast/foremast | src/foremast/utils/credentials.py | get_env_credential | def get_env_credential(env='dev'):
"""Get Account Credential from Spinnaker for *env*.
Args:
env (str): Environment name to find credentials for.
Returns:
dict: Complete credentials for *env*::
{
'accountId': '123098123',
'accountType': 'dev',
... | python | def get_env_credential(env='dev'):
"""Get Account Credential from Spinnaker for *env*.
Args:
env (str): Environment name to find credentials for.
Returns:
dict: Complete credentials for *env*::
{
'accountId': '123098123',
'accountType': 'dev',
... | [
"def",
"get_env_credential",
"(",
"env",
"=",
"'dev'",
")",
":",
"url",
"=",
"'/'",
".",
"join",
"(",
"[",
"API_URL",
",",
"'credentials'",
",",
"env",
"]",
")",
"credential_response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"verify",
"=",
"GATE_... | Get Account Credential from Spinnaker for *env*.
Args:
env (str): Environment name to find credentials for.
Returns:
dict: Complete credentials for *env*::
{
'accountId': '123098123',
'accountType': 'dev',
'assumeRole': 'role/spinnak... | [
"Get",
"Account",
"Credential",
"from",
"Spinnaker",
"for",
"*",
"env",
"*",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/credentials.py#L26-L81 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.find_api_id | def find_api_id(self):
"""Given API name, find API ID."""
allapis = self.client.get_rest_apis()
api_name = self.trigger_settings['api_name']
api_id = None
for api in allapis['items']:
if api['name'] == api_name:
api_id = api['id']
self.... | python | def find_api_id(self):
"""Given API name, find API ID."""
allapis = self.client.get_rest_apis()
api_name = self.trigger_settings['api_name']
api_id = None
for api in allapis['items']:
if api['name'] == api_name:
api_id = api['id']
self.... | [
"def",
"find_api_id",
"(",
"self",
")",
":",
"allapis",
"=",
"self",
".",
"client",
".",
"get_rest_apis",
"(",
")",
"api_name",
"=",
"self",
".",
"trigger_settings",
"[",
"'api_name'",
"]",
"api_id",
"=",
"None",
"for",
"api",
"in",
"allapis",
"[",
"'ite... | Given API name, find API ID. | [
"Given",
"API",
"name",
"find",
"API",
"ID",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L59-L72 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.find_resource_ids | def find_resource_ids(self):
"""Given a resource path and API Id, find resource Id."""
all_resources = self.client.get_resources(restApiId=self.api_id)
parent_id = None
resource_id = None
for resource in all_resources['items']:
if resource['path'] == "/":
... | python | def find_resource_ids(self):
"""Given a resource path and API Id, find resource Id."""
all_resources = self.client.get_resources(restApiId=self.api_id)
parent_id = None
resource_id = None
for resource in all_resources['items']:
if resource['path'] == "/":
... | [
"def",
"find_resource_ids",
"(",
"self",
")",
":",
"all_resources",
"=",
"self",
".",
"client",
".",
"get_resources",
"(",
"restApiId",
"=",
"self",
".",
"api_id",
")",
"parent_id",
"=",
"None",
"resource_id",
"=",
"None",
"for",
"resource",
"in",
"all_resou... | Given a resource path and API Id, find resource Id. | [
"Given",
"a",
"resource",
"path",
"and",
"API",
"Id",
"find",
"resource",
"Id",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L74-L85 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.add_lambda_integration | def add_lambda_integration(self):
"""Attach lambda found to API."""
lambda_uri = self.generate_uris()['lambda_uri']
self.client.put_integration(
restApiId=self.api_id,
resourceId=self.resource_id,
httpMethod=self.trigger_settings['method'],
integra... | python | def add_lambda_integration(self):
"""Attach lambda found to API."""
lambda_uri = self.generate_uris()['lambda_uri']
self.client.put_integration(
restApiId=self.api_id,
resourceId=self.resource_id,
httpMethod=self.trigger_settings['method'],
integra... | [
"def",
"add_lambda_integration",
"(",
"self",
")",
":",
"lambda_uri",
"=",
"self",
".",
"generate_uris",
"(",
")",
"[",
"'lambda_uri'",
"]",
"self",
".",
"client",
".",
"put_integration",
"(",
"restApiId",
"=",
"self",
".",
"api_id",
",",
"resourceId",
"=",
... | Attach lambda found to API. | [
"Attach",
"lambda",
"found",
"to",
"API",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L87-L98 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.add_integration_response | def add_integration_response(self):
"""Add an intergation response to the API for the lambda integration."""
self.client.put_integration_response(
restApiId=self.api_id,
resourceId=self.resource_id,
httpMethod=self.trigger_settings['method'],
statusCode='2... | python | def add_integration_response(self):
"""Add an intergation response to the API for the lambda integration."""
self.client.put_integration_response(
restApiId=self.api_id,
resourceId=self.resource_id,
httpMethod=self.trigger_settings['method'],
statusCode='2... | [
"def",
"add_integration_response",
"(",
"self",
")",
":",
"self",
".",
"client",
".",
"put_integration_response",
"(",
"restApiId",
"=",
"self",
".",
"api_id",
",",
"resourceId",
"=",
"self",
".",
"resource_id",
",",
"httpMethod",
"=",
"self",
".",
"trigger_se... | Add an intergation response to the API for the lambda integration. | [
"Add",
"an",
"intergation",
"response",
"to",
"the",
"API",
"for",
"the",
"lambda",
"integration",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L100-L107 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.add_permission | def add_permission(self):
"""Add permission to Lambda for the API Trigger."""
statement_id = '{}_api_{}'.format(self.app_name, self.trigger_settings['api_name'])
principal = 'apigateway.amazonaws.com'
lambda_alias_arn = get_lambda_alias_arn(self.app_name, self.env, self.region)
l... | python | def add_permission(self):
"""Add permission to Lambda for the API Trigger."""
statement_id = '{}_api_{}'.format(self.app_name, self.trigger_settings['api_name'])
principal = 'apigateway.amazonaws.com'
lambda_alias_arn = get_lambda_alias_arn(self.app_name, self.env, self.region)
l... | [
"def",
"add_permission",
"(",
"self",
")",
":",
"statement_id",
"=",
"'{}_api_{}'",
".",
"format",
"(",
"self",
".",
"app_name",
",",
"self",
".",
"trigger_settings",
"[",
"'api_name'",
"]",
")",
"principal",
"=",
"'apigateway.amazonaws.com'",
"lambda_alias_arn",
... | Add permission to Lambda for the API Trigger. | [
"Add",
"permission",
"to",
"Lambda",
"for",
"the",
"API",
"Trigger",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L109-L152 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.create_api_deployment | def create_api_deployment(self):
"""Create API deployment of ENV name."""
try:
self.client.create_deployment(restApiId=self.api_id, stageName=self.env)
self.log.info('Created a deployment resource.')
except botocore.exceptions.ClientError as error:
error_code ... | python | def create_api_deployment(self):
"""Create API deployment of ENV name."""
try:
self.client.create_deployment(restApiId=self.api_id, stageName=self.env)
self.log.info('Created a deployment resource.')
except botocore.exceptions.ClientError as error:
error_code ... | [
"def",
"create_api_deployment",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"client",
".",
"create_deployment",
"(",
"restApiId",
"=",
"self",
".",
"api_id",
",",
"stageName",
"=",
"self",
".",
"env",
")",
"self",
".",
"log",
".",
"info",
"(",
"'Cr... | Create API deployment of ENV name. | [
"Create",
"API",
"deployment",
"of",
"ENV",
"name",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L155-L165 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.create_api_key | def create_api_key(self):
"""Create API Key for API access."""
apikeys = self.client.get_api_keys()
for key in apikeys['items']:
if key['name'] == self.app_name:
self.log.info("Key %s already exists", self.app_name)
break
else:
self... | python | def create_api_key(self):
"""Create API Key for API access."""
apikeys = self.client.get_api_keys()
for key in apikeys['items']:
if key['name'] == self.app_name:
self.log.info("Key %s already exists", self.app_name)
break
else:
self... | [
"def",
"create_api_key",
"(",
"self",
")",
":",
"apikeys",
"=",
"self",
".",
"client",
".",
"get_api_keys",
"(",
")",
"for",
"key",
"in",
"apikeys",
"[",
"'items'",
"]",
":",
"if",
"key",
"[",
"'name'",
"]",
"==",
"self",
".",
"app_name",
":",
"self"... | Create API Key for API access. | [
"Create",
"API",
"Key",
"for",
"API",
"access",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L167-L180 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway._format_base_path | def _format_base_path(self, api_name):
"""Format the base path name."""
name = self.app_name
if self.app_name != api_name:
name = '{0}-{1}'.format(self.app_name, api_name)
return name | python | def _format_base_path(self, api_name):
"""Format the base path name."""
name = self.app_name
if self.app_name != api_name:
name = '{0}-{1}'.format(self.app_name, api_name)
return name | [
"def",
"_format_base_path",
"(",
"self",
",",
"api_name",
")",
":",
"name",
"=",
"self",
".",
"app_name",
"if",
"self",
".",
"app_name",
"!=",
"api_name",
":",
"name",
"=",
"'{0}-{1}'",
".",
"format",
"(",
"self",
".",
"app_name",
",",
"api_name",
")",
... | Format the base path name. | [
"Format",
"the",
"base",
"path",
"name",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L182-L187 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.update_api_mappings | def update_api_mappings(self):
"""Create a cname for the API deployment."""
response_provider = None
response_action = None
domain = self.generated.apigateway()['domain']
try:
response_provider = self.client.create_base_path_mapping(
domainName=domain,... | python | def update_api_mappings(self):
"""Create a cname for the API deployment."""
response_provider = None
response_action = None
domain = self.generated.apigateway()['domain']
try:
response_provider = self.client.create_base_path_mapping(
domainName=domain,... | [
"def",
"update_api_mappings",
"(",
"self",
")",
":",
"response_provider",
"=",
"None",
"response_action",
"=",
"None",
"domain",
"=",
"self",
".",
"generated",
".",
"apigateway",
"(",
")",
"[",
"'domain'",
"]",
"try",
":",
"response_provider",
"=",
"self",
"... | Create a cname for the API deployment. | [
"Create",
"a",
"cname",
"for",
"the",
"API",
"deployment",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L189-L210 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.generate_uris | def generate_uris(self):
"""Generate several lambda uris."""
lambda_arn = "arn:aws:execute-api:{0}:{1}:{2}/*/{3}/{4}".format(self.region, self.account_id, self.api_id,
self.trigger_settings['method'],
... | python | def generate_uris(self):
"""Generate several lambda uris."""
lambda_arn = "arn:aws:execute-api:{0}:{1}:{2}/*/{3}/{4}".format(self.region, self.account_id, self.api_id,
self.trigger_settings['method'],
... | [
"def",
"generate_uris",
"(",
"self",
")",
":",
"lambda_arn",
"=",
"\"arn:aws:execute-api:{0}:{1}:{2}/*/{3}/{4}\"",
".",
"format",
"(",
"self",
".",
"region",
",",
"self",
".",
"account_id",
",",
"self",
".",
"api_id",
",",
"self",
".",
"trigger_settings",
"[",
... | Generate several lambda uris. | [
"Generate",
"several",
"lambda",
"uris",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L212-L225 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.create_api | def create_api(self):
"""Create the REST API."""
created_api = self.client.create_rest_api(name=self.trigger_settings.get('api_name', self.app_name))
api_id = created_api['id']
self.log.info("Successfully created API")
return api_id | python | def create_api(self):
"""Create the REST API."""
created_api = self.client.create_rest_api(name=self.trigger_settings.get('api_name', self.app_name))
api_id = created_api['id']
self.log.info("Successfully created API")
return api_id | [
"def",
"create_api",
"(",
"self",
")",
":",
"created_api",
"=",
"self",
".",
"client",
".",
"create_rest_api",
"(",
"name",
"=",
"self",
".",
"trigger_settings",
".",
"get",
"(",
"'api_name'",
",",
"self",
".",
"app_name",
")",
")",
"api_id",
"=",
"creat... | Create the REST API. | [
"Create",
"the",
"REST",
"API",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L227-L232 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.create_resource | def create_resource(self, parent_id=""):
"""Create the specified resource.
Args:
parent_id (str): The resource ID of the parent resource in API Gateway
"""
resource_name = self.trigger_settings.get('resource', '')
resource_name = resource_name.replace('/', '')
... | python | def create_resource(self, parent_id=""):
"""Create the specified resource.
Args:
parent_id (str): The resource ID of the parent resource in API Gateway
"""
resource_name = self.trigger_settings.get('resource', '')
resource_name = resource_name.replace('/', '')
... | [
"def",
"create_resource",
"(",
"self",
",",
"parent_id",
"=",
"\"\"",
")",
":",
"resource_name",
"=",
"self",
".",
"trigger_settings",
".",
"get",
"(",
"'resource'",
",",
"''",
")",
"resource_name",
"=",
"resource_name",
".",
"replace",
"(",
"'/'",
",",
"'... | Create the specified resource.
Args:
parent_id (str): The resource ID of the parent resource in API Gateway | [
"Create",
"the",
"specified",
"resource",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L234-L249 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.attach_method | def attach_method(self, resource_id):
"""Attach the defined method."""
try:
_response = self.client.put_method(
restApiId=self.api_id,
resourceId=resource_id,
httpMethod=self.trigger_settings['method'],
authorizationType="NONE",... | python | def attach_method(self, resource_id):
"""Attach the defined method."""
try:
_response = self.client.put_method(
restApiId=self.api_id,
resourceId=resource_id,
httpMethod=self.trigger_settings['method'],
authorizationType="NONE",... | [
"def",
"attach_method",
"(",
"self",
",",
"resource_id",
")",
":",
"try",
":",
"_response",
"=",
"self",
".",
"client",
".",
"put_method",
"(",
"restApiId",
"=",
"self",
".",
"api_id",
",",
"resourceId",
"=",
"resource_id",
",",
"httpMethod",
"=",
"self",
... | Attach the defined method. | [
"Attach",
"the",
"defined",
"method",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L251-L270 |
foremast/foremast | src/foremast/awslambda/api_gateway_event/api_gateway_event.py | APIGateway.setup_lambda_api | def setup_lambda_api(self):
"""A wrapper for all the steps needed to setup the integration."""
self.create_resource(self.parent_id)
self.attach_method(self.resource_id)
self.add_lambda_integration()
self.add_permission()
self.create_api_deployment()
self.create_ap... | python | def setup_lambda_api(self):
"""A wrapper for all the steps needed to setup the integration."""
self.create_resource(self.parent_id)
self.attach_method(self.resource_id)
self.add_lambda_integration()
self.add_permission()
self.create_api_deployment()
self.create_ap... | [
"def",
"setup_lambda_api",
"(",
"self",
")",
":",
"self",
".",
"create_resource",
"(",
"self",
".",
"parent_id",
")",
"self",
".",
"attach_method",
"(",
"self",
".",
"resource_id",
")",
"self",
".",
"add_lambda_integration",
"(",
")",
"self",
".",
"add_permi... | A wrapper for all the steps needed to setup the integration. | [
"A",
"wrapper",
"for",
"all",
"the",
"steps",
"needed",
"to",
"setup",
"the",
"integration",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/api_gateway_event/api_gateway_event.py#L272-L280 |
foremast/foremast | src/foremast/dns/__main__.py | main | def main():
"""Run newer stuffs."""
logging.basicConfig(format=LOGGING_FORMAT)
log = logging.getLogger(__name__)
parser = argparse.ArgumentParser()
add_debug(parser)
add_app(parser)
add_env(parser)
add_region(parser)
add_properties(parser)
parser.add_argument("--elb-subnet", hel... | python | def main():
"""Run newer stuffs."""
logging.basicConfig(format=LOGGING_FORMAT)
log = logging.getLogger(__name__)
parser = argparse.ArgumentParser()
add_debug(parser)
add_app(parser)
add_env(parser)
add_region(parser)
add_properties(parser)
parser.add_argument("--elb-subnet", hel... | [
"def",
"main",
"(",
")",
":",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"LOGGING_FORMAT",
")",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"add_debug",
"(",
"parser",
... | Run newer stuffs. | [
"Run",
"newer",
"stuffs",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/dns/__main__.py#L28-L48 |
foremast/foremast | src/foremast/securitygroup/create_securitygroup.py | SpinnakerSecurityGroup._validate_cidr | def _validate_cidr(self, rule):
"""Validate the cidr block in a rule.
Returns:
True: Upon successful completion.
Raises:
SpinnakerSecurityGroupCreationFailed: CIDR definition is invalid or
the network range is too wide.
"""
try:
... | python | def _validate_cidr(self, rule):
"""Validate the cidr block in a rule.
Returns:
True: Upon successful completion.
Raises:
SpinnakerSecurityGroupCreationFailed: CIDR definition is invalid or
the network range is too wide.
"""
try:
... | [
"def",
"_validate_cidr",
"(",
"self",
",",
"rule",
")",
":",
"try",
":",
"network",
"=",
"ipaddress",
".",
"IPv4Network",
"(",
"rule",
"[",
"'app'",
"]",
")",
"except",
"(",
"ipaddress",
".",
"NetmaskValueError",
",",
"ValueError",
")",
"as",
"error",
":... | Validate the cidr block in a rule.
Returns:
True: Upon successful completion.
Raises:
SpinnakerSecurityGroupCreationFailed: CIDR definition is invalid or
the network range is too wide. | [
"Validate",
"the",
"cidr",
"block",
"in",
"a",
"rule",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/securitygroup/create_securitygroup.py#L77-L94 |
foremast/foremast | src/foremast/securitygroup/create_securitygroup.py | SpinnakerSecurityGroup._process_rules | def _process_rules(self, rules):
"""Process rules into cidr and non-cidr lists.
Args:
rules (list): Allowed Security Group ports and protocols.
Returns:
(list, list): Security Group reference rules and custom CIDR rules.
"""
cidr = []
non_cidr = ... | python | def _process_rules(self, rules):
"""Process rules into cidr and non-cidr lists.
Args:
rules (list): Allowed Security Group ports and protocols.
Returns:
(list, list): Security Group reference rules and custom CIDR rules.
"""
cidr = []
non_cidr = ... | [
"def",
"_process_rules",
"(",
"self",
",",
"rules",
")",
":",
"cidr",
"=",
"[",
"]",
"non_cidr",
"=",
"[",
"]",
"for",
"rule",
"in",
"rules",
":",
"if",
"'.'",
"in",
"rule",
"[",
"'app'",
"]",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Custom ... | Process rules into cidr and non-cidr lists.
Args:
rules (list): Allowed Security Group ports and protocols.
Returns:
(list, list): Security Group reference rules and custom CIDR rules. | [
"Process",
"rules",
"into",
"cidr",
"and",
"non",
"-",
"cidr",
"lists",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/securitygroup/create_securitygroup.py#L96-L119 |
foremast/foremast | src/foremast/securitygroup/create_securitygroup.py | SpinnakerSecurityGroup.add_tags | def add_tags(self):
"""Add tags to security group.
Returns:
True: Upon successful completion.
"""
session = boto3.session.Session(profile_name=self.env, region_name=self.region)
resource = session.resource('ec2')
group_id = get_security_group_id(self.app_name... | python | def add_tags(self):
"""Add tags to security group.
Returns:
True: Upon successful completion.
"""
session = boto3.session.Session(profile_name=self.env, region_name=self.region)
resource = session.resource('ec2')
group_id = get_security_group_id(self.app_name... | [
"def",
"add_tags",
"(",
"self",
")",
":",
"session",
"=",
"boto3",
".",
"session",
".",
"Session",
"(",
"profile_name",
"=",
"self",
".",
"env",
",",
"region_name",
"=",
"self",
".",
"region",
")",
"resource",
"=",
"session",
".",
"resource",
"(",
"'ec... | Add tags to security group.
Returns:
True: Upon successful completion. | [
"Add",
"tags",
"to",
"security",
"group",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/securitygroup/create_securitygroup.py#L121-L146 |
foremast/foremast | src/foremast/securitygroup/create_securitygroup.py | SpinnakerSecurityGroup.add_cidr_rules | def add_cidr_rules(self, rules):
"""Add cidr rules to security group via boto.
Args:
rules (list): Allowed Security Group ports and protocols.
Returns:
True: Upon successful completion.
Raises:
SpinnakerSecurityGroupError: boto3 call failed to add C... | python | def add_cidr_rules(self, rules):
"""Add cidr rules to security group via boto.
Args:
rules (list): Allowed Security Group ports and protocols.
Returns:
True: Upon successful completion.
Raises:
SpinnakerSecurityGroupError: boto3 call failed to add C... | [
"def",
"add_cidr_rules",
"(",
"self",
",",
"rules",
")",
":",
"session",
"=",
"boto3",
".",
"session",
".",
"Session",
"(",
"profile_name",
"=",
"self",
".",
"env",
",",
"region_name",
"=",
"self",
".",
"region",
")",
"client",
"=",
"session",
".",
"cl... | Add cidr rules to security group via boto.
Args:
rules (list): Allowed Security Group ports and protocols.
Returns:
True: Upon successful completion.
Raises:
SpinnakerSecurityGroupError: boto3 call failed to add CIDR block to
Security Group. | [
"Add",
"cidr",
"rules",
"to",
"security",
"group",
"via",
"boto",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/securitygroup/create_securitygroup.py#L148-L193 |
foremast/foremast | src/foremast/securitygroup/create_securitygroup.py | SpinnakerSecurityGroup.resolve_self_references | def resolve_self_references(self, rules):
"""Resolves `$self` references to actual application name in security group rules."""
with suppress(KeyError):
rule = rules.pop('$self')
rules[self.app_name] = rule
return rules | python | def resolve_self_references(self, rules):
"""Resolves `$self` references to actual application name in security group rules."""
with suppress(KeyError):
rule = rules.pop('$self')
rules[self.app_name] = rule
return rules | [
"def",
"resolve_self_references",
"(",
"self",
",",
"rules",
")",
":",
"with",
"suppress",
"(",
"KeyError",
")",
":",
"rule",
"=",
"rules",
".",
"pop",
"(",
"'$self'",
")",
"rules",
"[",
"self",
".",
"app_name",
"]",
"=",
"rule",
"return",
"rules"
] | Resolves `$self` references to actual application name in security group rules. | [
"Resolves",
"$self",
"references",
"to",
"actual",
"application",
"name",
"in",
"security",
"group",
"rules",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/securitygroup/create_securitygroup.py#L195-L200 |
foremast/foremast | src/foremast/securitygroup/create_securitygroup.py | SpinnakerSecurityGroup.update_default_rules | def update_default_rules(self):
"""Concatinate application and global security group rules."""
app_ingress = self.properties['security_group']['ingress']
ingress = conservative_merger.merge(DEFAULT_SECURITYGROUP_RULES, app_ingress)
resolved_ingress = self.resolve_self_references(ingress)... | python | def update_default_rules(self):
"""Concatinate application and global security group rules."""
app_ingress = self.properties['security_group']['ingress']
ingress = conservative_merger.merge(DEFAULT_SECURITYGROUP_RULES, app_ingress)
resolved_ingress = self.resolve_self_references(ingress)... | [
"def",
"update_default_rules",
"(",
"self",
")",
":",
"app_ingress",
"=",
"self",
".",
"properties",
"[",
"'security_group'",
"]",
"[",
"'ingress'",
"]",
"ingress",
"=",
"conservative_merger",
".",
"merge",
"(",
"DEFAULT_SECURITYGROUP_RULES",
",",
"app_ingress",
"... | Concatinate application and global security group rules. | [
"Concatinate",
"application",
"and",
"global",
"security",
"group",
"rules",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/securitygroup/create_securitygroup.py#L202-L208 |
foremast/foremast | src/foremast/securitygroup/create_securitygroup.py | SpinnakerSecurityGroup._create_security_group | def _create_security_group(self, ingress):
"""Send a POST to spinnaker to create a new security group.
Returns:
boolean: True if created successfully
"""
template_kwargs = {
'app': self.app_name,
'env': self.env,
'region': self.region,
... | python | def _create_security_group(self, ingress):
"""Send a POST to spinnaker to create a new security group.
Returns:
boolean: True if created successfully
"""
template_kwargs = {
'app': self.app_name,
'env': self.env,
'region': self.region,
... | [
"def",
"_create_security_group",
"(",
"self",
",",
"ingress",
")",
":",
"template_kwargs",
"=",
"{",
"'app'",
":",
"self",
".",
"app_name",
",",
"'env'",
":",
"self",
".",
"env",
",",
"'region'",
":",
"self",
".",
"region",
",",
"'vpc'",
":",
"get_vpc_id... | Send a POST to spinnaker to create a new security group.
Returns:
boolean: True if created successfully | [
"Send",
"a",
"POST",
"to",
"spinnaker",
"to",
"create",
"a",
"new",
"security",
"group",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/securitygroup/create_securitygroup.py#L210-L230 |
foremast/foremast | src/foremast/securitygroup/create_securitygroup.py | SpinnakerSecurityGroup.create_security_group | def create_security_group(self): # noqa
"""Send a POST to spinnaker to create or update a security group.
Returns:
boolean: True if created successfully
Raises:
ForemastConfigurationFileError: Missing environment configuration or
misconfigured Security ... | python | def create_security_group(self): # noqa
"""Send a POST to spinnaker to create or update a security group.
Returns:
boolean: True if created successfully
Raises:
ForemastConfigurationFileError: Missing environment configuration or
misconfigured Security ... | [
"def",
"create_security_group",
"(",
"self",
")",
":",
"# noqa",
"ingress_rules",
"=",
"[",
"]",
"try",
":",
"security_id",
"=",
"get_security_group_id",
"(",
"name",
"=",
"self",
".",
"app_name",
",",
"env",
"=",
"self",
".",
"env",
",",
"region",
"=",
... | Send a POST to spinnaker to create or update a security group.
Returns:
boolean: True if created successfully
Raises:
ForemastConfigurationFileError: Missing environment configuration or
misconfigured Security Group definition. | [
"Send",
"a",
"POST",
"to",
"spinnaker",
"to",
"create",
"or",
"update",
"a",
"security",
"group",
"."
] | train | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/securitygroup/create_securitygroup.py#L232-L279 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.