Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kellerza committed May 25, 2021
1 parent bd3a858 commit 224a26d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
5 changes: 1 addition & 4 deletions clab/config/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ type SshSession struct {
Session *ssh.Session
}

// Display the SSH login message
var LoginMessages bool

// Debug count
var DebugCount int

Expand Down Expand Up @@ -102,7 +99,7 @@ func (t *SshTransport) InChannel() {

// Save first prompt
t.LoginMessage = t.Run("", 15)
if LoginMessages {
if DebugCount > 1 {
t.LoginMessage.Info(t.Target)
}
}
Expand Down
2 changes: 1 addition & 1 deletion clab/config/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func LoadTemplate(kind, templatePath string) error {
var err error
templates[kind], err = ct.ParseGlob(tp)
if err != nil {
log.Errorf("could not load template %s", err)
log.Errorf("Could not load %s %s", tp, err)
return err
}
return nil
Expand Down
6 changes: 3 additions & 3 deletions clab/config/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func WriteConfig(transport Transport, snips []ConfigSnippet) error {
}

// templates to execute
var TemplateOverride string
var TemplateOverride []string

// the new agreed node config
type NodeConfig struct {
Expand All @@ -59,8 +59,8 @@ func GetNodeConfigFromLabels(labels map[string]string) NodeConfig {
Vars: labels,
Transport: "ssh",
}
if TemplateOverride != "" {
nc.Templates = SplitTrim(TemplateOverride)
if len(TemplateOverride) > 0 {
nc.Templates = TemplateOverride
} else if t, ok := labels["templates"]; ok {
nc.Templates = SplitTrim(t)
} else {
Expand Down
14 changes: 6 additions & 8 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var configCmd = &cobra.Command{
//defer cancel()

setFlags(c.Config)
log.Debugf("lab Conf: %+v", c.Config)
log.Debugf("Topology definition: %+v", c.Config)
// Parse topology information
if err = c.ParseTopology(); err != nil {
return err
Expand All @@ -56,8 +56,7 @@ var configCmd = &cobra.Command{
renderErr := 0

for _, node := range c.Nodes {
kind := node.Labels["clab-node-kind"]
err = config.LoadTemplate(kind, templatePath)
err = config.LoadTemplate(node.Kind, templatePath)
if err != nil {
return err
}
Expand Down Expand Up @@ -167,9 +166,8 @@ func newSSHTransport(node *clab.Node) (*config.SshTransport, error) {

func init() {
rootCmd.AddCommand(configCmd)
configCmd.Flags().StringVarP(&templatePath, "path", "", "", "specify template path")
configCmd.MarkFlagDirname("path")
configCmd.Flags().StringVarP(&config.TemplateOverride, "templates", "", "", "specify a list of template to apply")
configCmd.Flags().IntVarP(&printLines, "print-only", "p", 0, "print config, don't send it. Restricted to n lines")
configCmd.Flags().BoolVarP(&config.LoginMessages, "login-message", "", false, "show the SSH login message")
configCmd.Flags().StringVarP(&templatePath, "template-path", "p", "", "directory with templates used to render config")
configCmd.MarkFlagDirname("template-path")
configCmd.Flags().StringSliceVarP(&config.TemplateOverride, "template-list", "l", []string{}, "comma separated list of template names to render")
configCmd.Flags().IntVarP(&printLines, "check", "c", 0, "render dry-run & print n lines of config")
}

0 comments on commit 224a26d

Please sign in to comment.