Files
pack/core/providers/provider.go
T

42 lines
1.1 KiB
Go

package providers
import (
"github.com/railwayapp/railpack/core/generate"
"github.com/railwayapp/railpack/core/providers/golang"
"github.com/railwayapp/railpack/core/providers/node"
"github.com/railwayapp/railpack/core/providers/php"
"github.com/railwayapp/railpack/core/providers/python"
"github.com/railwayapp/railpack/core/providers/shell"
"github.com/railwayapp/railpack/core/providers/staticfile"
)
type Provider interface {
Name() string
Detect(ctx *generate.GenerateContext) (bool, error)
Initialize(ctx *generate.GenerateContext) error
Plan(ctx *generate.GenerateContext) error
StartCommandHelp() string
}
func GetLanguageProviders() []Provider {
// Order is important here. The first provider that returns true from Detect() will be used.
return []Provider{
&php.PhpProvider{},
&golang.GoProvider{},
&python.PythonProvider{},
&node.NodeProvider{},
&staticfile.StaticfileProvider{},
&shell.ShellProvider{},
}
}
func GetProvider(name string) Provider {
for _, provider := range GetLanguageProviders() {
if provider.Name() == name {
return provider
}
}
return nil
}