mirror of
https://github.com/mcuadros/ascode
synced 2024-06-11 01:06:13 +02:00
starlark/runtime: yaml module
This commit is contained in:
parent
206a079519
commit
32ceb6f7a7
1
Makefile
1
Makefile
|
@ -8,6 +8,7 @@ RUNTIME_MODULES = \
|
||||||
github.com/qri-io/starlib/encoding/base64 \
|
github.com/qri-io/starlib/encoding/base64 \
|
||||||
github.com/qri-io/starlib/encoding/csv \
|
github.com/qri-io/starlib/encoding/csv \
|
||||||
github.com/qri-io/starlib/encoding/json \
|
github.com/qri-io/starlib/encoding/json \
|
||||||
|
github.com/qri-io/starlib/encoding/yaml \
|
||||||
github.com/qri-io/starlib/re \
|
github.com/qri-io/starlib/re \
|
||||||
github.com/qri-io/starlib/http
|
github.com/qri-io/starlib/http
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ title: 'encoding/base64'
|
||||||
base64 defines base64 encoding & decoding functions, often used to represent binary as text.
|
base64 defines base64 encoding & decoding functions, often used to represent binary as text.
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
|
|
||||||
#### def <b>decode</b>
|
#### def <b>decode</b>
|
||||||
```go
|
```go
|
||||||
decode(src,encoding="standard") string
|
decode(src,encoding="standard") string
|
||||||
|
@ -19,6 +20,7 @@ parse base64 input, giving back the plain string representation
|
||||||
| 'encoding' | 'string' | optional. string to set decoding dialect. allowed values are: standard,standard_raw,url,url_raw |
|
| 'encoding' | 'string' | optional. string to set decoding dialect. allowed values are: standard,standard_raw,url,url_raw |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>encode</b>
|
#### def <b>encode</b>
|
||||||
```go
|
```go
|
||||||
encode(src,encoding="standard") string
|
encode(src,encoding="standard") string
|
||||||
|
|
|
@ -5,6 +5,7 @@ title: 'encoding/csv'
|
||||||
csv reads comma-separated values files
|
csv reads comma-separated values files
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
|
|
||||||
#### def <b>read_all</b>
|
#### def <b>read_all</b>
|
||||||
```go
|
```go
|
||||||
read_all(source, comma=",", comment="", lazy_quotes=False, trim_leading_space=False, fields_per_record=0, skip=0) [][]string
|
read_all(source, comma=",", comment="", lazy_quotes=False, trim_leading_space=False, fields_per_record=0, skip=0) [][]string
|
||||||
|
@ -24,6 +25,7 @@ read all rows from a source string, returning a list of string lists
|
||||||
| 'skip' | 'int' | number of rows to skip, omitting from returned rows |
|
| 'skip' | 'int' | number of rows to skip, omitting from returned rows |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>write_all</b>
|
#### def <b>write_all</b>
|
||||||
```go
|
```go
|
||||||
write_all(source,comma=",") string
|
write_all(source,comma=",") string
|
||||||
|
|
|
@ -5,6 +5,7 @@ title: 'path/filepath'
|
||||||
filepath implements utility routines for manipulating filename paths in a way compatible with the target operating system-defined file path
|
filepath implements utility routines for manipulating filename paths in a way compatible with the target operating system-defined file path
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
|
|
||||||
#### def <b>abs</b>
|
#### def <b>abs</b>
|
||||||
```go
|
```go
|
||||||
abs(path) string
|
abs(path) string
|
||||||
|
@ -18,6 +19,7 @@ returns an absolute representation of path. If the path is not absolute it will
|
||||||
| 'path' | 'string' | relative or absolute path |
|
| 'path' | 'string' | relative or absolute path |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>base</b>
|
#### def <b>base</b>
|
||||||
```go
|
```go
|
||||||
base(path) string
|
base(path) string
|
||||||
|
@ -31,6 +33,7 @@ returns the last element of path. Trailing path separators are removed before ex
|
||||||
| 'path' | 'string' | input path |
|
| 'path' | 'string' | input path |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>clean</b>
|
#### def <b>clean</b>
|
||||||
```go
|
```go
|
||||||
clean(path) string
|
clean(path) string
|
||||||
|
@ -44,6 +47,7 @@ returns the shortest path name equivalent to path by purely lexical processing.
|
||||||
| 'path' | 'string' | input path |
|
| 'path' | 'string' | input path |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>dir</b>
|
#### def <b>dir</b>
|
||||||
```go
|
```go
|
||||||
dir(path) string
|
dir(path) string
|
||||||
|
@ -57,6 +61,7 @@ returns all but the last element of path, typically the path's directory. After
|
||||||
| 'path' | 'string' | input path |
|
| 'path' | 'string' | input path |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>ext</b>
|
#### def <b>ext</b>
|
||||||
```go
|
```go
|
||||||
ext(path) string
|
ext(path) string
|
||||||
|
@ -70,6 +75,7 @@ returns the file name extension used by path. The extension is the suffix beginn
|
||||||
| 'path' | 'string' | input path |
|
| 'path' | 'string' | input path |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>glob</b>
|
#### def <b>glob</b>
|
||||||
```go
|
```go
|
||||||
glob(pattern) list
|
glob(pattern) list
|
||||||
|
@ -83,6 +89,7 @@ returns the names of all files matching pattern or None if there is no matching
|
||||||
| 'pattern' | 'string' | pattern ([syntax](https://golang.org/pkg/path/filepath/#Match)) |
|
| 'pattern' | 'string' | pattern ([syntax](https://golang.org/pkg/path/filepath/#Match)) |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>is_abs</b>
|
#### def <b>is_abs</b>
|
||||||
```go
|
```go
|
||||||
is_abs(path) bool
|
is_abs(path) bool
|
||||||
|
@ -96,6 +103,7 @@ reports whether the path is absolute.
|
||||||
| 'path' | 'string' | input path |
|
| 'path' | 'string' | input path |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>join</b>
|
#### def <b>join</b>
|
||||||
```go
|
```go
|
||||||
join(elements) string
|
join(elements) string
|
||||||
|
@ -109,6 +117,7 @@ joins any number of path elements into a single path, adding a `filepath.separat
|
||||||
| 'elements' | 'lists' | list of path elements to be joined |
|
| 'elements' | 'lists' | list of path elements to be joined |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>rel</b>
|
#### def <b>rel</b>
|
||||||
```go
|
```go
|
||||||
rel(basepath, targpath) string
|
rel(basepath, targpath) string
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
---
|
---
|
||||||
title: ''
|
title: 'http'
|
||||||
---
|
---
|
||||||
|
|
||||||
http defines an HTTP client implementation
|
http defines an HTTP client implementation
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
|
|
||||||
#### def <b>delete</b>
|
#### def <b>delete</b>
|
||||||
```go
|
```go
|
||||||
delete(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
delete(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
||||||
|
@ -23,6 +24,7 @@ perform an HTTP DELETE request, returning a response
|
||||||
| 'auth' | 'tuple' | optional. (username,password) tuple for http basic authorization |
|
| 'auth' | 'tuple' | optional. (username,password) tuple for http basic authorization |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>get</b>
|
#### def <b>get</b>
|
||||||
```go
|
```go
|
||||||
get(url,params={},headers={},auth=()) response
|
get(url,params={},headers={},auth=()) response
|
||||||
|
@ -38,6 +40,7 @@ perform an HTTP GET request, returning a response
|
||||||
| 'auth' | 'tuple' | optional. (username,password) tuple for http basic authorization |
|
| 'auth' | 'tuple' | optional. (username,password) tuple for http basic authorization |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>options</b>
|
#### def <b>options</b>
|
||||||
```go
|
```go
|
||||||
options(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
options(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
||||||
|
@ -56,6 +59,7 @@ perform an HTTP OPTIONS request, returning a response
|
||||||
| 'auth' | 'tuple' | optional. (username,password) tuple for http basic authorization |
|
| 'auth' | 'tuple' | optional. (username,password) tuple for http basic authorization |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>patch</b>
|
#### def <b>patch</b>
|
||||||
```go
|
```go
|
||||||
patch(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
patch(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
||||||
|
@ -74,6 +78,7 @@ perform an HTTP PATCH request, returning a response
|
||||||
| 'auth' | 'tuple' | optional. (username,password) tuple for http basic authorization |
|
| 'auth' | 'tuple' | optional. (username,password) tuple for http basic authorization |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>post</b>
|
#### def <b>post</b>
|
||||||
```go
|
```go
|
||||||
post(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
post(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
||||||
|
@ -92,6 +97,7 @@ perform an HTTP POST request, returning a response
|
||||||
| 'auth' | 'tuple' | optional. (username,password) tuple for http basic authorization |
|
| 'auth' | 'tuple' | optional. (username,password) tuple for http basic authorization |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>put</b>
|
#### def <b>put</b>
|
||||||
```go
|
```go
|
||||||
put(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
put(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
||||||
|
@ -127,12 +133,14 @@ the result of performing a http request
|
||||||
|
|
||||||
|
|
||||||
**Methods**
|
**Methods**
|
||||||
|
|
||||||
#### def <b>body</b>
|
#### def <b>body</b>
|
||||||
```go
|
```go
|
||||||
body() string
|
body() string
|
||||||
```
|
```
|
||||||
output response body as a string
|
output response body as a string
|
||||||
|
|
||||||
|
|
||||||
#### def <b>json</b>
|
#### def <b>json</b>
|
||||||
```go
|
```go
|
||||||
json()
|
json()
|
||||||
|
|
|
@ -5,6 +5,7 @@ title: 'encoding/json'
|
||||||
json provides functions for working with json data
|
json provides functions for working with json data
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
|
|
||||||
#### def <b>dumps</b>
|
#### def <b>dumps</b>
|
||||||
```go
|
```go
|
||||||
dumps(obj) string
|
dumps(obj) string
|
||||||
|
@ -18,6 +19,7 @@ serialize obj to a JSON string
|
||||||
| 'obj' | 'object' | input object |
|
| 'obj' | 'object' | input object |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>loads</b>
|
#### def <b>loads</b>
|
||||||
```go
|
```go
|
||||||
loads(source) object
|
loads(source) object
|
||||||
|
|
|
@ -5,6 +5,7 @@ title: 'os'
|
||||||
os provides a platform-independent interface to operating system functionality.
|
os provides a platform-independent interface to operating system functionality.
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
|
|
||||||
#### def <b>chdir</b>
|
#### def <b>chdir</b>
|
||||||
```go
|
```go
|
||||||
chdir(dir)
|
chdir(dir)
|
||||||
|
@ -18,6 +19,7 @@ changes the current working directory to the named directory.
|
||||||
| 'dir' | 'string' | target dir |
|
| 'dir' | 'string' | target dir |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>getenv</b>
|
#### def <b>getenv</b>
|
||||||
```go
|
```go
|
||||||
getenv(key) dir
|
getenv(key) dir
|
||||||
|
@ -31,12 +33,14 @@ retrieves the value of the environment variable named by the key.
|
||||||
| 'key' | 'string' | name of the environment variable |
|
| 'key' | 'string' | name of the environment variable |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>getwd</b>
|
#### def <b>getwd</b>
|
||||||
```go
|
```go
|
||||||
getwd() dir
|
getwd() dir
|
||||||
```
|
```
|
||||||
returns a rooted path name corresponding to the current directory.
|
returns a rooted path name corresponding to the current directory.
|
||||||
|
|
||||||
|
|
||||||
#### def <b>mkdir</b>
|
#### def <b>mkdir</b>
|
||||||
```go
|
```go
|
||||||
mkdir(name, perms=0o777)
|
mkdir(name, perms=0o777)
|
||||||
|
@ -51,6 +55,7 @@ creates a new directory with the specified name and permission bits (before umas
|
||||||
| 'perms' | 'int' | optional, permission of the folder |
|
| 'perms' | 'int' | optional, permission of the folder |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>mkdir_all</b>
|
#### def <b>mkdir_all</b>
|
||||||
```go
|
```go
|
||||||
mkdir_all(name, perms=0o777)
|
mkdir_all(name, perms=0o777)
|
||||||
|
@ -65,6 +70,7 @@ creates a new directory with the specified name and permission bits (before umas
|
||||||
| 'perms' | 'int' | optional, permission of the folder |
|
| 'perms' | 'int' | optional, permission of the folder |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>read_file</b>
|
#### def <b>read_file</b>
|
||||||
```go
|
```go
|
||||||
read_file(filename) string
|
read_file(filename) string
|
||||||
|
@ -80,6 +86,7 @@ reads the file named by filename and returns the contents.
|
||||||
| 'perms' | 'int' | optional, permission of the file |
|
| 'perms' | 'int' | optional, permission of the file |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>remove</b>
|
#### def <b>remove</b>
|
||||||
```go
|
```go
|
||||||
remove(name)
|
remove(name)
|
||||||
|
@ -93,6 +100,7 @@ removes the named file or (empty) directory.
|
||||||
| 'name' | 'string' | name of the file or directory to be deleted |
|
| 'name' | 'string' | name of the file or directory to be deleted |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>remove_all</b>
|
#### def <b>remove_all</b>
|
||||||
```go
|
```go
|
||||||
remove_all(path)
|
remove_all(path)
|
||||||
|
@ -106,6 +114,7 @@ removes path and any children it contains. It removes everything it can but retu
|
||||||
| 'name' | 'string' | path to be deleted |
|
| 'name' | 'string' | path to be deleted |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>rename</b>
|
#### def <b>rename</b>
|
||||||
```go
|
```go
|
||||||
rename(oldpath, newpath)
|
rename(oldpath, newpath)
|
||||||
|
@ -120,6 +129,7 @@ renames (moves) oldpath to newpath. If newpath already exists and is not a direc
|
||||||
| 'newpath' | 'string' | new path |
|
| 'newpath' | 'string' | new path |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>setenv</b>
|
#### def <b>setenv</b>
|
||||||
```go
|
```go
|
||||||
setenv(key, value) dir
|
setenv(key, value) dir
|
||||||
|
@ -134,6 +144,7 @@ sets the value of the environment variable named by the key.
|
||||||
| 'value' | 'string' | value of the environment variable |
|
| 'value' | 'string' | value of the environment variable |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>write_file</b>
|
#### def <b>write_file</b>
|
||||||
```go
|
```go
|
||||||
write_file(filename, data, perms=0o644)
|
write_file(filename, data, perms=0o644)
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
---
|
---
|
||||||
title: ''
|
title: 're'
|
||||||
---
|
---
|
||||||
|
|
||||||
re defines regular expression functions, it's intended to be a drop-in subset of python's re module for starlark: https://docs.python.org/3/library/re.html
|
re defines regular expression functions, it's intended to be a drop-in subset of python's re module for starlark: https://docs.python.org/3/library/re.html
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
|
|
||||||
#### def <b>findall</b>
|
#### def <b>findall</b>
|
||||||
```go
|
```go
|
||||||
findall(pattern, text, flags=0)
|
findall(pattern, text, flags=0)
|
||||||
|
@ -20,6 +21,7 @@ Returns all non-overlapping matches of pattern in string, as a list of strings.
|
||||||
| 'flags' | 'int' | integer flags to control regex behaviour. reserved for future use |
|
| 'flags' | 'int' | integer flags to control regex behaviour. reserved for future use |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>split</b>
|
#### def <b>split</b>
|
||||||
```go
|
```go
|
||||||
split(pattern, text, maxsplit=0, flags=0)
|
split(pattern, text, maxsplit=0, flags=0)
|
||||||
|
@ -36,6 +38,7 @@ Split text by the occurrences of pattern. If capturing parentheses are used in p
|
||||||
| 'flags' | 'int' | integer flags to control regex behaviour. reserved for future use |
|
| 'flags' | 'int' | integer flags to control regex behaviour. reserved for future use |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### def <b>sub</b>
|
#### def <b>sub</b>
|
||||||
```go
|
```go
|
||||||
sub(pattern, repl, text, count=0, flags=0)
|
sub(pattern, repl, text, count=0, flags=0)
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
title: 'encoding/yaml'
|
||||||
|
---
|
||||||
|
|
||||||
|
yaml provides functions for working with yaml data
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
|
||||||
|
#### def <b>dumps</b>
|
||||||
|
```go
|
||||||
|
dumps(obj) string
|
||||||
|
```
|
||||||
|
serialize obj to a yaml string
|
||||||
|
|
||||||
|
**parameters:**
|
||||||
|
|
||||||
|
| name | type | description |
|
||||||
|
|------|------|-------------|
|
||||||
|
| 'obj' | 'object' | input object |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### def <b>loads</b>
|
||||||
|
```go
|
||||||
|
loads(source) object
|
||||||
|
```
|
||||||
|
read a source yaml string to a starlark object
|
||||||
|
|
||||||
|
**parameters:**
|
||||||
|
|
||||||
|
| name | type | description |
|
||||||
|
|------|------|-------------|
|
||||||
|
| 'source' | 'string' | input string of yaml data |
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/qri-io/starlib/encoding/base64"
|
"github.com/qri-io/starlib/encoding/base64"
|
||||||
"github.com/qri-io/starlib/encoding/csv"
|
"github.com/qri-io/starlib/encoding/csv"
|
||||||
"github.com/qri-io/starlib/encoding/json"
|
"github.com/qri-io/starlib/encoding/json"
|
||||||
|
"github.com/qri-io/starlib/encoding/yaml"
|
||||||
"github.com/qri-io/starlib/http"
|
"github.com/qri-io/starlib/http"
|
||||||
"github.com/qri-io/starlib/re"
|
"github.com/qri-io/starlib/re"
|
||||||
"go.starlark.net/repl"
|
"go.starlark.net/repl"
|
||||||
|
@ -37,6 +38,7 @@ func NewRuntime(pm *terraform.PluginManager) *Runtime {
|
||||||
"encoding/json": json.LoadModule,
|
"encoding/json": json.LoadModule,
|
||||||
"encoding/base64": base64.LoadModule,
|
"encoding/base64": base64.LoadModule,
|
||||||
"encoding/csv": csv.LoadModule,
|
"encoding/csv": csv.LoadModule,
|
||||||
|
"encoding/yaml": yaml.LoadModule,
|
||||||
"re": re.LoadModule,
|
"re": re.LoadModule,
|
||||||
"http": http.LoadModule,
|
"http": http.LoadModule,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue