set default resource type to file when importing a resource
This commit is contained in:
parent
025f265705
commit
c25857fff9
@ -15,6 +15,7 @@ _ "gopkg.in/yaml.v3"
|
||||
"decl/internal/source"
|
||||
"decl/internal/target"
|
||||
"decl/internal/codec"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -138,7 +139,14 @@ func ImportSubCommand(cmd *flag.FlagSet, output io.Writer) (err error) {
|
||||
|
||||
if *ImportResource != "" {
|
||||
slog.Info("ImportResource", "resource", ImportResource)
|
||||
if addResourceErr := d.AddResource(*ImportResource); addResourceErr != nil {
|
||||
resourceUri, uriErr := url.Parse(*ImportResource)
|
||||
if uriErr != nil {
|
||||
slog.Error("Failed adding resource", "error", uriErr)
|
||||
}
|
||||
if resourceUri.Scheme == "" {
|
||||
resourceUri.Scheme = "file"
|
||||
}
|
||||
if addResourceErr := d.AddResource(resourceUri.String()); addResourceErr != nil {
|
||||
slog.Error("Failed adding resource", "error", addResourceErr)
|
||||
}
|
||||
}
|
||||
|
@ -125,15 +125,12 @@ func (d *Document) AddResourceDeclaration(resourceType string, resourceDeclarati
|
||||
}
|
||||
|
||||
func (d *Document) AddResource(uri string) error {
|
||||
//parsedResourceURI, e := url.Parse(uri)
|
||||
//if e == nil {
|
||||
decl := NewDeclaration()
|
||||
if e := decl.SetURI(uri); e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
d.ResourceDecls = append(d.ResourceDecls, *decl)
|
||||
//}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user