Skip to content

Conversation

@doanac
Copy link
Member

@doanac doanac commented Dec 15, 2025

No description provided.

Signed-off-by: Andy Doan <andy@foundries.io>
@doanac
Copy link
Member Author

doanac commented Dec 15, 2025

I was hesitant to pull in the nanoid stuff, but it does make the tests a lot more readable (better than b32 in my opinion). You can see before(regular UUID) and after here:

$ ./bin/fioctl-linux-amd64 devices tests qc-t14-qemu
NAME       STATUS  ID                                    CREATED AT
----       ------  --                                    ----------
dmesg-man  PASSED  3528fb7a-f9fb-470e-8e24-5f108e4b92b5  2025-07-24 16:19:12 +0000 UTC
diag-man   FAILED  e83ea855-5ef0-408c-902a-f42577237576  2025-07-24 16:27:44 +0000 UTC
diag-man   PASSED  7ec2e4d6-a391-4208-a226-f03f6c53a318  2025-07-24 16:32:00 +0000 UTC
diag       PASSED  diag_zTK-B2kMXtIp1vl                  2025-08-22 16:12:48 +0000 UTC
diag       PASSED  diag_cTLD_J_Nu6mSRpW                  2025-08-26 16:38:24 +0000 UTC
diag       PASSED  diag_2gKXjezZzcL_I9D                  2025-08-27 15:40:48 +0000 UTC
diag       PASSED  diag_VCoCdjGwzxLErhh                  2025-12-12 23:02:24 +0000 UTC
reboot     FAILED  reboot_fUeLdVza6kh2PkZ                2025-12-12 23:04:32 +0000 UTC
diag       PASSED  diag_8u_42JiMRZ9VAhR                  2025-12-12 23:13:04 +0000 UTC
reboot     FAILED  reboot_7Dol0brjAaiIMjS                2025-12-12 23:13:04 +0000 UTC
reboot     FAILED  reboot_hr6BlnBX7b_jKLT                2025-12-12 23:17:20 +0000 UTC
reboot     PASSED  reboot_fZA31Esg2tGRxRY                2025-12-12 23:30:08 +0000 UTC

@doanac doanac requested a review from vkhoroz December 15, 2025 14:48
Use: "trigger",
Short: "Trigger remote actions on device",
Long: `
*NOTE*: Requires devices running LmP version 97 or later.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long help usually starts with the same line as the short help (without a leading newline). They are not being concatenated.


func init() {
triggerCmd := &cobra.Command{
Use: "trigger",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use something like action or run or exec?
I find the word trigger rather cryptic in this context.

TBH the most natural choice would be to do fioctl device actions [list] to list available remote actions, and fioctl device [actions] run|exec to run an action. I'm not sure if we need the actions keyword for the latter, it depends. If we also want something like fioctl device actions tail, then it would probably be handy to group all these commands. Also, I'm not sure if it is possible to show the user currently running actions... probably possible, right?


ccr := opts.AsConfig()
subcommands.DieNotNil(d.Api.PatchConfig(ccr, false))
fmt.Println("Config change submitted. Command ID is:", opts.CommandId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we print here how the user can see the command log/result? Is there a fioctl command for that?

}
}
fmt.Println("Remote actions are not configured for this device")
os.Exit(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is strange to have an exit here. It would look better inside doTrigger.

Note: in case if the user wants to execute some action and there are no available actions, we need to DieNotNil.


action := args[1]
if !slices.Contains(allowed, action) {
subcommands.DieNotNil(fmt.Errorf("Invalid action: %s", action))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, we also show what are the available actions in this case?

if len(action) > maxActionLen { // Device Gateway has max len of 48
subcommands.DieNotNil(fmt.Errorf("Action name(%s) too long. Max length is %d", action, maxActionLen))
}
id, err := nanoid.New(idLen)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a NanoID dependency here? Ain't the rand.Text()[:15] good enough.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess not. I just find nano ids to be much more visibly pleasant:
diag_8u_42JiMRZ9VAhR feels better on my eyes than diag_UPBBEVTHF4FQWIZ when I'm trying to look things up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no difference between these IDs... it's just a copy-paste either way.
My point was to have one less dependency.


// For the random part anything >= 15 characters will give us about 1,000
// years before a collision (assuming 100 IDs per second):
// https://zelark.github.io/nano-id-cc/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this comment - it is a common wisdom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants