removed dagger up in favor of dagger do

Signed-off-by: Richard Jones <richard@dagger.io>
This commit is contained in:
Richard Jones 2022-03-09 11:45:46 -07:00
parent 945b7293af
commit 6b81dc439d
No known key found for this signature in database
GPG Key ID: CFB3A382EB166F4C
34 changed files with 286 additions and 536 deletions

View File

@ -38,7 +38,6 @@ func init() {
}
rootCmd.AddCommand(
upCmd,
versionCmd,
docCmd,
doCmd,

View File

@ -1,98 +0,0 @@
package cmd
import (
"context"
"os"
"cuelang.org/go/cue"
"go.dagger.io/dagger/cmd/dagger/cmd/common"
"go.dagger.io/dagger/cmd/dagger/logger"
"go.dagger.io/dagger/plan"
"go.dagger.io/dagger/solver"
"golang.org/x/term"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var upCmd = &cobra.Command{
// FIXME: this command will be removed soon
Hidden: true,
Deprecated: "please use `dagger do ACTION` instead",
Use: "up",
Short: "Bring an environment online with latest plan and inputs",
Args: cobra.MaximumNArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
// Fix Viper bug for duplicate flags:
// https://github.com/spf13/viper/issues/233
if err := viper.BindPFlags(cmd.Flags()); err != nil {
panic(err)
}
},
Run: func(cmd *cobra.Command, args []string) {
var (
lg = logger.New()
tty *logger.TTYOutput
err error
)
if f := viper.GetString("log-format"); f == "tty" || f == "auto" && term.IsTerminal(int(os.Stdout.Fd())) {
tty, err = logger.NewTTYOutput(os.Stderr)
if err != nil {
lg.Fatal().Err(err).Msg("failed to initialize TTY logger")
}
tty.Start()
defer tty.Stop()
lg = lg.Output(tty)
}
ctx := lg.WithContext(cmd.Context())
cl := common.NewClient(ctx)
p, err := plan.Load(ctx, plan.Config{
Args: args,
With: viper.GetStringSlice("with"),
Target: viper.GetString("target"),
})
if err != nil {
lg.Fatal().Err(err).Msg("failed to load plan")
}
doneCh := common.TrackCommand(ctx, cmd)
err = cl.Do(ctx, p.Context(), func(ctx context.Context, s solver.Solver) error {
return p.Do(ctx, cue.ParsePath(viper.GetString("target")), s)
})
<-doneCh
if err != nil {
lg.Fatal().Err(err).Msg("failed to up environment")
}
},
}
// func checkUniverseVersion(ctx context.Context, projectPath string) bool {
// lg := log.Ctx(ctx)
// isLatest, err := mod.IsUniverseLatest(ctx, projectPath)
// if err != nil {
// lg.Debug().Err(err).Msg("failed to check universe version")
// return false
// }
// if !isLatest {
// return true
// }
// lg.Debug().Msg("universe is up to date")
// return false
// }
func init() {
upCmd.Flags().BoolP("force", "f", false, "Force up, disable inputs check")
upCmd.Flags().StringArrayP("with", "w", []string{}, "")
upCmd.Flags().StringP("target", "t", "", "Run a single target of the DAG (for debugging only)")
if err := viper.BindPFlags(upCmd.Flags()); err != nil {
panic(err)
}
}

View File

@ -4,5 +4,5 @@ setup() {
common_setup
}
@test "alpine" {
dagger up
dagger "do" -p ./test.cue test
}

View File

@ -8,7 +8,7 @@ import (
)
dagger.#Plan & {
actions: tests: {
actions: test: {
// Test: customize alpine version
alpineVersion: {
build: alpine.#Build & {

View File

@ -5,5 +5,5 @@ setup() {
}
@test "aws/cli" {
dagger up ./sts_get_caller_identity.cue
dagger "do" -p ./sts_get_caller_identity.cue verify
}

View File

@ -5,7 +5,7 @@ setup() {
}
@test "aws" {
dagger up ./default_version.cue
dagger up ./credentials.cue
dagger up ./config_file.cue
dagger "do" -p ./default_version.cue getVersion
dagger "do" -p ./credentials.cue verify
dagger "do" -p ./config_file.cue verify
}

View File

@ -5,6 +5,6 @@ setup() {
}
@test "bash" {
dagger up
dagger "do" -p ./test.cue test
}

View File

@ -8,7 +8,7 @@ import (
)
dagger.#Plan & {
actions: tests: {
actions: test: {
_pull: docker.#Pull & {
source: "index.docker.io/debian"

View File

@ -8,7 +8,7 @@ import (
)
dagger.#Plan & {
actions: tests: build: {
actions: test: build: {
// Test: simple docker.#Build
simple: {
#testValue: "hello world"

View File

@ -7,7 +7,7 @@ import (
dagger.#Plan & {
actions: tests: image: {
actions: test: image: {
// Test: change image config with docker.#Set
set: {

View File

@ -8,7 +8,7 @@ import (
)
dagger.#Plan & {
actions: tests: run: {
actions: test: run: {
_build: alpine.#Build
_image: _build.output

View File

@ -5,5 +5,5 @@ setup() {
}
@test "docker" {
dagger up
dagger "do" -p ./ test
}

View File

@ -10,7 +10,7 @@ import (
dagger.#Plan & {
client: filesystem: "./data/hello": read: contents: dagger.#FS
actions: tests: build: {
actions: test: {
_baseImage: alpine.#Build
simple: {

View File

@ -7,7 +7,7 @@ import (
)
dagger.#Plan & {
actions: tests: container: {
actions: test: {
_source: dagger.#Scratch & {}
simple: go.#Container & {

View File

@ -7,7 +7,7 @@ import (
)
dagger.#Plan & {
actions: tests: image: {
actions: test: {
_source: dagger.#Scratch & {}
simple: {

View File

@ -5,8 +5,8 @@ setup() {
}
@test "bash" {
dagger up ./build.cue
dagger up ./container.cue
dagger up ./image.cue
dagger up ./test.cue
dagger "do" -p ./build.cue test
dagger "do" -p ./container.cue test
dagger "do" -p ./image.cue test
dagger "do" -p ./test.cue test
}

View File

@ -8,7 +8,7 @@ import (
dagger.#Plan & {
client: filesystem: "./data/hello": read: contents: dagger.#FS
actions: tests: test: simple: go.#Test & {
actions: test: go.#Test & {
source: client.filesystem."./data/hello".read.contents
package: "./greeting"
}

View File

@ -5,5 +5,5 @@ setup() {
}
@test "netlify" {
dagger up
dagger "do" test
}

View File

@ -16,7 +16,7 @@ dagger.#Plan & {
stdout: dagger.#Secret
}
actions: tests: {
actions: test: {
// Configuration common to all tests
common: {

View File

@ -5,5 +5,5 @@ setup() {
}
@test "yarn" {
dagger up
dagger "do" test
}

View File

@ -13,7 +13,7 @@ dagger.#Plan & {
"./data/bar": read: contents: dagger.#FS
}
actions: tests: {
actions: test: {
// Configuration for all tests
common: {

View File

@ -198,12 +198,12 @@ setup() {
cd "$TESTDIR"
# Run with amd64 platform
run "$DAGGER" up ./plan/platform/config_platform_linux_amd64.cue
run "$DAGGER" "do" -p./plan/platform/config_platform_linux_amd64.cue verify
# Run with arm64 platform
run "$DAGGER" up ./plan/platform/config_platform_linux_arm64.cue
run "$DAGGER" "do" -p./plan/platform/config_platform_linux_arm64.cue verify
# Run with invalid platform
run "$DAGGER" up ./plan/platform/config_platform_failure_invalid_platform.cue
run "$DAGGER" "do" -p./plan/platform/config_platform_failure_invalid_platform.cue verify
assert_failure
}

View File

@ -2,153 +2,129 @@ setup() {
load 'helpers'
common_setup
cd "$TESTDIR" || exit
}
@test "task: #Pull" {
cd "$TESTDIR"/tasks/pull
"$DAGGER" up ./pull.cue
}
@test "task: #Pull with auth" {
cd "$TESTDIR"
"$DAGGER" up ./tasks/pull/pull_auth.cue
"$DAGGER" "do" -p ./tasks/pull/pull.cue pull
"$DAGGER" "do" -p ./tasks/pull/pull_auth.cue pull
}
@test "task: #Push" {
cd "$TESTDIR"
"$DAGGER" up ./tasks/push/push.cue
"$DAGGER" "do" -p ./tasks/push/push.cue pullContent
}
@test "task: #ReadFile" {
cd "$TESTDIR"/tasks/readfile
"$DAGGER" up
"$DAGGER" "do" -p ./tasks/readfile/readfile.cue readfile
}
@test "task: #WriteFile" {
cd "$TESTDIR"/tasks/writefile
"$DAGGER" up ./writefile.cue
}
@test "task: #WriteFile failure: different contents" {
cd "$TESTDIR"/tasks/writefile
run "$DAGGER" up ./writefile_failure_diff_contents.cue
"$DAGGER" "do" -p ./tasks/writefile/writefile.cue readfile
run "$DAGGER" "do" -p ./tasks/writefile/writefile_failure_diff_contents.cue readfile
assert_failure
}
@test "task: #Exec" {
cd "$TESTDIR"/tasks/exec
"$DAGGER" up ./args.cue
"$DAGGER" up ./env.cue
"$DAGGER" up ./env_secret.cue
"$DAGGER" up ./hosts.cue
cd ./tasks/exec
"$DAGGER" "do" -p ./args.cue verify
"$DAGGER" "do" -p ./env.cue verify
"$DAGGER" "do" -p ./env_secret.cue verify
"$DAGGER" "do" -p ./hosts.cue verify
"$DAGGER" up ./mount_cache.cue
"$DAGGER" up ./mount_fs.cue
TESTSECRET="hello world" "$DAGGER" up ./mount_secret.cue
"$DAGGER" up ./mount_tmp.cue
"$DAGGER" up ./mount_service.cue
"$DAGGER" "do" -p ./mount_cache.cue test
"$DAGGER" "do" -p ./mount_fs.cue test
TESTSECRET="hello world" "$DAGGER" "do" -p ./mount_secret.cue test
"$DAGGER" "do" -p ./mount_tmp.cue verify
"$DAGGER" "do" -p ./mount_service.cue verify
"$DAGGER" up ./user.cue
"$DAGGER" up ./workdir.cue
"$DAGGER" "do" -p ./user.cue test
"$DAGGER" "do" -p ./workdir.cue verify
}
@test "task: #Copy" {
cd "$TESTDIR"/tasks/copy
"$DAGGER" up ./copy_exec.cue
"$DAGGER" up ./copy_file.cue
"$DAGGER" "do" -p ./tasks/copy/copy_exec.cue test
"$DAGGER" "do" -p ./tasks/copy/copy_file.cue test
run "$DAGGER" up ./copy_exec_invalid.cue
run "$DAGGER" "do" -p ./tasks/copy/copy_exec_invalid.cue test
assert_failure
}
@test "task: #Mkdir" {
# Make directory
cd "$TESTDIR"/tasks/mkdir
"$DAGGER" up ./mkdir.cue
"$DAGGER" "do" -p ./tasks/mkdir/mkdir.cue readChecker
# Create parents
cd "$TESTDIR"/tasks/mkdir
"$DAGGER" up ./mkdir_parents.cue
"$DAGGER" "do" -p ./tasks/mkdir/mkdir_parents.cue readChecker
# Disable parents creation
cd "$TESTDIR"/tasks/mkdir
run "$DAGGER" up ./mkdir_failure_disable_parents.cue
run "$DAGGER" "do" -p ./tasks/mkdir/mkdir_failure_disable_parents.cue readChecker
assert_failure
}
@test "task: #Dockerfile" {
cd "$TESTDIR"/tasks/dockerfile
"$DAGGER" up ./dockerfile.cue
"$DAGGER" up ./inlined_dockerfile.cue
"$DAGGER" up ./inlined_dockerfile_heredoc.cue
"$DAGGER" up ./dockerfile_path.cue
"$DAGGER" up ./build_args.cue
"$DAGGER" up ./image_config.cue
"$DAGGER" up ./labels.cue
"$DAGGER" up ./platform.cue
"$DAGGER" up ./build_auth.cue
"$DAGGER" "do" -p ./dockerfile.cue
"$DAGGER" "do" -p ./inlined_dockerfile.cue verify
"$DAGGER" "do" -p ./inlined_dockerfile_heredoc.cue verify
"$DAGGER" "do" -p ./dockerfile_path.cue verify
"$DAGGER" "do" -p ./build_args.cue build
"$DAGGER" "do" -p ./image_config.cue build
"$DAGGER" "do" -p ./labels.cue build
"$DAGGER" "do" -p ./platform.cue build
"$DAGGER" "do" -p ./build_auth.cue build
}
@test "task: #Scratch" {
cd "$TESTDIR"/tasks/scratch
"$DAGGER" up ./scratch.cue -l debug
"$DAGGER" up ./scratch_build_scratch.cue -l debug
"$DAGGER" up ./scratch_writefile.cue -l debug
"$DAGGER" "do" -p ./tasks/scratch/scratch.cue exec
"$DAGGER" "do" -p ./tasks/scratch/scratch_build_scratch.cue build
"$DAGGER" "do" -p ./tasks/scratch/scratch_writefile.cue readfile
}
@test "task: #Subdir" {
cd "$TESTDIR"/tasks/subdir
"$DAGGER" up ./subdir_simple.cue
"$DAGGER" "do" -p ./tasks/subdir/subdir_simple.cue verify
run "$DAGGER" up ./subdir_invalid_path.cue
run "$DAGGER" "do" -p ./tasks/subdir/subdir_invalid_path.cue verify
assert_failure
run "$DAGGER" up ./subdir_invalid_exec.cue
run "$DAGGER" "do" -p ./tasks/subdir/subdir_invalid_exec.cue verify
assert_failure
}
@test "task: #GitPull" {
cd "$TESTDIR"
"$DAGGER" up ./tasks/gitpull/exists.cue
"$DAGGER" up ./tasks/gitpull/git_dir.cue
"$DAGGER" up ./tasks/gitpull/private_repo.cue
"$DAGGER" "do" -p ./tasks/gitpull/exists.cue gitPull
"$DAGGER" "do" -p ./tasks/gitpull/git_dir.cue verify
"$DAGGER" "do" -p ./tasks/gitpull/private_repo.cue testContent
run "$DAGGER" up ./tasks/gitpull/invalid.cue
run "$DAGGER" "do" -p ./tasks/gitpull/invalid.cue invalid
assert_failure
run "$DAGGER" up ./tasks/gitpull/bad_remote.cue
run "$DAGGER" "do" -p ./tasks/gitpull/bad_remote.cue badremote
assert_failure
run "$DAGGER" up ./tasks/gitpull/bad_ref.cue
run "$DAGGER" "do" -p ./tasks/gitpull/bad_ref.cue badref
assert_failure
}
@test "task: #HTTPFetch" {
cd "$TESTDIR"
"$DAGGER" up ./tasks/httpfetch/exist.cue
run "$DAGGER" up ./tasks/httpfetch/not_exist.cue
"$DAGGER" "do" -p ./tasks/httpfetch/exist.cue fetch
run "$DAGGER" "do" -p ./tasks/httpfetch/not_exist.cue fetch
assert_failure
}
@test "task: #NewSecret" {
cd "$TESTDIR"/tasks/newsecret
"$DAGGER" up ./newsecret.cue
"$DAGGER" "do" -p ./tasks/newsecret/newsecret.cue verify
}
@test "task: #TrimSecret" {
cd "$TESTDIR"/tasks/trimsecret
"$DAGGER" up ./trimsecret.cue
"$DAGGER" "do" -p ./tasks/trimsecret/trimsecret.cue verify
}
@test "task: #Source" {
cd "$TESTDIR"/tasks/source
"$DAGGER" up ./source.cue
"$DAGGER" up ./source_include_exclude.cue
"$DAGGER" up ./source_relative.cue
"$DAGGER" "do" -p ./tasks/source/source.cue test
"$DAGGER" "do" -p ./tasks/source/source_include_exclude.cue test
"$DAGGER" "do" -p ./tasks/source/source_relative.cue verifyHello
run "$DAGGER" up ./source_invalid_path.cue
run "$DAGGER" "do" -p ./tasks/source/source_invalid_path.cue source
assert_failure
run "$DAGGER" up ./source_not_exist.cue
run "$DAGGER" "do" -p ./tasks/source/source_not_exist.cue source
assert_failure
}

View File

@ -19,7 +19,7 @@ dagger.#Plan & {
"""#,
]
}
test: {
verify_file: dagger.#ReadFile & {
input: exec.output
path: "/output.txt"
@ -44,3 +44,4 @@ dagger.#Plan & {
}
}
}
}

View File

@ -20,6 +20,7 @@ dagger.#Plan & {
]
}
test: {
verify_file: dagger.#ReadFile & {
input: exec.output
path: "/output.txt"
@ -43,3 +44,4 @@ dagger.#Plan & {
}
}
}
}

View File

@ -14,6 +14,7 @@ dagger.#Plan & {
source: "busybox:1.34.1-glibc@sha256:ec98391b8f0911db08be2ee6c46813eeac17b9625b402ea1ce45dcfcd05d78d6"
}
test: {
verify_alpine_3_15_0: dagger.#ReadFile & {
input: alpine3_15_0.output
path: "/etc/alpine-release"
@ -38,3 +39,4 @@ dagger.#Plan & {
}
}
}
}

View File

@ -22,73 +22,3 @@ dagger.#Plan & {
}
}
}
// TestDockerfilePath: #up: [
// op.#DockerBuild & {
// context: TestData
// dockerfilePath: "./dockerfilepath/Dockerfile.custom"
// },
// op.#Exec & {
// args: ["sh", "-c", "test $(cat /test) = dockerfilePath"]
// },
// ]
// TestBuildArgs: #up: [
// op.#DockerBuild & {
// dockerfile: """
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
// ARG TEST=foo
// RUN test "${TEST}" = "bar"
// """
// buildArg: TEST: "bar"
// },
// ]
// // FIXME: this doesn't test anything beside not crashing
// TestBuildLabels: #up: [
// op.#DockerBuild & {
// dockerfile: """
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
// """
// label: FOO: "bar"
// },
// ]
// // FIXME: this doesn't test anything beside not crashing
// TestBuildPlatform: #up: [
// op.#DockerBuild & {
// dockerfile: """
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
// """
// platforms: ["linux/amd64"]
// },
// ]
// TestImageMetadata: #up: [
// op.#DockerBuild & {
// dockerfile: """
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
// ENV CHECK foobar
// ENV DOUBLECHECK test
// """
// },
// op.#Exec & {
// args: ["sh", "-c", #"""
// env
// test "$CHECK" = "foobar"
// """#]
// },
// ]
// // Make sure the metadata is carried over with a `Load`
// TestImageMetadataIndirect: #up: [
// op.#Load & {
// from: TestImageMetadata
// },
// op.#Exec & {
// args: ["sh", "-c", #"""
// env
// test "$DOUBLECHECK" = "test"
// """#]
// },
// ]

View File

@ -23,73 +23,3 @@ dagger.#Plan & {
}
}
}
// TestDockerfilePath: #up: [
// op.#DockerBuild & {
// context: TestData
// dockerfilePath: "./dockerfilepath/Dockerfile.custom"
// },
// op.#Exec & {
// args: ["sh", "-c", "test $(cat /test) = dockerfilePath"]
// },
// ]
// TestBuildArgs: #up: [
// op.#DockerBuild & {
// dockerfile: """
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
// ARG TEST=foo
// RUN test "${TEST}" = "bar"
// """
// buildArg: TEST: "bar"
// },
// ]
// // FIXME: this doesn't test anything beside not crashing
// TestBuildLabels: #up: [
// op.#DockerBuild & {
// dockerfile: """
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
// """
// label: FOO: "bar"
// },
// ]
// // FIXME: this doesn't test anything beside not crashing
// TestBuildPlatform: #up: [
// op.#DockerBuild & {
// dockerfile: """
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
// """
// platforms: ["linux/amd64"]
// },
// ]
// TestImageMetadata: #up: [
// op.#DockerBuild & {
// dockerfile: """
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
// ENV CHECK foobar
// ENV DOUBLECHECK test
// """
// },
// op.#Exec & {
// args: ["sh", "-c", #"""
// env
// test "$CHECK" = "foobar"
// """#]
// },
// ]
// // Make sure the metadata is carried over with a `Load`
// TestImageMetadataIndirect: #up: [
// op.#Load & {
// from: TestImageMetadata
// },
// op.#Exec & {
// args: ["sh", "-c", #"""
// env
// test "$DOUBLECHECK" = "test"
// """#]
// },
// ]

View File

@ -6,6 +6,7 @@ import (
dagger.#Plan & {
client: filesystem: "secret.txt": read: contents: dagger.#Secret
actions: {
image: dagger.#Pull & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"

View File

@ -28,6 +28,7 @@ dagger.#Plan & {
]
}
test: {
verify: dagger.#Exec & {
input: image.output
mounts: cache: {
@ -61,3 +62,4 @@ dagger.#Plan & {
}
}
}
}

View File

@ -20,6 +20,7 @@ dagger.#Plan & {
]
}
test: {
verify: dagger.#Exec & {
input: image.output
mounts: fs: {
@ -69,3 +70,4 @@ dagger.#Plan & {
}
}
}
}

View File

@ -11,6 +11,7 @@ dagger.#Plan & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3"
}
test: {
verify: dagger.#Exec & {
input: image.output
mounts: secret: {
@ -44,6 +45,6 @@ dagger.#Plan & {
"""#,
]
}
}
}
}

View File

@ -14,7 +14,7 @@ dagger.#Plan & {
input: image.output
args: ["adduser", "-D", "test"]
}
test: {
verifyUsername: dagger.#Exec & {
input: addUser.output
user: "test"
@ -36,6 +36,6 @@ dagger.#Plan & {
"""#,
]
}
}
}
}

View File

@ -23,6 +23,7 @@ dagger.#Plan & {
args: ["/src/test.sh"]
}
test: {
verifyHello: dagger.#ReadFile & {
input: source.output
path: "/world.txt"
@ -40,3 +41,4 @@ dagger.#Plan & {
}
}
}
}