Skip to content

Commit

Permalink
Cleanup of text for subcommands c-k
Browse files Browse the repository at this point in the history
Applied style-guide rules and made other changes towards readability.

Changes made to files/directories in alphabetical order from "c" to "k".
Due to the number of files, cleanup is being broken up over multiple
commits.

This commit applies to FFTK-2391, "Fix Fioctl style and typos"

Signed-off-by: Katrina Prosise <[email protected]>
  • Loading branch information
kprosise committed Oct 2, 2024
1 parent 9662e81 commit 9cb21dd
Show file tree
Hide file tree
Showing 50 changed files with 172 additions and 173 deletions.
2 changes: 1 addition & 1 deletion subcommands/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var (
)

func RequireFactory(cmd *cobra.Command) {
cmd.PersistentFlags().StringP("factory", "f", "", "Factory to list targets for")
cmd.PersistentFlags().StringP("factory", "f", "", "Factory to list Targets for")
cmd.PersistentFlags().StringP("token", "t", "", "API token from https://app.foundries.io/settings/tokens/")
}

Expand Down
2 changes: 1 addition & 1 deletion subcommands/common_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func loadSotaConfig(dcl *client.DeviceConfigList) (sota *toml.Tree, err error) {
}

if !found {
logrus.Debugf("Not found a FIO toml in the latest config")
logrus.Debugf("FIO toml not found in the latest config")
}
// In case if FIO TOML file is missing or an error - return an empty one.
// Let a caller decide what to do in case of an error.
Expand Down
2 changes: 1 addition & 1 deletion subcommands/config/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var (

var cmd = &cobra.Command{
Use: "config",
Short: "Manage configuration common to all devices in a factory",
Short: "Manage configuration common to all devices in a Factory",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
api = subcommands.Login(cmd)
},
Expand Down
8 changes: 4 additions & 4 deletions subcommands/config/device_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func init() {
groupCmd := &cobra.Command{
Use: "device-group",
Short: "Manage factory device groups",
Short: "Manage Factory device groups",
}
cmd.AddCommand(groupCmd)

Expand All @@ -25,7 +25,7 @@ func init() {
})
groupCmd.AddCommand(&cobra.Command{
Use: "create <name> [<description>]",
Short: "Create a new device groups",
Short: "Create a new device group",
Run: doCreateDeviceGroup,
Args: cobra.RangeArgs(1, 2),
})
Expand All @@ -49,7 +49,7 @@ func init() {

func doListDeviceGroup(cmd *cobra.Command, args []string) {
factory := viper.GetString("factory")
logrus.Debugf("Showing a list of device groups for %s", factory)
logrus.Debugf("Showing list of device groups for %s", factory)

lst, err := api.FactoryListDeviceGroup(factory)
subcommands.DieNotNil(err)
Expand Down Expand Up @@ -95,7 +95,7 @@ func doUpdateDeviceGroup(cmd *cobra.Command, args []string) {
factory := viper.GetString("factory")
old_name := args[0]
var new_name, new_desc *string
logrus.Debugf("Updating a device group %s for %s", old_name, factory)
logrus.Debugf("Updating device group %s for %s", old_name, factory)
if cmd.Flags().Changed("name") {
s, _ := cmd.Flags().GetString("name")
logrus.Debugf("New name: %s", s)
Expand Down
2 changes: 1 addition & 1 deletion subcommands/config/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func init() {
logCmd := &cobra.Command{
Use: "log",
Short: "Show a changelog of configuration",
Short: "Show a configuration changelog",
Run: doConfigLog,
}
cmd.AddCommand(logCmd)
Expand Down
8 changes: 4 additions & 4 deletions subcommands/config/rotate_certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ This command will only work for devices running LmP version 90 and later.`,
}
cmd.AddCommand(rotateCmd)
rotateCmd.Flags().StringP("group", "g", "", "Device group to use")
rotateCmd.Flags().StringP("est-resource", "e", "/.well-known/est", "The path the to EST resource on your server")
rotateCmd.Flags().IntP("est-port", "p", 8443, "The EST server port")
rotateCmd.Flags().StringP("reason", "r", "", "The reason for changing the cert")
rotateCmd.Flags().StringP("est-resource", "e", "/.well-known/est", "Path to the EST resource on your server")
rotateCmd.Flags().IntP("est-port", "p", 8443, "EST server port")
rotateCmd.Flags().StringP("reason", "r", "", "reason for changing the cert")
rotateCmd.Flags().StringP("hsm-pkey-ids", "", "01,07", "Available PKCS11 slot IDs for the private key")
rotateCmd.Flags().StringP("hsm-cert-ids", "", "03,09", "Available PKCS11 slot IDs for the client certificate")
rotateCmd.Flags().StringP("server-name", "", "", "EST server name when not using the Foundries managed server. e.g. est.example.com")
rotateCmd.Flags().StringP("server-name", "", "", "EST server name when not using the Foundries.io managed server. e.g. est.example.com")
rotateCmd.Flags().BoolP("dryrun", "", false, "Show what the fioconfig entry will be and exit")
_ = cmd.MarkFlagRequired("reason")
_ = cmd.MarkFlagRequired("group")
Expand Down
16 changes: 8 additions & 8 deletions subcommands/config/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ import (
func init() {
setCmd := &cobra.Command{
Use: "set file=content <file2=content ...>",
Short: "Create a new factory-wide configuration",
Long: `Creates a factory wide configuration. The fioconfig daemon running on
each device will then be able to grab the latest version of the configuration
and the device's configuration and apply it. Use the --group parameter to
Short: "Create a new Factory-wide configuration",
Long: `Creates a Factory wide configuration. The fioconfig daemon running on
each device will then be able to grab and apply the latest version of the configuration
and the device's configuration. Use the --group parameter to
create a device group wide configuration instead.`,
Example: `
# Basic use
fioctl config set npmtok="root" githubtok="1234" readme.md==./readme.md
There are several ways how to pass a file content into this command:
- with filename="filecontent" format, a file content is passed directly.
- with filename==/path/to/file format, a file content is read from a specified file path.
There are several ways to pass a file's content into this command:
- with the filename="filecontent" format, content is passed directly.
- with the filename==/path/to/file format, content is read from the specified file path.
# The configuration format also allows specifying what command to
# run after a configuration file is updated on the device. To take
Expand Down Expand Up @@ -61,7 +61,7 @@ create a device group wide configuration instead.`,
setCmd.Flags().StringP("group", "g", "", "Device group to use")
setCmd.Flags().StringP("reason", "m", "", "Add a message to store as the \"reason\" for this change")
setCmd.Flags().BoolP("raw", "", false, "Use raw configuration file")
setCmd.Flags().BoolP("create", "", false, "Replace the whole config with these values. Default is to merge these values in with the existing config values")
setCmd.Flags().BoolP("create", "", false, "Replace the whole config with these values. Default is to merge these values with the existing config values")
}

func doConfigSet(cmd *cobra.Command, args []string) {
Expand Down
3 changes: 1 addition & 2 deletions subcommands/config/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ func init() {
Short: "Configure aktualizr-lite settings for how updates are applied to a device group",
Run: doConfigUpdates,
Long: `View or change configuration parameters used by aktualizr-lite for updating devices
in a device group. When run with no options, this command will print out how the
group is currently configured.`,
in a device group. When run without options, prints out the current configuration.`,
Example: `
# Make devices start taking updates from Targets tagged with "devel":
fioctl config updates --group beta --tag devel
Expand Down
2 changes: 1 addition & 1 deletion subcommands/config/wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var wireguardDisable bool
func init() {
wireguardCmd := &cobra.Command{
Use: "wireguard",
Short: "Show current wireguard server config for factory",
Short: "Show current wireguard server config for Factory",
Run: doWireguard,
Args: cobra.MinimumNArgs(0),
}
Expand Down
4 changes: 2 additions & 2 deletions subcommands/devices/apps_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ var (
func init() {
appsStatesCmd := &cobra.Command{
Use: "apps-states <name>",
Short: "List states of Apps reported by a device",
Short: "List the states of Apps reported by a device",
Run: doListStates,
Args: cobra.ExactArgs(1),
}
cmd.AddCommand(appsStatesCmd)
appsStatesCmd.Flags().IntVarP(&asListLimit, "limit", "n", 1, "Limit the number of Apps states to display.")
appsStatesCmd.Flags().IntVarP(&asListLimit, "limit", "n", 1, "Limit the number of App states to display.")
}

func doListStates(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion subcommands/devices/chown.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func init() {
Short: "Change the device's owner",
Run: doChown,
Args: cobra.ExactArgs(2),
Long: `Change the owner of a device. This command can only be run by factory admins
Long: `Change the owner of a device. This command can only be run by Factory admins
and owners. The new owner-id can be found by running 'fioctl users'`,
})
}
Expand Down
2 changes: 1 addition & 1 deletion subcommands/devices/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
var cmd = &cobra.Command{
Use: "devices",
Aliases: []string{"device"},
Short: "Manage devices registered to a factory",
Short: "Manage devices registered to a Factory",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
api = subcommands.Login(cmd)
},
Expand Down
2 changes: 1 addition & 1 deletion subcommands/devices/config_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func init() {
groupCmd := &cobra.Command{
Use: "group <device> [<group>]",
Short: "Assign a device to an existing factory device group",
Short: "Assign a device to an existing Factory device group",
Run: doConfigGroup,
Args: cobra.RangeArgs(1, 2),
}
Expand Down
2 changes: 1 addition & 1 deletion subcommands/devices/config_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func init() {
logConfigCmd := &cobra.Command{
Use: "log <device>",
Short: "Show a changelog of device's configuration",
Short: "Show a changelog of the device's configuration",
Run: doConfigLog,
Args: cobra.ExactArgs(1),
}
Expand Down
4 changes: 2 additions & 2 deletions subcommands/devices/config_rotate_certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func init() {
Short: "Rotate a device's x509 keypair used to connect to the device gateway",
Args: cobra.ExactArgs(1),
Run: doConfigRotate,
Long: `This command will send a fioconfig change to a device to instruct it to perform
Long: `This command will send a fioconfig change to a device instructing it to perform
a certificate rotation using the EST server configured with "fioctl keys est".
This command will only work for devices running LmP version 90 and later.`,
Expand All @@ -26,7 +26,7 @@ This command will only work for devices running LmP version 90 and later.`,
cmd.Flags().StringP("reason", "r", "", "The reason for changing the cert")
cmd.Flags().StringP("hsm-pkey-ids", "", "01,07", "Available PKCS11 slot IDs for the private key")
cmd.Flags().StringP("hsm-cert-ids", "", "03,09", "Available PKCS11 slot IDs for the client certificate")
cmd.Flags().StringP("server-name", "", "", "EST server name when not using the Foundries managed server. e.g. est.example.com")
cmd.Flags().StringP("server-name", "", "", "EST server name when not using the Foundries.io managed server. e.g. est.example.com")
cmd.Flags().BoolP("dryrun", "", false, "Show what the fioconfig entry will be and exit")
configCmd.AddCommand(cmd)
_ = cmd.MarkFlagRequired("reason")
Expand Down
4 changes: 2 additions & 2 deletions subcommands/devices/config_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func init() {
setConfigCmd := &cobra.Command{
Use: "set <device> <file1=content> <file2=content ...>",
Short: "Create a secure configuration for the device",
Long: `Creates a secure configuration for device encrypting the contents each
Long: `Creates a secure configuration for the device, encrypting the contents of each
file using the device's public key. The fioconfig daemon running
on each device will then be able to grab the latest version of the
device's configuration and apply it. The maximum size of a config is 1Mb.`,
Expand Down Expand Up @@ -68,7 +68,7 @@ device's configuration and apply it. The maximum size of a config is 1Mb.`,
configCmd.AddCommand(setConfigCmd)
setConfigCmd.Flags().StringP("reason", "m", "", "Add a message to store as the \"reason\" for this change")
setConfigCmd.Flags().BoolP("raw", "", false, "Use raw configuration file")
setConfigCmd.Flags().BoolP("create", "", false, "Replace the whole config with these values. Default is to merge these values in with the existing config values")
setConfigCmd.Flags().BoolP("create", "", false, "Replace the whole config with these values. Default is to merge these values with the existing config values")
}

func loadEciesPub(pubkey string) *ecies.PublicKey {
Expand Down
2 changes: 1 addition & 1 deletion subcommands/devices/config_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func init() {
Run: doConfigUpdates,
Args: cobra.ExactArgs(1),
Long: `View or change configuration parameters used by aktualizr-lite for updating a device.
When run with no options, this command will print out how the device is
When run with no options, this command prinst out how the device is
currently configured and reporting.`,
Example: `
# Make a device start taking updates from Targets tagged with "devel"
Expand Down
2 changes: 1 addition & 1 deletion subcommands/devices/config_wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func factoryIps(factory string) map[uint32]bool {
func findVpnAddress(factory string) string {
wsc := config.LoadWireguardServerConfig(factory, api)
if len(wsc.VpnAddress) == 0 || !wsc.Enabled {
fmt.Println("ERROR: A wireguard server has not been configured for this factory")
fmt.Println("ERROR: A wireguard server has not been configured for this Factory")
os.Exit(1)
}
logrus.Debugf("VPN server address is: %s", wsc.VpnAddress)
Expand Down
2 changes: 1 addition & 1 deletion subcommands/devices/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func init() {
cmd.AddCommand(&cobra.Command{
Use: "delete",
Short: "Delete a device(s) registered to a factory.",
Short: "Delete device(s) registered to a Factory.",
Run: doDelete,
Args: cobra.MinimumNArgs(1),
})
Expand Down
6 changes: 3 additions & 3 deletions subcommands/devices/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func ownerFormatter(d *client.Device) string {
if ok {
return name
}
logrus.Debugf("Looking up user %s in factory %s", d.Owner, d.Factory)
logrus.Debugf("Looking up user %s in Factory %s", d.Owner, d.Factory)
users, err := api.UsersList(d.Factory)
if err != nil {
logrus.Errorf("Unable to look up users: %s", err)
Expand Down Expand Up @@ -137,7 +137,7 @@ func init() {
sort.Strings(allCols)
listCmd := &cobra.Command{
Use: "list [pattern]",
Short: "List devices registered to factories. Optionally include filepath style patterns to limit to device names. eg device-*",
Short: "List devices registered to Factories. Optionally, include filepath style patterns to limit to device names. e.g. device-*",
Run: doList,
Args: cobra.MaximumNArgs(1),
Long: "Available columns for display:\n\n * " + strings.Join(allCols, "\n * "),
Expand All @@ -148,7 +148,7 @@ func init() {
listCmd.Flags().BoolVarP(&deviceOnlyNonProd, "only-non-prod", "", false, "Only include non-production devices")
listCmd.Flags().StringVarP(&deviceByTag, "by-tag", "", "", "Only list devices configured with the given tag")
listCmd.Flags().StringVarP(&deviceByTarget, "by-target", "", "", "Only list devices updated to the given target name")
listCmd.Flags().StringVarP(&deviceByGroup, "by-group", "g", "", "Only list devices belonging to this group (factory is mandatory)")
listCmd.Flags().StringVarP(&deviceByGroup, "by-group", "g", "", "Only list devices belonging to this group (Factory is mandatory)")
listCmd.Flags().IntVarP(&deviceInactiveHours, "offline-threshold", "", 4, "List the device as 'OFFLINE' if not seen in the last X hours")
listCmd.Flags().StringVarP(&deviceUuid, "uuid", "", "", "Find device with the given UUID")
listCmd.Flags().StringSliceVarP(&showColumns, "columns", "", defCols, "Specify which columns to display")
Expand Down
2 changes: 1 addition & 1 deletion subcommands/devices/list_denied.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func init() {
Short: "List device UUIDs that have been denied access to the device-gateway",
Run: doListDenied,
Long: `Devices created using a factory-registration-reference server get created
created on-demand. Because of this, devices are placed into a deny-list when
on-demand. Because of this, devices are placed into a deny-list when
they are deleted, so that they can't continue to access the system by getting
re-created.`,
}
Expand Down
24 changes: 12 additions & 12 deletions subcommands/devices/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ func doShow(cmd *cobra.Command, args []string) {
fmt.Printf("Production:\t%v%s\n", device.IsProd, waveSuffix)
fmt.Printf("Up to date:\t%v\n", device.UpToDate)
fmt.Printf("Target:\t\t%s / sha256(%s)\n", device.TargetName, device.OstreeHash)
fmt.Printf("Ostree Hash:\t%s\n", device.OstreeHash)
fmt.Printf("Ostree hash:\t%s\n", device.OstreeHash)
if len(device.LmpVer) > 0 {
fmt.Printf("LmP Version:\t%s\n", device.LmpVer)
fmt.Printf("LmP version:\t%s\n", device.LmpVer)
}
fmt.Printf("Created At:\t%s\n", device.ChangeMeta.CreatedAt)
fmt.Printf("Created at:\t%s\n", device.ChangeMeta.CreatedAt)
if len(device.ChangeMeta.CreatedBy) > 0 {
fmt.Printf("Created By:\t%s\n", device.ChangeMeta.CreatedBy)
fmt.Printf("Created by:\t%s\n", device.ChangeMeta.CreatedBy)
}
if len(device.ChangeMeta.UpdatedAt) > 0 {
fmt.Printf("Updated At:\t%s\n", device.ChangeMeta.UpdatedAt)
fmt.Printf("Updated at:\t%s\n", device.ChangeMeta.UpdatedAt)
}
if len(device.ChangeMeta.UpdatedBy) > 0 {
fmt.Printf("Updated By:\t%s\n", device.ChangeMeta.UpdatedBy)
fmt.Printf("Updated by:\t%s\n", device.ChangeMeta.UpdatedBy)
}
fmt.Printf("Last Seen:\t%s\n", device.LastSeen)
fmt.Printf("Last seen:\t%s\n", device.LastSeen)
if len(device.Tag) > 0 {
fmt.Printf("Tag:\t\t%s\n", device.Tag)
}
Expand All @@ -71,7 +71,7 @@ func doShow(cmd *cobra.Command, args []string) {
fmt.Printf("Status:\t\t%s\n", device.Status)
}
if len(device.CurrentUpdate) > 0 {
fmt.Printf("Update Id:\t%s\n", device.CurrentUpdate)
fmt.Printf("Update ID:\t%s\n", device.CurrentUpdate)
}
if device.AppsState != nil && device.AppsState.Apps != nil {
var healthyApps []string
Expand All @@ -87,7 +87,7 @@ func doShow(cmd *cobra.Command, args []string) {
fmt.Printf("Unhealthy Apps:\t%s\n", strings.Join(unhealthyApps, ","))
}
if device.Network != nil {
fmt.Println("Network Info:")
fmt.Println("Network info:")
fmt.Printf("\tHostname:\t%s\n", device.Network.Hostname)
fmt.Printf("\tIP:\t\t%s\n", device.Network.Ipv4)
fmt.Printf("\tMAC:\t\t%s\n", device.Network.MAC)
Expand All @@ -108,11 +108,11 @@ func doShow(cmd *cobra.Command, args []string) {
fmt.Println("Unable to marshall hardware info: ", err)
}
if showHWInfo {
fmt.Printf("Hardware Info:\n\t")
fmt.Printf("Hardware info:\n\t")
os.Stdout.Write(b)
fmt.Println("")
} else {
fmt.Printf("Hardware Info: (hidden, use --hwinfo)\n")
fmt.Printf("Hardware info: (hidden, use --hwinfo)\n")
}
}
if len(device.AktualizrToml) > 0 {
Expand All @@ -126,7 +126,7 @@ func doShow(cmd *cobra.Command, args []string) {

}
if device.ActiveConfig != nil {
fmt.Println("Active Config:")
fmt.Println("Active config:")
if len(device.ActiveConfig.CreatedBy) > 0 {
user, err := api.UserAccessDetails(device.Factory, device.ActiveConfig.CreatedBy)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions subcommands/docker/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func NewCommand() *cobra.Command {
Long: `Configure a Docker credential helper that allows Docker to access
hub.foundries.io.
This command will likely need to be run as root. It creates a symlink,
docker-credential-fio, in the same directory as the docker client binary.
This command likely needs to be run as root. It creates a symlink,
docker-credential-fio, in the same directory as the Docker client binary.
NOTE: The credentials will need the "containers:read" scope to work with Docker`,
Run: doDockerCreds,
Expand Down Expand Up @@ -97,7 +97,7 @@ func doDockerCreds(cmd *cobra.Command, args []string) {
if errors.Is(err, fs.ErrNotExist) {
dockerConfig := filepath.Dir(dockerConfigFile)
if _, err := os.Stat(dockerConfig); errors.Is(err, fs.ErrNotExist) {
fmt.Println("Creating docker config directory:", dockerConfig)
fmt.Println("Creating Docker config directory:", dockerConfig)
subcommands.DieNotNil(os.Mkdir(dockerConfig, 0o755))
}
config = make(map[string]interface{})
Expand Down
Loading

0 comments on commit 9cb21dd

Please sign in to comment.