Skip to content

Commit 183bfdf

Browse files
authored
(fix) update doc links, broken import, and flowfile schema (#134)
1 parent 23878ae commit 183bfdf

31 files changed

+91
-52
lines changed

README.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,21 @@ flow init workspace <name> <path>
5959
```
6060

6161
This command will register the Workspace and create the root config file for you.
62-
For more information on Workspaces and it's config, see [Workspaces](docs/config/workspace_config.md).
62+
For more information on Workspaces and it's config, see [Workspaces](docs/types/workspace.md).
6363

6464
#### Defining Executables
6565

66-
Executables are the core of flow. Each executable is driven by its definition within an executable definition file
67-
(`*.flow` file). There are several types of executables that can be defined.
68-
For more information on Executables and it's config, see [Executables](docs/config/executables.md).
66+
Executables are the core of flow. Each executable is driven by its definition within a flow file (`*.flow`).
67+
There are several types of executables that can be defined. For more information on Executables and the flow file, see [FlowFile.md](docs/types/flowfile.md).
68+
69+
There is also a JSON Schema that can be used in IDEs with the Language Server Protocol (LSP) to perform intelligent
70+
suggestions. You can add the following comment to the top of your flow files to enable this:
71+
72+
```yaml
73+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
74+
```
75+
76+
See the [schemas](schemas/) directory all available schemas.
6977

7078
#### Running and managing workflows
7179

cmd/internal/exec.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ func RegisterExecCmd(ctx *context.Context, rootCmd *cobra.Command) {
3232
Use: "exec EXECUTABLE_ID [args...]",
3333
Aliases: executable.SortedValidVerbs(),
3434
Short: "Execute a flow by ID.",
35-
Long: execDocumentation + "\n\n" + execExamples + "\n\n" +
36-
"See " + io.ConfigDocsURL("executables", "Verb") + "for more information on executable verbs." +
37-
"See " + io.ConfigDocsURL("executables", "Ref") + "for more information on executable IDs.",
35+
Long: execDocumentation + fmt.Sprintf(
36+
"\n\n%s\n\nSee %s for more information on executable verbs."+
37+
"See %s for more information on executable IDs.",
38+
execExamples, io.TypesDocsURL("flowfile", "ExecutableVerb"),
39+
io.TypesDocsURL("flowfile", "ExecutableRef"),
40+
),
3841
Args: cobra.MinimumNArgs(1),
3942
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
4043
execList, err := ctx.ExecutableCache.GetExecutableList(ctx.Logger)

cmd/internal/get.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package internal
22

33
import (
4+
"fmt"
5+
46
"github.com/jahvon/tuikit/components"
57
"github.com/pkg/errors"
68
"github.com/spf13/cobra"
@@ -109,8 +111,12 @@ func registerGetExecCmd(ctx *context.Context, getCmd *cobra.Command) {
109111
Short: "Print an executable flow by reference.",
110112
Long: "Print an executable by the executable's verb and ID.\nThe target executable's ID should be in the " +
111113
"form of 'ws/ns:name' and the verb should match the target executable's verb or one of its aliases.\n\n" +
112-
"See" + io.ConfigDocsURL("executables", "Verb") + "for more information on executable verbs." +
113-
"See" + io.ConfigDocsURL("executable", "Ref") + "for more information on executable IDs.",
114+
fmt.Sprintf(
115+
"See %s for more information on executable verbs.\n"+
116+
"See %s for more information on executable IDs.",
117+
io.TypesDocsURL("flowfile", "ExecutableVerb"),
118+
io.TypesDocsURL("flowfile", "ExecutableRef"),
119+
),
114120
Args: cobra.ExactArgs(2),
115121
PreRun: func(cmd *cobra.Command, args []string) { interactive.InitInteractiveContainer(ctx, cmd) },
116122
PostRun: func(cmd *cobra.Command, args []string) { interactive.WaitForExit(ctx, cmd) },

development.flow

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
12
visibility: private
23
tags: [development]
34
executables:

docs/cli/flow_exec.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ flow exec ws/ns:build
2727
flow exec ws/ns:build flag1=value1 flag2=value2 value3 value4
2828

2929

30-
See https://github.com/jahvon/flow/blob/main/docs/config/executables.md#Verbfor more information on executable verbs.See https://github.com/jahvon/flow/blob/main/docs/config/executables.md#Reffor more information on executable IDs.
30+
See https://github.com/jahvon/flow/blob/main/docs/types/flowfile.md#ExecutableVerb for more information on executable verbs.See https://github.com/jahvon/flow/blob/main/docs/types/flowfile.md#ExecutableRef for more information on executable IDs.
3131

3232
```
3333
flow exec EXECUTABLE_ID [args...] [flags]

docs/cli/flow_get_executable.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Print an executable flow by reference.
77
Print an executable by the executable's verb and ID.
88
The target executable's ID should be in the form of 'ws/ns:name' and the verb should match the target executable's verb or one of its aliases.
99

10-
Seehttps://github.com/jahvon/flow/blob/main/docs/config/executables.md#Verbfor more information on executable verbs.Seehttps://github.com/jahvon/flow/blob/main/docs/config/executable.md#Reffor more information on executable IDs.
10+
See https://github.com/jahvon/flow/blob/main/docs/types/flowfile.md#ExecutableVerb for more information on executable verbs.
11+
See https://github.com/jahvon/flow/blob/main/docs/types/flowfile.md#ExecutableRef for more information on executable IDs.
1112

1213
```
1314
flow get executable VERB ID [flags]

docs/docs.flow

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
12
visibility: public
23
namespace: docs
34
tags: [documentation]

docs/types/config.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Alternatively, a custom path can be set using the `FLOW_CONFIG_PATH` environment
2727
| `currentWorkspace` | The name of the current workspace. This should match a key in the `workspaces` or `remoteWorkspaces` map. | `string` | | [] |
2828
| `defaultLogMode` | The default log mode to use when running executables. This can either be `hidden`, `json`, `logfmt` or `text` `hidden` will not display any logs. `json` will display logs in JSON format. `logfmt` will display logs with a log level, timestamp, and message. `text` will just display the log message. | `string` | logfmt | [] |
2929
| `interactive` | | [Interactive](#Interactive) | <no value> | [] |
30-
| `templates` | A map of flowfile template names to their paths. | map (`string -> string`) | map[] | [] |
30+
| `templates` | A map of flowfile template names to their paths. | `map` (`string` -> `string`) | map[] | [] |
3131
| `workspaceMode` | The mode of the workspace. This can be either `fixed` or `dynamic`. In `fixed` mode, the current workspace used at runtime is always the one set in the currentWorkspace config field. In `dynamic` mode, the current workspace used at runtime is determined by the current directory. If the current directory is within a workspace, that workspace is used. | `string` | dynamic | [] |
32-
| `workspaces` | Map of workspace names to their paths. The path should be a valid absolute path to the workspace directory. | map (`string -> string`) | <no value> | [] |
32+
| `workspaces` | Map of workspace names to their paths. The path should be a valid absolute path to the workspace directory. | `map` (`string` -> `string`) | <no value> | [] |
3333

3434

3535
## Definitions

docs/types/flowfile.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ A workspace can have multiple flow files located anywhere in the workspace direc
1515
| Field | Description | Type | Default | Required |
1616
| ----- | ----------- | ---- | ------- | -------- |
1717
| `description` | A description of the executables defined within the flow file. This description will be set as the executables' description if not defined at the executable level. | `string` | | [] |
18-
| `executables` | | [Executable](#Executable) | [] | [] |
18+
| `executables` | | `array` ([Executable](#Executable)) | [] | [] |
1919
| `fromFile` | | [FromFile](#FromFile) | [] | [] |
2020
| `namespace` | The namespace to be given to all executables in the flow file. If not set, the executables in the file will be grouped into the root (*) namespace. Namespaces can be reused across multiple flow files. Namespaces are used to reference executables in the CLI using the format `workspace:namespace/name`. | `string` | | [] |
21-
| `tags` | Tags to be applied to all executables defined within the flow file. | array (``string``) | [] | [] |
21+
| `tags` | Tags to be applied to all executables defined within the flow file. | `array` (`string`) | [] | [] |
2222
| `visibility` | | [CommonVisibility](#CommonVisibility) | <no value> | [] |
2323

2424

@@ -28,7 +28,7 @@ A workspace can have multiple flow files located anywhere in the workspace direc
2828

2929
Alternate names that can be used to reference the executable in the CLI.
3030

31-
**Type:** array (``string``)
31+
**Type:** `array` (`string`)
3232

3333

3434

@@ -39,7 +39,7 @@ A list of tags.
3939
Tags can be used with list commands to filter returned data.
4040

4141

42-
**Type:** array (``string``)
42+
**Type:** `array` (`string`)
4343

4444

4545

@@ -116,7 +116,7 @@ Executables are the building blocks of workflows and are used to define the acti
116116

117117

118118

119-
**Type:** array (`[ExecutableArgument](#ExecutableArgument)`)
119+
**Type:** `array` ([ExecutableArgument](#ExecutableArgument))
120120

121121

122122

@@ -214,7 +214,7 @@ Only one of `text`, `secretRef`, or `prompt` must be set. Specifying more than o
214214

215215

216216

217-
**Type:** array (`[ExecutableParameter](#ExecutableParameter)`)
217+
**Type:** `array` ([ExecutableParameter](#ExecutableParameter))
218218

219219

220220

@@ -239,7 +239,7 @@ If the namespace is not specified, the current namespace will be used.
239239

240240

241241

242-
**Type:** array (`[ExecutableRef](#ExecutableRef)`)
242+
**Type:** `array` ([ExecutableRef](#ExecutableRef))
243243

244244

245245

@@ -276,15 +276,15 @@ Makes an HTTP request.
276276
| ----- | ----------- | ---- | ------- | -------- |
277277
| `args` | | [ExecutableArgumentList](#ExecutableArgumentList) | <no value> | [] |
278278
| `body` | The body of the request. | `string` | | [] |
279-
| `headers` | A map of headers to include in the request. | map (`string -> string`) | map[] | [] |
279+
| `headers` | A map of headers to include in the request. | `map` (`string` -> `string`) | map[] | [] |
280280
| `logResponse` | If set to true, the response will be logged as program output. | `boolean` | false | [] |
281281
| `method` | The HTTP method to use when making the request. | `string` | GET | [] |
282282
| `params` | | [ExecutableParameterList](#ExecutableParameterList) | <no value> | [] |
283283
| `responseFile` | | [ExecutableRequestResponseFile](#ExecutableRequestResponseFile) | <no value> | [] |
284284
| `timeout` | The timeout for the request in Go duration format (e.g. 30s, 5m, 1h). | `string` | 30m0s | [] |
285285
| `transformResponse` | JQ query to transform the response before saving it to a file or outputting it. | `string` | | [] |
286286
| `url` | The URL to make the request to. | `string` | | [] |
287-
| `validStatusCodes` | A list of valid status codes. If the response status code is not in this list, the executable will fail. If not set, the response status code will not be checked. | array (``integer``) | [] | [] |
287+
| `validStatusCodes` | A list of valid status codes. If the response status code is not in this list, the executable will fail. If not set, the response status code will not be checked. | `array` (`integer`) | [] | [] |
288288

289289
### ExecutableRequestResponseFile
290290

@@ -377,7 +377,7 @@ This allows users to use the verb that best describes the action they are perfor
377377

378378
A list of `.sh` files to convert into generated executables in the file's executable group.
379379

380-
**Type:** array (``string``)
380+
**Type:** `array` (`string`)
381381

382382

383383

docs/types/workspace.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ A list of tags.
2828
Tags can be used with list commands to filter returned data.
2929

3030

31-
**Type:** array (``string``)
31+
**Type:** `array` (`string`)
3232

3333

3434

@@ -45,7 +45,7 @@ Tags can be used with list commands to filter returned data.
4545

4646
| Field | Description | Type | Default | Required |
4747
| ----- | ----------- | ---- | ------- | -------- |
48-
| `excluded` | A list of directories to exclude from the executable search. | array (``string``) | [] | [] |
49-
| `included` | A list of directories to include in the executable search. | array (``string``) | [] | [] |
48+
| `excluded` | A list of directories to exclude from the executable search. | `array` (`string`) | [] | [] |
49+
| `included` | A list of directories to include in the executable search. | `array` (`string`) | [] | [] |
5050

5151

examples/dirs.flow

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
12
visibility: private
23
namespace: examples
34
executables:

examples/env.flow

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
12
visibility: private
23
namespace: examples
34
executables:

examples/exec.flow

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
12
visibility: private
23
namespace: examples
34
executables:

examples/generated.flow

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
12
visibility: private
23
namespace: examples
34
fromFile:

examples/launch.flow

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
12
visibility: private
23
namespace: examples
34
executables:

examples/parallel.flow

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
12
visibility: private
23
namespace: examples
34
executables:

examples/render.flow

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
12
visibility: private
23
namespace: examples
34
executables:

examples/request.flow

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
12
visibility: private
23
namespace: examples
34
executables:

examples/serial.flow

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/flowfile_schema.json
12
visibility: private
23
namespace: examples
34
executables:

flow.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jahvon/flow/HEAD/schemas/workspace_schema.json
12
displayName: flow
23
git:
34
enabled: false

internal/cache/executables_cache.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (c *ExecutableCacheImpl) GetExecutableByRef(logger io.Logger, ref executabl
177177
}
178178
cfg.Executables = append(cfg.Executables, generated...)
179179

180-
execs := executable.ExecutableList(cfg.Executables)
180+
execs := cfg.Executables
181181
exec, err := execs.FindByVerbAndID(ref.GetVerb(), ref.GetID())
182182
if err != nil {
183183
return nil, err

internal/cache/executables_cache_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var _ = Describe("ExecutableCacheImpl", func() {
4848
execCfg := &executable.FlowFile{
4949
Namespace: "testdata",
5050
Visibility: &v,
51-
Executables: executable.FlowFileExecutables{
51+
Executables: executable.ExecutableList{
5252
{Verb: "run", Name: "exec"},
5353
},
5454
}

internal/filesystem/executables_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var _ = Describe("Executables", func() {
4141
It("writes and reads executable definition correctly", func() {
4242
executableDefinition := &executable.FlowFile{
4343
Namespace: "test",
44-
Executables: executable.FlowFileExecutables{
44+
Executables: executable.ExecutableList{
4545
{
4646
Verb: "exec",
4747
Name: "test-executable",
@@ -62,7 +62,7 @@ var _ = Describe("Executables", func() {
6262
It("loads all executable definitions if no paths are set", func() {
6363
executableDefinition := &executable.FlowFile{
6464
Namespace: "test",
65-
Executables: executable.FlowFileExecutables{
65+
Executables: executable.ExecutableList{
6666
{
6767
Verb: "exec",
6868
Name: "test-executable",
@@ -88,7 +88,7 @@ var _ = Describe("Executables", func() {
8888
It("loads executable definitions from the included path", func() {
8989
executableDefinition := &executable.FlowFile{
9090
Namespace: "test",
91-
Executables: executable.FlowFileExecutables{
91+
Executables: executable.ExecutableList{
9292
{
9393
Verb: "exec",
9494
Name: "test-executable",
@@ -120,7 +120,7 @@ var _ = Describe("Executables", func() {
120120
It("does not load executable definitions from excluded paths", func() {
121121
executableDefinition := &executable.FlowFile{
122122
Namespace: "test",
123-
Executables: executable.FlowFileExecutables{
123+
Executables: executable.ExecutableList{
124124
{
125125
Verb: "exec",
126126
Name: "test-executable",

internal/filesystem/templates_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var _ = Describe("Templates", func() {
3232
definitionTemplate := &executable.FlowFileTemplate{
3333
FlowFile: &executable.FlowFile{
3434
Namespace: "test",
35-
Executables: executable.FlowFileExecutables{
35+
Executables: executable.ExecutableList{
3636
{Verb: "run", Name: "test-executable", Description: "{{ .key }}"},
3737
},
3838
},
@@ -53,7 +53,7 @@ var _ = Describe("Templates", func() {
5353
definitionTemplate := &executable.FlowFileTemplate{
5454
FlowFile: &executable.FlowFile{
5555
Namespace: "test",
56-
Executables: executable.FlowFileExecutables{
56+
Executables: executable.ExecutableList{
5757
{Verb: "run", Name: "test-executable", Description: "{{ .key }}"},
5858
},
5959
},
@@ -83,7 +83,7 @@ var _ = Describe("Templates", func() {
8383
definitionTemplate := &executable.FlowFileTemplate{
8484
FlowFile: &executable.FlowFile{
8585
Namespace: "test",
86-
Executables: executable.FlowFileExecutables{
86+
Executables: executable.ExecutableList{
8787
{Verb: "exec", Name: "test-executable", Description: "{{ .key }}"},
8888
},
8989
},

internal/io/output.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"fmt"
55
)
66

7-
func ConfigDocsURL(docID, anchor string) string {
7+
func TypesDocsURL(docID, anchor string) string {
88
if anchor != "" {
99
anchor = "#" + anchor
1010
}
11-
return fmt.Sprintf("https://github.com/jahvon/flow/blob/main/docs/config/%s.md%s", docID, anchor)
11+
return fmt.Sprintf("https://github.com/jahvon/flow/blob/main/docs/types/%s.md%s", docID, anchor)
1212
}

internal/io/secret/views.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"github.com/jahvon/tuikit/components"
77
"github.com/jahvon/tuikit/styles"
8-
"github.com/samber/lo"
98

109
"github.com/jahvon/flow/internal/context"
1110
"github.com/jahvon/flow/internal/io"
@@ -90,9 +89,15 @@ func NewSecretListView(
9089
}
9190

9291
selectFunc := func(filterVal string) error {
93-
secret, found := lo.Find(secrets, func(s vault.Secret) bool {
94-
return s.Reference == filterVal
95-
})
92+
var secret vault.Secret
93+
var found bool
94+
for _, s := range secrets {
95+
if s.Reference == filterVal {
96+
secret = s
97+
found = true
98+
break
99+
}
100+
}
96101
if !found {
97102
return fmt.Errorf("secret not found")
98103
}

schemas/flowfile_schema.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,11 @@
483483
"default": ""
484484
},
485485
"executables": {
486-
"$ref": "#/definitions/Executable",
487-
"default": []
486+
"type": "array",
487+
"default": [],
488+
"items": {
489+
"$ref": "#/definitions/Executable"
490+
}
488491
},
489492
"fromFile": {
490493
"$ref": "#/definitions/FromFile",

0 commit comments

Comments
 (0)