Compare commits
No commits in common. "18c19174a2a892ff3157a4a3a8bb06ab6dcb50fe" and "e41778d37361d4dd96c5616ba6745ee4ff8b964c" have entirely different histories.
18c19174a2
...
e41778d373
@ -23,8 +23,6 @@ type PlainOutput struct {
|
|||||||
Out io.Writer
|
Out io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
const systemGroup = "system"
|
|
||||||
|
|
||||||
func (c *PlainOutput) Write(p []byte) (int, error) {
|
func (c *PlainOutput) Write(p []byte) (int, error) {
|
||||||
event := map[string]interface{}{}
|
event := map[string]interface{}{}
|
||||||
d := json.NewDecoder(bytes.NewReader(p))
|
d := json.NewDecoder(bytes.NewReader(p))
|
||||||
@ -119,7 +117,7 @@ func formatMessage(event map[string]interface{}) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parseSource(event map[string]interface{}) string {
|
func parseSource(event map[string]interface{}) string {
|
||||||
source := systemGroup
|
source := "system"
|
||||||
if task, ok := event["task"].(string); ok && task != "" {
|
if task, ok := event["task"].(string); ok && task != "" {
|
||||||
source = task
|
source = task
|
||||||
}
|
}
|
||||||
|
@ -43,14 +43,8 @@ func (l *Logs) Add(event Event) error {
|
|||||||
l.l.Lock()
|
l.l.Lock()
|
||||||
defer l.l.Unlock()
|
defer l.l.Unlock()
|
||||||
|
|
||||||
// same thing as in plain.go group all the non-identified tasks
|
|
||||||
// into a general group called system
|
|
||||||
source := systemGroup
|
|
||||||
taskPath, ok := event["task"].(string)
|
taskPath, ok := event["task"].(string)
|
||||||
|
if !ok {
|
||||||
if ok && len(taskPath) > 0 {
|
|
||||||
source = taskPath
|
|
||||||
} else if !ok {
|
|
||||||
l.Messages = append(l.Messages, Message{
|
l.Messages = append(l.Messages, Message{
|
||||||
Event: event,
|
Event: event,
|
||||||
})
|
})
|
||||||
@ -59,7 +53,7 @@ func (l *Logs) Add(event Event) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hide hidden fields (e.g. `._*`) from log group names
|
// Hide hidden fields (e.g. `._*`) from log group names
|
||||||
groupKey := strings.Split(source, "._")[0]
|
groupKey := strings.Split(taskPath, "._")[0]
|
||||||
|
|
||||||
group := l.groups[groupKey]
|
group := l.groups[groupKey]
|
||||||
|
|
||||||
@ -84,20 +78,12 @@ func (l *Logs) Add(event Event) error {
|
|||||||
// For each task in a group, the status will transition from computing to complete, then back to computing and so on.
|
// For each task in a group, the status will transition from computing to complete, then back to computing and so on.
|
||||||
// The transition is fast enough not to cause a problem.
|
// The transition is fast enough not to cause a problem.
|
||||||
if st, ok := event["state"].(string); ok {
|
if st, ok := event["state"].(string); ok {
|
||||||
if t, err := task.ParseState(st); err != nil {
|
group.State = task.State(st)
|
||||||
return err
|
if group.State == task.StateComputing {
|
||||||
// concurrent "system" tasks are the only exception to transition
|
group.Completed = nil
|
||||||
// from another state to failed since we need to show the error to
|
} else {
|
||||||
// the user
|
now := time.Now()
|
||||||
} else if group.State.CanTransition(t) ||
|
group.Completed = &now
|
||||||
(group.Name == systemGroup && t == task.StateFailed) {
|
|
||||||
group.State = t
|
|
||||||
if group.State == task.StateComputing {
|
|
||||||
group.Completed = nil
|
|
||||||
} else {
|
|
||||||
now := time.Now()
|
|
||||||
group.Completed = &now
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -276,57 +262,52 @@ func (c *TTYOutput) printLine(w io.Writer, event Event, width int) int {
|
|||||||
func (c *TTYOutput) printGroup(group *Group, width, maxLines int) int {
|
func (c *TTYOutput) printGroup(group *Group, width, maxLines int) int {
|
||||||
lineCount := 0
|
lineCount := 0
|
||||||
|
|
||||||
var out string
|
prefix := ""
|
||||||
// treat the "system" group as a special case as we don't
|
switch group.State {
|
||||||
// want it to be displayed as an action in the output
|
case task.StateComputing:
|
||||||
if group.Name != systemGroup {
|
prefix = "[+]"
|
||||||
prefix := ""
|
case task.StateCanceled:
|
||||||
switch group.State {
|
prefix = "[✗]"
|
||||||
case task.StateComputing:
|
case task.StateFailed:
|
||||||
prefix = "[+]"
|
prefix = "[✗]"
|
||||||
case task.StateCanceled:
|
case task.StateCompleted:
|
||||||
prefix = "[✗]"
|
prefix = "[✔]"
|
||||||
case task.StateFailed:
|
|
||||||
prefix = "[✗]"
|
|
||||||
case task.StateCompleted:
|
|
||||||
prefix = "[✔]"
|
|
||||||
}
|
|
||||||
|
|
||||||
out = prefix + " " + group.Name
|
|
||||||
|
|
||||||
endTime := time.Now()
|
|
||||||
if group.Completed != nil {
|
|
||||||
endTime = *group.Completed
|
|
||||||
}
|
|
||||||
|
|
||||||
dt := endTime.Sub(*group.Started).Seconds()
|
|
||||||
if dt < 0.05 {
|
|
||||||
dt = 0
|
|
||||||
}
|
|
||||||
timer := fmt.Sprintf("%3.1fs", dt)
|
|
||||||
|
|
||||||
// align
|
|
||||||
out += strings.Repeat(" ", width-utf8.RuneCountInString(out)-len(timer))
|
|
||||||
out += timer
|
|
||||||
out += "\n"
|
|
||||||
|
|
||||||
// color
|
|
||||||
switch group.State {
|
|
||||||
case task.StateComputing:
|
|
||||||
out = aec.Apply(out, aec.LightBlueF)
|
|
||||||
case task.StateCanceled:
|
|
||||||
out = aec.Apply(out, aec.LightYellowF)
|
|
||||||
case task.StateFailed:
|
|
||||||
out = aec.Apply(out, aec.LightRedF)
|
|
||||||
case task.StateCompleted:
|
|
||||||
out = aec.Apply(out, aec.LightGreenF)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print
|
|
||||||
fmt.Fprint(c.cons, out)
|
|
||||||
lineCount++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out := prefix + " " + group.Name
|
||||||
|
|
||||||
|
endTime := time.Now()
|
||||||
|
if group.Completed != nil {
|
||||||
|
endTime = *group.Completed
|
||||||
|
}
|
||||||
|
|
||||||
|
dt := endTime.Sub(*group.Started).Seconds()
|
||||||
|
if dt < 0.05 {
|
||||||
|
dt = 0
|
||||||
|
}
|
||||||
|
timer := fmt.Sprintf("%3.1fs", dt)
|
||||||
|
|
||||||
|
// align
|
||||||
|
out += strings.Repeat(" ", width-utf8.RuneCountInString(out)-len(timer))
|
||||||
|
out += timer
|
||||||
|
out += "\n"
|
||||||
|
|
||||||
|
// color
|
||||||
|
switch group.State {
|
||||||
|
case task.StateComputing:
|
||||||
|
out = aec.Apply(out, aec.LightBlueF)
|
||||||
|
case task.StateCanceled:
|
||||||
|
out = aec.Apply(out, aec.LightYellowF)
|
||||||
|
case task.StateFailed:
|
||||||
|
out = aec.Apply(out, aec.LightRedF)
|
||||||
|
case task.StateCompleted:
|
||||||
|
out = aec.Apply(out, aec.LightGreenF)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print
|
||||||
|
fmt.Fprint(c.cons, out)
|
||||||
|
lineCount++
|
||||||
|
|
||||||
printEvents := []Event{}
|
printEvents := []Event{}
|
||||||
switch group.State {
|
switch group.State {
|
||||||
case task.StateComputing:
|
case task.StateComputing:
|
||||||
|
@ -42,7 +42,7 @@ bar: bash.#Run & {
|
|||||||
script: contents: #"""
|
script: contents: #"""
|
||||||
echo "hello"
|
echo "hello"
|
||||||
"""#
|
"""#
|
||||||
env: HACK: "\(foo.success)" // <== HACK: CHAINING of action happening here
|
env: HACK: "\(test.success)" // <== HACK: CHAINING of action happening here
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package helm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"universe.dagger.io/docker"
|
|
||||||
)
|
|
||||||
|
|
||||||
#Image: {
|
|
||||||
version: string | *"latest"
|
|
||||||
|
|
||||||
docker.#Pull & {
|
|
||||||
source: "index.docker.io/alpine/helm:\(version)"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
package helm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"dagger.io/dagger"
|
|
||||||
"universe.dagger.io/docker"
|
|
||||||
)
|
|
||||||
|
|
||||||
#Install: {
|
|
||||||
// Name of your release
|
|
||||||
name: string | *""
|
|
||||||
kubeconfig: dagger.#Secret
|
|
||||||
source: *"repository" | "URL"
|
|
||||||
{
|
|
||||||
source: "repository"
|
|
||||||
chart: string
|
|
||||||
repoName: string
|
|
||||||
repository: string
|
|
||||||
run: {
|
|
||||||
env: {
|
|
||||||
CHART: chart
|
|
||||||
REPO_NAME: repoName
|
|
||||||
REPOSITORY: repository
|
|
||||||
}
|
|
||||||
_script: #"""
|
|
||||||
helm repo add $REPO_NAME $REPOSITORY
|
|
||||||
helm repo update
|
|
||||||
helm install $NAME $REPO_NAME/$CHART $GENERATE_NAME
|
|
||||||
"""#
|
|
||||||
}
|
|
||||||
} | {
|
|
||||||
source: "URL"
|
|
||||||
URL: string
|
|
||||||
run: {
|
|
||||||
env: "URL": URL
|
|
||||||
_script: #"""
|
|
||||||
helm install $NAME $URL $GENERATE_NAME
|
|
||||||
"""#
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_base: #Image
|
|
||||||
run: docker.#Run & {
|
|
||||||
input: _base.output
|
|
||||||
env: {
|
|
||||||
NAME: name
|
|
||||||
GENERATE_NAME: _generateName
|
|
||||||
}
|
|
||||||
mounts: "/root/.kube/config": {
|
|
||||||
dest: "/root/.kube/config"
|
|
||||||
type: "secret"
|
|
||||||
contents: kubeconfig
|
|
||||||
}
|
|
||||||
entrypoint: ["/bin/sh"]
|
|
||||||
command: {
|
|
||||||
name: "-c"
|
|
||||||
args: [run._script]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_generateName: string | *""
|
|
||||||
if name == "" {
|
|
||||||
_generateName: "--generate-name"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package helm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"dagger.io/dagger"
|
|
||||||
"universe.dagger.io/x/vgjm456@qq.com/helm"
|
|
||||||
)
|
|
||||||
|
|
||||||
dagger.#Plan & {
|
|
||||||
client: {
|
|
||||||
env: KUBECONFIG: string
|
|
||||||
commands: kubeconfig: {
|
|
||||||
name: "cat"
|
|
||||||
args: ["\(env.KUBECONFIG)"]
|
|
||||||
stdout: dagger.#Secret
|
|
||||||
}
|
|
||||||
}
|
|
||||||
actions: test: {
|
|
||||||
URL: helm.#Install & {
|
|
||||||
name: "test-pgsql"
|
|
||||||
source: "URL"
|
|
||||||
URL: "https://charts.bitnami.com/bitnami/postgresql-11.1.12.tgz"
|
|
||||||
kubeconfig: client.commands.kubeconfig.stdout
|
|
||||||
}
|
|
||||||
repository: helm.#Install & {
|
|
||||||
name: "test-redis"
|
|
||||||
source: "repository"
|
|
||||||
chart: "redis"
|
|
||||||
repoName: "bitnami"
|
|
||||||
repository: "https://charts.bitnami.com/bitnami"
|
|
||||||
kubeconfig: client.commands.kubeconfig.stdout
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,7 +8,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.dagger.io/dagger/compiler"
|
"go.dagger.io/dagger/compiler"
|
||||||
|
|
||||||
"go.dagger.io/dagger/plan/task"
|
"go.dagger.io/dagger/plan/task"
|
||||||
"go.dagger.io/dagger/plancontext"
|
"go.dagger.io/dagger/plancontext"
|
||||||
"go.dagger.io/dagger/solver"
|
"go.dagger.io/dagger/solver"
|
||||||
@ -16,7 +15,6 @@ import (
|
|||||||
"cuelang.org/go/cue"
|
"cuelang.org/go/cue"
|
||||||
cueflow "cuelang.org/go/tools/flow"
|
cueflow "cuelang.org/go/tools/flow"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
)
|
)
|
||||||
@ -126,15 +124,6 @@ func (r *Runner) shouldRun(p cue.Path) bool {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func taskLog(tp string, log *zerolog.Logger, t task.Task, fn func(lg zerolog.Logger)) {
|
|
||||||
fn(log.With().Str("task", tp).Logger())
|
|
||||||
// setup logger here
|
|
||||||
_, isDockerfileTask := t.(*task.DockerfileTask)
|
|
||||||
if isDockerfileTask {
|
|
||||||
fn(log.With().Str("task", "system").Logger())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Runner) taskFunc(flowVal cue.Value) (cueflow.Runner, error) {
|
func (r *Runner) taskFunc(flowVal cue.Value) (cueflow.Runner, error) {
|
||||||
v := compiler.Wrap(flowVal)
|
v := compiler.Wrap(flowVal)
|
||||||
handler, err := task.Lookup(v)
|
handler, err := task.Lookup(v)
|
||||||
@ -153,45 +142,31 @@ func (r *Runner) taskFunc(flowVal cue.Value) (cueflow.Runner, error) {
|
|||||||
// Wrapper around `task.Run` that handles logging, tracing, etc.
|
// Wrapper around `task.Run` that handles logging, tracing, etc.
|
||||||
return cueflow.RunnerFunc(func(t *cueflow.Task) error {
|
return cueflow.RunnerFunc(func(t *cueflow.Task) error {
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
taskPath := t.Path().String()
|
lg := log.Ctx(ctx).With().Str("task", t.Path().String()).Logger()
|
||||||
lg := log.Ctx(ctx).With().Logger()
|
|
||||||
ctx = lg.WithContext(ctx)
|
ctx = lg.WithContext(ctx)
|
||||||
ctx, span := otel.Tracer("dagger").Start(ctx, fmt.Sprintf("up: %s", t.Path().String()))
|
ctx, span := otel.Tracer("dagger").Start(ctx, fmt.Sprintf("up: %s", t.Path().String()))
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
taskLog(taskPath, &lg, handler, func(lg zerolog.Logger) {
|
lg.Info().Str("state", string(task.StateComputing)).Msg(string(task.StateComputing))
|
||||||
lg.Info().Str("state", task.StateComputing.String()).Msg(task.StateComputing.String())
|
|
||||||
})
|
|
||||||
|
|
||||||
// Debug: dump dependencies
|
// Debug: dump dependencies
|
||||||
for _, dep := range t.Dependencies() {
|
for _, dep := range t.Dependencies() {
|
||||||
taskLog(taskPath, &lg, handler, func(lg zerolog.Logger) {
|
lg.Debug().Str("dependency", dep.Path().String()).Msg("dependency detected")
|
||||||
lg.Debug().Str("dependency", dep.Path().String()).Msg("dependency detected")
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
result, err := handler.Run(ctx, r.pctx, r.s, compiler.Wrap(t.Value()))
|
result, err := handler.Run(ctx, r.pctx, r.s, compiler.Wrap(t.Value()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// FIXME: this should use errdefs.IsCanceled(err)
|
// FIXME: this should use errdefs.IsCanceled(err)
|
||||||
|
|
||||||
// we don't wrap taskLog here since in some cases, actions could still be
|
|
||||||
// running in goroutines which will scramble outputs.
|
|
||||||
if strings.Contains(err.Error(), "context canceled") {
|
if strings.Contains(err.Error(), "context canceled") {
|
||||||
taskLog(taskPath, &lg, handler, func(lg zerolog.Logger) {
|
lg.Error().Dur("duration", time.Since(start)).Str("state", string(task.StateCanceled)).Msg(string(task.StateCanceled))
|
||||||
lg.Error().Dur("duration", time.Since(start)).Str("state", task.StateCanceled.String()).Msg(task.StateCanceled.String())
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
taskLog(taskPath, &lg, handler, func(lg zerolog.Logger) {
|
lg.Error().Dur("duration", time.Since(start)).Err(compiler.Err(err)).Str("state", string(task.StateFailed)).Msg(string(task.StateFailed))
|
||||||
lg.Error().Dur("duration", time.Since(start)).Err(compiler.Err(err)).Str("state", task.StateFailed.String()).Msg(task.StateFailed.String())
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return fmt.Errorf("%s: %w", t.Path().String(), compiler.Err(err))
|
return fmt.Errorf("%s: %w", t.Path().String(), compiler.Err(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
taskLog(taskPath, &lg, handler, func(lg zerolog.Logger) {
|
lg.Info().Dur("duration", time.Since(start)).Str("state", string(task.StateCompleted)).Msg(string(task.StateCompleted))
|
||||||
lg.Info().Dur("duration", time.Since(start)).Str("state", task.StateCompleted.String()).Msg(task.StateCompleted.String())
|
|
||||||
})
|
|
||||||
|
|
||||||
// If the result is not concrete (e.g. empty value), there's nothing to merge.
|
// If the result is not concrete (e.g. empty value), there's nothing to merge.
|
||||||
if !result.IsConcrete() {
|
if !result.IsConcrete() {
|
||||||
@ -199,9 +174,7 @@ func (r *Runner) taskFunc(flowVal cue.Value) (cueflow.Runner, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if src, err := result.Source(); err == nil {
|
if src, err := result.Source(); err == nil {
|
||||||
taskLog(taskPath, &lg, handler, func(lg zerolog.Logger) {
|
lg.Debug().Str("result", string(src)).Msg("merging task result")
|
||||||
lg.Debug().Str("result", string(src)).Msg("merging task result")
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mirror task result and re-scan tasks that should run.
|
// Mirror task result and re-scan tasks that should run.
|
||||||
@ -211,9 +184,7 @@ func (r *Runner) taskFunc(flowVal cue.Value) (cueflow.Runner, error) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if err := t.Fill(result.Cue()); err != nil {
|
if err := t.Fill(result.Cue()); err != nil {
|
||||||
taskLog(taskPath, &lg, handler, func(lg zerolog.Logger) {
|
lg.Error().Err(err).Msg("failed to fill task")
|
||||||
lg.Error().Err(err).Msg("failed to fill task")
|
|
||||||
})
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Register("Dockerfile", func() Task { return &DockerfileTask{} })
|
Register("Dockerfile", func() Task { return &dockerfileTask{} })
|
||||||
}
|
}
|
||||||
|
|
||||||
type DockerfileTask struct{}
|
type dockerfileTask struct {
|
||||||
|
}
|
||||||
|
|
||||||
func (t *DockerfileTask) Run(ctx context.Context, pctx *plancontext.Context, s *solver.Solver, v *compiler.Value) (*compiler.Value, error) {
|
func (t *dockerfileTask) Run(ctx context.Context, pctx *plancontext.Context, s *solver.Solver, v *compiler.Value) (*compiler.Value, error) {
|
||||||
lg := log.Ctx(ctx)
|
lg := log.Ctx(ctx)
|
||||||
auths, err := v.Lookup("auth").Fields()
|
auths, err := v.Lookup("auth").Fields()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -75,7 +76,7 @@ func (t *DockerfileTask) Run(ctx context.Context, pctx *plancontext.Context, s *
|
|||||||
}
|
}
|
||||||
dockerfileDef, err = s.Marshal(ctx,
|
dockerfileDef, err = s.Marshal(ctx,
|
||||||
llb.Scratch().File(
|
llb.Scratch().File(
|
||||||
llb.Mkfile("/Dockerfile", 0o644, []byte(contents)),
|
llb.Mkfile("/Dockerfile", 0644, []byte(contents)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -138,7 +139,7 @@ func (t *DockerfileTask) Run(ctx context.Context, pctx *plancontext.Context, s *
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *DockerfileTask) dockerBuildOpts(v *compiler.Value, pctx *plancontext.Context) (map[string]string, error) {
|
func (t *dockerfileTask) dockerBuildOpts(v *compiler.Value, pctx *plancontext.Context) (map[string]string, error) {
|
||||||
opts := map[string]string{}
|
opts := map[string]string{}
|
||||||
|
|
||||||
if dockerfilePath := v.Lookup("dockerfile.path"); dockerfilePath.Exists() {
|
if dockerfilePath := v.Lookup("dockerfile.path"); dockerfilePath.Exists() {
|
||||||
|
@ -28,36 +28,13 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// State is the state of the task.
|
// State is the state of the task.
|
||||||
type State int8
|
type State string
|
||||||
|
|
||||||
func (s State) String() string {
|
|
||||||
return [...]string{"computing", "cancelled", "failed", "completed"}[s]
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseState(s string) (State, error) {
|
|
||||||
switch s {
|
|
||||||
case "computing":
|
|
||||||
return StateComputing, nil
|
|
||||||
case "cancelled":
|
|
||||||
return StateCanceled, nil
|
|
||||||
case "failed":
|
|
||||||
return StateFailed, nil
|
|
||||||
case "completed":
|
|
||||||
return StateCompleted, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1, fmt.Errorf("invalid state [%s]", s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s State) CanTransition(t State) bool {
|
|
||||||
return s == StateComputing && s <= t
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
StateComputing State = iota
|
StateComputing = State("computing")
|
||||||
StateCanceled
|
StateCanceled = State("canceled")
|
||||||
StateFailed
|
StateFailed = State("failed")
|
||||||
StateCompleted
|
StateCompleted = State("completed")
|
||||||
)
|
)
|
||||||
|
|
||||||
type NewFunc func() Task
|
type NewFunc func() Task
|
||||||
|
@ -12,10 +12,12 @@ import (
|
|||||||
"go.dagger.io/dagger/pkg"
|
"go.dagger.io/dagger/pkg"
|
||||||
)
|
)
|
||||||
|
|
||||||
var fsIDPath = cue.MakePath(
|
var (
|
||||||
cue.Str("$dagger"),
|
fsIDPath = cue.MakePath(
|
||||||
cue.Str("fs"),
|
cue.Str("$dagger"),
|
||||||
cue.Hid("_id", pkg.DaggerPackage),
|
cue.Str("fs"),
|
||||||
|
cue.Hid("_id", pkg.DaggerPackage),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsFSValue(v *compiler.Value) bool {
|
func IsFSValue(v *compiler.Value) bool {
|
||||||
|
@ -25,11 +25,9 @@ const (
|
|||||||
defaultDisplayTimeout = 100 * time.Millisecond
|
defaultDisplayTimeout = 100 * time.Millisecond
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type VertexPrintFunc func(v *client.Vertex, index int)
|
||||||
VertexPrintFunc func(v *client.Vertex, index int)
|
type StatusPrintFunc func(v *client.Vertex, format string, a ...interface{})
|
||||||
StatusPrintFunc func(v *client.Vertex, format string, a ...interface{})
|
type LogPrintFunc func(v *client.Vertex, stream int, partial bool, format string, a ...interface{})
|
||||||
LogPrintFunc func(v *client.Vertex, stream int, partial bool, format string, a ...interface{})
|
|
||||||
)
|
|
||||||
|
|
||||||
func PrintSolveStatus(ctx context.Context, ch chan *client.SolveStatus, vertexPrintCb VertexPrintFunc, statusPrintCb StatusPrintFunc, logPrintCb LogPrintFunc) error {
|
func PrintSolveStatus(ctx context.Context, ch chan *client.SolveStatus, vertexPrintCb VertexPrintFunc, statusPrintCb StatusPrintFunc, logPrintCb LogPrintFunc) error {
|
||||||
printer := &textMux{
|
printer := &textMux{
|
||||||
@ -150,10 +148,8 @@ func DisplaySolveStatus(ctx context.Context, phase string, c console.Console, w
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const termHeight = 6
|
||||||
termHeight = 6
|
const termPad = 10
|
||||||
termPad = 10
|
|
||||||
)
|
|
||||||
|
|
||||||
type displayInfo struct {
|
type displayInfo struct {
|
||||||
startTime time.Time
|
startTime time.Time
|
||||||
|
@ -11,12 +11,10 @@ import (
|
|||||||
"github.com/tonistiigi/units"
|
"github.com/tonistiigi/units"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const antiFlicker = 5 * time.Second
|
||||||
antiFlicker = 5 * time.Second
|
const maxDelay = 10 * time.Second
|
||||||
maxDelay = 10 * time.Second
|
const minTimeDelta = 5 * time.Second
|
||||||
minTimeDelta = 5 * time.Second
|
const minProgressDelta = 0.05 // %
|
||||||
minProgressDelta = 0.05 // %
|
|
||||||
)
|
|
||||||
|
|
||||||
type lastStatus struct {
|
type lastStatus struct {
|
||||||
Current int64
|
Current int64
|
||||||
|
@ -2842,9 +2842,9 @@ astral-regex@^2.0.0:
|
|||||||
integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==
|
integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==
|
||||||
|
|
||||||
async@^2.6.2:
|
async@^2.6.2:
|
||||||
version "2.6.4"
|
version "2.6.3"
|
||||||
resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221"
|
resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff"
|
||||||
integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==
|
integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==
|
||||||
dependencies:
|
dependencies:
|
||||||
lodash "^4.17.14"
|
lodash "^4.17.14"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user