本文整理汇总了Golang中github.com/appc/spec/schema.ImageManifest.Dependencies方法的典型用法代码示例。如果您正苦于以下问题:Golang ImageManifest.Dependencies方法的具体用法?Golang ImageManifest.Dependencies怎么用?Golang ImageManifest.Dependencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/appc/spec/schema.ImageManifest
的用法示例。
在下文中一共展示了ImageManifest.Dependencies方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: prepareStage1aci
func (aci *Aci) prepareStage1aci() (string, error) {
ImportInternalBuilderIfNeeded(aci.manifest)
if len(aci.manifest.Builder.Dependencies) == 0 {
return "", nil
}
logs.WithFields(aci.fields).Debug("Preparing stage1")
if err := os.MkdirAll(aci.target+pathStage1+common.PathRootfs, 0777); err != nil {
return "", errs.WithEF(err, aci.fields.WithField("path", aci.target+pathBuilder), "Failed to create stage1 aci path")
}
Home.Rkt.Fetch(aci.manifest.Builder.Image.String())
manifestStr, err := Home.Rkt.CatManifest(aci.manifest.Builder.Image.String())
if err != nil {
return "", errs.WithEF(err, aci.fields, "Failed to read stage1 image manifest")
}
manifest := schema.ImageManifest{}
if err := json.Unmarshal([]byte(manifestStr), &manifest); err != nil {
return "", errs.WithEF(err, aci.fields.WithField("content", manifestStr), "Failed to unmarshal stage1 manifest received from rkt")
}
manifest.Dependencies = types.Dependencies{}
dep, err := common.ToAppcDependencies(aci.manifest.Builder.Dependencies)
if err != nil {
return "", errs.WithEF(err, aci.fields, "Invalid dependency on stage1 for rkt")
}
manifest.Dependencies = append(manifest.Dependencies, dep...)
stage1Image, err := common.ToAppcDependencies([]common.ACFullname{aci.manifest.Builder.Image})
if err != nil {
return "", errs.WithEF(err, aci.fields, "Invalid image on stage1 for rkt")
}
manifest.Dependencies = append(manifest.Dependencies, stage1Image...)
name, err := types.NewACIdentifier(prefixBuilderStage1 + aci.manifest.NameAndVersion.Name())
if err != nil {
return "", errs.WithEF(err, aci.fields.WithField("name", prefixBuilderStage1+aci.manifest.NameAndVersion.Name()),
"aci name is not a valid identifier for rkt")
}
manifest.Name = *name
content, err := json.MarshalIndent(&manifest, "", " ")
if err != nil {
return "", errs.WithEF(err, aci.fields, "Failed to marshal builder's stage1 manifest")
}
if err := ioutil.WriteFile(aci.target+pathStage1+common.PathManifest, content, 0644); err != nil {
return "", errs.WithEF(err, aci.fields.WithField("path", aci.target+pathStage1+common.PathManifest),
"Failed to write builder's stage1 manifest to file")
}
if err := aci.tarAci(aci.target + pathStage1); err != nil {
return "", err
}
logs.WithF(aci.fields.WithField("path", aci.target+pathStage1+pathImageAci)).Info("Importing builder's stage1")
hash, err := Home.Rkt.FetchInsecure(aci.target + pathStage1 + pathImageAci)
if err != nil {
return "", errs.WithEF(err, aci.fields, "fetch of builder's stage1 aci failed")
}
return hash, nil
}