Exemple #1
0
func (b *Builder) runBuildSetup() error { //TODO REMOVE
	if empty, err := common.IsDirEmpty(b.aciHomePath + PATH_RUNLEVELS + PATH_BUILD_SETUP); empty || err != nil {
		return nil
	}

	logs.WithF(b.fields).Info("Running build setup")

	for _, e := range manifestApp(b.pod).App.Environment {
		logs.WithField("name", e.Name).WithField("value", e.Value).Debug("Adding environment var")
		os.Setenv(e.Name, e.Value)
	}

	logs.WithF(b.fields).Warn("Build setup is deprecated and will be removed. it create unreproductible builds and run as root directly on the host. Please use builder dependencies and builder runlevels instead")
	time.Sleep(5 * time.Second)

	os.Setenv("BASEDIR", b.aciHomePath)
	os.Setenv("TARGET", b.stage2Rootfs+"/..")
	os.Setenv("ROOTFS", b.stage2Rootfs+"/../rootfs")
	os.Setenv(common.EnvLogLevel, logs.GetLevel().String())

	if err := common.ExecCmd(b.stage1Rootfs + PATH_DGR + PATH_BUILDER + "/stage2/build-setup.sh"); err != nil {
		return errs.WithEF(err, b.fields, "Build setup failed")
	}

	return nil
}
Exemple #2
0
func (p *Pod) buildAci(e common.RuntimeApp) (*Aci, error) {
	if err := p.fillRuntimeAppFromDependencies(&e); err != nil {
		return nil, err
	}

	aci, err := p.toPodAci(e)
	if err != nil {
		return nil, err
	}

	aci.Clean()

	// TODO attributes should be builder dependent only
	if empty, err := common.IsDirEmpty(p.path + "/attributes"); !empty && err == nil {
		path := aci.target + pathBuilder + common.PathRootfs + "/dgr/pod/attributes"
		if err := os.MkdirAll(path, 0777); err != nil {
			return nil, errs.WithEF(err, aci.fields.WithField("path", path), "Failed to create pod attributes directory in builder")
		}
		if err := common.CopyDir(p.path+"/attributes", path); err != nil {
			return nil, errs.WithEF(err, aci.fields, "Failed to copy pod attributes to aci builder")
		}
	}

	if err := aci.Build(); err != nil {
		return nil, errs.WithEF(err, p.fields.WithField("name", e.Name), "build of  pod's aci failed")
	}
	return aci, nil
}
Exemple #3
0
func (e *Env) loadPartials() {
	if ok, err := common.IsDirEmpty(e.path + PATH_TEMPLATES); ok || err != nil {
		return
	}
	tmplDir, err := template.NewTemplateDir(e.path+PATH_TEMPLATES, "", false)
	if err != nil {
		logs.WithEF(err, e.fields).WithField("path", e.path+PATH_ATTRIBUTES).Fatal("Failed to load partial templating")
	}
	e.Partials = tmplDir.Partials
}
Exemple #4
0
var initCmd = &cobra.Command{

	Use:   "init",
	Short: "init files-tree",
	Long:  `init files-tree`,
	Run: func(cmd *cobra.Command, args []string) {
		checkNoArgs(args)

		fields := data.WithField("path", workPath)
		if _, err := os.Stat(workPath); err != nil {
			if err := os.MkdirAll(workPath, 0755); err != nil {
				logs.WithEF(err, fields).Fatal("Cannot create path directory")
			}
		}

		empty, err := common.IsDirEmpty(workPath)
		if err != nil {
			logs.WithEF(err, fields).Fatal("Cannot read path directory")
		}
		if !Args.Force {
			if !empty {
				logs.WithEF(err, fields).Fatal("Path is not empty cannot init")
			}
		}

		if err := ioutil.WriteFile(workPath+common.PathAciManifest, []byte(initManifestContent), 0644); err != nil {
			logs.WithEF(err, fields).Fatal("failed to write aci manifest")
		}

		defer giveBackUserRights(workPath)
		checkWg := &sync.WaitGroup{}