Beispiel #1
0
    def get_env_vars(self):
        env_vars = get_internal_env_vars(service_internal_header=InternalServices.DOCKERIZER,
                                         namespace=self.namespace,
                                         authentication_type=AuthenticationTypes.INTERNAL_TOKEN,
                                         include_internal_token=True)
        if conf.get('REGISTRY_PASSWORD') and conf.get('REGISTRY_USER'):
            env_vars += [
                get_env_var(name='POLYAXON_REGISTRY_USER', value=conf.get('REGISTRY_USER')),
                get_env_var(name='POLYAXON_REGISTRY_URI', value=conf.get('REGISTRY_LOCAL_URI')),
                get_from_secret('POLYAXON_REGISTRY_PASSWORD',
                                'registry-password',
                                settings.POLYAXON_K8S_REGISTRY_SECRET_NAME),
            ]
        # Add private registries secrets keys
        for key in config.keys_startswith(settings.PRIVATE_REGISTRIES_PREFIX):
            env_vars.append(get_from_secret(key, key))

        # Add set env lang
        get_env_var(name='POLYAXON_JOB_DOCKERIZER_SET_LANG_ENV',
                    value=conf.get('JOB_DOCKERIZER_SET_LANG_ENV'))
        # Add security context if set
        if conf.get('JOB_DOCKERIZER_SET_SECURITY_CONTEXT'):
            get_env_var('POLYAXON_SECURITY_CONTEXT_USER', value=conf.get('SECURITY_CONTEXT_USER'))
            get_env_var('POLYAXON_SECURITY_CONTEXT_GROUP', value=conf.get('SECURITY_CONTEXT_GROUP'))

        return env_vars
Beispiel #2
0
    def get_env_vars(self):
        env_vars = get_service_env_vars(namespace=self.namespace)
        for k, v in config.get_requested_data(to_str=True).items():
            env_vars.append(get_env_var(name=k, value=v))

        # Add private registries secrets keys
        for key in config.keys_startswith(settings.PRIVATE_REGISTRIES_PREFIX):
            env_vars.append(get_from_secret(key, key))

        # Add repos access token secret key
        if settings.REPOS_ACCESS_TOKEN:
            env_vars.append(get_from_secret(settings.REPOS_ACCESS_TOKEN_KEY,
                                            settings.REPOS_ACCESS_TOKEN_KEY))

        return env_vars
Beispiel #3
0
    def get_env_vars(self):
        env_vars = get_internal_env_vars(
            service_internal_header=InternalServices.DOCKERIZER,
            namespace=self.namespace,
            authentication_type=AuthenticationTypes.INTERNAL_TOKEN)
        if conf.get('REGISTRY_PASSWORD') and conf.get('REGISTRY_USER'):
            env_vars += [
                get_env_var(name='POLYAXON_REGISTRY_USER',
                            value=conf.get('REGISTRY_USER')),
                get_env_var(name='POLYAXON_REGISTRY_URI',
                            value=conf.get('REGISTRY_LOCAL_URI')),
                get_from_secret('POLYAXON_REGISTRY_PASSWORD',
                                'registry-password',
                                settings.POLYAXON_K8S_REGISTRY_SECRET_NAME),
            ]
        # Add private registries secrets keys
        for key in config.keys_startswith(settings.PRIVATE_REGISTRIES_PREFIX):
            env_vars.append(get_from_secret(key, key))

        return env_vars
Beispiel #4
0
def get_external_registries():
    registries = []
    for key in config.keys_startswith(PRIVATE_REGISTRIES_PREFIX):

        try:
            registry_dict = config.get_dict(key, is_secret=True)
            registry_spec = UriSpec(**registry_dict)
        except RheaError:
            registry_spec = config.get_string(key, is_secret=True)
            try:
                # We might get this value from a chart with `toJson` applied.
                registry_spec = json.loads(registry_spec)
            except json.decoder.JSONDecodeError:
                pass

            registry_spec = config.parse_uri_spec(registry_spec)

        if registry_spec:
            registries.append(registry_spec)

    return registries