Beispiel #1
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
}
Beispiel #2
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{}