in controllers/stage/chain/put_codebase_image_stream.go [74:106]
func (h PutCodebaseImageStream) getDockerRegistryUrl(ctx context.Context, namespace string) (string, error) {
config := &corev1.ConfigMap{}
if err := h.client.Get(ctx, types.NamespacedName{
Name: edpConfigMap,
Namespace: namespace,
}, config); err != nil {
if !k8sErrors.IsNotFound(err) {
return "", fmt.Errorf("failed to get %s config map: %w", edpConfigMap, err)
}
// to save backward compatibility we need to get docker registry url
// from edp component if config map doesn't exist. We can remove this in the future.
ec := &componentApi.EDPComponent{}
if err = h.client.Get(ctx, types.NamespacedName{
Name: dockerRegistryName,
Namespace: namespace,
}, ec); err != nil {
return "", fmt.Errorf("failed to fetch %q resource %q: %w", ec.TypeMeta.Kind, dockerRegistryName, err)
}
return ec.Spec.Url, nil
}
if _, ok := config.Data[edpConfigContainerRegistryHost]; !ok {
return "", fmt.Errorf("%s is not set in %s config map", edpConfigContainerRegistryHost, edpConfigMap)
}
if _, ok := config.Data[edpConfigContainerRegistrySpace]; !ok {
return "", fmt.Errorf("%s is not set in %s config map", edpConfigContainerRegistrySpace, edpConfigMap)
}
return fmt.Sprintf("%s/%s", config.Data[edpConfigContainerRegistryHost], config.Data[edpConfigContainerRegistrySpace]), nil
}