Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions internal/fleetkey/fleetkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ func Create(invocation api.Invocation, arguments []string) error {
}

if created.FleetKey == "" {
return errors.New("the key was not created, try again")
return errors.New("the fleet key was not created, try again")
}

fmt.Fprintf(invocation.Out, "Created key %d.\n\n %s\n\nAnyone holding it can send data to the fleet, and you will not see it again.\n", created.Id, api.Printable(created.FleetKey))
fmt.Fprintf(invocation.Out, "Created fleet key %d.\n\n %s\n\nAnyone holding it can send data to the fleet, and you will not see it again.\n", created.Id, api.Printable(created.FleetKey))

return nil
}
Expand Down Expand Up @@ -130,9 +130,9 @@ func List(invocation api.Invocation, arguments []string) error {

if len(fleetKeys) == 0 {
if chosenFleetId == 0 {
fmt.Fprintln(invocation.Out, "No keys yet. Create one with key create.")
fmt.Fprintln(invocation.Out, "No fleet keys yet. Create one with key create.")
} else {
fmt.Fprintln(invocation.Out, "No keys on that fleet yet.")
fmt.Fprintln(invocation.Out, "No fleet keys on that fleet yet.")
}

return nil
Expand Down Expand Up @@ -181,7 +181,7 @@ func Revoke(invocation api.Invocation, arguments []string) error {
fleetKeyId, err := strconv.ParseInt(arguments[0], 10, 64)

if err != nil || fleetKeyId < 1 {
return errors.New("the key id is the number shown by key list")
return errors.New("the fleet key id is the number shown by key list")
}

fleetKeys, err := api.FetchFleetKeys(invocation)
Expand All @@ -201,10 +201,10 @@ func Revoke(invocation api.Invocation, arguments []string) error {
}

if !found {
return errors.New("no such key")
return errors.New("no such fleet key")
}

fmt.Fprintf(invocation.Out, "Revoke key %q? Anything still using it stops reaching the fleet. [y/N] ", label)
fmt.Fprintf(invocation.Out, "Revoke fleet key %q? Anything still using it stops reaching the fleet. [y/N] ", label)

answer, _ := bufio.NewReader(invocation.In).ReadString('\n')

Expand Down Expand Up @@ -234,7 +234,7 @@ func Revoke(invocation api.Invocation, arguments []string) error {
return api.ServerError(response)
}

fmt.Fprintf(invocation.Out, "Revoked key %q.\n", label)
fmt.Fprintf(invocation.Out, "Revoked fleet key %q.\n", label)

return nil
}
10 changes: 5 additions & 5 deletions internal/fleetkey/fleetkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestFleetKeyCreate(t *testing.T) {
t.Errorf("the output %q does not warn that the fleet key cannot be shown again", printed)
}

if !strings.Contains(printed, "Created key 1.") {
if !strings.Contains(printed, "Created fleet key 1.") {
t.Errorf("the output %q does not name the fleet key it created", printed)
}
})
Expand Down Expand Up @@ -182,13 +182,13 @@ func TestFleetKeyList(t *testing.T) {
{
name: "no fleet keys",
arguments: []string{},
wantShown: []string{"No keys yet. Create one with key create."},
wantShown: []string{"No fleet keys yet. Create one with key create."},
fleetKeys: `[]`,
},
{
name: "a fleet without fleet keys",
arguments: []string{"5"},
wantShown: []string{"No keys on that fleet yet."},
wantShown: []string{"No fleet keys on that fleet yet."},
wantHidden: []string{"ID FLEET"},
},
{
Expand Down Expand Up @@ -297,7 +297,7 @@ func TestFleetKeyRevoke(t *testing.T) {
arguments: []string{"3"},
answer: "y\n",
wantRevoked: "/fleet-keys/3",
wantShown: "Revoked key \"production\".",
wantShown: "Revoked fleet key \"production\".",
},
{
name: "declined by default",
Expand Down Expand Up @@ -328,7 +328,7 @@ func TestFleetKeyRevoke(t *testing.T) {
name: "a fleet key that is not yours",
arguments: []string{"9"},
answer: "y\n",
wantError: "no such key",
wantError: "no such fleet key",
},
{
name: "no fleet key id",
Expand Down
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ var sections = []dispatch.Section{
},
},
{
Title: "Keys",
Title: "Fleet keys",
Commands: []dispatch.Command{
{Name: "key create", Arguments: "<fleet_id> <label>", Summary: "Create a key for sending data to a fleet", Run: fleetkey.Create,
Details: "Shows the key once, so copy it then. Anyone holding it can send data to\n" +
"the fleet."},
{Name: "key list", Arguments: "[fleet_id] [--json]", Summary: "List the keys that can reach your fleets", Run: fleetkey.List},
{Name: "key revoke", Arguments: "<key_id>", Summary: "Stop a key from reaching its fleet", Run: fleetkey.Revoke,
Details: "Asks first. Anything still using the key can no longer reach the fleet."},
{Name: "key create", Arguments: "<fleet_id> <label>", Summary: "Create a fleet key for sending data to a fleet", Run: fleetkey.Create,
Details: "Shows the fleet key once, so copy it then. Anyone holding it can send\n" +
"data to the fleet."},
{Name: "key list", Arguments: "[fleet_id] [--json]", Summary: "List the fleet keys that can reach your fleets", Run: fleetkey.List},
{Name: "key revoke", Arguments: "<key_id>", Summary: "Stop a fleet key from reaching its fleet", Run: fleetkey.Revoke,
Details: "Asks first. Anything still using the fleet key can no longer reach the fleet."},
},
},
{
Expand Down
Loading