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
2 changes: 1 addition & 1 deletion cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (cmd *DeployCmd) Run(cobraCmd *cobra.Command, args []string) {
// Print domain name if we use a cloud provider
// TODO: Change this
if cloud.DevSpaceURL != "" {
log.Infof("Your DevSpace is now reachable via ingress on this URL: http://%s", cloud.DevSpaceURL)
log.Infof("Your LiveSpace is now reachable via ingress on this URL: http://%s", cloud.DevSpaceURL)
log.Info("See https://devspace-cloud.com/domain-guide for more information")
}

Expand Down
15 changes: 14 additions & 1 deletion cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type UpCmdFlags struct {
initRegistries bool
build bool
sync bool
terminal bool
deploy bool
exitAfterDeploy bool
allyes bool
Expand All @@ -50,6 +51,7 @@ var UpFlagsDefault = &UpCmdFlags{
initRegistries: true,
build: false,
sync: true,
terminal: true,
switchContext: false,
exitAfterDeploy: false,
allyes: false,
Expand Down Expand Up @@ -90,6 +92,7 @@ Starts and connects your DevSpace:
cobraCmd.Flags().BoolVar(&cmd.flags.sync, "sync", cmd.flags.sync, "Enable code synchronization")
cobraCmd.Flags().BoolVar(&cmd.flags.verboseSync, "verbose-sync", cmd.flags.verboseSync, "When enabled the sync will log every file change")
cobraCmd.Flags().BoolVar(&cmd.flags.portforwarding, "portforwarding", cmd.flags.portforwarding, "Enable port forwarding")
cobraCmd.Flags().BoolVar(&cmd.flags.terminal, "terminal", cmd.flags.terminal, "Enable terminal")
cobraCmd.Flags().BoolVarP(&cmd.flags.deploy, "deploy", "d", cmd.flags.deploy, "Force chart deployment")
cobraCmd.Flags().BoolVar(&cmd.flags.switchContext, "switch-context", cmd.flags.switchContext, "Switch kubectl context to the devspace context")
cobraCmd.Flags().BoolVar(&cmd.flags.exitAfterDeploy, "exit-after-deploy", cmd.flags.exitAfterDeploy, "Exits the command after building the images and deploying the devspace")
Expand Down Expand Up @@ -251,5 +254,15 @@ func startServices(flags *UpCmdFlags, kubectl *kubernetes.Clientset, args []stri
log.Info("See https://devspace-cloud.com/domain-guide for more information")
}

return services.StartTerminal(kubectl, flags.service, flags.container, flags.labelSelector, flags.namespace, args, log)
config := configutil.GetConfig()

if flags.terminal && (config.DevSpace == nil || config.DevSpace.Terminal == nil || config.DevSpace.Terminal.Disabled == nil || *config.DevSpace.Terminal.Disabled == false) {
return services.StartTerminal(kubectl, flags.service, flags.container, flags.labelSelector, flags.namespace, args, log)
} else if config.DevSpace != nil && ((flags.portforwarding && config.DevSpace.Ports != nil && len(*config.DevSpace.Ports) > 0) || (flags.sync && config.DevSpace.Sync != nil && len(*config.DevSpace.Sync) > 0)) {
log.Done("Services started (Press Ctrl+C to abort port-forwarding and sync)")

<-make(chan bool)
}

return nil
}
4 changes: 4 additions & 0 deletions docs/docs/configuration/config.yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ These services can be referenced within other config options (e.g. terminal, por

### devspace.terminal
In this section options are defined, what should happen when devspace up or devspace enter try to open a terminal. By default, devspace will select pods with the labels `release=devspace-default` and try to start a bash or sh terminal in the container.
- `disabled` *bool* if true no terminal will be opened on `devspace up` and `devspace enter`
- `service` *string* DevSpace service to start the terminal for (use either service OR namespace, labelSelector, containerName)
- `namespace` *string* the namespace where to select pods from
- `labelSelector` *map[string]string* a key value map with the labels to select the correct pod (default: release: devspace-default)
Expand Down Expand Up @@ -217,6 +218,9 @@ devSpace:
resourceType: pod
# terminal options for devspace up and devspace enter
terminal:
# if you don't want devspace to automatically open a terminal for
# you set disabled to true
disabled: false
# define the service to start the terminal for
service: default
# Alternative to using a service is to
Expand Down
23 changes: 23 additions & 0 deletions pkg/devspace/builder/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"context"
"encoding/base64"
"encoding/json"
"os"
"path/filepath"
"strings"

dockerclient "github.com/covexo/devspace/pkg/devspace/docker"

Expand Down Expand Up @@ -84,6 +87,18 @@ func (b *Builder) BuildImage(contextPath, dockerfilePath string, options *types.
return err
}

var dockerfileCtx *os.File

// Dockerfile is out of context
if err == nil && strings.HasPrefix(relDockerfile, ".."+string(filepath.Separator)) {
// Dockerfile is outside of build-context; read the Dockerfile and pass it as dockerfileCtx
dockerfileCtx, err = os.Open(dockerfilePath)
if err != nil {
return errors.Errorf("unable to open Dockerfile: %v", err)
}
defer dockerfileCtx.Close()
}

excludes, err := build.ReadDockerignore(contextDir)
if err != nil {
return err
Expand All @@ -109,6 +124,14 @@ func (b *Builder) BuildImage(contextPath, dockerfilePath string, options *types.
return err
}

// replace Dockerfile if it was added from stdin or a file outside the build-context, and there is archive context
if dockerfileCtx != nil && buildCtx != nil {
buildCtx, relDockerfile, err = build.AddDockerfileToBuildContext(dockerfileCtx, buildCtx)
if err != nil {
return err
}
}

// Setup an upload progress bar
progressOutput := streamformatter.NewProgressOutput(outStream)
body := progress.NewProgressReader(buildCtx, progressOutput, 0, "", "Sending build context to Docker daemon")
Expand Down
1 change: 1 addition & 0 deletions pkg/devspace/config/v1/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1

// Terminal describes the terminal options
type Terminal struct {
Disabled *bool `yaml:"disabled,omitempty"`
Service *string `yaml:"service,omitempty"`
ResourceType *string `yaml:"resourceType"`
LabelSelector *map[string]*string `yaml:"labelSelector"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/devspace/configure/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func Image(dockerUsername string, skipQuestions bool, registryURL, defaultImageN

createPullSecret = createPullSecret || *stdinutil.GetFromStdin(&stdinutil.GetFromStdinParams{
Question: "Do you want to enable automatic creation of pull secrets for this image? (yes | no)",
DefaultValue: "no",
DefaultValue: "yes",
ValidationRegexPattern: "^(yes|no)$",
}) == "yes"
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/devspace/services/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func StartTerminal(client *kubernetes.Clientset, serviceNameOverride, containerN
pod, err := kubectl.GetNewestRunningPod(client, labelSelector, namespace)
log.StopWait()
if err != nil {
return fmt.Errorf("Cannot find running pod: %v", err)
return fmt.Errorf("Error starting terminal: Cannot find running pod: %v", err)
}

// Get container name
Expand Down