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
6 changes: 4 additions & 2 deletions cli/module_reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,12 @@ func configureModule(
return partResponse.Part, needsRestart, nil
}

// localizeModuleID converts a module ID to its 'local mode' name.
// localizeModuleID converts a module ID of the form "<namespace>:<moduleName>"
// (or "<orgID>:<moduleName>" if no namespace is set) into a name suitable for
// adding to a robot config, i.e. "<namespace>_<moduleName>" or "<orgID>_<moduleName>".
// TODO(APP-4019): remove this logic after registry modules can have local ExecPath.
func localizeModuleID(moduleID string) string {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not entirely privy to the callers of this and how this affects the robot config we generate. Specifically if removing _from_reload results in module name collisions we wouldn't expect before. Do you need any additional vetting from me that this is kosher?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I see your concern, but i think its fine. The app, rdk, and cli are resilient on changes in the name field of the JSON. The uniqueness and searching is on the module_id field and not the name field for modules https://github.com/viamrobotics/rdk/blob/main/cli/module_reload.go#L413. The behavior for modules is different than other areas of the config that treat name as needing to be unique. It is also currently allowed that you can change name field in app and reload will still find the module, so I'm not concerned about this. Also the RDK allows multiple modules with the same name, but not with the same moduleID (I just tested to reaffirm my understanding).

return strings.ReplaceAll(moduleID, ":", "_") + "_from_reload"
return strings.ReplaceAll(moduleID, ":", "_")
}

// mutateModuleConfig edits the modules list to hot-reload with the given manifest.
Expand Down
4 changes: 2 additions & 2 deletions cli/module_reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ func TestMutateModuleConfig(t *testing.T) {
JSONManifest: rdkConfig.JSONManifest{Entrypoint: "/bin/mod"},
Build: &manifestBuildInfo{Path: "module.tar.gz"},
}
expectedName := "viam-labs_test-module_from_reload"
expectedName := "viam-labs_test-module"
expectedVersion := "latest-with-prerelease"
remoteReloadPath := ".viam/packages-local/viam-labs_test-module_from_reload-module.tar.gz"
remoteReloadPath := ".viam/packages-local/viam-labs_test-module-module.tar.gz"
testUser := "test@viam.com"
testReloadUnixTS := time.Date(2024, 3, 18, 12, 0, 0, 0, time.UTC).Unix()

Expand Down
Loading