Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "bsp", Short: "Collection of commands relating to the bsp rest api", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { err := cmd.ValidateRequiredFlags() if err != nil { return err } err = cmd.ValidateFlagGroups() if err != nil { return err } targets, err := targetsFromFlags(cmd) if err != nil { return fmt.Errorf("could not get targets from flags: %w", err) } options := make([]auth.Option, 0) insecure, _ := cmd.Flags().GetBool("insecure") if insecure { options = append(options, auth.WithInsecure) } sshProxyJumps, _ := cmd.Flags().GetStringSlice("ssh-proxyjump") sshProxyJumpInsecure, _ := cmd.Flags().GetBool("ssh-proxyjump-insecure") sshOpts := make([]sshc.Option, 0) if sshProxyJumpInsecure { sshOpts = append(sshOpts, sshc.WithInsecureIgnoreHostkey) } sshProxyJumpIdentity, _ := cmd.Flags().GetString("ssh-proxyjump-identity") if sshProxyJumpIdentity != "" { opt, err := sshc.WithIdentityFile(sshProxyJumpIdentity) if err != nil { return fmt.Errorf("unable to create ssh client config for proxyjump identity %s: %w", sshProxyJumpIdentity, err) } sshOpts = append(sshOpts, opt) } for _, v := range sshProxyJumps { c, err := sshc.ClientConfig(sshOpts...) if err != nil { return fmt.Errorf("unable to create ssh client config for proxyjump %s: %w", v, err) } opt, err := auth.WithSSHTunnel(v, c) if err != nil { return fmt.Errorf("unable to create ssh tunnel for proxyjump %s: %w", v, err) } options = append(options, opt) } user, _ := cmd.Flags().GetString("username") pass, _ := cmd.Flags().GetString("password") interactive, _ := cmd.Flags().GetBool("interactive") collection := target.Collection{} for _, host := range targets { c, err := auth.Client(host, user, pass, options...) if errors.Is(err, auth.ErrInvalidCredentials) && interactive { for { fmt.Printf("Enter password for https://%s@%s: ", user, host) var p []byte p, err = readPassword() if err != nil { return fmt.Errorf("unable to ask for password: %w", err) } pass = string(p) fmt.Println() c, err = auth.Client(host, user, pass, options...) if errors.Is(err, auth.ErrInvalidCredentials) { continue } if err != nil { return fmt.Errorf("unable to authenticate: %w", err) } break } } if err != nil { return fmt.Errorf("unable to authenticate: %w", err) } collection = append(collection, target.Endpoint{Hostname: host, Client: c}) } cmd.SetContext(target.NewContext(cmd.Context(), collection)) return nil }, }
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
Hostname string `json:"hostname"`
Interfaces []Interface `json:"interfaces"`
Mountpoints []MountPoint `json:"mountpoints"`
Serial string `json:"serialnumber"`
Software Software `json:"software"`
}
type Interface ¶
type Interface struct {
Description string `json:"description"`
Ifname string `json:"ifname"`
Kind string `json:"kind"`
Status struct {
LinkState string `json:"link_state"`
MacAddress string `json:"mac_address"`
IPv4 *struct {
IP string `json:"ip"`
PrefixLength int `json:"prefix_length"`
} `json:"ipv4,omitempty"`
IPv6 *struct {
IP string `json:"ip"`
PrefixLength int `json:"prefix_length"`
} `json:"ipv6,omitempty"`
} `json:"status"`
}
type MountPoint ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.