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
14 changes: 7 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ on: [push, pull_request]

jobs:
golangci:
name: "Lint Go"
name: "Lint"
runs-on: "ubuntu-latest"
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.20"
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
- uses: actions/checkout@v4
- name: Crete empty build directory
run: mkdir ui/build && touch ui/build/.gitkeep
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.54
version: v1.64

codeql:
name: "Analyze with CodeQL"
Expand Down
19 changes: 10 additions & 9 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
run:
timeout: 5m
skip-dirs:
- api/proto
- clients/java
- clients/js
- docs
- scripts
- ui
output:
format: line-number
formats:
- format: colored-line-number
linters:
enable-all: false
disable-all: true
enable:
- vet
- govet
- goimports
- thelper
- tparallel
Expand All @@ -29,6 +23,13 @@ linters-settings:
ignore-generated-header: true
severity: warning
issues:
exclude-dirs:
- api/proto
- clients/java
- clients/js
- docs
- scripts
- ui
fix: true
severity:
default-severity: error
5 changes: 2 additions & 3 deletions cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"os"

"github.com/MakeNowJust/heredoc"
"github.com/raystack/salt/printer"
"github.com/raystack/salt/term"
"github.com/raystack/salt/cli/printer"
stencilv1beta1 "github.com/raystack/stencil/proto/raystack/stencil/v1beta1"
"github.com/spf13/cobra"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -57,7 +56,7 @@ func checkSchemaCmd(cdk *CDK) *cobra.Command {
}

spinner.Stop()
fmt.Printf("\n%s Schema is compatible.\n", term.Green(term.SuccessIcon()))
fmt.Printf("\n%s Schema is compatible.\n", printer.Green(printer.Icon("success")))
return nil
},
}
Expand Down
9 changes: 2 additions & 7 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package cmd

