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

Add golang source detector for new-app #12485

Merged
merged 1 commit into from
Jan 14, 2017
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
5 changes: 5 additions & 0 deletions examples/gitserver/hooks/detect-language
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,9 @@ if has project.json || hasglob '*.csproj'; then
exit 0
fi

if has main.go Godeps; then
echo "${prefix}golang"
exit 0
fi

exit 1
6 changes: 6 additions & 0 deletions pkg/generate/source/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var DefaultDetectors = Detectors{
DetectScala,
DetectDotNet,
DetectLiteralDotNet,
DetectGolang,
}

// DetectRuby detects Ruby source
Expand Down Expand Up @@ -74,6 +75,11 @@ func DetectLiteralDotNet(dir string) *Info {
return detect(".net", dir, "project.json", "*.csproj")
}

// DetectGolang detects Go source
func DetectGolang(dir string) *Info {
return detect("golang", dir, "main.go", "Godeps")
Copy link

Choose a reason for hiding this comment

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

Can we use *.go here, similar to *.csproj for .NET? At the moment s2i-go requires a main.go file, but I would like to fix that limitation eventually, to be able to run arbitrary programs (given a go install-style path)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, please submit a PR adding *.go

}

// detect returns an Info object with the given platform if the source at dir contains any of the argument files
func detect(platform string, dir string, globs ...string) *Info {
for _, g := range globs {
Expand Down