Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions cmd/config/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/devsy-org/devsy/pkg/devcontainer/feature"
"github.com/devsy-org/devsy/pkg/docker"
cliflags "github.com/devsy-org/devsy/pkg/flags"
"github.com/devsy-org/devsy/pkg/flags/names"
"github.com/devsy-org/devsy/pkg/log"
"github.com/devsy-org/devsy/pkg/output"
"github.com/devsy-org/devsy/pkg/types"
Expand All @@ -24,11 +25,6 @@ import (
)

const (
flagApplyContainer = "container"
flagApplyConfig = "config"
flagApplyWorkspaceFolder = "workspace-folder"
flagApplyDockerPath = "docker-path"

hookOnCreate = "onCreateCommand"
hookUpdateContent = "updateContentCommand"
hookPostCreate = "postCreateCommand"
Expand Down Expand Up @@ -56,16 +52,16 @@ func NewApplyCmd(f *flags.GlobalFlags) *cobra.Command {
}

cliflags.Add(applyCmd,
cliflags.String(&cmd.Container, flagApplyContainer, "",
cliflags.String(&cmd.Container, names.Container, "",
"The container ID or name to apply configuration to (required)"),
cliflags.String(&cmd.Config, flagApplyConfig, "",
cliflags.String(&cmd.Config, names.Config, "",
"Path to devcontainer.json (defaults to auto-detection in current workspace)"),
cliflags.String(&cmd.WorkspaceFolder, flagApplyWorkspaceFolder, "",
cliflags.String(&cmd.WorkspaceFolder, names.WorkspaceFolder, "",
"Workspace folder path inside the container"),
cliflags.String(&cmd.DockerPath, flagApplyDockerPath, "",
cliflags.String(&cmd.DockerPath, names.DockerPath, "",
"Path to the docker/podman executable (defaults to 'docker')"),
)
_ = applyCmd.MarkFlagRequired(flagApplyContainer)
_ = applyCmd.MarkFlagRequired(names.Container)

return applyCmd
}
Expand Down
11 changes: 6 additions & 5 deletions cmd/config/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/devsy-org/devsy/cmd/flags"
"github.com/devsy-org/devsy/pkg/flags/names"
"github.com/devsy-org/devsy/pkg/workspace"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -27,30 +28,30 @@ func TestNewApplyCmd_CommandName(t *testing.T) {

func TestNewApplyCmd_ContainerFlagRequired(t *testing.T) {
cmd := NewApplyCmd(&flags.GlobalFlags{})
f := cmd.Flags().Lookup(flagApplyContainer)
f := cmd.Flags().Lookup(names.Container)
require.NotNil(t, f)

annotations := cmd.MarkFlagRequired(flagApplyContainer)
annotations := cmd.MarkFlagRequired(names.Container)
assert.NoError(t, annotations)
}

func TestNewApplyCmd_ConfigFlagOptional(t *testing.T) {
cmd := NewApplyCmd(&flags.GlobalFlags{})
f := cmd.Flags().Lookup(flagApplyConfig)
f := cmd.Flags().Lookup(names.Config)
require.NotNil(t, f)
assert.Equal(t, "", f.DefValue)
}

func TestNewApplyCmd_WorkspaceFolderFlagOptional(t *testing.T) {
cmd := NewApplyCmd(&flags.GlobalFlags{})
f := cmd.Flags().Lookup(flagApplyWorkspaceFolder)
f := cmd.Flags().Lookup(names.WorkspaceFolder)
require.NotNil(t, f)
assert.Equal(t, "", f.DefValue)
}

func TestNewApplyCmd_DockerPathFlagOptional(t *testing.T) {
cmd := NewApplyCmd(&flags.GlobalFlags{})
f := cmd.Flags().Lookup(flagApplyDockerPath)
f := cmd.Flags().Lookup(names.DockerPath)
require.NotNil(t, f)
assert.Equal(t, "", f.DefValue)
}
Expand Down
Loading