Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
janosmiko committed Jun 21, 2023
1 parent dec2d62 commit 90bdf70
Show file tree
Hide file tree
Showing 26 changed files with 992 additions and 293 deletions.
36 changes: 21 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ linters:
# PANICS START
- exhaustruct
# PANICS END
- unused
- varnamelen
- gomnd
- depguard
- ireturn
- testpackage
- wsl
# TODO
- paralleltest
- dupl
- gocognit

enable:
- asasalint
Expand All @@ -51,9 +62,7 @@ linters:
- containedctx
- cyclop
- decorder
- depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
Expand All @@ -66,7 +75,6 @@ linters:
- forcetypeassert
- funlen
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
Expand All @@ -76,7 +84,6 @@ linters:
- gofumpt
- goheader
- goimports
- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
Expand All @@ -86,7 +93,6 @@ linters:
- grouper
- importas
- ineffassign
- ireturn
- lll
- maintidx
- makezero
Expand All @@ -97,7 +103,6 @@ linters:
- nlreturn
- nolintlint
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
Expand All @@ -106,22 +111,14 @@ linters:
- stylecheck
- tagliatelle
- tenv
- testpackage
- thelper
- typecheck
- unconvert
- unparam
- unused
- varnamelen
- whitespace
- wrapcheck
- wsl

linters-settings:
wsl:
allow-separated-leading-comment: true
allow-trailing-comment: true
allow-assign-and-anything: true
staticcheck:
checks: [ "all", "-SA5008" ]
goconst:
Expand All @@ -138,4 +135,13 @@ linters-settings:
- i int
- FS *afero.Afero
funlen:
lines: 100
lines: 150
statements: 50
cyclop:
max-complexity: 15
nestif:
min-complexity: 7
revive:
rules:
- name: "unused-parameter"
disabled: true
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ gomod: ## Update Go Dependencies
go mod tidy

lint: ## Lint Go Code
golangci-lint run ./...
golangci-lint run -c .golangci.yml ./...

lint-fix: ## Lint Go Code
golangci-lint run --fix ./...
golangci-lint run -c .golangci.yml --fix ./...

test: ## Run Go tests
go test -race -v ./...
2 changes: 1 addition & 1 deletion cmd/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewCmdCache(app *config.App) *cmdpkg.Command {
return nil, cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
return cmd.Help() //nolint:wrapcheck
},
},
App: app,
Expand Down
6 changes: 3 additions & 3 deletions cmd/cloud/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ limitations under the License.
package main

import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"os"
"os/signal"
"syscall"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/rewardenv/reward-cloud-cli/cmd/root"
"github.com/rewardenv/reward-cloud-cli/internal/config"
)
Expand All @@ -39,7 +40,6 @@ func main() {
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT,
syscall.SIGKILL,
)

app := config.New(APPNAME, PARENTAPPNAME, VERSION)
Expand Down
29 changes: 28 additions & 1 deletion cmd/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewCmdContext(app *config.App) *cmdpkg.Command {
return nil, cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
return cmd.Help() //nolint:wrapcheck
},
},
App: app,
Expand All @@ -31,6 +31,7 @@ func NewCmdContext(app *config.App) *cmdpkg.Command {
NewCmdContextCreate(app),
NewCmdContextDelete(app),
NewCmdContextSelect(app),
NewCmdContextCheck(app),
)

return cmd
Expand Down Expand Up @@ -146,3 +147,29 @@ func NewCmdContextSelect(app *config.App) *cmdpkg.Command {

return cmd
}

func NewCmdContextCheck(app *config.App) *cmdpkg.Command {
cmd := &cmdpkg.Command{
Command: &cobra.Command{
Use: "check",
Short: "check context",
Long: `check the current context`,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) (
[]string, cobra.ShellCompDirective,
) {
return nil, cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
err := logic.NewContextClient(app).RunCmdContextCheck(cmd, args)
if err != nil {
return errors.Wrap(err, "select a specified context")
}

return nil
},
},
App: app,
}

return cmd
}
31 changes: 2 additions & 29 deletions cmd/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ func NewCmdEnv(app *config.App) *cmdpkg.Command {
return nil, cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
return cmd.Help() //nolint:wrapcheck
},
},
App: app,
}

cmd.AddCommands(
NewCmdEnvStatus(app),
NewCmdEnvBuildAndDeploy(app),
NewCmdEnvExportDB(app),
NewCmdEnvExportMedia(app),
Expand All @@ -36,32 +35,6 @@ func NewCmdEnv(app *config.App) *cmdpkg.Command {
return cmd
}

func NewCmdEnvStatus(app *config.App) *cmdpkg.Command {
cmd := &cmdpkg.Command{
Command: &cobra.Command{
Use: "status",
Short: "environment status",
Long: `environment status`,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) (
[]string, cobra.ShellCompDirective,
) {
return nil, cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
err := logic.NewEnvClient(app).RunCmdEnvStatus(cmd, args)
if err != nil {
return errors.Wrap(err, "running db port-forward command")
}

return nil
},
},
App: app,
}

return cmd
}

