Ejemplo n.º 1
0
func (cmd *Push) instantiateManifest(c *cli.Context) (m *manifest.Manifest) {
	if c.Bool("no-manifest") {
		m = manifest.NewEmptyManifest()
		return
	}

	var path string
	if c.String("f") != "" {
		path = c.String("f")
	} else {
		var err error
		path, err = os.Getwd()
		if err != nil {
			cmd.ui.Failed("Could not determine the current working directory!", err)
			return
		}
	}

	m, manifestPath, errs := cmd.manifestRepo.ReadManifest(path)

	if !errs.Empty() {
		if manifestPath == "" && c.String("f") == "" {
			m = manifest.NewEmptyManifest()
		} else {
			cmd.ui.Failed("Error reading manifest file:\n%s", errs)
		}
		return
	}

	cmd.ui.Say("Using manifest file %s\n", terminal.EntityNameColor(manifestPath))
	return
}
Ejemplo n.º 2
0
func (repo *FakeManifestRepository) ReadManifest(inputPath string) (m *manifest.Manifest, errs manifest.ManifestErrors) {
	repo.ReadManifestArgs.Path = inputPath
	if repo.ReadManifestReturns.Manifest != nil {
		m = repo.ReadManifestReturns.Manifest
	} else {
		m = manifest.NewEmptyManifest()
	}
	errs = repo.ReadManifestReturns.Errors
	return
}
Ejemplo n.º 3
0
func (repo *FakeManifestRepository) ReadManifest(dir string) (m *manifest.Manifest, errs manifest.ManifestErrors) {
	repo.ReadManifestPath = dir
	errs = repo.ReadManifestErrors

	if repo.ReadManifestManifest != nil {
		m = repo.ReadManifestManifest
	} else {
		m = manifest.NewEmptyManifest()
	}
	return
}
Ejemplo n.º 4
0
Archivo: push.go Proyecto: nsnt/cli
func (cmd *Push) instantiateManifest(c *cli.Context, manifestPath string) (m *manifest.Manifest) {
	if c.Bool("no-manifest") {
		m = manifest.NewEmptyManifest()
		return
	}

	m, errs := cmd.manifestRepo.ReadManifest(manifestPath)

	if !errs.Empty() {
		if os.IsNotExist(errs[0]) && c.String("f") == "" {
			m = manifest.NewEmptyManifest()
			return
		} else {
			cmd.ui.Failed("Error reading manifest file:\n%s", errs)
			return
		}
	}

	cmd.ui.Say("Using manifest file %s\n", terminal.EntityNameColor(manifestPath))
	return
}
Ejemplo n.º 5
0
	})

	It("pushes the current working directory if a path is not given", func() {
		appRepo.ReadNotFound = true

		callPush("app-with-default-path")

		dir, err := os.Getwd()
		Expect(err).NotTo(HaveOccurred())
		Expect(appBitsRepo.UploadedDir).To(Equal(dir))
	})

	It("fails when given a bad manifest path", func() {
		appRepo.ReadNotFound = true

		manifestRepo.ReadManifestReturns.Manifest = manifest.NewEmptyManifest()
		manifestRepo.ReadManifestReturns.Errors = []error{errors.New("read manifest error")}

		callPush("-f", "bad/manifest/path")

		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"FAILED"},
			{"read manifest error"},
		})
	})

	It("does not fail when the current working directory does not contain a manifest", func() {
		appRepo.ReadNotFound = true
		manifestRepo.ReadManifestReturns.Manifest = singleAppManifest()
		manifestRepo.ReadManifestReturns.Errors = manifest.ManifestErrors{syscall.ENOENT}
		manifestRepo.ReadManifestReturns.Manifest.Path = ""