Compare commits
No commits in common. "pipeline_reader" and "master" have entirely different histories.
pipeline_r
...
master
5
go.mod
5
go.mod
@ -3,7 +3,6 @@ module git.optclblast.xyz/optclblast/gustav
|
||||
go 1.23.0
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
golang.org/x/sync v0.8.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
5
go.sum
5
go.sum
@ -1,8 +1,7 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
@ -2,4 +2,3 @@ package config
|
||||
|
||||
type Config struct {
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ func prepareShelling[OutT any](ctx context.Context, cc HttpClient, pre Prepare)
|
||||
|
||||
respBody, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("[%s] failed to read response body: %w", op, err)
|
||||
return nil, fmt.Errorf("[%s] failed to read response body: %w", err)
|
||||
}
|
||||
|
||||
out := new(OutT)
|
||||
|
@ -1,94 +0,0 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func TestLoader(t *testing.T) {
|
||||
type args struct {
|
||||
yaml string
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want *Pipeline
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "example pipeline",
|
||||
args: args{
|
||||
yaml: `
|
||||
name: "My pipeline" # The name of pipeline
|
||||
description: "Test pipeline"
|
||||
|
||||
steps: # Steps
|
||||
step1:
|
||||
# The preparatory phase of our pipeline. Here we can perform authorizations and other actions that must
|
||||
# be performed BEFORE the main part.
|
||||
prepare:
|
||||
type: "http_call" # Call type.
|
||||
expected_codes: [200] # Expected return codes
|
||||
# The name of the variable in which the result of this call will be stored.
|
||||
# This value will be accessible only in scope of current stop.
|
||||
save_into: "prepare_step1_result"
|
||||
# The name of the variable in which the result of this call will be stored.
|
||||
# This value will be accessible globally.
|
||||
global_save_into: "global_variable"
|
||||
call: # Request configuration
|
||||
target: "http://127.0.0.1:8080/login" # Endpoint
|
||||
headers:
|
||||
secret: "xxx"
|
||||
logon-with: "password"
|
||||
method: "POST"
|
||||
body: |-
|
||||
{
|
||||
"login":"admin",
|
||||
"password":"password"
|
||||
}
|
||||
repeat: 1000
|
||||
# The main part of the step. The set of requests that will be executed.
|
||||
# They will be looped until the repeat number reached`,
|
||||
},
|
||||
want: &Pipeline{
|
||||
Name: "My pipeline",
|
||||
Description: "Test pipeline",
|
||||
Steps: []Step{{
|
||||
Name: "",
|
||||
Repeat: 1000,
|
||||
Prepare: Prepare{
|
||||
Type: "http_call",
|
||||
ExpectedCodes: []int{200},
|
||||
SaveInto: "prepare_step1_result",
|
||||
GlobalSaveInto: "global_variable",
|
||||
Call: Call{
|
||||
Target: "http://127.0.0.1:8080/login",
|
||||
Headers: map[string]string{
|
||||
"secret": "xxx",
|
||||
"logon-with": "password",
|
||||
},
|
||||
Method: "POST",
|
||||
Body: []byte("{\"login\":\"admin\",\"password\":\"password\"}"),
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
pipeline := new(Pipeline)
|
||||
|
||||
if err := yaml.Unmarshal([]byte(tt.args.yaml), pipeline); err != nil {
|
||||
t.Fatal(fmt.Errorf("failed to unmarshall pipeline: %v", err))
|
||||
}
|
||||
|
||||
t.Logf("pipeline: %v", spew.Sdump(pipeline))
|
||||
})
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ func FindPipelines(path string) []string {
|
||||
func LoadPipelines(ctx context.Context, paths []string) ([]*Pipeline, error) {
|
||||
pipelines := make([]*Pipeline, len(paths))
|
||||
|
||||
eg, _ := errgroup.WithContext(ctx)
|
||||
eg, ctx := errgroup.WithContext(ctx)
|
||||
|
||||
for i, p := range paths {
|
||||
i := i
|
||||
|
Loading…
Reference in New Issue
Block a user