Skip to content

Commit f556d9c

Browse files
authored
Merge pull request #301 from covexo/examples
Examples
2 parents 0663c79 + b2c9567 commit f556d9c

3 files changed

Lines changed: 63 additions & 58 deletions

File tree

cmd/up.go

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,36 @@ type UpCmd struct {
3636

3737
// UpCmdFlags are the flags available for the up-command
3838
type UpCmdFlags struct {
39-
tiller bool
40-
open string
41-
initRegistries bool
42-
build bool
43-
sync bool
44-
deploy bool
45-
skipBuild bool
46-
switchContext bool
47-
portforwarding bool
48-
verboseSync bool
49-
container string
50-
labelSelector string
51-
namespace string
39+
tiller bool
40+
open string
41+
initRegistries bool
42+
build bool
43+
sync bool
44+
deploy bool
45+
exitAfterDeploy bool
46+
switchContext bool
47+
portforwarding bool
48+
verboseSync bool
49+
container string
50+
labelSelector string
51+
namespace string
5252
}
5353

5454
//UpFlagsDefault are the default flags for UpCmdFlags
5555
var UpFlagsDefault = &UpCmdFlags{
56-
tiller: true,
57-
open: "cmd",
58-
initRegistries: true,
59-
build: false,
60-
sync: true,
61-
switchContext: false,
62-
skipBuild: false,
63-
deploy: false,
64-
portforwarding: true,
65-
verboseSync: false,
66-
container: "",
67-
namespace: "",
68-
labelSelector: "",
56+
tiller: true,
57+
open: "cmd",
58+
initRegistries: true,
59+
build: false,
60+
sync: true,
61+
switchContext: false,
62+
exitAfterDeploy: false,
63+
deploy: false,
64+
portforwarding: true,
65+
verboseSync: false,
66+
container: "",
67+
namespace: "",
68+
labelSelector: "",
6969
}
7070

7171
const clusterRoleBindingName = "devspace-users"
@@ -102,7 +102,7 @@ Starts and connects your DevSpace:
102102
cobraCmd.Flags().BoolVar(&cmd.flags.portforwarding, "portforwarding", cmd.flags.portforwarding, "Enable port forwarding")
103103
cobraCmd.Flags().BoolVarP(&cmd.flags.deploy, "deploy", "d", cmd.flags.deploy, "Force chart deployment")
104104
cobraCmd.Flags().BoolVar(&cmd.flags.switchContext, "switch-context", cmd.flags.switchContext, "Switch kubectl context to the devspace context")
105-
cobraCmd.Flags().BoolVar(&cmd.flags.skipBuild, "skip-build", cmd.flags.skipBuild, "Forces devspace to skip the building step")
105+
cobraCmd.Flags().BoolVar(&cmd.flags.exitAfterDeploy, "exit-after-deploy", cmd.flags.exitAfterDeploy, "Exits the command after building the images and deploying the devspace")
106106
cobraCmd.Flags().StringVarP(&cmd.flags.namespace, "namespace", "n", "", "Namespace where to select pods")
107107
cobraCmd.Flags().StringVarP(&cmd.flags.labelSelector, "label-selector", "l", "", "Comma separated key=value selector list (e.g. release=test)")
108108
}
@@ -147,27 +147,9 @@ func (cmd *UpCmd) Run(cobraCmd *cobra.Command, args []string) {
147147

148148
cmd.buildAndDeploy()
149149

150-
if cmd.flags.portforwarding {
151-
err := services.StartPortForwarding(cmd.kubectl, log.GetInstance())
152-
if err != nil {
153-
log.Fatalf("Unable to start portforwarding: %v", err)
154-
}
150+
if cmd.flags.exitAfterDeploy == false {
151+
cmd.startServices(args)
155152
}
156-
157-
if cmd.flags.sync {
158-
syncConfigs, err := services.StartSync(cmd.kubectl, cmd.flags.verboseSync, log.GetInstance())
159-
if err != nil {
160-
log.Fatalf("Unable to start sync: %v", err)
161-
}
162-
163-
defer func() {
164-
for _, v := range syncConfigs {
165-
v.Stop(nil)
166-
}
167-
}()
168-
}
169-
170-
services.StartTerminal(cmd.kubectl, cmd.flags.container, cmd.flags.labelSelector, cmd.flags.namespace, args, log.GetInstance())
171153
}
172154

173155
func (cmd *UpCmd) ensureNamespace() error {
@@ -393,20 +375,42 @@ func (cmd *UpCmd) buildAndDeploy() {
393375
func (cmd *UpCmd) buildImages(generatedConfig *generated.Config) bool {
394376
re := false
395377

396-
if cmd.flags.skipBuild == false {
397-
config := configutil.GetConfig()
378+
config := configutil.GetConfig()
398379

399-
for imageName, imageConf := range *config.Images {
400-
shouldRebuild, err := image.Build(cmd.kubectl, generatedConfig, imageName, imageConf, cmd.flags.build)
401-
if err != nil {
402-
log.Fatal(err)
403-
}
380+
for imageName, imageConf := range *config.Images {
381+
shouldRebuild, err := image.Build(cmd.kubectl, generatedConfig, imageName, imageConf, cmd.flags.build)
382+
if err != nil {
383+
log.Fatal(err)
384+
}
404385

405-
if shouldRebuild {
406-
re = true
407-
}
386+
if shouldRebuild {
387+
re = true
408388
}
409389
}
410390

411391
return re
412392
}
393+
394+
func (cmd *UpCmd) startServices(args []string) {
395+
if cmd.flags.portforwarding {
396+
err := services.StartPortForwarding(cmd.kubectl, log.GetInstance())
397+
if err != nil {
398+
log.Fatalf("Unable to start portforwarding: %v", err)
399+
}
400+
}
401+
402+
if cmd.flags.sync {
403+
syncConfigs, err := services.StartSync(cmd.kubectl, cmd.flags.verboseSync, log.GetInstance())
404+
if err != nil {
405+
log.Fatalf("Unable to start sync: %v", err)
406+
}
407+
408+
defer func() {
409+
for _, v := range syncConfigs {
410+
v.Stop(nil)
411+
}
412+
}()
413+
}
414+
415+
services.StartTerminal(cmd.kubectl, cmd.flags.container, cmd.flags.labelSelector, cmd.flags.namespace, args, log.GetInstance())
416+
}

docs/docs/cli/up.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Flags:
2020
-b, --build Force image build
2121
-c, --container string Container name where to open the shell
2222
-d, --deploy Force chart deployment
23+
--exit-after-deploy Exits the command after building the images and deploying the devspace
2324
-h, --help help for up
2425
--init-registries Initialize registries (and install internal one) (default true)
2526
-l, --label-selector string Comma separated key=value selector list (e.g. release=test)

pkg/devspace/cloud/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const GetClusterConfigEndpoint = "/clusterConfig"
4040

4141
// DevSpaceCloudProviderConfig holds the information for the devspace-cloud
4242
var DevSpaceCloudProviderConfig = &Provider{
43-
Host: "https://cli.devspace-cloud.com",
43+
Host: "http://cli.devspace-cloud.com",
4444
}
4545

4646
// ParseCloudConfig parses the cloud configuration and returns a map containing the configurations

0 commit comments

Comments
 (0)