mirror of
https://github.com/mcuadros/ascode
synced 2024-11-22 17:02:03 +01: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/csv \
|
||||
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/http
|
||||
|
||||
|
@ -5,6 +5,7 @@ title: 'encoding/base64'
|
||||
base64 defines base64 encoding & decoding functions, often used to represent binary as text.
|
||||
## Functions
|
||||
|
||||
|
||||
#### def <b>decode</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>encode</b>
|
||||
```go
|
||||
encode(src,encoding="standard") string
|
||||
|
@ -5,6 +5,7 @@ title: 'encoding/csv'
|
||||
csv reads comma-separated values files
|
||||
## Functions
|
||||
|
||||
|
||||
#### def <b>read_all</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>write_all</b>
|
||||
```go
|
||||
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
|
||||
## Functions
|
||||
|
||||
|
||||
#### def <b>abs</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>base</b>
|
||||
```go
|
||||
base(path) string
|
||||
@ -31,6 +33,7 @@ returns the last element of path. Trailing path separators are removed before ex
|
||||
| 'path' | 'string' | input path |
|
||||
|
||||
|
||||
|
||||
#### def <b>clean</b>
|
||||
```go
|
||||
clean(path) string
|
||||
@ -44,6 +47,7 @@ returns the shortest path name equivalent to path by purely lexical processing.
|
||||
| 'path' | 'string' | input path |
|
||||
|
||||
|
||||
|
||||
#### def <b>dir</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>ext</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>glob</b>
|
||||
```go
|
||||
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)) |
|
||||
|
||||
|
||||
|
||||
#### def <b>is_abs</b>
|
||||
```go
|
||||
is_abs(path) bool
|
||||
@ -96,6 +103,7 @@ reports whether the path is absolute.
|
||||
| 'path' | 'string' | input path |
|
||||
|
||||
|
||||
|
||||
#### def <b>join</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>rel</b>
|
||||
```go
|
||||
rel(basepath, targpath) string
|
||||
|
@ -1,10 +1,11 @@
|
||||
---
|
||||
title: ''
|
||||
title: 'http'
|
||||
---
|
||||
|
||||
http defines an HTTP client implementation
|
||||
## Functions
|
||||
|
||||
|
||||
#### def <b>delete</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>get</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>options</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>patch</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>post</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>put</b>
|
||||
```go
|
||||
put(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
||||
@ -127,12 +133,14 @@ the result of performing a http request
|
||||
|
||||
|
||||
**Methods**
|
||||
|
||||
#### def <b>body</b>
|
||||
```go
|
||||
body() string
|
||||
```
|
||||
output response body as a string
|
||||
|
||||
|
||||
#### def <b>json</b>
|
||||
```go
|
||||
json()
|
||||
|
@ -5,6 +5,7 @@ title: 'encoding/json'
|
||||
json provides functions for working with json data
|
||||
## Functions
|
||||
|
||||
|
||||
#### def <b>dumps</b>
|
||||
```go
|
||||
dumps(obj) string
|
||||
@ -18,6 +19,7 @@ serialize obj to a JSON string
|
||||
| 'obj' | 'object' | input object |
|
||||
|
||||
|
||||
|
||||
#### def <b>loads</b>
|
||||
```go
|
||||
loads(source) object
|
||||
|
@ -5,6 +5,7 @@ title: 'os'
|
||||
os provides a platform-independent interface to operating system functionality.
|
||||
## Functions
|
||||
|
||||
|
||||
#### def <b>chdir</b>
|
||||
```go
|
||||
chdir(dir)
|
||||
@ -18,6 +19,7 @@ changes the current working directory to the named directory.
|
||||
| 'dir' | 'string' | target dir |
|
||||
|
||||
|
||||
|
||||
#### def <b>getenv</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>getwd</b>
|
||||
```go
|
||||
getwd() dir
|
||||
```
|
||||
returns a rooted path name corresponding to the current directory.
|
||||
|
||||
|
||||
#### def <b>mkdir</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>mkdir_all</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>read_file</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>remove</b>
|
||||
```go
|
||||
remove(name)
|
||||
@ -93,6 +100,7 @@ removes the named file or (empty) directory.
|
||||
| 'name' | 'string' | name of the file or directory to be deleted |
|
||||
|
||||
|
||||
|
||||
#### def <b>remove_all</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>rename</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>setenv</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>write_file</b>
|
||||
```go
|
||||
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
|
||||
## Functions
|
||||
|
||||
|
||||
#### def <b>findall</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>split</b>
|
||||
```go
|
||||
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 |
|
||||
|
||||
|
||||
|
||||
#### def <b>sub</b>
|
||||
```go
|
||||
sub(pattern, repl, text, count=0, flags=0)
|
||||
|
36
_documentation/runtime/yaml.md
Normal file
36
_documentation/runtime/yaml.md
Normal file
@ -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/csv"
|
||||
"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/re"
|
||||
"go.starlark.net/repl"
|
||||
@ -37,6 +38,7 @@ func NewRuntime(pm *terraform.PluginManager) *Runtime {
|
||||
"encoding/json": json.LoadModule,
|
||||
"encoding/base64": base64.LoadModule,
|
||||
"encoding/csv": csv.LoadModule,
|
||||
"encoding/yaml": yaml.LoadModule,
|
||||
"re": re.LoadModule,
|
||||
"http": http.LoadModule,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user