Преглед на файлове

Remove redundant test-runtime CLI tool and associated source files

Mohammed Nafees преди 4 години
родител
ревизия
d088c14013

+ 0 - 4
Makefile

@@ -18,7 +18,3 @@ build-cli:
 
 build-cli-dev:
 	go build -tags cli -o $(BINDIR)/porter ./cli
-
-test-runtime:
-	cp ./cmd/test-runtime/buildpacks-toml/nodejs.buildpack.toml $(BINDIR)/
-	go build -tags test-runtime -o $(BINDIR)/test-runtime ./cmd/test-runtime

+ 4 - 4
api/server/handlers/gitinstallation/get_buildpack.go

@@ -74,11 +74,11 @@ func (c *GithubGetBuildpackHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
 	}
 
 	var wg sync.WaitGroup
-	wg.Add(len(buildpacks.APIRuntimes))
-	detectResults := make(chan *buildpacks.RuntimeResponse, len(buildpacks.APIRuntimes))
-	for i := range buildpacks.APIRuntimes {
+	wg.Add(len(buildpacks.Runtimes))
+	detectResults := make(chan *buildpacks.RuntimeResponse, len(buildpacks.Runtimes))
+	for i := range buildpacks.Runtimes {
 		go func(idx int) {
-			detectResults <- buildpacks.APIRuntimes[idx].Detect(
+			detectResults <- buildpacks.Runtimes[idx].Detect(
 				client, directoryContents, owner, name, request.Dir, repoContentOptions,
 			)
 			wg.Done()

+ 0 - 136
cmd/test-runtime/buildpacks-toml/nodejs.buildpack.toml

@@ -1,136 +0,0 @@
-api = "0.4"
-
-[buildpack]
-  homepage = "https://github.com/paketo-buildpacks/nodejs"
-  id = "paketo-buildpacks/nodejs"
-  name = "Paketo Node.js Buildpack"
-
-[metadata]
-  include-files = ["buildpack.toml"]
-
-[[order]]
-
-  [[order.group]]
-    id = "paketo-buildpacks/ca-certificates"
-    optional = true
-    version = "2.4.2"
-
-  [[order.group]]
-    id = "paketo-buildpacks/node-engine"
-    version = "0.10.0"
-
-  [[order.group]]
-    id = "paketo-buildpacks/yarn"
-    version = "0.4.3"
-
-  [[order.group]]
-    id = "paketo-buildpacks/yarn-install"
-    version = "0.5.0"
-
-  [[order.group]]
-    id = "paketo-buildpacks/node-module-bom"
-    optional = true
-    version = "0.1.2"
-
-  [[order.group]]
-    id = "paketo-buildpacks/node-run-script"
-    optional = true
-    version = "0.2.0"
-
-  [[order.group]]
-    id = "paketo-buildpacks/yarn-start"
-    version = "0.4.0"
-
-  [[order.group]]
-    id = "paketo-buildpacks/procfile"
-    optional = true
-    version = "4.4.1"
-
-  [[order.group]]
-    id = "paketo-buildpacks/environment-variables"
-    optional = true
-    version = "3.2.2"
-
-  [[order.group]]
-    id = "paketo-buildpacks/image-labels"
-    optional = true
-    version = "3.2.3"
-
-[[order]]
-
-  [[order.group]]
-    id = "paketo-buildpacks/ca-certificates"
-    optional = true
-    version = "2.4.2"
-
-  [[order.group]]
-    id = "paketo-buildpacks/node-engine"
-    version = "0.10.0"
-
-  [[order.group]]
-    id = "paketo-buildpacks/npm-install"
-    version = "0.5.0"
-
-  [[order.group]]
-    id = "paketo-buildpacks/node-module-bom"
-    optional = true
-    version = "0.1.2"
-
-  [[order.group]]
-    id = "paketo-buildpacks/node-run-script"
-    optional = true
-    version = "0.2.0"
-
-  [[order.group]]
-    id = "paketo-buildpacks/npm-start"
-    version = "0.5.0"
-
-  [[order.group]]
-    id = "paketo-buildpacks/procfile"
-    optional = true
-    version = "4.4.1"
-
-  [[order.group]]
-    id = "paketo-buildpacks/environment-variables"
-    optional = true
-    version = "3.2.2"
-
-  [[order.group]]
-    id = "paketo-buildpacks/image-labels"
-    optional = true
-    version = "3.2.3"
-
-[[order]]
-
-  [[order.group]]
-    id = "paketo-buildpacks/ca-certificates"
-    optional = true
-    version = "2.4.2"
-
-  [[order.group]]
-    id = "paketo-buildpacks/node-engine"
-    version = "0.10.0"
-
-  [[order.group]]
-    id = "paketo-buildpacks/node-module-bom"
-    optional = true
-    version = "0.1.2"
-
-  [[order.group]]
-    id = "paketo-buildpacks/node-start"
-    version = "0.5.0"
-
-  [[order.group]]
-    id = "paketo-buildpacks/procfile"
-    optional = true
-    version = "4.4.1"
-
-  [[order.group]]
-    id = "paketo-buildpacks/environment-variables"
-    optional = true
-    version = "3.2.2"
-
-  [[order.group]]
-    id = "paketo-buildpacks/image-labels"
-    optional = true
-    version = "3.2.3"

+ 0 - 155
cmd/test-runtime/main.go

@@ -1,155 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"log"
-	"os"
-	"path/filepath"
-
-	condaenvupdate "github.com/paketo-buildpacks/conda-env-update"
-	gomodvendor "github.com/paketo-buildpacks/go-mod-vendor"
-	"github.com/paketo-buildpacks/packit"
-	pipenvinstall "github.com/paketo-buildpacks/pipenv-install"
-	pythonstart "github.com/paketo-buildpacks/python-start"
-	"github.com/paketo-buildpacks/rackup"
-	railsassets "github.com/paketo-buildpacks/rails-assets"
-	"github.com/paketo-buildpacks/rake"
-	"github.com/porter-dev/porter/internal/integrations/buildpacks"
-)
-
-const GoModLocation = "go.mod"
-
-var workingDir string
-
-func detectGo() {
-	/* First check if it is a go.mod project */
-	goModParser := gomodvendor.NewGoModParser()
-	detect := gomodvendor.Detect(goModParser)
-
-	_, err := detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		log.Println("go.mod project detected")
-		return
-	}
-
-	/* Next, check if it is a Gopkg.toml */
-	_, err = os.Stat(filepath.Join(workingDir, "Gopkg.toml"))
-	if err == nil {
-		log.Println("Gopkg.toml project detected")
-		return
-	}
-
-	/* Finally, check if it is a Go vendor */
-	_, err = os.Stat(filepath.Join(workingDir, "vendor"))
-	if err == nil {
-		log.Println("Go vendor project detected")
-		return
-	}
-
-	// FIXME: what about Go projects that do not use any of the
-	//        above but contain a Makefile to call 'go build'
-
-	/* Not a Go project */
-	log.Println("Not a Go project")
-}
-
-func detectPython() {
-	/* Check for Pipfile project */
-	pipfileParser := pipenvinstall.NewPipfileParser()
-	pipfileLockParser := pipenvinstall.NewPipfileLockParser()
-	detect := pipenvinstall.Detect(pipfileParser, pipfileLockParser)
-	_, err := detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		log.Println("Python Pipfile project detected")
-		return
-	}
-
-	/* Check for pip project */
-	_, err = os.Stat(filepath.Join(workingDir, "requirements.txt"))
-	if err == nil {
-		log.Println("Python pip project detected")
-		return
-	}
-
-	/* Check for conda project */
-	detect = condaenvupdate.Detect()
-	_, err = detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		log.Println("Python conda project detected")
-		return
-	}
-
-	/* Check for all other possibilities of a Python project */
-	detect = pythonstart.Detect()
-	_, err = detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		log.Println("Python project detected")
-		return
-	}
-
-	/* Not a Python project */
-	log.Println("Not a Python project")
-}
-
-func detectRuby() {
-	/* Check for rackup project  */
-	gemParser := rackup.NewGemfileLockParser()
-	detect := rackup.Detect(gemParser)
-	_, err := detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		log.Println("Ruby rackup project detected")
-		return
-	}
-
-	/* Check for Rails app with assets */
-	railsGemfileParser := railsassets.NewGemfileParser()
-	detect = railsassets.Detect(railsGemfileParser)
-	_, err = detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		log.Println("Ruby rails project detected")
-		return
-	}
-
-	/* Check for rakefile project */
-	rakeGemfileParser := rake.NewGemfileParser()
-	detect = rake.Detect(rakeGemfileParser)
-	_, err = detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		log.Println("Ruby rakefile project detected")
-		return
-	}
-
-	/* Not a Ruby project */
-	log.Println("Not a Ruby project")
-}
-
-func main() {
-	if len(os.Args) < 2 {
-		log.Fatalln("Usage: ./test-runtime <project directory>")
-	}
-
-	workingDir = os.Args[1]
-
-	nodeRuntime := buildpacks.NewCLINodeRuntime()
-	buildpackInfo, data := nodeRuntime.Detect(workingDir)
-	if data != nil {
-		fmt.Println(data)
-		for i := 0; i < len(buildpackInfo.Packs); i++ {
-			fmt.Println(buildpackInfo.Packs[i])
-		}
-	}
-}

