func (aci *Aci) Push() error { defer aci.giveBackUserRightsToTarget() if err := aci.EnsureBuilt(); err != nil { return err } if aci.args.Test { aci.args.Test = false if err := aci.Test(); err != nil { return err } } if err := aci.EnsureZipSign(); err != nil { return err } im, err := common.ExtractManifestFromAci(aci.target + pathImageAci) if err != nil { return errs.WithEF(err, aci.fields.WithField("file", pathImageAci), "Failed to extract manifest from aci file") } return aci.upload(common.ExtractNameVersionFromManifest(im)) }
func (aci *Aci) buildTestAci() (string, error) { manifest, err := common.ExtractManifestFromAci(aci.target + common.PathImageAci) if err != nil { return "", errs.WithEF(err, aci.fields.WithField("file", aci.target+common.PathImageAci), "Failed to extract manifest from aci") } name := prefixTest + manifest.Name.String() if version, ok := manifest.Labels.Get("version"); ok { name += ":" + version } fullname := common.NewACFullName(name) resultMountName, _ := types.NewACName(mountAcname) aciManifest := &common.AciManifest{ Builder: aci.manifest.Tester.Builder, Aci: common.AciDefinition{ App: common.DgrApp{ Exec: aci.manifest.Aci.App.Exec, MountPoints: []types.MountPoint{{Path: pathTestsResult, Name: *resultMountName}}, WorkingDirectory: aci.manifest.Aci.App.WorkingDirectory, User: aci.manifest.Aci.App.User, Group: aci.manifest.Aci.App.Group, SupplementaryGIDs: aci.manifest.Aci.App.SupplementaryGIDs, Environment: aci.manifest.Aci.App.Environment, Ports: aci.manifest.Aci.App.Ports, Isolators: aci.manifest.Aci.App.Isolators, }, Dependencies: append(aci.manifest.Tester.Aci.Dependencies, *common.NewACFullName(name[len(prefixTest):])), Annotations: aci.manifest.Aci.Annotations, PathWhitelist: aci.manifest.Aci.PathWhitelist, }, NameAndVersion: *fullname, } content, err := yaml.Marshal(aciManifest) if err != nil { return "", errs.WithEF(err, aci.fields, "Failed to marshall manifest for test aci") } testAci, err := NewAciWithManifest(aci.path, aci.args, string(content), aci.checkWg) if err != nil { return "", errs.WithEF(err, aci.fields, "Failed to prepare test's build aci") } testAci.FullyResolveDep = false // this is required to run local tests without discovery testAci.target = aci.target + pathTestsTarget if err := testAci.CleanAndBuild(); err != nil { return "", errs.WithEF(err, aci.fields, "Build of test aci failed") } hash, err := Home.Rkt.Fetch(aci.target + pathTestsTarget + pathImageAci) if err != nil { return "", errs.WithEF(err, aci.fields, "fetch of test aci failed") } return hash, nil }
func (aci *Aci) Push() error { defer aci.giveBackUserRightsToTarget() if Home.Config.Push.Type == "" { return errs.WithF(aci.fields, "Cannot push, push is not configured in dgr global configuration file") } if err := aci.EnsureBuilt(); err != nil { return err } if aci.args.Test { aci.args.Test = false if err := aci.Test(); err != nil { return err } } logs.WithF(aci.fields).Info("Gzipping aci before upload") im, err := common.ExtractManifestFromAci(aci.target + pathImageAci) if err != nil { return errs.WithEF(err, aci.fields.WithField("file", pathImageAci), "Failed to extract manifest from aci file") } val, ok := im.Labels.Get("version") if !ok { return errs.WithEF(err, aci.fields.WithField("file", pathImageAci), "Failed to get version from aci manifest") } if err := aci.zipAci(); err != nil { return errs.WithEF(err, aci.fields, "Failed to zip aci") } logs.WithF(aci.fields).Info("Uploading aci") if err := common.ExecCmd("curl", "-f", "-i", "-F", "r=releases", "-F", "hasPom=false", "-F", "e=aci", "-F", "g=com.blablacar.aci.linux.amd64", "-F", "p=aci", "-F", "v="+val, "-F", "a="+strings.Split(string(im.Name), "/")[1], "-F", "file=@"+aci.target+pathImageGzAci, "-u", Home.Config.Push.Username+":"+Home.Config.Push.Password, Home.Config.Push.Url+"/service/local/artifact/maven/content"); err != nil { return errs.WithEF(err, aci.fields, "Failed to push aci") } return nil }
if err := NewAciOrPod(workPath, Args, checkWg).Graph(); err != nil { logs.WithE(err).Fatal("Install command failed") } checkWg.Wait() }, } var aciVersion = &cobra.Command{ Use: "aci-version file", Short: "display version of aci", Run: func(cmd *cobra.Command, args []string) { if len(args) != 1 { cmd.Usage() os.Exit(1) } im, err := common.ExtractManifestFromAci(args[0]) if err != nil { logs.WithE(err).Fatal("Failed to get manifest from file") } val, _ := im.Labels.Get("version") fmt.Println(val) }, } var configCmd = &cobra.Command{ Use: "config", Short: "display config elements", Run: func(cmd *cobra.Command, args []string) { templateStr := "{{.}}" if len(args) > 1 { for i := 0; i < len(args); i++ {