Skip to content

Commit

Permalink
Finish cleanup of text
Browse files Browse the repository at this point in the history
This is part 2 of 2 of the effort to cleanup the text for help commands
and logging. Mostly minor changes made so as to align with style-guide,
or in a effort to increase readability.

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

Signed-off-by: Katrina Prosise <katrina.prosise@foundries.io>
  • Loading branch information
kprosise committed Oct 18, 2024
1 parent 9662e81 commit 1e6371a
Show file tree
Hide file tree
Showing 31 changed files with 206 additions and 207 deletions.
2 changes: 1 addition & 1 deletion subcommands/secrets/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var api *client.Api

var cmd = &cobra.Command{
Use: "secrets",
Short: "Manage secret credentials configured in a factory",
Short: "Manage secret credentials configured in a Factory",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
api = subcommands.Login(cmd)
},
Expand Down
4 changes: 2 additions & 2 deletions subcommands/secrets/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import (
func init() {
cmd.AddCommand(&cobra.Command{
Use: "list",
Short: "List secret credentials configured in the factory",
Short: "List secret credentials configured in the Factory",
Run: doList,
})
}

func doList(cmd *cobra.Command, args []string) {
factory := viper.GetString("factory")
logrus.Debugf("Listing factory secrets for: %s", factory)
logrus.Debugf("Listing Factory secrets for: %s", factory)

triggers, err := api.FactoryTriggers(factory)
subcommands.DieNotNil(err)
Expand Down
4 changes: 2 additions & 2 deletions subcommands/secrets/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func init() {
cmd.AddCommand(&cobra.Command{
Use: "update secret_name=secret_val...",
Short: "Update secret(s) in a factory",
Short: "Update secret(s) in a Factory",
Example: `
# Create or update a secret
fioctl secrets update githubtok=foo
Expand All @@ -33,7 +33,7 @@ func init() {

func doUpdate(cmd *cobra.Command, args []string) {
factory := viper.GetString("factory")
logrus.Debugf("Updating factory secrets for: %s", factory)
logrus.Debugf("Updating Factory secrets for: %s", factory)

triggers, err := api.FactoryTriggers(factory)
subcommands.DieNotNil(err)
Expand Down
2 changes: 1 addition & 1 deletion subcommands/status/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var inactiveThreshold int
func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "status",
Short: "Get dashboard view of a factory and its devices",
Short: "Get dashboard view of a Factory and its devices",
Run: showStatus,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
api = subcommands.Login(cmd)
Expand Down
10 changes: 5 additions & 5 deletions subcommands/targets/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ type Targets map[string]*client.Target
func init() {
addCmd := &cobra.Command{
Use: "add",
Short: "Compose and add Targets to Factory's TUF targets metadata",
Short: "Compose and add Targets to Factory's TUF Targets metadata",
Run: doAdd,
Long: `
Compose new Targets out of the latest Targets tagged with the specified source tag and the specified via the command arguments either OSTree commit hashes or App URIs.
Compose new Targets out of the latest ones with the specified source tag via the command argumentseither OSTree commit hashes or App URIs.
fioctl targets add --type <ostree | app> --tags <comma,separate,list of Target tags> --src-tag <source Target tag> [--targets-creator <something about Targets originator>]\
<hardware ID> <ostree commit hash> [<hardware ID> <ostree commit hash>] (for ostree type)
Expand All @@ -45,7 +45,7 @@ Add new App Targets:
cmd.AddCommand(addCmd)
addCmd.Flags().StringVarP(&addTargetType, "type", "", "", "Target type")
addCmd.Flags().StringVarP(&addTags, "tags", "", "", "comma,separate,list of Target tags")
addCmd.Flags().StringVarP(&addSrcTag, "src-tag", "", "", "OSTree Target tag to base app targets on")
addCmd.Flags().StringVarP(&addSrcTag, "src-tag", "", "", "OSTree Target tag to base app Targets on")
addCmd.Flags().BoolVarP(&addQuiet, "quiet", "", false, "don't print generated new Targets to stdout")
addCmd.Flags().BoolVarP(&addDryRun, "dry-run", "", false, "don't post generated new Targets")
addCmd.Flags().StringVarP(&addTargetsCreator, "targets-creator", "", "fioctl", "optional name/comment/context about Targets origination")
Expand Down Expand Up @@ -169,11 +169,11 @@ func deriveTargets(factory string, hwIds map[string]interface{}, srcTag string,
// We assume that the initial OSTree Target(s) is/are created by the OTA service during Factory creation,
// hence we don't need to create a new Target from scratch in this command, just derive Targets from existing one.
if len(latestTargetsPerHwId) == 0 {
return nil, fmt.Errorf("no any source Targets to derive new Targets from are found; source tag: %s", srcTag)
return nil, fmt.Errorf("Could not find source Target to derive new Target from; source tag: %s", srcTag)
}
for id := range hwIds {
if _, ok := latestTargetsPerHwId[id]; !ok {
return nil, fmt.Errorf("no source Target to derive new Target from is found"+
return nil, fmt.Errorf("Could not find source Target to derive new Target from"+
" for the source tag `%s` and the hardware ID `%s`", srcTag, id)
}
}
Expand Down
4 changes: 2 additions & 2 deletions subcommands/targets/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func doArtifacts(cmd *cobra.Command, args []string) {
factory := viper.GetString("factory")

if len(args) == 0 {
logrus.Debugf("Showing all testing done for factory: %s", factory)
logrus.Debugf("Showing all testing done for Factory: %s", factory)
listAll(factory)
os.Exit(0)
}
Expand All @@ -123,7 +123,7 @@ func doArtifacts(cmd *cobra.Command, args []string) {
subcommands.DieNotNil(fmt.Errorf("Invalid Target number: %s", args[0]))
}
if len(args) == 1 {
logrus.Debugf("Showing target artifacts for %s %d", factory, target)
logrus.Debugf("Showing Target artifacts for %s %d", factory, target)
listArtifacts(factory, target)
} else {
artifact := args[1]
Expand Down
2 changes: 1 addition & 1 deletion subcommands/targets/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var api *client.Api

var cmd = &cobra.Command{
Use: "targets",
Short: "Manage factory's TUF targets",
Short: "Manage Factory TUF targets",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
api = subcommands.Login(cmd)
},
Expand Down
20 changes: 10 additions & 10 deletions subcommands/targets/deltas.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ var (
func init() {
var deltas = &cobra.Command{
Use: "static-deltas <target-version> [<from-version>...]",
Short: "Generate static deltas to the given target version to make OTAs faster",
Short: "Generate static deltas to the given Target version to make OTAs faster",
Run: doDeltas,
Args: cobra.MinimumNArgs(1),
Long: `In many cases OTA updates will have many OSTree changes. These updates
can be downloaded significantly faster by generating OSTree static
deltas. Static deltas are generated with a "from(sha) -> to(sha)" type
logic. This command takes the given Target version and will produce a
number of static deltas to ensure devices will be updated efficiently.`,
Long: `In many cases OTA updates will have multiple OSTree changes. These updates
can be downloaded faster by generating OSTree static
deltas. Static deltas are generated using "from(sha) -> to(sha)" type
logic. This command takes the given Target version, and produces a
number of static deltas to ensure devices are updated efficiently.`,
Example: `
# There are two ways to run this command:
Expand All @@ -43,7 +43,7 @@ number of static deltas to ensure devices will be updated efficiently.`,
deltas.Flags().StringVarP(&byTag, "by-tag", "", "", "Find from-versions devices on the given tag")
deltas.Flags().BoolVarP(&noTail, "no-tail", "", false, "Don't tail output of CI Job")
deltas.Flags().BoolVarP(&dryRun, "dryrun", "", false, "Only show what deltas would be produced")
deltas.Flags().StringVarP(&hwId, "hw-id", "", "", "Filter from and to targets by the given hardware ID")
deltas.Flags().StringVarP(&hwId, "hw-id", "", "", "Filter from and to Targets by the given hardware ID")
}

func findVersions(maxVer int, forTag string, tags []client.TagStatus) (bool, []int) {
Expand Down Expand Up @@ -97,13 +97,13 @@ func doDeltas(cmd *cobra.Command, args []string) {
}
}
if len(froms) == 0 {
subcommands.DieNotNil(errors.New("No targets found to generate deltas for."))
subcommands.DieNotNil(errors.New("No Targets found to generate deltas for."))
}
if dryRun {
if len(hwId) > 0 {
fmt.Printf("Dry run: Would be generated static deltas for targets with hardware ID %s and versions:\n", hwId)
fmt.Printf("Dry run: Would generate static deltas for Targets with hardware ID %s and versions:\n", hwId)
} else {
fmt.Println("Dry run: Would be generated static deltas for target versions:")
fmt.Println("Dry run: Would generate static deltas for Target versions:")
}
for _, v := range froms {
fmt.Println(" ", v, "->", toVer)
Expand Down
6 changes: 3 additions & 3 deletions subcommands/targets/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {

func doEdit(cmd *cobra.Command, args []string) {
factory := viper.GetString("factory")
logrus.Debugf("Editing targets for %s", factory)
logrus.Debugf("Editing Targets for %s", factory)

// Get raw json
targets, err := api.TargetsList(factory)
Expand Down Expand Up @@ -83,7 +83,7 @@ func doEdit(cmd *cobra.Command, args []string) {
var newTargets tuf.Files
err = json.Unmarshal(content, &newTargets)
if err != nil {
fmt.Println("Unable to parse new targets: ", err)
fmt.Println("Unable to parse new Targets: ", err)
os.Exit(1)
}
type TargetsUp struct {
Expand All @@ -92,7 +92,7 @@ func doEdit(cmd *cobra.Command, args []string) {
upload := TargetsUp{newTargets}
content, err = json.Marshal(upload)
if err != nil {
fmt.Println("Unable to marshall targets data: ", err)
fmt.Println("Unable to marshal Targets data: ", err)
os.Exit(1)
}

Expand Down
2 changes: 1 addition & 1 deletion subcommands/targets/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {
}
cmd.AddCommand(imageCmd)
imageCmd.Flags().StringVarP(&appsShortlist, "apps", "", "",
"comma,separate,list of Target apps to preload into a resultant image."+
"comma,separate,list of Target apps to preload into an image."+
" All apps of Target are preloaded if the flag is not defined or empty")
imageCmd.Flags().BoolVarP(&noTail, "no-tail", "", false, "Don't tail output of CI Job")
imageCmd.Flags().StringVarP(&ciScriptsRepo, "ci-scripts-repo", "", "https://github.com/foundriesio/ci-scripts", "Override to custom version of ci-scripts")
Expand Down
4 changes: 2 additions & 2 deletions subcommands/targets/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ func init() {
cmd.AddCommand(listCmd)
listCmd.Flags().BoolVarP(&listRaw, "raw", "r", false, "Print raw targets.json")
listCmd.Flags().BoolVarP(&listProd, "production", "", false, "Show the production version targets.json")
listCmd.Flags().StringVarP(&listByTag, "by-tag", "", "", "Only list targets that match the given tag")
listCmd.Flags().StringVarP(&listByTag, "by-tag", "", "", "Only list Targets that match the given tag")
listCmd.Flags().StringSliceVarP(&showColumns, "columns", "", defCols, "Specify which columns to display")
}

func doList(cmd *cobra.Command, args []string) {
factory := viper.GetString("factory")
logrus.Debugf("Listing targets for %s tag(%s)", factory, listByTag)
logrus.Debugf("Listing Targets for %s tag(%s)", factory, listByTag)

if listProd && len(listByTag) == 0 {
subcommands.DieNotNil(errors.New("--production flag requires --by-tag flag"))
Expand Down
44 changes: 22 additions & 22 deletions subcommands/targets/offline-update.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ func init() {
Run: doOfflineUpdate,
Args: cobra.ExactArgs(2),
Example: `
# Download update content of the wave target #1451 for "intel-corei7-64" hardware type
# Download update content of the Wave Target #1451 for "intel-corei7-64" hardware type
fioctl targets offline-update intel-corei7-64-lmp-1451 /mnt/flash-drive/offline-update-content --wave wave-deployment-001
# Download update content of the production target #1451 tagged by "release-01" for "intel-corei7-64" hardware type
# Download update content of the production Target #1451 tagged by "release-01" for "intel-corei7-64" hardware type
fioctl targets offline-update intel-corei7-64-lmp-1451 /mnt/flash-drive/offline-update-content --tag release-01 --prod
# Download update content of the CI target #1451 tagged by "devel" for "raspberrypi4-64" hardware type
# Download update content of the CI Target #1451 tagged by "devel" for "raspberrypi4-64" hardware type
fioctl targets offline-update raspberrypi4-64-lmp-1448 /mnt/flash-drive/offline-update-content --tag devel --expires-in-days 15
`,
Expand All @@ -78,15 +78,15 @@ func init() {
offlineUpdateCmd.Flags().BoolVarP(&ouProd, "prod", "", false,
"Instruct to fetch content of production Target")
offlineUpdateCmd.Flags().StringVarP(&ouWave, "wave", "", "",
"Instruct to fetch content of wave Target; a wave name should be specified")
"Instruct to fetch content of Wave Target; a wave name should be specified")
offlineUpdateCmd.Flags().IntVarP(&ouExpiresIn, "expires-in-days", "e", 30,
"Desired metadata validity period in days")
offlineUpdateCmd.Flags().BoolVarP(&ouTufOnly, "tuf-only", "m", false,
"Fetch only TUF metadata")
offlineUpdateCmd.Flags().BoolVarP(&ouNoApps, "no-apps", "", false,
"Skip fetching Target Apps")
offlineUpdateCmd.Flags().BoolVarP(&ouAllowMultipleTargets, "allow-multiple-targets", "", false,
"Allow multiple targets to be stored in the same <dst> directory")
"Allow multiple Targets to be stored in the same <dst> directory")
offlineUpdateCmd.MarkFlagsMutuallyExclusive("tag", "wave")
offlineUpdateCmd.MarkFlagsMutuallyExclusive("prod", "wave")
initSignCmd(offlineUpdateCmd)
Expand All @@ -96,19 +96,19 @@ func init() {
func initSignCmd(parentCmd *cobra.Command) {
signCmd := &cobra.Command{
Use: "sign <path to an offline bundle>",
Short: "Sign an offline bundle with a targets role offline key",
Long: `Sign an offline bundle with a targets role offline key.
Short: "Sign an offline bundle with a Targets role offline key",
Long: `Sign an offline bundle with a Targets role offline key.
Run this command if your offline update bundle contains production/wave targets.
In this case, the bundle has to be signed by one or more targets role offline keys.
Run this command if your offline update bundle contains production/Wave targets.
In this case, the bundle has to be signed by one or more Targets role offline key.
The number of required signatures depends on the threshold number set in the current TUF root role metadata,
and is printed by this command.`,
Run: doSignBundle,
Args: cobra.ExactArgs(1),
}
signCmd.Flags().StringP("keys", "k", "",
"Path to the <tuf-targets-keys.tgz> key to sign the bundle metadata with. "+
"This is the same key used to sign prod & wave TUF targets.")
"This is the same key used to sign prod & Wave TUF Targets.")
_ = signCmd.MarkFlagRequired("keys")
parentCmd.AddCommand(signCmd)
}
Expand All @@ -120,7 +120,7 @@ func initShowCmd(parentCmd *cobra.Command) {
Long: `Parse and print the specified bundle metadata.
Run this command if you would like to get information about an offline bundle.
Specifically, what targets it includes, what the type of the targets (CI or production),
Specifically, what Targets it includes, what the type of the Targets (CI or production),
a bundle's expiration time', etc.`,
Run: doShowBundle,
Args: cobra.ExactArgs(1),
Expand Down Expand Up @@ -160,8 +160,8 @@ func doOfflineUpdate(cmd *cobra.Command, args []string) {
if !isDstDirClean(dstDir) {
if !ouAllowMultipleTargets {
subcommands.DieNotNil(errors.New(`Destination directory already has update data.
Provide a clean destination directory or re-run with --allow-multiple-targets to add a new target to a directory which already has update data.
Notice that multiple targets in the same directory is only supported in LmP >= v92.`))
Provide a clean destination directory or re-run with --allow-multiple-targets to add a new Target to a directory which already has update data.
Notice that multiple Targets in the same directory is only supported in LmP >= v92.`))
}
}

Expand Down Expand Up @@ -191,8 +191,8 @@ Notice that multiple targets in the same directory is only supported in LmP >= v
fmt.Printf("Downloading Apps fetched by the `publish-compose-apps` run; apps: %s, uri: %s...\n", ti.fetchedApps.Shortlist, ti.fetchedApps.Uri)
err = downloadAppsArchive(ti.fetchedApps.Uri, path.Join(dstDir, "apps"))
} else {
fmt.Println("No apps found to fetch for an offline update to a given target. " +
"The bundle will update only rootfs/ostree. Check your factory configuration if this is not your intention.")
fmt.Println("No apps found to fetch for an offline update to a given Target. " +
"The bundle will only update rootfs/ostree. Check your Factory configuration if this is not your intention.")
}
}
if herr := client.AsHttpError(err); herr != nil && herr.Response.StatusCode == 404 {
Expand Down Expand Up @@ -253,7 +253,7 @@ func getWaveTargetMeta(factory string, targetName string, wave string) (*tuf.Fil
if foundTargetMeta, ok := waveTargets[wave].Signed.Targets[targetName]; ok {
return &foundTargetMeta, nil
} else {
return nil, fmt.Errorf("The specified Target is not found among wave targets;"+
return nil, fmt.Errorf("The specified Target is not found among Wave Targets;"+
" target: %s, wave: %s", targetName, wave)
}
}
Expand All @@ -262,14 +262,14 @@ func getProdTargetMeta(factory string, targetName string, tag string) (*tuf.File
targets, err := api.ProdTargetsGet(factory, tag, true)
if err != nil {
if herr := client.AsHttpError(err); herr != nil && herr.Response.StatusCode == 404 {
return nil, fmt.Errorf("No production targets were found for the specified tag `%s`", tag)
return nil, fmt.Errorf("No production Targets were found for the specified tag `%s`", tag)
}
return nil, fmt.Errorf("Failed to get production Target metadata: %s", err.Error())
}
if foundTargetMeta, ok := targets.Signed.Targets[targetName]; ok {
return &foundTargetMeta, nil
} else {
return nil, fmt.Errorf("No production target with the given tag is found;"+
return nil, fmt.Errorf("No production Target with the given tag found;"+
" target: %s, tag: %s", targetName, tag)
}
}
Expand All @@ -278,7 +278,7 @@ func getCiTargetMeta(factory string, targetName string, tag string) (*tuf.FileMe
data, err := api.TufMetadataGet(factory, "targets.json", tag, false)
if err != nil {
if herr := client.AsHttpError(err); herr != nil && herr.Response.StatusCode == 404 {
return nil, fmt.Errorf("No CI targets were found for the specified tag `%s`", tag)
return nil, fmt.Errorf("No CI Targets found for the specified tag `%s`", tag)
}
return nil, fmt.Errorf("Failed to get CI Target metadata: %s", err.Error())
}
Expand All @@ -290,7 +290,7 @@ func getCiTargetMeta(factory string, targetName string, tag string) (*tuf.FileMe
if foundTargetMeta, ok := targets.Signed.Targets[targetName]; ok {
return &foundTargetMeta, nil
} else {
return nil, fmt.Errorf("No CI target with the given tag is found;"+
return nil, fmt.Errorf("No CI Target with the given tag found;"+
" target: %s, tag: %s", targetName, tag)
}
}
Expand Down Expand Up @@ -541,7 +541,7 @@ func signBundleTargets(rootMeta *client.AtsTufRoot, bundleTargetsMeta *tuf.Signe
if bundleTargetsMeta.Signed == nil {
panic(fmt.Errorf("the input bundle metadata to sign is nil"))
}
fmt.Printf("Signing the bundle with a new key; ID: %s, type: %s\n", signer.Id, signer.Type.Name())
fmt.Printf("Signing the bundle with new key; ID: %s, type: %s\n", signer.Id, signer.Type.Name())
signatures, err := keys.SignTufMeta(*bundleTargetsMeta.Signed, signer)
if err != nil {
return err
Expand All @@ -556,7 +556,7 @@ func doShowBundle(cmd *cobra.Command, args []string) {
subcommands.DieNotNil(err)
bundleMeta := ouBundleTufMeta{}
subcommands.DieNotNil(json.Unmarshal(*bundleTufMeta.Signed, &bundleMeta))
fmt.Println("Bundle targets info:")
fmt.Println("Bundle Targets info:")
fmt.Printf("\tType:\t\t%s\n", bundleMeta.ouBundleMeta.Type)
fmt.Printf("\tTag:\t\t%s\n", bundleMeta.Tag)
fmt.Printf("\tExpires:\t%s\n", bundleMeta.SignedCommon.Expires)
Expand Down
Loading

0 comments on commit 1e6371a

Please sign in to comment.