mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-12 08:00:05 +01:00
fix: this was missing
This commit is contained in:
parent
428608f190
commit
5eb92a0677
1 changed files with 37 additions and 2 deletions
|
|
@ -16,6 +16,7 @@ package deps
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Dependency struct {
|
type Dependency struct {
|
||||||
|
|
@ -38,7 +39,11 @@ func Parse(dir, uri string) *Dependency {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
return parseLocal(dir, uri)
|
if d := parseLocal(dir, uri); d != nil {
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseHttp(uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Dependency) Name() string {
|
func (d Dependency) Name() string {
|
||||||
|
|
@ -55,6 +60,7 @@ func (d Dependency) LegacyName() string {
|
||||||
type Source struct {
|
type Source struct {
|
||||||
GitSource *Git `json:"git,omitempty"`
|
GitSource *Git `json:"git,omitempty"`
|
||||||
LocalSource *Local `json:"local,omitempty"`
|
LocalSource *Local `json:"local,omitempty"`
|
||||||
|
HttpSource *Http `json:"http,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Source) Name() string {
|
func (s Source) Name() string {
|
||||||
|
|
@ -63,6 +69,8 @@ func (s Source) Name() string {
|
||||||
return s.GitSource.Name()
|
return s.GitSource.Name()
|
||||||
case s.LocalSource != nil:
|
case s.LocalSource != nil:
|
||||||
return s.LegacyName()
|
return s.LegacyName()
|
||||||
|
case s.HttpSource != nil:
|
||||||
|
return s.LegacyName()
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
@ -78,6 +86,16 @@ func (s Source) LegacyName() string {
|
||||||
panic("unable to create absolute path from local source directory: " + err.Error())
|
panic("unable to create absolute path from local source directory: " + err.Error())
|
||||||
}
|
}
|
||||||
return filepath.Base(p)
|
return filepath.Base(p)
|
||||||
|
case s.HttpSource != nil:
|
||||||
|
if s.HttpSource.Target != "" {
|
||||||
|
return s.HttpSource.Target
|
||||||
|
}
|
||||||
|
|
||||||
|
file := filepath.Base(s.HttpSource.Url)
|
||||||
|
if strings.Contains(file, ".tar.gz") {
|
||||||
|
return strings.TrimSuffix(file, ".tar.gz")
|
||||||
|
}
|
||||||
|
return strings.Replace(file, filepath.Ext(file), "", 1)
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
@ -109,3 +127,20 @@ func parseLocal(dir, p string) *Dependency {
|
||||||
Version: "",
|
Version: "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Http struct {
|
||||||
|
Url string `json:"url"`
|
||||||
|
Target string `json:"target"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseHttp(uri string) *Dependency {
|
||||||
|
return &Dependency{
|
||||||
|
Source: Source{
|
||||||
|
HttpSource: &Http{
|
||||||
|
Url: uri,
|
||||||
|
Target: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Version: "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue