func (aci *Aci) upload(name *common.ACFullname) error { if Home.Config.Push.Type == "maven" && name.DomainName() == "aci.blbl.cr" { // TODO this definitely need to be removed logs.WithF(aci.fields).Info("Uploading aci") if err := common.ExecCmd("curl", "-f", "-i", "-L", "-F", "r=releases", "-F", "hasPom=false", "-F", "e=aci", "-F", "g=com.blablacar.aci.linux.amd64", "-F", "p=aci", "-F", "v="+name.Version(), "-F", "a="+strings.Split(string(name.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") } } else { systemConf := Home.Config.Rkt.SystemConfig if systemConf == "" { systemConf = "/usr/lib/rkt" } localConf := Home.Config.Rkt.LocalConfig if localConf == "" { localConf = "/etc/rkt" } conf, err := config.GetConfigFrom(systemConf, localConf) if err != nil { return errs.WithEF(err, aci.fields, "Failed to get rkt configuration") } upload := Uploader{ Acipath: aci.target + pathImageGzAci, Ascpath: aci.target + pathImageGzAciAsc, Uri: name.String(), Debug: false, SetHTTPHeaders: func(r *http.Request) { if r.URL == nil { return } headerer, ok := conf.AuthPerHost[r.URL.Host] if !ok { logs.WithFields(aci.fields).WithField("domain", r.URL.Host). Warn("No auth credential found in rkt configuration for this domain") return } header := headerer.GetHeader() for k, v := range header { r.Header[k] = append(r.Header[k], v...) } }, } err = upload.Upload() if err != nil { return errs.WithEF(err, aci.fields, "Failed to upload aci") } } return nil }
func (aci *Aci) signFile(file string) error { sign, err := Home.Config.GetSignKeyring(aci.manifest.NameAndVersion.DomainName()) if err != nil { return errs.WithEF(err, aci.fields, "Failed to sign image. Cannot found keyring") } if sign.Disabled { logs.WithF(aci.fields).WithField("domain", aci.manifest.NameAndVersion.DomainName()).Warn("Sign disabled for this aci's domain") return nil } if err := common.ExecCmd("gpg", "--yes", "--no-default-keyring", "--armor", "--keyring", sign.Keyring, "--output", file+suffixAsc, "--detach-sig", file); err != nil { return errs.WithEF(err, aci.fields, "Failed to sign image") } return nil }
func (p *Pod) Push() error { logs.WithF(p.fields).Info("Pushing") if err := p.CleanAndBuild(); err != nil { return err } for _, e := range p.manifest.Pod.Apps { aci, err := p.toPodAci(e) if err != nil { return err } if err := aci.Push(); err != nil { return err } } if Home.Config.Push.Type == "maven" && p.manifest.Name.DomainName() == "aci.blbl.cr" { // TODO this definitely need to be removed if err := common.ExecCmd("curl", "-i", "-F", "r=releases", "-F", "hasPom=false", "-F", "e=pod", "-F", "g=com.blablacar.aci.linux.amd64", "-F", "p=pod", "-F", "v="+p.manifest.Name.Version(), "-F", "a="+p.manifest.Name.ShortName(), "-F", "file=@"+p.target+"/pod-manifest.json", "-u", Home.Config.Push.Username+":"+Home.Config.Push.Password, Home.Config.Push.Url+"/service/local/artifact/maven/content"); err != nil { return errs.WithEF(err, p.fields, "Failed to push pod") } } return nil }