github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/docker/registry/internal/provider.go (about)

     1  // Copyright 2021 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package internal
     5  
     6  import (
     7  	"net/http"
     8  
     9  	"github.com/juju/errors"
    10  
    11  	"github.com/juju/juju/docker"
    12  )
    13  
    14  // NewBase creates a new base provider.
    15  func NewBase(repoDetails docker.ImageRepoDetails, transport http.RoundTripper) (*baseClient, error) {
    16  	return newBase(repoDetails, transport, normalizeRepoDetailsCommon)
    17  }
    18  
    19  // Providers returns all the supported registry providers.
    20  func Providers() []func(docker.ImageRepoDetails, http.RoundTripper) (RegistryInternal, error) {
    21  	return []func(docker.ImageRepoDetails, http.RoundTripper) (RegistryInternal, error){
    22  		newAzureContainerRegistry,
    23  		newGitlabContainerRegistry,
    24  		newGithubContainerRegistry,
    25  		newQuayContainerRegistry,
    26  		newGoogleContainerRegistry,
    27  		newElasticContainerRegistry,
    28  		newElasticContainerRegistryPublic,
    29  		newDockerhub, // DockerHub must be last as it matches on default domain.
    30  	}
    31  }
    32  
    33  // InitProvider does some initialization steps for a provider.
    34  func InitProvider(c Initializer) error {
    35  	if err := c.DecideBaseURL(); err != nil {
    36  		return errors.Trace(err)
    37  	}
    38  	if err := c.WrapTransport(); err != nil {
    39  		return errors.Trace(err)
    40  	}
    41  	return nil
    42  }