Skip to content

Commit

Permalink
Fix: check if go extensions have duplicated go module name (#150)
Browse files Browse the repository at this point in the history
Co-authored-by: adonia <[email protected]>
  • Loading branch information
leoadonia and adonia authored Aug 2, 2024
1 parent f26ffed commit 1e1cc87
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions agents/scripts/build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,10 @@ func (ab *AppBuilder) autoDetectExtensions() error {
return err
}

// Ensure that all extension modules are unique, otherwise the modules with
// same name will be overwritten.
uniqueModules := make(map[string]string)

for _, entry := range entries {
if !entry.IsDir() {
continue
Expand All @@ -1076,6 +1080,16 @@ func (ab *AppBuilder) autoDetectExtensions() error {
continue
}

if location, ok := uniqueModules[ext.module]; ok {
return fmt.Errorf(
"the extensions [%s] and [%s] have duplicated module name [%s]",
path.Base(location),
path.Base(ext.location),
ext.module,
)
}

uniqueModules[ext.module] = ext.location
ab.extensions = append(ab.extensions, ext)
}

Expand Down
4 changes: 4 additions & 0 deletions agents/scripts/install_deps_and_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ build_go_app() {
cd $app_dir

go run scripts/build/main.go --verbose
if [[ $? -ne 0 ]]; then
echo "FATAL: failed to build go app, see logs for detail."
exit 1
fi
}

clean() {
Expand Down

0 comments on commit 1e1cc87

Please sign in to comment.