コード例 #1
0
def canonicalize_namespaces(namespaces):
    canonicalized_namespaces = []
    for namespace_info in namespaces:
        ob.aggregate_shared_resources(
            namespace_info, 'openshiftServiceAccountTokens')
        openshift_serviceaccount_tokens = \
            namespace_info.get('openshiftServiceAccountTokens')
        if openshift_serviceaccount_tokens:
            canonicalized_namespaces.append(namespace_info)
            for sat in openshift_serviceaccount_tokens:
                canonicalized_namespaces.append(sat['namespace'])

    return canonicalized_namespaces
コード例 #2
0
def canonicalize_namespaces(namespaces, providers):
    canonicalized_namespaces = []
    for namespace_info in namespaces:
        ob.aggregate_shared_resources(namespace_info, 'openshiftResources')
        openshift_resources = namespace_info.get('openshiftResources')
        if openshift_resources:
            for resource in openshift_resources[:]:
                if resource['provider'] not in providers:
                    openshift_resources.remove(resource)
        if openshift_resources:
            if len(providers) == 1:
                if providers[0] == 'vault-secret':
                    namespace_info['managedResourceTypes'] = ['Secret']
                elif providers[0] == 'route':
                    namespace_info['managedResourceTypes'] = ['Route']
            canonicalized_namespaces.append(namespace_info)

    return canonicalized_namespaces
コード例 #3
0
def canonicalize_namespaces(
        namespaces: Iterable[dict[str, Any]], providers: list[str]
) -> Tuple[list[dict[str, Any]], Optional[list[str]]]:
    canonicalized_namespaces = []
    override = None
    logging.debug(f"Received providers {providers}")
    for namespace_info in namespaces:
        ob.aggregate_shared_resources(namespace_info, "openshiftResources")
        openshift_resources: list = namespace_info.get(
            "openshiftResources") or []
        ors = [r for r in openshift_resources if r["provider"] in providers]
        if ors and providers:
            # For the time being we only care about the first item in
            # providers
            # TODO: confvert it to a scalar?
            if providers[0] == "vault-secret":
                override = ["Secret"]
            elif providers[0] == "route":
                override = ["Route"]
            namespace_info["openshiftResources"] = ors
            canonicalized_namespaces.append(namespace_info)
    logging.debug(f"Overriding {override}")
    return canonicalized_namespaces, override