Skip to content

Conversation

@matevz
Copy link
Member

@matevz matevz commented Jan 22, 2026

This PR adds support for addressing ROFL machines directly using provider-address:machine-id syntax. This enables showing machine info, removing it, topping it up, changing admin, showing logs without needing rofl.yaml manifest.

Useful for automation. Related #677 .

@netlify
Copy link

netlify bot commented Jan 22, 2026

Deploy Preview for oasisprotocol-cli canceled.

Name Link
🔨 Latest commit 8d48aed
🔍 Latest deploy log https://app.netlify.com/projects/oasisprotocol-cli/deploys/697211c4bd7c4f000895384e

@matevz matevz force-pushed the matevz/feature/rofl-machine-id branch 2 times, most recently from 3c5a323 to 61b5349 Compare January 22, 2026 10:55
@matevz matevz requested review from peternose and ptrus January 22, 2026 11:10
@matevz matevz force-pushed the matevz/feature/rofl-machine-id branch from 61b5349 to 59fa883 Compare January 22, 2026 11:52
@matevz matevz force-pushed the matevz/feature/rofl-machine-id branch from 59fa883 to 8d48aed Compare January 22, 2026 12:02
Copy link
Contributor

@peternose peternose left a comment

Choose a reason for hiding this comment

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

Looks like these changes should work, but I did not test them. The code (previous and changes) is quite complicated and could be improved.

)

func resolveMachine(args []string, deployment *buildRofl.Deployment) (*buildRofl.Machine, string, roflmarket.InstanceID) {
func resolveMachineManifestNpa(args []string, manifestOpts *roflCommon.ManifestOptions) (machineCfg *buildRofl.Machine, machineName string, machineID roflmarket.InstanceID, manifest *buildRofl.Manifest, extraCfg *roflCmdBuild.AppExtraConfig, providerAddr *types.Address, npa *common.NPASelection) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Few remarks:

  • Returned data should be collected in a struct, as Go methods should return at most 2 values.
  • The returned values should also not be named, unless this is needed because of defer statement or to explain what the function returns.
  • The code is very complicated, and should be changed in such a way that you a) get npa b) resolve machine from args or manifest c) resolve provider address.

Aliases: []string{"cancel", "rm"},
Args: cobra.MaximumNArgs(1),
Run: func(_ *cobra.Command, args []string) {
txCfg := common.GetTransactionConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same could be done in change-admin.

return machineCfg, machineName, machineID, manifest, extraCfg, providerAddr, npa
}

func resolveMachineFromArgs(args []string) (*buildRofl.Machine, string, roflmarket.InstanceID) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If function optionally returns values, it should return two values, the second one being bool, e.g. func resolve() (*mystruct, bool).

Also, happy path should not be indented.

if len(args) == 0
...
if len(parts) != 2
...


if err = manifest.Save(); err != nil {
cobra.CheckErr(fmt.Errorf("failed to update manifest: %w", err))
if manifest != nil {
Copy link
Contributor

@peternose peternose Jan 22, 2026

Choose a reason for hiding this comment

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

This complicates everything. Since helper function can return nil manifest, I would expect it could also return nil for other values. So I would expect these kind of checks for all values. Therefore, I don't allow returning nil values, and if I do, the function returns also bool to indicate whether the value is nil.

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.

3 participants