コード例 #1
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)
}
コード例 #2
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)
}
コード例 #3
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)
}
コード例 #4
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)
}
コード例 #5
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)
}
コード例 #6
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)
}