Пример #1
0
func run(c *cli.Context) {
	config, err := loadConfiguration(c)
	if err != nil {
		die("Couldn't load the inductor.json configuration file.", err)
	}
	opts, err := createRenderOpts(c, config)
	if err != nil {
		die(err)
	}
	outDir, err := outDir(c, config)
	if err != nil {
		die(err)
	}

	// find all templates
	cwd, err := os.Getwd()
	if err != nil {
		die(err)
	}
	templates := tpl.New(cwd, opts.OSName)

	// render all the templates to the output directory
	renderer := renderer.New(opts, outDir)
	err = renderer.Render(templates)
	if err != nil {
		die(err)
	}

	// copy over any non-templates to the output directory
	copier := cpy.New()
	err = copier.Copy(cwd, outDir)
	if err != nil {
		die(err)
	}
}
Пример #2
0
	)

	BeforeEach(func() {
		srcDir, err = ioutil.TempDir("", "inductor")
		Expect(err).NotTo(HaveOccurred())
		createFile(srcDir, "README.md")
		createFile(srcDir, "Vagrantfile")
		createFile(srcDir, "Autounattend.xml.template")
		createFile(srcDir, "Autounattend.xml.oobe.partial")
		createFile(srcDir, "scripts/winrm.ps1")
		createFile(srcDir, "scripts/windows-updates.ps1")
		createFile(srcDir, "scripts/nano/SetupComplete.cmd")
		createFile(srcDir, ".git/blah")
		createFile(srcDir, ".gitignore")
		outDir = filepath.Join(srcDir, "out")
		copier = cpy.New()
		err = copier.Copy(srcDir, outDir)
	})
	AfterEach(func() {
		os.RemoveAll(srcDir)
	})

	Describe("Copy recursive", func() {
		It("should not error", func() {
			Expect(err).NotTo(HaveOccurred())
		})
		It("should ignore .template files", func() {
			path := filepath.Join(outDir, "Autounattend.xml.template")
			Expect(path).ToNot(BeARegularFile())
		})
		It("should ignore .partial files", func() {