コード例 #1
0
def fetch_desired_state(
    gabi_instances: Iterable[Mapping], ri: ResourceInventory
) -> None:
    for g in gabi_instances:
        exp_date = datetime.strptime(g["expirationDate"], "%Y-%m-%d").date()
        users = [u["github_username"] for u in g["users"]]
        if exp_date < date.today():
            users = []
        elif (exp_date - date.today()).days > EXPIRATION_MAX:
            raise RunnerException(
                f'The maximum expiration date of {g["name"]} '
                f"shall not exceed {EXPIRATION_MAX} days form today"
            )
        resource = construct_gabi_oc_resource(g["name"], users)
        for i in g["instances"]:
            namespace = i["namespace"]
            account = i["account"]
            identifier = i["identifier"]
            tf_resources = namespace["terraformResources"]
            found = False
            for t in tf_resources:
                if t["provider"] != "rds":
                    continue
                if (t["account"], t["identifier"]) == (account, identifier):
                    found = True
                    break
            if not found:
                raise RunnerException(
                    f"Could not find rds identifier {identifier} "
                    f'for account {account} in namespace {namespace["name"]}'
                )
            cluster = namespace["cluster"]["name"]
            ri.add_desired(cluster, namespace["name"], "ConfigMap", g["name"], resource)
コード例 #2
0
def fetch_desired_state(gabi_instances: Iterable[Mapping],
                        ri: ResourceInventory) -> None:
    for g in gabi_instances:
        exp_date = datetime.strptime(g['expirationDate'], '%Y-%m-%d').date()
        users = [u['github_username'] for u in g['users']]
        if exp_date < date.today():
            users = []
        elif (exp_date - date.today()).days > EXPIRATION_MAX:
            raise RunnerException(
                f'The maximum expiration date of {g["name"]} '
                f'shall not exceed {EXPIRATION_MAX} days form today')
        resource = construct_gabi_oc_resource(g['name'], users)
        for i in g['instances']:
            namespace = i['namespace']
            account = i['account']
            identifier = i['identifier']
            tf_resources = namespace['terraformResources']
            found = False
            for t in tf_resources:
                if t['provider'] != 'rds':
                    continue
                if (t['account'], t['identifier']) == \
                        (account, identifier):
                    found = True
                    break
            if not found:
                raise RunnerException(
                    f'Could not find rds identifier {identifier} '
                    f'for account {account} in namespace {namespace["name"]}')
            cluster = namespace['cluster']['name']
            ri.add_desired(cluster, namespace['name'], 'ConfigMap', g['name'],
                           resource)
コード例 #3
0
def fill_desired_state(provider: EndpointMonitoringProvider,
                       endpoints: list[Endpoint],
                       ri: ResourceInventory) -> None:
    probe = build_probe(provider, endpoints)
    if probe and provider.blackboxExporter:
        ns = provider.blackboxExporter.namespace
        ri.add_desired(cluster=ns["cluster"]["name"],
                       namespace=ns["name"],
                       resource_type=probe.kind,
                       name=probe.name,
                       value=probe)