Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: check if go extensions have duplicated go module name #150

Merged
merged 1 commit into from
Aug 2, 2024
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
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