shared.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package buildpacks
  2. import (
  3. "github.com/google/go-github/v41/github"
  4. "github.com/xanzy/go-gitlab"
  5. )
  6. const (
  7. // NodeJS
  8. yarn = "yarn"
  9. npm = "npm"
  10. // Go
  11. mod = "mod"
  12. dep = "dep"
  13. // Python
  14. pipenv = "pipenv"
  15. pip = "pip"
  16. conda = "conda"
  17. // Ruby
  18. puma = "puma"
  19. thin = "thin"
  20. unicorn = "unicorn"
  21. passenger = "passenger"
  22. rackup = "rackup"
  23. rake = "rake"
  24. // Common
  25. standalone = "standalone"
  26. // Builders
  27. PaketoBuilder = "paketo"
  28. HerokuBuilder = "heroku"
  29. )
  30. type BuildpackInfo struct {
  31. Name string `json:"name"`
  32. Buildpack string `json:"buildpack"`
  33. Config map[string]interface{} `json:"config"`
  34. }
  35. type BuilderInfo struct {
  36. Name string `json:"name"`
  37. Builders []string `json:"builders"`
  38. Detected []BuildpackInfo `json:"detected"`
  39. Others []BuildpackInfo `json:"others"`
  40. }
  41. type Runtime interface {
  42. DetectGithub(
  43. *github.Client, // github client to pull contents of files
  44. []*github.RepositoryContent, // the root folder structure of the git repo
  45. string, // owner
  46. string, // name
  47. string, // path
  48. github.RepositoryContentGetOptions, // SHA, branch or tag
  49. *BuilderInfo, // paketo
  50. *BuilderInfo, // heroku
  51. ) error
  52. DetectGitlab(
  53. *gitlab.Client, // github client to pull contents of files
  54. []*gitlab.TreeNode, // the root folder structure of the git repo
  55. string, // owner
  56. string, // name
  57. string, // path
  58. string, // SHA, branch or tag
  59. *BuilderInfo, // paketo
  60. *BuilderInfo, // heroku
  61. ) error
  62. }
  63. // Runtimes is a list of all API runtimes
  64. var Runtimes = []Runtime{
  65. NewGoRuntime(),
  66. NewNodeRuntime(),
  67. NewPythonRuntime(),
  68. NewRubyRuntime(),
  69. }