func NewInmemRegistryService() common.RegistryService {
	rs := &inmemRegistryService{
		registries: make(map[string]*common.Registry),
	}

	pFormat := fmt.Sprintf("%s;%s", common.UnversionedRegistry, common.OneLevelRegistry)
	rs.Create(&common.Registry{
		Name:           "charts",
		Type:           common.GithubRegistryType,
		URL:            "github.com/helm/charts",
		Format:         common.RegistryFormat(pFormat),
		CredentialName: "default",
	})

	tFormat := fmt.Sprintf("%s;%s", common.VersionedRegistry, common.CollectionRegistry)
	rs.Create(&common.Registry{
		Name:           "application-dm-templates",
		Type:           common.GithubRegistryType,
		URL:            "github.com/kubernetes/application-dm-templates",
		Format:         common.RegistryFormat(tFormat),
		CredentialName: "default",
	})

	return rs
}
// ParseRegistryFormat creates a map from a registry format string.
func ParseRegistryFormat(rf common.RegistryFormat) map[common.RegistryFormat]bool {
	split := strings.Split(string(rf), ";")
	var result = map[common.RegistryFormat]bool{}
	for _, format := range split {
		result[common.RegistryFormat(format)] = true
	}

	return result
}
Esempio n. 3
0
func newRegistry(URL string) *common.Registry {
	tFormat := fmt.Sprintf("%s;%s", common.VersionedRegistry, common.CollectionRegistry)
	return &common.Registry{
		Name:           util.TrimURLScheme(URL),
		Type:           common.GithubRegistryType,
		URL:            URL,
		Format:         common.RegistryFormat(tFormat),
		CredentialName: "default",
	}
}
// NewGithubTemplateRegistry creates a GithubTemplateRegistry.
func NewGithubTemplateRegistry(name, shortURL string, service GithubRepositoryService, client *github.Client) (*GithubTemplateRegistry, error) {
	format := fmt.Sprintf("%s;%s", common.VersionedRegistry, common.CollectionRegistry)
	if service == nil {
		service = client.Repositories
	}

	gr, err := newGithubRegistry(name, shortURL, common.RegistryFormat(format), service)
	if err != nil {
		return nil, err
	}

	return &GithubTemplateRegistry{githubRegistry: *gr}, nil
}
// NewGithubPackageRegistry creates a GithubPackageRegistry.
func NewGithubPackageRegistry(name, shortURL string, service GithubRepositoryService, httpClient *http.Client, client *github.Client) (*GithubPackageRegistry, error) {
	format := fmt.Sprintf("%s;%s", common.UnversionedRegistry, common.OneLevelRegistry)
	if service == nil {
		if client == nil {
			service = github.NewClient(nil).Repositories
		} else {
			service = client.Repositories
		}
	}

	gr, err := newGithubRegistry(name, shortURL, common.RegistryFormat(format), httpClient, service)
	if err != nil {
		return nil, err
	}

	return &GithubPackageRegistry{githubRegistry: *gr}, nil
}