+ 0 - 81
internal/integrations/buildpacks/cli_go.go

@@ -1,81 +0,0 @@
-package buildpacks
-
-import (
-	"sync"
-
-	depensure "github.com/paketo-buildpacks/dep-ensure"
-	gomodvendor "github.com/paketo-buildpacks/go-mod-vendor"
-	"github.com/paketo-buildpacks/packit"
-)
-
-type cliGoRuntime struct {
-	wg sync.WaitGroup
-}
-
-func NewCLIGoRuntime() CLIRuntime {
-	// adding packs to the Go runtime does not make sense
-	// since we will be using a Packaeto builder that
-	// already comes with the Go buildpack
-
-	return &cliGoRuntime{}
-}
-
-func (runtime *cliGoRuntime) detectMod(results chan struct {
-	string
-	bool
-}, workingDir string) {
-	goModParser := gomodvendor.NewGoModParser()
-	detect := gomodvendor.Detect(goModParser)
-	_, err := detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		results <- struct {
-			string
-			bool
-		}{mod, true}
-	} else {
-		results <- struct {
-			string
-			bool
-		}{mod, false}
-	}
-	runtime.wg.Done()
-}
-
-func (runtime *cliGoRuntime) detectDep(results chan struct {
-	string
-	bool
-}, workingDir string) {
-	detect := depensure.Detect()
-	_, err := detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		results <- struct {
-			string
-			bool
-		}{dep, true}
-	} else {
-		results <- struct {
-			string
-			bool
-		}{dep, false}
-	}
-	runtime.wg.Done()
-}
-
-func (runtime *cliGoRuntime) Detect(workingDir string) (BuildpackInfo, map[string]interface{}) {
-	results := make(chan struct {
-		string
-		bool
-	}, 3)
-
-	runtime.wg.Add(3)
-	go runtime.detectMod(results, workingDir)
-	go runtime.detectDep(results, workingDir)
-	runtime.wg.Wait()
-	close(results)
-
-	return BuildpackInfo{}, nil
-}

