|
|
@ -31,6 +31,8 @@ const (
|
|
|
|
schemaSuffix = ".schema"
|
|
|
|
schemaSuffix = ".schema"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var re = regexp.MustCompile("github.com/(.*)/(.*)/(.*)/(.*):(.*)")
|
|
|
|
|
|
|
|
|
|
|
|
// TypeResolver finds Types in a Configuration which aren't yet reduceable to an import file
|
|
|
|
// TypeResolver finds Types in a Configuration which aren't yet reduceable to an import file
|
|
|
|
// or primitive, and attempts to replace them with a template from a URL.
|
|
|
|
// or primitive, and attempts to replace them with a template from a URL.
|
|
|
|
type TypeResolver interface {
|
|
|
|
type TypeResolver interface {
|
|
|
@ -40,7 +42,6 @@ type TypeResolver interface {
|
|
|
|
type typeResolver struct {
|
|
|
|
type typeResolver struct {
|
|
|
|
getter util.HTTPClient
|
|
|
|
getter util.HTTPClient
|
|
|
|
maxUrls int
|
|
|
|
maxUrls int
|
|
|
|
re *regexp.Regexp
|
|
|
|
|
|
|
|
rp registry.RegistryProvider
|
|
|
|
rp registry.RegistryProvider
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -53,7 +54,6 @@ func NewTypeResolver() TypeResolver {
|
|
|
|
client.Timeout = timeout
|
|
|
|
client.Timeout = timeout
|
|
|
|
ret.getter = util.NewHTTPClient(3, client, util.NewSleeper())
|
|
|
|
ret.getter = util.NewHTTPClient(3, client, util.NewSleeper())
|
|
|
|
ret.maxUrls = maxURLImports
|
|
|
|
ret.maxUrls = maxURLImports
|
|
|
|
ret.re = regexp.MustCompile("github.com/(.*)/(.*)/(.*)/(.*):(.*)")
|
|
|
|
|
|
|
|
ret.rp = ®istry.DefaultRegistryProvider{}
|
|
|
|
ret.rp = ®istry.DefaultRegistryProvider{}
|
|
|
|
return ret
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -215,7 +215,7 @@ func (tr *typeResolver) MapFetchableURL(t string) (string, error) {
|
|
|
|
// for example:
|
|
|
|
// for example:
|
|
|
|
// github.com/kubernetes/application-dm-templates/storage/redis:v1
|
|
|
|
// github.com/kubernetes/application-dm-templates/storage/redis:v1
|
|
|
|
func (tr *typeResolver) ShortTypeToDownloadURL(template string) (string, error) {
|
|
|
|
func (tr *typeResolver) ShortTypeToDownloadURL(template string) (string, error) {
|
|
|
|
m := tr.re.FindStringSubmatch(template)
|
|
|
|
m := re.FindStringSubmatch(template)
|
|
|
|
if len(m) != 6 {
|
|
|
|
if len(m) != 6 {
|
|
|
|
return "", fmt.Errorf("Failed to parse short github url: %s", template)
|
|
|
|
return "", fmt.Errorf("Failed to parse short github url: %s", template)
|
|
|
|
}
|
|
|
|
}
|
|
|
|