mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-12 16:10:04 +01:00
feat: add gitlab source for gitlab package registry
cleanup http source
This commit is contained in:
parent
8ffad5a3ea
commit
d655269156
7 changed files with 180 additions and 70 deletions
|
|
@ -14,6 +14,7 @@
|
|||
package deps
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
|
@ -58,9 +59,10 @@ func (d Dependency) LegacyName() string {
|
|||
}
|
||||
|
||||
type Source struct {
|
||||
GitSource *Git `json:"git,omitempty"`
|
||||
LocalSource *Local `json:"local,omitempty"`
|
||||
HttpSource *Http `json:"http,omitempty"`
|
||||
GitSource *Git `json:"git,omitempty"`
|
||||
LocalSource *Local `json:"local,omitempty"`
|
||||
HttpSource *Http `json:"http,omitempty"`
|
||||
GitlabRegistrySource *GitlabRegistry `json:"gitlab,omitempty"`
|
||||
}
|
||||
|
||||
func (s Source) Name() string {
|
||||
|
|
@ -70,7 +72,13 @@ func (s Source) Name() string {
|
|||
case s.LocalSource != nil:
|
||||
return s.LegacyName()
|
||||
case s.HttpSource != nil:
|
||||
return s.LegacyName()
|
||||
parsed, err := url.Parse(s.HttpSource.Url)
|
||||
if err != nil {
|
||||
return "http/" + s.LegacyName()
|
||||
}
|
||||
return parsed.Hostname() + "/" + s.LegacyName()
|
||||
case s.GitlabRegistrySource != nil:
|
||||
return "gitlab.com/" + s.LegacyName()
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
|
@ -96,6 +104,8 @@ func (s Source) LegacyName() string {
|
|||
return strings.TrimSuffix(file, ".tar.gz")
|
||||
}
|
||||
return strings.Replace(file, filepath.Ext(file), "", 1)
|
||||
case s.GitlabRegistrySource != nil:
|
||||
return s.GitlabRegistrySource.Package
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
|
@ -144,3 +154,10 @@ func parseHttp(uri string) *Dependency {
|
|||
Version: "",
|
||||
}
|
||||
}
|
||||
|
||||
type GitlabRegistry struct {
|
||||
Project string `json:"project"`
|
||||
Package string `json:"package"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Filename string `json:"filename,omitempty"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue