diff --git a/deploy.go b/deploy.go index 73b6dfe..dcdfaa5 100644 --- a/deploy.go +++ b/deploy.go @@ -37,10 +37,7 @@ func deploy(c tsuru.Client, appName string, fs Filesystem, executor exec.Executo return err } } - rawYamlData, err := loadTsuruYamlRaw(fs) - if err != nil { - return err - } + rawYamlData := loadTsuruYamlRaw(fs) yamlData, err := parseTsuruYaml(rawYamlData) if err != nil { return err @@ -119,7 +116,7 @@ func inspect(dockerClient *docker.Client, image string, filesystem Filesystem, w if err != nil { return fmt.Errorf("failed to inspect image %q: %v", image, err) } - rawYamlData, err := loadTsuruYamlRaw(filesystem) + rawYamlData := loadTsuruYamlRaw(filesystem) if err != nil { return err } diff --git a/tasks.go b/tasks.go index 5116605..c1f368f 100644 --- a/tasks.go +++ b/tasks.go @@ -71,15 +71,15 @@ func execScript(cmds []string, envs []bind.EnvVar, w io.Writer, fs Filesystem, e return nil } -func loadTsuruYamlRaw(fs Filesystem) ([]byte, error) { +func loadTsuruYamlRaw(fs Filesystem) []byte { for _, yamlFile := range tsuruYamlFiles { filePath := fmt.Sprintf("%s/%s", defaultWorkingDir, yamlFile) tsuruYaml, err := fs.ReadFile(filePath) if err == nil { - return tsuruYaml, nil + return tsuruYaml } } - return nil, fmt.Errorf("error loading tsuru yaml file") + return nil } func parseTsuruYaml(data []byte) (tsuru.TsuruYaml, error) { diff --git a/tasks_test.go b/tasks_test.go index 0b102b1..7d9c287 100644 --- a/tasks_test.go +++ b/tasks_test.go @@ -89,11 +89,15 @@ unknown: ok` _, err := s.fs.Create(tsuruYmlPath) c.Assert(err, check.IsNil) c.Assert(s.testFS().HasAction(fmt.Sprintf("create %s", tsuruYmlPath)), check.Equals, true) - raw, err := loadTsuruYamlRaw(s.fs) - c.Assert(err, check.IsNil) + raw := loadTsuruYamlRaw(s.fs) c.Assert(string(raw), check.DeepEquals, tsuruYmlData) } +func (s *S) TestLoadTsuruYamlRawNotFound(c *check.C) { + raw := loadTsuruYamlRaw(s.fs) + c.Assert(raw, check.IsNil) +} + func (s *S) TestParseAppYaml(c *check.C) { tsuruYmlData := `hooks: build: @@ -302,3 +306,15 @@ func (s *S) TestReadProcfileNormalizeCRLFToLF(c *check.C) { c.Assert(err, check.IsNil) c.Assert(result, check.Equals, expected) } + +func (s *S) TestParseTsuruYamlEmpty(c *check.C) { + t, err := parseTsuruYaml(nil) + c.Assert(err, check.IsNil) + c.Assert(t, check.DeepEquals, tsuru.TsuruYaml{}) +} + +func (s *S) TestParseAllTsuruYamlEmpty(c *check.C) { + t, err := parseAllTsuruYaml(nil) + c.Assert(err, check.IsNil) + c.Assert(t, check.IsNil) +}