create.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package create
  2. import (
  3. "fmt"
  4. "os"
  5. "path/filepath"
  6. "github.com/porter-dev/porter/cli/cmd/api"
  7. "github.com/porter-dev/porter/cli/cmd/docker"
  8. )
  9. // CreateAgent handles the creation of a new application on Porter
  10. type CreateAgent struct {
  11. client *api.Client
  12. agent *docker.Agent
  13. opts *CreateOpts
  14. }
  15. // CreateOpts are the options for creating a new CreateAgent
  16. type CreateOpts struct {
  17. ProjectID uint
  18. ClusterID uint
  19. Namespace string
  20. }
  21. func (c *CreateAgent) CreateFromDocker() error {
  22. // read values from local file
  23. // overwrite with docker image repository and tag
  24. // call subdomain creation if necessary
  25. return nil
  26. }
  27. type CreateConfig struct {
  28. DockerfilePath string
  29. }
  30. func (c *CreateAgent) DetectConfig(buildPath string) (*CreateConfig, error) {
  31. // detect if there is a dockerfile at the path `./Dockerfile`
  32. dockerFilePath := filepath.Join(buildPath, "./Dockerfile")
  33. if info, err := os.Stat(dockerFilePath); !os.IsNotExist(err) && !info.IsDir() {
  34. // path/to/whatever does not exist
  35. return &CreateConfig{
  36. DockerfilePath: dockerFilePath,
  37. }, nil
  38. }
  39. return nil, fmt.Errorf("no supported build configuration detected")
  40. }