當前位置: 首頁>>代碼示例>>Golang>>正文


Golang types.NewACIdentifier函數代碼示例

本文整理匯總了Golang中github.com/appc/acbuild/Godeps/_workspace/src/github.com/appc/spec/schema/types.NewACIdentifier函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewACIdentifier函數的具體用法?Golang NewACIdentifier怎麽用?Golang NewACIdentifier使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewACIdentifier函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: writeEmptyManifest

func (a *ACBuild) writeEmptyManifest() error {
	acid, err := types.NewACIdentifier("acbuild-unnamed")
	if err != nil {
		return err
	}

	archlabel, err := types.NewACIdentifier("arch")
	if err != nil {
		return err
	}

	oslabel, err := types.NewACIdentifier("os")
	if err != nil {
		return err
	}

	manifest := &schema.ImageManifest{
		ACKind:    schema.ImageManifestKind,
		ACVersion: schema.AppContainerVersion,
		Name:      *acid,
		Labels: types.Labels{
			types.Label{
				*archlabel,
				runtime.GOARCH,
			},
			types.Label{
				*oslabel,
				runtime.GOOS,
			},
		},
	}

	manblob, err := manifest.MarshalJSON()
	if err != nil {
		return err
	}

	manfile, err := os.Create(path.Join(a.CurrentACIPath, aci.ManifestFile))
	if err != nil {
		return err
	}

	_, err = manfile.Write(manblob)
	if err != nil {
		return err
	}

	err = manfile.Close()
	if err != nil {
		return err
	}

	return nil
}
開發者ID:rhencke,項目名稱:acbuild,代碼行數:54,代碼來源:begin.go

示例2: NewAppFromString

// NewAppFromString takes a command line app parameter and returns a map of labels.
//
// Example app parameters:
// 	example.com/reduce-worker:1.0.0
// 	example.com/reduce-worker,channel=alpha,label=value
// 	example.com/reduce-worker:1.0.0,label=value
//
// As can be seen in above examples - colon, comma and equal sign have
// special meaning. If any of them has to be a part of a label's value
// then consider writing your own string to App parser.
func NewAppFromString(app string) (*App, error) {
	var (
		name   string
		labels map[types.ACIdentifier]string
	)

	preparedApp, err := prepareAppString(app)
	if err != nil {
		return nil, err
	}
	v, err := url.ParseQuery(preparedApp)
	if err != nil {
		return nil, err
	}
	labels = make(map[types.ACIdentifier]string, 0)
	for key, val := range v {
		if len(val) > 1 {
			return nil, fmt.Errorf("label %s with multiple values %q", key, val)
		}
		if key == "name" {
			name = val[0]
			continue
		}
		labelName, err := types.NewACIdentifier(key)
		if err != nil {
			return nil, err
		}
		labels[*labelName] = val[0]
	}
	a, err := NewApp(name, labels)
	if err != nil {
		return nil, err
	}
	return a, nil
}
開發者ID:kinvolk,項目名稱:acbuild,代碼行數:45,代碼來源:parse.go

示例3: 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)
}
開發者ID:aaronlevy,項目名稱:acbuild,代碼行數:28,代碼來源:label.go

示例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)
}
開發者ID:jaypipes,項目名稱:acbuild,代碼行數:30,代碼來源:dependencies.go

示例5: NewAppFromString

// NewAppFromString takes a command line app parameter and returns a map of labels.
//
// Example app parameters:
// 	example.com/reduce-worker:1.0.0
// 	example.com/reduce-worker,channel=alpha,label=value
func NewAppFromString(app string) (*App, error) {
	var (
		name   string
		labels map[types.ACIdentifier]string
	)

	app = strings.Replace(app, ":", ",version=", -1)
	app = "name=" + app
	v, err := url.ParseQuery(strings.Replace(app, ",", "&", -1))
	if err != nil {
		return nil, err
	}
	labels = make(map[types.ACIdentifier]string, 0)
	for key, val := range v {
		if len(val) > 1 {
			return nil, fmt.Errorf("label %s with multiple values %q", key, val)
		}
		if key == "name" {
			name = val[0]
			continue
		}
		labelName, err := types.NewACIdentifier(key)
		if err != nil {
			return nil, err
		}
		labels[*labelName] = val[0]
	}
	a, err := NewApp(name, labels)
	if err != nil {
		return nil, err
	}
	return a, nil
}
開發者ID:jaypipes,項目名稱:acbuild,代碼行數:38,代碼來源:parse.go

示例6: 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)
}
開發者ID:kinvolk,項目名稱:acbuild,代碼行數:30,代碼來源:isolator.go

示例7: 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)
}
開發者ID:jaypipes,項目名稱:acbuild,代碼行數:10,代碼來源:dependencies.go

示例8: 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)
}
開發者ID:jaypipes,項目名稱:acbuild,代碼行數:10,代碼來源:annotations.go

示例9: 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)
}
開發者ID:jaypipes,項目名稱:acbuild,代碼行數:14,代碼來源:annotations.go

示例10: NewApp

func NewApp(name string, labels map[types.ACIdentifier]string) (*App, error) {
	if labels == nil {
		labels = make(map[types.ACIdentifier]string, 0)
	}
	acn, err := types.NewACIdentifier(name)
	if err != nil {
		return nil, err
	}
	return &App{
		Name:   *acn,
		Labels: labels,
	}, nil
}
開發者ID:jaypipes,項目名稱:acbuild,代碼行數:13,代碼來源:parse.go

示例11: 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)
}
開發者ID:jaypipes,項目名稱:acbuild,代碼行數:15,代碼來源:set-name.go

示例12: Set

func (ls *labellist) Set(input string) error {
	parts := strings.SplitN(input, "=", 2)
	if len(parts) != 2 {
		return fmt.Errorf("no '=' character in %q", input)
	}
	acid, err := types.NewACIdentifier(parts[0])
	if err != nil {
		return err
	}
	*ls = append(*ls, types.Label{
		Name:  *acid,
		Value: parts[1],
	})
	return nil
}
開發者ID:jaypipes,項目名稱:acbuild,代碼行數:15,代碼來源:dependency.go

示例13: AddLabel

// 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)
}
開發者ID:jaypipes,項目名稱:acbuild,代碼行數:19,代碼來源:label.go

示例14: RemoveAnnotation

// 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)
}
開發者ID:aaronlevy,項目名稱:acbuild,代碼行數:19,代碼來源:annotations.go

示例15: AddAnnotation

// 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)
}
開發者ID:aaronlevy,項目名稱:acbuild,代碼行數:23,代碼來源:annotations.go


注:本文中的github.com/appc/acbuild/Godeps/_workspace/src/github.com/appc/spec/schema/types.NewACIdentifier函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。