+ 0 - 244
internal/integrations/buildpacks/cli_nodejs.go

@@ -1,244 +0,0 @@
-package buildpacks
-
-import (
-	"fmt"
-	"os"
-	"path/filepath"
-	"sync"
-
-	nodeengine "github.com/paketo-buildpacks/node-engine"
-	noderunscript "github.com/paketo-buildpacks/node-run-script"
-	nodestart "github.com/paketo-buildpacks/node-start"
-	npminstall "github.com/paketo-buildpacks/npm-install"
-	"github.com/paketo-buildpacks/packit"
-	yarninstall "github.com/paketo-buildpacks/yarn-install"
-	"github.com/pelletier/go-toml"
-)
-
-const nodejsTomlFile = "nodejs.buildpack.toml"
-
-type cliNodeRuntime struct {
-	packs map[string]*BuildpackInfo
-	wg    sync.WaitGroup
-}
-
-func NewCLINodeRuntime() CLIRuntime {
-	packs := make(map[string]*BuildpackInfo)
-
-	buildpackToml, err := toml.LoadFile(filepath.Join(getExecPath(), nodejsTomlFile))
-	if err != nil {
-		fmt.Printf("Error while reading %s: %v\n", nodejsTomlFile, err)
-		os.Exit(1)
-	}
-	order := buildpackToml.Get("order").([]*toml.Tree)
-
-	// yarn
-	packs[yarn] = newBuildpackInfo()
-	yarnGroup := order[0].GetArray("group").([]*toml.Tree)
-	for i := 0; i < len(yarnGroup); i++ {
-		packs[yarn].addPack(
-			buildpackOrderGroupInfo{
-				ID:       yarnGroup[i].Get("id").(string),
-				Optional: yarnGroup[i].GetDefault("optional", false).(bool),
-				Version:  yarnGroup[i].Get("version").(string),
-			},
-		)
-	}
-	packs[yarn].addEnvVar("SSL_CERT_DIR", "")
-	packs[yarn].addEnvVar("SSL_CERT_FILE", "")
-	packs[yarn].addEnvVar("BP_NODE_OPTIMIZE_MEMORY", "")
-	packs[yarn].addEnvVar("BP_NODE_PROJECT_PATH", "")
-	packs[yarn].addEnvVar("BP_NODE_VERSION", "")
-	packs[yarn].addEnvVar("BP_NODE_RUN_SCRIPTS", "")
-
-	// npm
-	packs[npm] = newBuildpackInfo()
-	npmGroup := order[1].GetArray("group").([]*toml.Tree)
-	for i := 0; i < len(npmGroup); i++ {
-		packs[npm].addPack(
-			buildpackOrderGroupInfo{
-				ID:       npmGroup[i].Get("id").(string),
-				Optional: npmGroup[i].GetDefault("optional", false).(bool),
-				Version:  npmGroup[i].Get("version").(string),
-			},
-		)
-	}
-	packs[npm].addEnvVar("SSL_CERT_DIR", "")
-	packs[npm].addEnvVar("SSL_CERT_FILE", "")
-	packs[npm].addEnvVar("BP_NODE_OPTIMIZE_MEMORY", "")
-	packs[npm].addEnvVar("BP_NODE_PROJECT_PATH", "")
-	packs[npm].addEnvVar("BP_NODE_VERSION", "")
-	packs[npm].addEnvVar("BP_NODE_RUN_SCRIPTS", "")
-
-	// no package manager
-	packs[standalone] = newBuildpackInfo()
-	standaloneGroup := order[2].GetArray("group").([]*toml.Tree)
-	for i := 0; i < len(standaloneGroup); i++ {
-		packs[standalone].addPack(
-			buildpackOrderGroupInfo{
-				ID:       standaloneGroup[i].Get("id").(string),
-				Optional: standaloneGroup[i].GetDefault("optional", false).(bool),
-				Version:  standaloneGroup[i].Get("version").(string),
-			},
-		)
-	}
-	packs[standalone].addEnvVar("SSL_CERT_DIR", "")
-	packs[standalone].addEnvVar("SSL_CERT_FILE", "")
-	packs[standalone].addEnvVar("BP_NODE_OPTIMIZE_MEMORY", "")
-	packs[standalone].addEnvVar("BP_NODE_PROJECT_PATH", "")
-	packs[standalone].addEnvVar("BP_NODE_VERSION", "")
-	packs[standalone].addEnvVar("BP_LAUNCHPOINT", "")
-	packs[standalone].addEnvVar("BP_LIVE_RELOAD_ENABLED", "")
-
-	return &cliNodeRuntime{
-		packs: packs,
-	}
-}
-
-func (runtime *cliNodeRuntime) detectYarn(results chan struct {
-	string
-	bool
-}, workingDir string) {
-	yarnProjectPathParser := yarninstall.NewProjectPathParser()
-	yarnVersionParser := yarninstall.NewPackageJSONParser()
-	detect := yarninstall.Detect(yarnProjectPathParser, yarnVersionParser)
-	_, err := detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		results <- struct {
-			string
-			bool
-		}{yarn, true}
-	} else {
-		results <- struct {
-			string
-			bool
-		}{yarn, false}
-	}
-	runtime.wg.Done()
-}
-
-func (runtime *cliNodeRuntime) detectNPM(results chan struct {
-	string
-	bool
-}, workingDir string) {
-	npmProjectPathParser := npminstall.NewProjectPathParser()
-	npmVersionParser := npminstall.NewPackageJSONParser()
-	detect := npminstall.Detect(npmProjectPathParser, npmVersionParser)
-	_, err := detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		results <- struct {
-			string
-			bool
-		}{npm, true}
-	} else {
-		results <- struct {
-			string
-			bool
-		}{npm, false}
-	}
-	runtime.wg.Done()
-}
-
-func (runtime *cliNodeRuntime) detectStandalone(results chan struct {
-	string
-	bool
-}, workingDir string) {
-	appFinder := nodestart.NewNodeApplicationFinder()
-	detect := nodestart.Detect(appFinder)
-	_, err := detect(packit.DetectContext{
-		WorkingDir: workingDir,
-	})
-	if err == nil {
-		results <- struct {
-			string
-			bool
-		}{standalone, true}
-	} else {
-		results <- struct {
-			string
-			bool
-		}{standalone, false}
-	}
-	runtime.wg.Done()
-}
-
-func (runtime *cliNodeRuntime) Detect(workingDir string) (BuildpackInfo, map[string]interface{}) {
-	results := make(chan struct {
-		string
-		bool
-	}, 3)
-
-	runtime.wg.Add(3)
-	go runtime.detectYarn(results, workingDir)
-	go runtime.detectNPM(results, workingDir)
-	go runtime.detectStandalone(results, workingDir)
-	runtime.wg.Wait()
-	close(results)
-
-	atLeastOne := false
-	detected := make(map[string]bool)
-	for result := range results {
-		if result.bool {
-			atLeastOne = true
-		}
-		detected[result.string] = result.bool
-	}
-
-	if atLeastOne {
-		if detected[yarn] || detected[npm] {
-			// it is safe to assume that the project contains a package.json
-			packageJSONPath := filepath.Join(workingDir, "package.json")
-			nvmrcPath := filepath.Join(workingDir, ".nvmrc")
-			nodeVersionPath := filepath.Join(workingDir, ".node-version")
-
-			scriptManager := noderunscript.NewScriptManager()
-			scripts, err := scriptManager.GetPackageScripts(workingDir)
-			if err != nil {
-				fmt.Printf("Error reading %s: %v\n", packageJSONPath, err)
-			}
-
-			packageJSONParser := npminstall.NewPackageJSONParser()
-			engineVersion, err := packageJSONParser.ParseVersion(packageJSONPath)
-			if err != nil {
-				fmt.Printf("Error reading %s: %v\n", packageJSONPath, err)
-			}
-
-			if engineVersion == "" {
-				nvmrcParser := nodeengine.NewNvmrcParser()
-				engineVersion, err = nvmrcParser.ParseVersion(nvmrcPath)
-				if err != nil {
-					fmt.Printf("Error reading %s: %v\n", nvmrcPath, err)
-				}
-			}
-
-			if engineVersion == "" {
-				versionParser := nodeengine.NewNodeVersionParser()
-				engineVersion, err = versionParser.ParseVersion(nodeVersionPath)
-				if err != nil {
-					fmt.Printf("Error reading %s: %v\n", nodeVersionPath, err)
-				}
-			}
-
-			if engineVersion == "" {
-				// taken from https://github.com/paketo-buildpacks/node-engine/blob/main/buildpack.toml
-				engineVersion = "16.*.*"
-			}
-
-			if detected[yarn] {
-				return *runtime.packs[yarn], map[string]interface{}{"scripts": scripts, "engine_version": engineVersion}
-			} else {
-				return *runtime.packs[npm], map[string]interface{}{"scripts": scripts, "engine_version": engineVersion}
-			}
-		}
-
-		if detected[standalone] {
-			return *runtime.packs[standalone], map[string]interface{}{}
-		}
-	}
-
-	return BuildpackInfo{}, nil
-}