import (
"context"
"errors"
"time"

"github.com/raystack/salt/cmdx"
"github.com/raystack/salt/config"
stencilv1beta1 "github.com/raystack/stencil/proto/raystack/stencil/v1beta1"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -54,16 +52,13 @@ func createClient(cmd *cobra.Command, cdk *CDK) (stencilv1beta1.StencilServiceCl
return client, cancel, nil
}

func loadClientConfig(cmd *cobra.Command, cmdxConfig *cmdx.Config) (*ClientConfig, error) {
func loadClientConfig(cmd *cobra.Command, cmdxConfig *config.Loader) (*ClientConfig, error) {
var clientConfig ClientConfig

if err := cmdxConfig.Load(
&clientConfig,
cmdx.WithFlags(cmd.Flags()),
); err != nil {
if !errors.Is(err, new(config.ConfigFileNotFoundError)) {
return nil, ErrClientConfigNotFound
}
return nil, err
}

return &clientConfig, nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func configInitCommand(cdk *CDK) *cobra.Command {
return err
}

fmt.Printf("Config created: %v\n", cdk.Config.File())
fmt.Printf("Config created\n")
return nil
},
}
Expand All @@ -49,7 +49,7 @@ func configListCommand(cdk *CDK) *cobra.Command {
"group": "core",
},
RunE: func(cmd *cobra.Command, args []string) error {
data, err := cdk.Config.Read()
data, err := cdk.Config.View()
if err != nil {
return ErrClientConfigNotFound
}
Expand Down
7 changes: 3 additions & 4 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"os"

"github.com/MakeNowJust/heredoc"
"github.com/raystack/salt/printer"
"github.com/raystack/salt/term"
"github.com/raystack/salt/cli/printer"
stencilv1beta1 "github.com/raystack/stencil/proto/raystack/stencil/v1beta1"
"github.com/spf13/cobra"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -52,7 +51,7 @@ func createSchemaCmd(cdk *CDK) *cobra.Command {
if err != nil {
errStatus := status.Convert(err)
if codes.AlreadyExists == errStatus.Code() {
fmt.Printf("\n%s Schema with id '%s' already exist.\n", term.FailureIcon(), args[0])
fmt.Printf("\n%s Schema with id '%s' already exist.\n", printer.Icon("failure"), args[0])
return nil
}
return errors.New(errStatus.Message())
Expand All @@ -61,7 +60,7 @@ func createSchemaCmd(cdk *CDK) *cobra.Command {
id := res.GetId()

spinner.Stop()
fmt.Printf("\n%s Created schema with id %s.\n", term.Green(term.SuccessIcon()), term.Cyan(id))
fmt.Printf("\n%s Created schema with id %s.\n", printer.Green(printer.Icon("success")), printer.Cyan(id))
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/MakeNowJust/heredoc"
"github.com/raystack/salt/printer"
"github.com/raystack/salt/cli/printer"
stencilv1beta1 "github.com/raystack/stencil/proto/raystack/stencil/v1beta1"
"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"

"github.com/MakeNowJust/heredoc"
"github.com/raystack/salt/printer"
"github.com/raystack/salt/cli/printer"
stencilv1beta1 "github.com/raystack/stencil/proto/raystack/stencil/v1beta1"
"github.com/spf13/cobra"
"github.com/yudai/gojsondiff"
Expand Down
5 changes: 2 additions & 3 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (
"os"

"github.com/MakeNowJust/heredoc"
"github.com/raystack/salt/printer"
"github.com/raystack/salt/term"
"github.com/raystack/salt/cli/printer"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -42,7 +41,7 @@ func downloadSchemaCmd(cdk *CDK) *cobra.Command {
return err
}

fmt.Printf("%s Schema successfully written to %s\n", term.Green(term.SuccessIcon()), output)
fmt.Printf("%s Schema successfully written to %s\n", printer.Green(printer.Icon("success")), output)
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/MakeNowJust/heredoc"
"github.com/raystack/salt/printer"
"github.com/raystack/salt/cli/printer"
stencilv1beta1 "github.com/raystack/stencil/proto/raystack/stencil/v1beta1"
"github.com/spf13/cobra"
)
Expand Down
20 changes: 12 additions & 8 deletions cmd/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ package cmd

import (
"github.com/MakeNowJust/heredoc"
"github.com/raystack/salt/cli/commander"
)

var envHelp = map[string]string{
"short": "List of supported environment variables",
"long": heredoc.Doc(`
RAYSTACK_CONFIG_DIR: the directory where stencil will store configuration files. Default:
"$XDG_CONFIG_HOME/raystack" or "$HOME/.config/raystack".
var envHelpTopics = []commander.HelpTopic{
{
Name: "environment",
Short: "List of supported environment variables",
Long: heredoc.Doc(`
RAYSTACK_CONFIG_DIR: the directory where stencil will store configuration files. Default:
"$XDG_CONFIG_HOME/raystack" or "$HOME/.config/raystack".

NO_COLOR: set to any value to avoid printing ANSI escape sequences for color output.
NO_COLOR: set to any value to avoid printing ANSI escape sequences for color output.

CLICOLOR: set to "0" to disable printing ANSI colors in output.
`),
CLICOLOR: set to "0" to disable printing ANSI colors in output.
`),
},
}
19 changes: 9 additions & 10 deletions cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"strconv"

"github.com/MakeNowJust/heredoc"
"github.com/raystack/salt/printer"
"github.com/raystack/salt/term"
"github.com/raystack/salt/cli/printer"
stencilv1beta1 "github.com/raystack/stencil/proto/raystack/stencil/v1beta1"
"github.com/spf13/cobra"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -44,18 +43,18 @@ func infoSchemaCmd(cdk *CDK) *cobra.Command {
if err != nil {
errStatus, _ := status.FromError(err)
if codes.NotFound == errStatus.Code() {
fmt.Printf("%s Schema with id '%s' not found.\n", term.Red(term.FailureIcon()), args[0])
fmt.Printf("%s Schema with id '%s' not found.\n", printer.Red(printer.Icon("failure")), args[0])
return nil
}
return err
}

fmt.Printf("\n%s\n", term.Blue(args[0]))
fmt.Printf("\n%s\n\n", term.Grey("No description provided"))
fmt.Printf("%s \t %s \n", term.Grey("Namespace:"), namespace)
fmt.Printf("%s \t %s \n", term.Grey("Format:"), dict[info.GetFormat().String()])
fmt.Printf("%s \t %s \n", term.Grey("Compatibility:"), dict[info.GetCompatibility().String()])
fmt.Printf("%s \t %s \n\n", term.Grey("Authority:"), dict[info.GetAuthority()])
fmt.Printf("\n%s\n", printer.Blue(args[0]))
fmt.Printf("\n%s\n\n", printer.Grey("No description provided"))
fmt.Printf("%s \t %s \n", printer.Grey("Namespace:"), namespace)
fmt.Printf("%s \t %s \n", printer.Grey("Format:"), dict[info.GetFormat().String()])
fmt.Printf("%s \t %s \n", printer.Grey("Compatibility:"), dict[info.GetCompatibility().String()])
fmt.Printf("%s \t %s \n\n", printer.Grey("Authority:"), dict[info.GetAuthority()])
return nil
},
}
Expand Down Expand Up @@ -109,7 +108,7 @@ func versionSchemaCmd(cdk *CDK) *cobra.Command {

for _, v := range versions {
report = append(report, []string{
term.Greenf("#%v", strconv.FormatInt(int64(v), 10)),
printer.Greenf("#%v", strconv.FormatInt(int64(v), 10)),
"-",
"-",
})
Expand Down
15 changes: 7 additions & 8 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"os"

"github.com/MakeNowJust/heredoc"
"github.com/raystack/salt/printer"
"github.com/raystack/salt/term"
"github.com/raystack/salt/cli/printer"
stencilv1beta1 "github.com/raystack/stencil/proto/raystack/stencil/v1beta1"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -53,11 +52,11 @@ func listSchemaCmd(cdk *CDK) *cobra.Command {
report := [][]string{}
index := 1
report = append(report, []string{
term.Bold("INDEX"),
term.Bold("NAME"),
term.Bold("FORMAT"),
term.Bold("COMPATIBILITY"),
term.Bold("AUTHORITY"),
printer.Bold("INDEX"),
printer.Bold("NAME"),
printer.Bold("FORMAT"),
printer.Bold("COMPATIBILITY"),
printer.Bold("AUTHORITY"),
})
for _, s := range schemas {
c := s.GetCompatibility().String()
Expand All @@ -67,7 +66,7 @@ func listSchemaCmd(cdk *CDK) *cobra.Command {
if a == "" {
a = "-"
}
report = append(report, []string{term.Greenf("#%d", index), s.GetName(), dict[f], dict[c], a})
report = append(report, []string{printer.Greenf("#%d", index), s.GetName(), dict[f], dict[c], a})
index++
}

Expand Down
Loading
Loading