Ejemplo n.º 1
0
func (n *NatsClient) uploadPackage(packageName string) (blobID string, err error) {
	var dirname string
	dirname, err = ioutil.TempDir("", "templates")
	if err != nil {
		return
	}
	defer os.RemoveAll(dirname)

	tarfile := filepath.Join(dirname, packageName+".tar")
	dir := filepath.Join("fixtures/templates", packageName)
	_, err = utils.TarDirectory(dir, dir, tarfile)
	if err != nil {
		return
	}

	return n.blobstoreClient.Create(tarfile)
}
Ejemplo n.º 2
0
func (n *NatsClient) uploadJob(jobName string) (templateID, renderedTemplateSha string, err error) {
	var dirname string
	dirname, err = ioutil.TempDir("", "templates")
	if err != nil {
		return
	}
	defer os.RemoveAll(dirname)

	tarfile := filepath.Join(dirname, jobName+".tar")
	chdir := "fixtures/templates"
	dir := filepath.Join(chdir, jobName)

	renderedTemplateSha, err = utils.TarDirectory(dir, chdir, tarfile)
	if err != nil {
		return
	}
	templateID, err = n.blobstoreClient.Create(tarfile)
	if err != nil {
		return
	}
	return
}