+ 0 - 1
internal/integrations/buildpacks/cli_python.go

@@ -1 +0,0 @@
-package buildpacks

+ 6 - 6
internal/integrations/buildpacks/api_go.go → internal/integrations/buildpacks/go.go

@@ -7,15 +7,15 @@ import (
 	"github.com/google/go-github/github"
 )
 
-type apiGoRuntime struct {
+type goRuntime struct {
 	wg sync.WaitGroup
 }
 
-func NewAPIGoRuntime() APIRuntime {
-	return &apiGoRuntime{}
+func NewGoRuntime() Runtime {
+	return &goRuntime{}
 }
 
-func (runtime *apiGoRuntime) detectMod(results chan struct {
+func (runtime *goRuntime) detectMod(results chan struct {
 	string
 	bool
 }, directoryContent []*github.RepositoryContent) {
@@ -40,7 +40,7 @@ func (runtime *apiGoRuntime) detectMod(results chan struct {
 	runtime.wg.Done()
 }
 
-func (runtime *apiGoRuntime) detectDep(results chan struct {
+func (runtime *goRuntime) detectDep(results chan struct {
 	string
 	bool
 }, directoryContent []*github.RepositoryContent) {
@@ -71,7 +71,7 @@ func (runtime *apiGoRuntime) detectDep(results chan struct {
 	runtime.wg.Done()
 }
 
-func (runtime *apiGoRuntime) Detect(
+func (runtime *goRuntime) Detect(
 	client *github.Client,
 	directoryContent []*github.RepositoryContent,
 	owner, name, path string,

+ 7 - 7
internal/integrations/buildpacks/api_nodejs.go → internal/integrations/buildpacks/nodejs.go

@@ -22,13 +22,13 @@ var (
 	}
 )
 
-type apiNodeRuntime struct {
+type nodejsRuntime struct {
 	wg    sync.WaitGroup
 	packs map[string]*BuildpackInfo
 }
 
-func NewAPINodeRuntime() APIRuntime {
-	return &apiNodeRuntime{}
+func NewNodeRuntime() Runtime {
+	return &nodejsRuntime{}
 }
 
 // FIXME: should be called once at the top-level somewhere in the backend
@@ -125,7 +125,7 @@ func populateNodePacks(client *github.Client) map[string]*BuildpackInfo {
 	return packs
 }
 
-func (runtime *apiNodeRuntime) detectYarn(results chan struct {
+func (runtime *nodejsRuntime) detectYarn(results chan struct {
 	string
 	bool
 }, directoryContent []*github.RepositoryContent) {
@@ -156,7 +156,7 @@ func (runtime *apiNodeRuntime) detectYarn(results chan struct {
 	runtime.wg.Done()
 }
 
-func (runtime *apiNodeRuntime) detectNPM(results chan struct {
+func (runtime *nodejsRuntime) detectNPM(results chan struct {
 	string
 	bool
 }, directoryContent []*github.RepositoryContent) {
@@ -182,7 +182,7 @@ func (runtime *apiNodeRuntime) detectNPM(results chan struct {
 	runtime.wg.Done()
 }
 
-func (runtime *apiNodeRuntime) detectStandalone(results chan struct {
+func (runtime *nodejsRuntime) detectStandalone(results chan struct {
 	string
 	bool
 }, directoryContent []*github.RepositoryContent) {
@@ -269,7 +269,7 @@ func validateNodeVersion(content string) (string, error) {
 	return content, nil
 }
 
-func (runtime *apiNodeRuntime) Detect(
+func (runtime *nodejsRuntime) Detect(
 	client *github.Client,
 	directoryContent []*github.RepositoryContent,
 	owner, name, path string,

+ 8 - 8
internal/integrations/buildpacks/api_python.go → internal/integrations/buildpacks/python.go

@@ -11,7 +11,7 @@ import (
 	"github.com/pelletier/go-toml"
 )
 
-type apiPythonRuntime struct {
+type pythonRuntime struct {
 	wg    sync.WaitGroup
 	packs map[string]*BuildpackInfo
 }
@@ -104,11 +104,11 @@ func populatePythonPacks(client *github.Client) map[string]*BuildpackInfo {
 	return packs
 }
 
-func NewAPIPythonRuntime() APIRuntime {
-	return &apiPythonRuntime{}
+func NewPythonRuntime() Runtime {
+	return &pythonRuntime{}
 }
 
-func (runtime *apiPythonRuntime) detectPipenv(results chan struct {
+func (runtime *pythonRuntime) detectPipenv(results chan struct {
 	string
 	bool
 }, directoryContent []*github.RepositoryContent) {
@@ -139,7 +139,7 @@ func (runtime *apiPythonRuntime) detectPipenv(results chan struct {
 	runtime.wg.Done()
 }
 
-func (runtime *apiPythonRuntime) detectPip(results chan struct {
+func (runtime *pythonRuntime) detectPip(results chan struct {
 	string
 	bool
 }, directoryContent []*github.RepositoryContent) {
@@ -164,7 +164,7 @@ func (runtime *apiPythonRuntime) detectPip(results chan struct {
 	runtime.wg.Done()
 }
 
-func (runtime *apiPythonRuntime) detectConda(results chan struct {
+func (runtime *pythonRuntime) detectConda(results chan struct {
 	string
 	bool
 }, directoryContent []*github.RepositoryContent) {
@@ -194,7 +194,7 @@ func (runtime *apiPythonRuntime) detectConda(results chan struct {
 	runtime.wg.Done()
 }
 
-func (runtime *apiPythonRuntime) detectStandalone(results chan struct {
+func (runtime *pythonRuntime) detectStandalone(results chan struct {
 	string
 	bool
 }, directoryContent []*github.RepositoryContent) {
@@ -220,7 +220,7 @@ func (runtime *apiPythonRuntime) detectStandalone(results chan struct {
 	runtime.wg.Done()
 }
 
-func (runtime *apiPythonRuntime) Detect(
+func (runtime *pythonRuntime) Detect(
 	client *github.Client,
 	directoryContent []*github.RepositoryContent,
 	owner, name, path string,

+ 10 - 10
internal/integrations/buildpacks/api_ruby.go → internal/integrations/buildpacks/ruby.go

@@ -13,7 +13,7 @@ import (
 	"github.com/pelletier/go-toml"
 )
 
-type apiRubyRuntime struct {
+type rubyRuntime struct {
 	wg    sync.WaitGroup
 	packs map[string]*BuildpackInfo
 }
@@ -132,11 +132,11 @@ func populateRubyPacks(client *github.Client) map[string]*BuildpackInfo {
 	return packs
 }
 
-func NewAPIRubyRuntime() APIRuntime {
-	return &apiRubyRuntime{}
+func NewRubyRuntime() Runtime {
+	return &rubyRuntime{}
 }
 
-func (runtime *apiRubyRuntime) detectPuma(gemfileContent string, results chan struct {
+func (runtime *rubyRuntime) detectPuma(gemfileContent string, results chan struct {
 	string
 	bool
 }) {
@@ -165,7 +165,7 @@ func (runtime *apiRubyRuntime) detectPuma(gemfileContent string, results chan st
 	runtime.wg.Done()
 }
 
-func (runtime *apiRubyRuntime) detectThin(gemfileContent string, results chan struct {
+func (runtime *rubyRuntime) detectThin(gemfileContent string, results chan struct {
 	string
 	bool
 }) {
@@ -194,7 +194,7 @@ func (runtime *apiRubyRuntime) detectThin(gemfileContent string, results chan st
 	runtime.wg.Done()
 }
 
-func (runtime *apiRubyRuntime) detectUnicorn(gemfileContent string, results chan struct {
+func (runtime *rubyRuntime) detectUnicorn(gemfileContent string, results chan struct {
 	string
 	bool
 }) {
@@ -223,7 +223,7 @@ func (runtime *apiRubyRuntime) detectUnicorn(gemfileContent string, results chan
 	runtime.wg.Done()
 }
 
-func (runtime *apiRubyRuntime) detectPassenger(gemfileContent string, results chan struct {
+func (runtime *rubyRuntime) detectPassenger(gemfileContent string, results chan struct {
 	string
 	bool
 }) {
@@ -252,7 +252,7 @@ func (runtime *apiRubyRuntime) detectPassenger(gemfileContent string, results ch
 	runtime.wg.Done()
 }
 
-func (runtime *apiRubyRuntime) detectRackup(
+func (runtime *rubyRuntime) detectRackup(
 	client *github.Client, owner, name string,
 	repoContentOptions github.RepositoryContentGetOptions, results chan struct {
 		string
@@ -299,7 +299,7 @@ func (runtime *apiRubyRuntime) detectRackup(
 	runtime.wg.Done()
 }
 
-func (runtime *apiRubyRuntime) detectRake(gemfileContent string, results chan struct {
+func (runtime *rubyRuntime) detectRake(gemfileContent string, results chan struct {
 	string
 	bool
 }) {
@@ -328,7 +328,7 @@ func (runtime *apiRubyRuntime) detectRake(gemfileContent string, results chan st
 	runtime.wg.Done()
 }
 
-func (runtime *apiRubyRuntime) Detect(
+func (runtime *rubyRuntime) Detect(
 	client *github.Client,
 	directoryContent []*github.RepositoryContent,
 	owner, name, path string,

+ 7 - 22
internal/integrations/buildpacks/shared.go

@@ -1,9 +1,6 @@
 package buildpacks
 
 import (
-	"os"
-	"path/filepath"
-
 	"github.com/google/go-github/github"
 )
 
@@ -60,14 +57,6 @@ func (info *BuildpackInfo) addEnvVar(id string, val string) {
 	info.EnvVars[id] = val
 }
 
-func getExecPath() string {
-	ex, err := os.Executable()
-	if err != nil {
-		panic(err)
-	}
-	return filepath.Dir(ex)
-}
-
 type RuntimeResponse struct {
 	Name       string                 `json:"name"`
 	Buildpacks *BuildpackInfo         `json:"buildpacks"`
@@ -75,11 +64,7 @@ type RuntimeResponse struct {
 	Config     map[string]interface{} `json:"config"`
 }
 
-type CLIRuntime interface {
-	Detect(string) (BuildpackInfo, map[string]interface{})
-}
-
-type APIRuntime interface {
+type Runtime interface {
 	Detect(
 		*github.Client, // github client to pull contents of files
 		[]*github.RepositoryContent, // the root folder structure of the git repo
@@ -90,10 +75,10 @@ type APIRuntime interface {
 	) *RuntimeResponse
 }
 
-// APIRuntimes is a list of all API runtimes
-var APIRuntimes = []APIRuntime{
-	NewAPIGoRuntime(),
-	NewAPINodeRuntime(),
-	NewAPIPythonRuntime(),
-	NewAPIRubyRuntime(),
+// Runtimes is a list of all API runtimes
+var Runtimes = []Runtime{
+	NewGoRuntime(),
+	NewNodeRuntime(),
+	NewPythonRuntime(),
+	NewRubyRuntime(),
 }