Skip to content

Commit 02ad8fd

Browse files
committed
initial
1 parent 2155433 commit 02ad8fd

File tree

1,891 files changed

+690272
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,891 files changed

+690272
-0
lines changed

.github/workflows/release.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Test & Release CLI Version
2+
3+
on:
4+
release:
5+
types: [created]
6+
push:
7+
branches:
8+
- master
9+
paths:
10+
- "**.go"
11+
- "hack/coverage.bash"
12+
- ".github/workflows/release.yaml"
13+
pull_request:
14+
branches:
15+
- master
16+
paths:
17+
- "**.go"
18+
- "hack/coverage.bash"
19+
- ".github/workflows/release.yaml"
20+
21+
jobs:
22+
test-linux:
23+
runs-on: ubuntu-18.04
24+
steps:
25+
- name: Set up Go 1.13
26+
uses: actions/setup-go@v1
27+
with:
28+
go-version: 1.13
29+
- name: Check out code into the Go module directory
30+
uses: actions/checkout@v1
31+
- name: Test
32+
run: ./hack/coverage.bash
33+
test-windows:
34+
if: github.ref != 'refs/heads/master'
35+
runs-on: windows-2019
36+
steps:
37+
- name: Set up Go 1.13
38+
uses: actions/setup-go@v1
39+
with:
40+
go-version: 1.13
41+
- name: Check out code into the Go module directory
42+
uses: actions/checkout@v1
43+
- name: Test
44+
run: ./hack/coverage.bash
45+
shell: bash
46+
release:
47+
if: startsWith(github.ref, 'refs/tags/v') == true
48+
needs: [test-linux]
49+
runs-on: macOS-latest
50+
steps:
51+
- name: Set up Go 1.13
52+
uses: actions/setup-go@v1
53+
with:
54+
go-version: 1.13
55+
- name: Check out code into the Go module directory
56+
uses: actions/checkout@v1
57+
- name: Compile binaries
58+
run: ./hack/build-all.bash
59+
- name: Publish
60+
uses: FabianKramm/release-asset-action@v1
61+
with:
62+
pattern: "release/*"
63+
github-token: ${{ secrets.GITHUB_TOKEN }}

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/devspace-cloud-plugin.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/flags/flags.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package flags
2+
3+
import (
4+
flag "github.com/spf13/pflag"
5+
)
6+
7+
// GlobalFlags is the flags that contains the global flags
8+
type GlobalFlags struct {
9+
Silent bool
10+
Debug bool
11+
12+
Flags *flag.FlagSet
13+
}
14+
15+
// SetGlobalFlags applies the global flags
16+
func SetGlobalFlags(flags *flag.FlagSet) *GlobalFlags {
17+
globalFlags := &GlobalFlags{
18+
Flags: flags,
19+
}
20+
21+
flags.BoolVar(&globalFlags.Debug, "debug", false, "Prints the stack trace if an error occurs")
22+
flags.BoolVar(&globalFlags.Silent, "silent", false, "Run in silent mode and prevents any devspace log output except panics & fatals")
23+
24+
return globalFlags
25+
}

cmd/root.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package cmd
2+
3+
import (
4+
"github.com/devspace-cloud/devspace-cloud-plugin/cmd/flags"
5+
"github.com/devspace-cloud/devspace-cloud-plugin/pkg/upgrade"
6+
"github.com/devspace-cloud/devspace/pkg/util/exit"
7+
flagspkg "github.com/devspace-cloud/devspace/pkg/util/flags"
8+
"github.com/devspace-cloud/devspace/pkg/util/log"
9+
"github.com/pkg/errors"
10+
"github.com/sirupsen/logrus"
11+
"github.com/spf13/cobra"
12+
"os"
13+
"strings"
14+
)
15+
16+
// NewRootCmd returns a new root command
17+
func NewRootCmd() *cobra.Command {
18+
return &cobra.Command{
19+
Use: "devspace-cloud-plugin",
20+
SilenceUsage: true,
21+
SilenceErrors: true,
22+
Short: "Welcome to the DevSpace Cloud!",
23+
PersistentPreRun: func(cobraCmd *cobra.Command, args []string) {
24+
log := log.GetInstance()
25+
if globalFlags.Silent {
26+
log.SetLevel(logrus.FatalLevel)
27+
}
28+
29+
// apply extra flags
30+
if cobraCmd.DisableFlagParsing == false {
31+
extraFlags, err := flagspkg.ApplyExtraFlags(cobraCmd, os.Args, false)
32+
if err != nil {
33+
log.Warnf("Error applying extra flags: %v", err)
34+
} else if len(extraFlags) > 0 {
35+
log.Infof("Applying extra flags from environment: %s", strings.Join(extraFlags, " "))
36+
}
37+
}
38+
39+
// Get version of current binary
40+
latestVersion := upgrade.NewerVersionAvailable()
41+
if latestVersion != "" {
42+
log.Warnf("There is a newer version of the DevSpace Cloud Plugin: v%s. Run `devspace update plugin devspace-cloud` to upgrade to the newest version.\n", latestVersion)
43+
}
44+
},
45+
Long: `DevSpace accelerates developing, deploying and debugging applications with Docker and Kubernetes. Get started by running the init command in one of your projects:
46+
47+
devspace init`,
48+
}
49+
}
50+
51+
var globalFlags *flags.GlobalFlags
52+
53+
// Execute adds all child commands to the root command and sets flags appropriately.
54+
// This is called by main.main(). It only needs to happen once to the rootCmd.
55+
func Execute() {
56+
// build the root command
57+
rootCmd := BuildRoot()
58+
59+
// set version for --version flag
60+
rootCmd.Version = upgrade.GetVersion()
61+
62+
// execute command
63+
err := rootCmd.Execute()
64+
if err != nil {
65+
// Check if return code error
66+
retCode, ok := errors.Cause(err).(*exit.ReturnCodeError)
67+
if ok {
68+
os.Exit(retCode.ExitCode)
69+
}
70+
71+
if globalFlags.Debug {
72+
log.GetInstance().Fatalf("%+v", err)
73+
} else {
74+
log.GetInstance().Fatal(err)
75+
}
76+
}
77+
}
78+
79+
// BuildRoot creates a new root command from the
80+
func BuildRoot() *cobra.Command {
81+
rootCmd := NewRootCmd()
82+
persistentFlags := rootCmd.PersistentFlags()
83+
globalFlags = flags.SetGlobalFlags(persistentFlags)
84+
85+
// Add sub commands
86+
return rootCmd
87+
}

go.mod

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module github.com/devspace-cloud/devspace-cloud-plugin
2+
3+
require (
4+
github.com/blang/semver v3.5.1+incompatible
5+
github.com/daviddengcn/go-colortext v1.0.0 // indirect
6+
github.com/devspace-cloud/devspace v1.1.1-0.20200724074930-ec77a1851818
7+
github.com/joho/godotenv v1.3.0
8+
github.com/mattn/go-colorable v0.1.7 // indirect
9+
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
10+
github.com/pkg/errors v0.9.1
11+
github.com/rhysd/go-github-selfupdate v0.0.0-20180520142321-41c1bbb0804a
12+
github.com/sirupsen/logrus v1.4.2
13+
github.com/spf13/cobra v1.0.0
14+
github.com/spf13/pflag v1.0.5
15+
k8s.io/apimachinery v0.18.6 // indirect
16+
)
17+
18+
replace (
19+
github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.3.0+incompatible
20+
github.com/agl/ed25519 => github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412
21+
golang.org/x/sys => golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9
22+
)
23+
24+
go 1.13

0 commit comments

Comments
 (0)