本文整理匯總了Golang中github.com/appc/acbuild/util.ModifyManifest函數的典型用法代碼示例。如果您正苦於以下問題:Golang ModifyManifest函數的具體用法?Golang ModifyManifest怎麽用?Golang ModifyManifest使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ModifyManifest函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AddPort
// 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: AddMount
// 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: AddIsolator
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: AddDependency
// 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: AddLabel
// 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: RemoveAnnotation
// 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: RemoveMount
// 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: RemoveDependency
// 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: AddEnv
// 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: SetExec
// 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: AddAnnotation
// 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: RemoveEnv
// 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: SetGroup
// 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: SetUser
// 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: SetName
// 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)
}