feat: remote taskfiles (HTTP) (#1152)

* feat: remote taskfiles over http

* feat: allow insecure connections when --insecure flag is provided

* feat: better error handling for fetch errors

* fix: ensure cache directory always exists

* fix: setup logger before everything else

* feat: put remote taskfiles behind an experiment

* feat: --download and --offline flags for remote taskfiles

* feat: node.Read accepts a context

* feat: experiment docs

* chore: changelog

* chore: remove unused optional param from Node interface

* chore: tidy up and generalise NewNode function

* fix: use sha256 in remote checksum

* feat: --download by itself will not run a task

* feat: custom error if remote taskfiles experiment is not enabled

* refactor: BaseNode functional options and simplified FileNode

* fix: use hex encoding for checksum instead of b64
This commit is contained in:
Pete Davison
2023-09-12 16:42:54 -05:00
committed by GitHub
parent 84ad0056e4
commit 22ce67c5e5
19 changed files with 611 additions and 120 deletions

View File

@@ -8,7 +8,7 @@ import (
// ParseV3 parses command line argument: tasks and global variables
func ParseV3(args ...string) ([]taskfile.Call, *taskfile.Vars) {
var calls []taskfile.Call
calls := []taskfile.Call{}
globals := &taskfile.Vars{}
for _, arg := range args {
@@ -21,16 +21,12 @@ func ParseV3(args ...string) ([]taskfile.Call, *taskfile.Vars) {
globals.Set(name, taskfile.Var{Static: value})
}
if len(calls) == 0 {
calls = append(calls, taskfile.Call{Task: "default", Direct: true})
}
return calls, globals
}
// ParseV2 parses command line argument: tasks and vars of each task
func ParseV2(args ...string) ([]taskfile.Call, *taskfile.Vars) {
var calls []taskfile.Call
calls := []taskfile.Call{}
globals := &taskfile.Vars{}
for _, arg := range args {
@@ -51,10 +47,6 @@ func ParseV2(args ...string) ([]taskfile.Call, *taskfile.Vars) {
}
}
if len(calls) == 0 {
calls = append(calls, taskfile.Call{Task: "default", Direct: true})
}
return calls, globals
}

View File

@@ -73,22 +73,16 @@ func TestArgsV3(t *testing.T) {
},
},
{
Args: nil,
ExpectedCalls: []taskfile.Call{
{Task: "default", Direct: true},
},
Args: nil,
ExpectedCalls: []taskfile.Call{},
},
{
Args: []string{},
ExpectedCalls: []taskfile.Call{
{Task: "default", Direct: true},
},
Args: []string{},
ExpectedCalls: []taskfile.Call{},
},
{
Args: []string{"FOO=bar", "BAR=baz"},
ExpectedCalls: []taskfile.Call{
{Task: "default", Direct: true},
},
Args: []string{"FOO=bar", "BAR=baz"},
ExpectedCalls: []taskfile.Call{},
ExpectedGlobals: &taskfile.Vars{
OrderedMap: orderedmap.FromMapWithOrder(
map[string]taskfile.Var{
@@ -191,22 +185,16 @@ func TestArgsV2(t *testing.T) {
},
},
{
Args: nil,
ExpectedCalls: []taskfile.Call{
{Task: "default", Direct: true},
},
Args: nil,
ExpectedCalls: []taskfile.Call{},
},
{
Args: []string{},
ExpectedCalls: []taskfile.Call{
{Task: "default", Direct: true},
},
Args: []string{},
ExpectedCalls: []taskfile.Call{},
},
{
Args: []string{"FOO=bar", "BAR=baz"},
ExpectedCalls: []taskfile.Call{
{Task: "default", Direct: true},
},
Args: []string{"FOO=bar", "BAR=baz"},
ExpectedCalls: []taskfile.Call{},
ExpectedGlobals: &taskfile.Vars{
OrderedMap: orderedmap.FromMapWithOrder(
map[string]taskfile.Var{