예제 #1
0
파일: port.go 프로젝트: kinvolk/acbuild
// AddPort will add a port with the given name, protocol, port, and count to
// the untarred ACI stored at a.CurrentACIPath. If the port already exists its
// value will be updated to the new value. socketActivated signifies whether or
// not the application will be socket activated via this port.
func (a *ACBuild) AddPort(name, protocol string, port, count uint, socketActivated bool) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	acn, err := types.NewACName(name)
	if err != nil {
		return err
	}

	fn := func(s *schema.ImageManifest) error {
		if s.App == nil {
			s.App = newManifestApp()
		}
		removePort(*acn)(s)
		s.App.Ports = append(s.App.Ports,
			types.Port{
				Name:            *acn,
				Protocol:        protocol,
				Port:            port,
				Count:           count,
				SocketActivated: socketActivated,
			})
		return nil
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #2
0
파일: mounts.go 프로젝트: kinvolk/acbuild
// AddMount will add a mount point with the given name and path to the untarred
// ACI stored at a.CurrentACIPath. If the mount point already exists its value
// will be updated to the new value. readOnly signifies whether or not the
// mount point should be read only.
func (a *ACBuild) AddMount(name, path string, readOnly bool) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	acn, err := types.NewACName(name)
	if err != nil {
		return err
	}

	fn := func(s *schema.ImageManifest) error {
		removeMount(*acn)(s)
		if s.App == nil {
			s.App = newManifestApp()
		}
		s.App.MountPoints = append(s.App.MountPoints,
			types.MountPoint{
				Name:     *acn,
				Path:     path,
				ReadOnly: readOnly,
			})
		return nil
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #3
0
파일: isolator.go 프로젝트: kinvolk/acbuild
func (a *ACBuild) AddIsolator(name string, value []byte) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	acid, err := types.NewACIdentifier(name)
	if err != nil {
		return err
	}
	rawMsg := json.RawMessage(value)

	fn := func(s *schema.ImageManifest) error {
		if s.App == nil {
			s.App = newManifestApp()
		}
		removeIsolatorFromMan(*acid)(s)
		s.App.Isolators = append(s.App.Isolators,
			types.Isolator{
				Name:     *acid,
				ValueRaw: &rawMsg,
			})
		return nil
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #4
0
// AddDependency will add a dependency with the given name, id, labels, and size
// to the untarred ACI stored at acipath. If the dependency already exists its
// fields will be updated to the new values.
func AddDependency(acipath, imageName, imageId string, labels types.Labels, size uint) error {
	acid, err := types.NewACIdentifier(imageName)
	if err != nil {
		return err
	}

	var hash *types.Hash
	if imageId != "" {
		var err error
		hash, err = types.NewHash(imageId)
		if err != nil {
			return err
		}
	}

	fn := func(s *schema.ImageManifest) {
		removeDep(*acid)(s)
		s.Dependencies = append(s.Dependencies,
			types.Dependency{
				ImageName: *acid,
				ImageID:   hash,
				Labels:    labels,
				Size:      size,
			})
	}
	return util.ModifyManifest(fn, acipath)
}
예제 #5
0
파일: label.go 프로젝트: aaronlevy/acbuild
// AddLabel will add a label with the given name and value to the untarred ACI
// stored at a.CurrentACIPath. If the label already exists its value will be updated to
// the new value.
func (a *ACBuild) AddLabel(name, value string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	acid, err := types.NewACIdentifier(name)
	if err != nil {
		return err
	}

	fn := func(s *schema.ImageManifest) {
		removeLabelFromMan(*acid)(s)
		s.Labels = append(s.Labels,
			types.Label{
				Name:  *acid,
				Value: value,
			})
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #6
0
// RemoveAnnotation will remove the annotation with the given name from the
// untarred ACI stored at acipath
func RemoveAnnotation(acipath, name string) error {
	acid, err := types.NewACIdentifier(name)
	if err != nil {
		return err
	}

	return util.ModifyManifest(removeAnnotation(*acid), acipath)
}
예제 #7
0
파일: mounts.go 프로젝트: jaypipes/acbuild
// RemoveMount will remove the mount point with the given name from the
// untarred ACI stored at acipath
func RemoveMount(acipath, name string) error {
	acn, err := types.NewACName(name)
	if err != nil {
		return err
	}

	return util.ModifyManifest(removeMount(*acn), acipath)
}
예제 #8
0
// RemoveDependency will remove the dependency with the given name from the
// untarred ACI stored at acipath
func RemoveDependency(acipath, imageName string) error {
	acid, err := types.NewACIdentifier(imageName)
	if err != nil {
		return err
	}

	return util.ModifyManifest(removeDep(*acid), acipath)
}
예제 #9
0
파일: env.go 프로젝트: jaypipes/acbuild
// AddEnv will add an environment variable with the given name and value to the
// untarred ACI stored at acipath. If the environment variable already exists
// its value will be updated to the new value.
func AddEnv(acipath, name, value string) error {
	fn := func(s *schema.ImageManifest) {
		if s.App == nil {
			s.App = &types.App{}
		}
		s.App.Environment.Set(name, value)
	}
	return util.ModifyManifest(fn, acipath)
}
예제 #10
0
// SetExec sets the exec command for the untarred ACI stored at acipath.
func SetExec(acipath string, cmd []string) error {
	fn := func(s *schema.ImageManifest) {
		if s.App == nil {
			s.App = &types.App{}
		}
		s.App.Exec = cmd
	}
	return util.ModifyManifest(fn, acipath)
}
예제 #11
0
// AddAnnotation will add an annotation with the given name and value to the
// untarred ACI stored at acipath. If the annotation already exists its value
// will be updated to the new value.
func AddAnnotation(acipath, name, value string) error {
	acid, err := types.NewACIdentifier(name)
	if err != nil {
		return err
	}

	fn := func(s *schema.ImageManifest) {
		s.Annotations.Set(*acid, value)
	}
	return util.ModifyManifest(fn, acipath)
}
예제 #12
0
파일: env.go 프로젝트: kinvolk/acbuild
// RemoveEnv will remove the environment variable with the given name from the
// untarred ACI stored at a.CurrentACIPath.
func (a *ACBuild) RemoveEnv(name string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	return util.ModifyManifest(removeFromEnv(name), a.CurrentACIPath)
}
예제 #13
0
// SetGroup sets the group the pod will run as in the untarred ACI stored at
// acipath.
func SetGroup(acipath, group string) error {
	if group == "" {
		return fmt.Errorf("group cannot be empty")
	}
	fn := func(s *schema.ImageManifest) {
		if s.App == nil {
			s.App = &types.App{}
		}
		s.App.Group = group
	}
	return util.ModifyManifest(fn, acipath)
}
예제 #14
0
// SetUser sets the user the pod will run as in the untarred ACI stored at
// acipath.
func SetUser(acipath, user string) error {
	if user == "" {
		return fmt.Errorf("user cannot be empty")
	}
	fn := func(s *schema.ImageManifest) {
		if s.App == nil {
			s.App = &types.App{}
		}
		s.App.User = user
	}
	return util.ModifyManifest(fn, acipath)
}
예제 #15
0
// SetName sets the name for the untarred ACI stored at acipath
func SetName(acipath, name string) error {
	if name == "" {
		return fmt.Errorf("name cannot be empty")
	}
	acid, err := types.NewACIdentifier(name)
	if err != nil {
		return err
	}

	fn := func(s *schema.ImageManifest) {
		s.Name = *acid
	}
	return util.ModifyManifest(fn, acipath)
}
예제 #16
0
파일: label.go 프로젝트: jaypipes/acbuild
// AddLabel will add a label with the given name and value to the untarred ACI
// stored at acipath. If the label already exists its value will be updated to
// the new value.
func AddLabel(acipath, name, value string) error {
	acid, err := types.NewACIdentifier(name)
	if err != nil {
		return err
	}

	fn := func(s *schema.ImageManifest) {
		removeLabelFromMan(*acid)(s)
		s.Labels = append(s.Labels,
			types.Label{
				Name:  *acid,
				Value: value,
			})
	}
	return util.ModifyManifest(fn, acipath)
}
예제 #17
0
// RemoveAnnotation will remove the annotation with the given name from the
// untarred ACI stored at a.CurrentACIPath
func (a *ACBuild) RemoveAnnotation(name string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	acid, err := types.NewACIdentifier(name)
	if err != nil {
		return err
	}

	return util.ModifyManifest(removeAnnotation(*acid), a.CurrentACIPath)
}
예제 #18
0
파일: mounts.go 프로젝트: kinvolk/acbuild
// RemoveMount will remove the mount point with the given name from the
// untarred ACI stored at a.CurrentACIPath
func (a *ACBuild) RemoveMount(name string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	acn, err := types.NewACName(name)
	if err != nil {
		return err
	}

	return util.ModifyManifest(removeMount(*acn), a.CurrentACIPath)
}
예제 #19
0
// SetExec sets the exec command for the untarred ACI stored at
// a.CurrentACIPath.
func (a *ACBuild) SetExec(cmd []string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	fn := func(s *schema.ImageManifest) {
		if s.App == nil {
			s.App = &types.App{}
		}
		s.App.Exec = cmd
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #20
0
파일: env.go 프로젝트: aaronlevy/acbuild
// AddEnv will add an environment variable with the given name and value to the
// untarred ACI stored at a.CurrentACIPath. If the environment variable already
// exists its value will be updated to the new value.
func (a *ACBuild) AddEnv(name, value string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	fn := func(s *schema.ImageManifest) {
		if s.App == nil {
			s.App = &types.App{}
		}
		s.App.Environment.Set(name, value)
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #21
0
// SetWorkingDir sets the workingDirectory value in the untarred ACI stored at
// a.CurrentACIPath
func (a *ACBuild) SetWorkingDir(dir string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	fn := func(s *schema.ImageManifest) error {
		if s.App == nil {
			s.App = newManifestApp()
		}
		s.App.WorkingDirectory = dir
		return nil
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #22
0
// AddAnnotation will add an annotation with the given name and value to the
// untarred ACI stored at a.CurrentACIPath. If the annotation already exists
// its value will be updated to the new value.
func (a *ACBuild) AddAnnotation(name, value string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	acid, err := types.NewACIdentifier(name)
	if err != nil {
		return err
	}

	fn := func(s *schema.ImageManifest) {
		s.Annotations.Set(*acid, value)
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #23
0
파일: mounts.go 프로젝트: jaypipes/acbuild
// AddMount will add a mount point with the given name and path to the untarred
// ACI stored at acipath. If the mount point already exists its value will be
// updated to the new value. readOnly signifies whether or not the mount point
// should be read only.
func AddMount(acipath, name, path string, readOnly bool) error {
	acn, err := types.NewACName(name)
	if err != nil {
		return err
	}

	fn := func(s *schema.ImageManifest) {
		removeMount(*acn)(s)
		if s.App == nil {
			s.App = &types.App{}
		}
		s.App.MountPoints = append(s.App.MountPoints,
			types.MountPoint{
				Name:     *acn,
				Path:     path,
				ReadOnly: readOnly,
			})
	}
	return util.ModifyManifest(fn, acipath)
}
예제 #24
0
// SetUser sets the user the pod will run as in the untarred ACI stored at
// a.CurrentACIPath.
func (a *ACBuild) SetUser(user string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	if user == "" {
		return fmt.Errorf("user cannot be empty")
	}
	fn := func(s *schema.ImageManifest) {
		if s.App == nil {
			s.App = &types.App{}
		}
		s.App.User = user
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #25
0
파일: port.go 프로젝트: jaypipes/acbuild
// AddPort will add a port with the given name, protocol, port, and count to
// the untarred ACI stored at acipath. If the port already exists its value
// will be updated to the new value. socketActivated signifies whether or not
// the application will be socket activated via this port.
func AddPort(acipath, name, protocol string, port, count uint, socketActivated bool) error {
	acn, err := types.NewACName(name)
	if err != nil {
		return err
	}

	fn := func(s *schema.ImageManifest) {
		removePort(*acn)(s)
		if s.App == nil {
			s.App = &types.App{}
		}
		s.App.Ports = append(s.App.Ports,
			types.Port{
				Name:            *acn,
				Protocol:        protocol,
				Port:            port,
				Count:           count,
				SocketActivated: socketActivated,
			})
	}
	return util.ModifyManifest(fn, acipath)
}
예제 #26
0
// SetGroup sets the group the pod will run as in the untarred ACI stored at
// a.CurrentACIPath.
func (a *ACBuild) SetGroup(group string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	if group == "" {
		return fmt.Errorf("group cannot be empty")
	}
	fn := func(s *schema.ImageManifest) error {
		if s.App == nil {
			s.App = newManifestApp()
		}
		s.App.Group = group
		return nil
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #27
0
// AddDependency will add a dependency with the given name, id, labels, and size
// to the untarred ACI stored at a.CurrentACIPath. If the dependency already
// exists its fields will be updated to the new values.
func (a *ACBuild) AddDependency(imageName types.ACIdentifier, imageId *types.Hash, labels types.Labels, size uint) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	fn := func(s *schema.ImageManifest) error {
		removeDep(imageName)(s)
		s.Dependencies = append(s.Dependencies,
			types.Dependency{
				ImageName: imageName,
				ImageID:   imageId,
				Labels:    labels,
				Size:      size,
			})
		return nil
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #28
0
// SetName sets the name for the untarred ACI stored at a.CurrentACIPath
func (a *ACBuild) SetName(name string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	if name == "" {
		return fmt.Errorf("name cannot be empty")
	}
	acid, err := types.NewACIdentifier(name)
	if err != nil {
		return err
	}

	fn := func(s *schema.ImageManifest) {
		s.Name = *acid
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #29
0
// AddDependency will add a dependency with the given name, id, labels, and size
// to the untarred ACI stored at a.CurrentACIPath. If the dependency already
// exists its fields will be updated to the new values.
func (a *ACBuild) AddDependency(imageName, imageId string, labels types.Labels, size uint) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	acid, err := types.NewACIdentifier(imageName)
	if err != nil {
		return err
	}

	var hash *types.Hash
	if imageId != "" {
		var err error
		hash, err = types.NewHash(imageId)
		if err != nil {
			return err
		}
	}

	fn := func(s *schema.ImageManifest) error {
		removeDep(*acid)(s)
		s.Dependencies = append(s.Dependencies,
			types.Dependency{
				ImageName: *acid,
				ImageID:   hash,
				Labels:    labels,
				Size:      size,
			})
		return nil
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}
예제 #30
0
func (a *ACBuild) setEventHandler(name string, exec []string) (err error) {
	if err = a.lock(); err != nil {
		return err
	}
	defer func() {
		if err1 := a.unlock(); err == nil {
			err = err1
		}
	}()

	fn := func(s *schema.ImageManifest) error {
		removeEventHandler(name, s)
		if s.App == nil {
			s.App = newManifestApp()
		}
		s.App.EventHandlers = append(s.App.EventHandlers,
			types.EventHandler{
				Name: name,
				Exec: exec,
			})
		return nil
	}
	return util.ModifyManifest(fn, a.CurrentACIPath)
}