func NewCmdEnvBuildAndDeploy(app *config.App) *cmdpkg.Command {
cmd := &cmdpkg.Command{
Command: &cobra.Command{
Expand Down Expand Up @@ -112,7 +85,7 @@ func NewCmdEnvExportDB(app *config.App) *cmdpkg.Command {
}

cmd.Flags().Bool("strip-database", false, "remove sensitve data from database dump")
cmd.App.BindPFlag("strip_database", cmd.Flags().Lookup("strip-database"))
_ = cmd.App.BindPFlag("strip_database", cmd.Flags().Lookup("strip-database"))

return cmd
}
Expand Down
36 changes: 36 additions & 0 deletions cmd/info/info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package info

import (
"github.com/pkg/errors"
"github.com/rewardenv/reward-cloud-cli/internal/logic"
"github.com/spf13/cobra"

cmdpkg "github.com/rewardenv/reward-cloud-cli/cmd"
"github.com/rewardenv/reward-cloud-cli/internal/config"
)

func NewCmdInfo(app *config.App) *cmdpkg.Command {
cmd := &cmdpkg.Command{
Command: &cobra.Command{
Use: "info",
Short: "info",
Long: `info`,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) (
[]string, cobra.ShellCompDirective,
) {
return nil, cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
err := logic.NewInfoClient(app).RunCmdInfo(cmd, args)
if err != nil {
return errors.Wrap(err, "running info command")
}

return nil
},
},
App: app,
}

return cmd
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package portForward
package portforward

import (
"github.com/pkg/errors"
Expand All @@ -21,7 +21,7 @@ func NewCmdPortForward(app *config.App) *cmdpkg.Command {
return nil, cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
return cmd.Help() //nolint:wrapcheck
},
},
App: app,
Expand Down
9 changes: 6 additions & 3 deletions cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package root

import (
"fmt"
"path/filepath"

"github.com/pkg/errors"
"github.com/rewardenv/reward-cloud-cli/cmd/cache"
"github.com/rewardenv/reward-cloud-cli/cmd/context"
"github.com/rewardenv/reward-cloud-cli/cmd/env"
"github.com/rewardenv/reward-cloud-cli/cmd/portForward"
"path/filepath"
"github.com/rewardenv/reward-cloud-cli/cmd/info"
"github.com/rewardenv/reward-cloud-cli/cmd/portforward"

"github.com/rewardenv/reward/pkg/util"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -65,8 +67,9 @@ func NewCmdRoot(conf *config.App) *cmdpkg.Command {
context.NewCmdContext(conf),
login.NewCmdLogin(conf),
shell.NewCmdShell(conf),
portForward.NewCmdPortForward(conf),
portforward.NewCmdPortForward(conf),
env.NewCmdEnv(conf),
info.NewCmdInfo(conf),
)

return cmd
Expand Down
19 changes: 17 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ module github.com/rewardenv/reward-cloud-cli

go 1.19

replace github.com/rewardenv/reward-cloud-sdk-go v0.1.3 => ../reward-cloud-sdk-go
//replace github.com/rewardenv/reward-cloud-sdk-go v0.1.3 => ../reward-cloud-sdk-go

require (
github.com/charmbracelet/bubbles v0.16.1
github.com/charmbracelet/bubbletea v0.24.1
github.com/charmbracelet/lipgloss v0.7.1
github.com/hashicorp/go-version v1.6.0
github.com/jedib0t/go-pretty/v6 v6.4.4
github.com/pkg/errors v0.9.1
github.com/rewardenv/reward v0.4.0-beta3
github.com/rewardenv/reward-cloud-sdk-go v0.1.3
github.com/rewardenv/reward-cloud-sdk-go v0.2.0
github.com/sirupsen/logrus v1.9.0
github.com/spf13/afero v1.9.3
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.1
gitlab.com/david_mbuvi/go_asterisks v0.0.0-20221114073100-4669d8bedcbe
golang.org/x/build v0.0.0-20230620205133-36b375984d42
gopkg.in/yaml.v3 v3.0.1
k8s.io/client-go v0.27.2
sigs.k8s.io/yaml v1.3.0
Expand All @@ -24,6 +28,8 @@ require (
require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v20.10.23+incompatible // indirect
Expand All @@ -35,11 +41,18 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
Expand All @@ -53,10 +66,12 @@ require (
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.7.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/apimachinery v0.27.2 // indirect
Expand Down
Loading

0 comments on commit 90bdf70

Please sign in to comment.