-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
292 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package js | ||
|
||
import ( | ||
problemspkg "github.com/tliron/kutil/problems" | ||
urlpkg "github.com/tliron/kutil/url" | ||
cloutpkg "github.com/tliron/puccini/clout" | ||
) | ||
|
||
func Resolve(clout *cloutpkg.Clout, problems *problemspkg.Problems, urlContext *urlpkg.Context, history bool, format string, strict bool, pretty bool) { | ||
var arguments map[string]string | ||
if !history { | ||
arguments = make(map[string]string) | ||
arguments["history"] = "false" | ||
} | ||
Exec("tosca.resolve", arguments, clout, problems, urlContext, format, strict, pretty) | ||
} | ||
|
||
func Coerce(clout *cloutpkg.Clout, problems *problemspkg.Problems, urlContext *urlpkg.Context, history bool, format string, strict bool, pretty bool) { | ||
var arguments map[string]string | ||
if !history { | ||
arguments = make(map[string]string) | ||
arguments["history"] = "false" | ||
} | ||
Exec("tosca.coerce", arguments, clout, problems, urlContext, format, strict, pretty) | ||
} | ||
|
||
func Outputs(clout *cloutpkg.Clout, problems *problemspkg.Problems, urlContext *urlpkg.Context, format string, strict bool, pretty bool) { | ||
Exec("tosca.outputs", nil, clout, problems, urlContext, format, strict, pretty) | ||
} | ||
|
||
func Exec(scriptletName string, arguments map[string]string, clout *cloutpkg.Clout, problems *problemspkg.Problems, urlContext *urlpkg.Context, format string, strict bool, pretty bool) { | ||
context := NewContext(scriptletName, log, arguments, true, format, strict, pretty, "", urlContext) | ||
if _, err := context.Require(clout, scriptletName, map[string]any{"problems": problems}); err != nil { | ||
problems.ReportError(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package util | ||
|
||
import ( | ||
"github.com/tliron/kutil/ard" | ||
) | ||
|
||
func Put(key string, value ard.Value, entity ard.Value, names ...string) bool { | ||
if map_, ok := ard.NewNode(entity).Get(names...).StringMap(); ok { | ||
map_[key] = value | ||
return true | ||
} else { | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package util | ||
|
||
import ( | ||
"github.com/tliron/kutil/ard" | ||
) | ||
|
||
func NewList(entryType string, values ard.List) ard.StringMap { | ||
return ard.StringMap{ | ||
"$information": NewListInformation(entryType), | ||
"$list": values, | ||
} | ||
} | ||
|
||
func NewListInformation(entryType string) ard.StringMap { | ||
return ard.StringMap{ | ||
"type": ard.StringMap{"name": "list"}, | ||
"entry": ard.StringMap{ | ||
"type": ard.StringMap{"name": entryType}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package util | ||
|
||
import ( | ||
"github.com/tliron/kutil/ard" | ||
) | ||
|
||
func NewStringMap(values ard.StringMap, valueType string) ard.StringMap { | ||
entries := make(ard.List, len(values)) | ||
index := 0 | ||
for key, value := range values { | ||
entries[index] = NewStringMapEntry(key, value, valueType) | ||
index++ | ||
} | ||
return ard.StringMap{"$map": entries} | ||
} | ||
|
||
func NewStringMapEntry(key string, value ard.Value, valueType string) ard.StringMap { | ||
return ard.StringMap{ | ||
"$information": NewValueInformation(valueType), | ||
"$key": ard.StringMap{"$value": key}, | ||
"$value": value, | ||
} | ||
} | ||
|
||
func NewValueInformation(type_ string) ard.StringMap { | ||
return ard.StringMap{ | ||
"type": ard.StringMap{"name": type_}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package util | ||
|
||
import ( | ||
"github.com/tliron/kutil/ard" | ||
) | ||
|
||
func IsTosca(metadata ard.Value, kind string) bool { | ||
var metadata_ struct { | ||
Puccini struct { | ||
Version string `ard:"version"` | ||
Kind string `ard:"kind"` | ||
} `ard:"puccini"` | ||
} | ||
|
||
if err := ard.NewReflector().ToComposite(metadata, &metadata_); err == nil { | ||
if metadata_.Puccini.Version == "1.0" { | ||
if kind != "" { | ||
return metadata_.Puccini.Kind == kind | ||
} else { | ||
return true | ||
} | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
func IsToscaType(entity ard.Value, type_ string) bool { | ||
if types, ok := ard.NewNode(entity).Get("types").StringMap(); ok { | ||
if _, ok := types[type_]; ok { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func GetToscaOutputs(properties ard.Value) (ard.StringMap, bool) { | ||
outputs, ok := ard.NewNode(properties).Get("tosca", "outputs").StringMap() | ||
return outputs, ok | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.