Skip to content

Commit

Permalink
Improve manage command and entity validation
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Fabry <ondrej.fabry@pantheon.tech>
  • Loading branch information
ondrej-fabry committed Apr 19, 2023
1 parent c6ce1a5 commit a99a31b
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 137 deletions.
4 changes: 2 additions & 2 deletions client/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "go.pantheon.tech/stonework/proto/cnfreg"
// a CNF connected to it or other Ligato service in connected to StoneWork.
type Component interface {
Name() string
CnfMode() cnfreg.CnfMode
Mode() cnfreg.CnfMode
}

type component struct {
Expand All @@ -18,6 +18,6 @@ func (c *component) Name() string {
return c.name
}

func (c *component) CnfMode() cnfreg.CnfMode {
func (c *component) Mode() cnfreg.CnfMode {
return c.mode
}
6 changes: 3 additions & 3 deletions cmd/swctl/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import (
// Cli is a client API for CLI application.
type Cli interface {
Initialize(opts Options) error
Apply(...CliOption) error
Client() client.API
Entities() []Entity
Exec(cmd string, args []string) (string, error)

Out() *streams.Out
Err() io.Writer
In() *streams.In
Apply(...CliOption) error
}

// CLI implements Cli interface.
Expand Down Expand Up @@ -65,10 +65,10 @@ func (cli *CLI) Initialize(opts Options) (err error) {
return fmt.Errorf("init error: %w", err)
}

// load entity file
// load entity files
cli.entities, err = loadEntityFiles(opts.EntityFiles)
if err != nil {
logrus.Errorf("failed to load entity files %s: %v", opts.EntityFiles, err)
return fmt.Errorf("loading entity files failed: %v", err)
}

// get vpp-probe
Expand Down
15 changes: 8 additions & 7 deletions cmd/swctl/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ package main
import (
"fmt"

"github.com/gookit/color"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"go.pantheon.tech/stonework/pkg/version"
)

const logo = `
███████╗██╗ ██╗ ██████╗████████╗██╗
██╔════╝██║ ██║██╔════╝╚══██╔══╝██║
███████╗██║ █╗ ██║██║ ██║ ██║ %s
╚════██║██║███╗██║██║ ██║ ██║ %s
███████║╚███╔███╔╝╚██████╗ ██║ ███████╗ %s
╚══════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚══════╝
<lightblue> ███████╗██╗ ██╗ ██████╗████████╗██╗ </>
<lightblue> ██╔════╝██║ ██║██╔════╝╚══██╔══╝██║ </>
<lightblue> ███████╗██║ █╗ ██║██║ ██║ ██║ </><lightyellow> %s </>
<lightblue> ╚════██║██║███╗██║██║ ██║ ██║ </><lightyellow> %s </>
<lightblue> ███████║╚███╔███╔╝╚██████╗ ██║ ███████╗ </><lightyellow> %s </>
<lightblue> ╚══════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚══════╝ </>

`

Expand All @@ -27,7 +28,7 @@ func NewRootCmd(cli Cli) *cobra.Command {
cmd := &cobra.Command{
Use: "swctl [options] [command]",
Short: "swctl is CLI app to manage StoneWork and its components",
Long: fmt.Sprintf(logo, version.Short(), version.BuildTime(), version.BuiltBy()),
Long: color.Sprintf(logo, version.Short(), version.BuildTime(), version.BuiltBy()),
Version: version.String(),
SilenceUsage: true,
SilenceErrors: true,
Expand Down
Loading

0 comments on commit a99a31b

Please sign in to comment.