package forgepb // functions to import and export the protobuf // data to and from config files import ( "errors" "strings" "time" "go.wit.com/log" ) func (f *Forge) SendPatches(what string, p *Patches) (*Patches, error) { route := "/patches/" + what data, err := p.Marshal() if err != nil { return nil, err } log.Infof("pb: len=%d, err=%v\n", len(data), err) newdata, err := f.HttpPost("rm this", route, data) if err != nil { return nil, err } if newdata == nil { return nil, err } if len(newdata) == 0 { return nil, err } log.Info("TODO: Unmarshal() to patches", len(newdata)) return nil, err } // makes a new patches protobuf. These are all the patches on your machine. func NewPatches() *Patches { x := new(Patches) x.Uuid = "2679065e-c81d-4a00-aca4-03c158a834fb" x.Version = "v2.0.0 go.wit.com/lib/protobuf/forgepb" return x } func (f *Forge) SendPatchSet(pset *Patchset) error { var err error data, err := pset.Marshal() if err != nil { log.Info("proto.Marshal() pset(len) error", len(data), err) return err } now := time.Now() timestamp := now.Format("2006.01.02.150405") // bummer. other date doesn't work? cfgfile := "patchset/patchset." + timestamp + ".pb" log.Info("proto.Marshal() pset(len)", len(data)) configWrite(cfgfile, data) return errors.New("don't know how to send yet") } func (f *Forge) SubmitDevelPatchSet(name string) (*Patchset, error) { pset, err := f.MakeDevelPatchSet(name) if err != nil { return nil, err } if err := f.submitPatchset(pset); err != nil { return nil, err } return pset, nil } func (f *Forge) submitPatchset(pset *Patchset) error { msg, err := pset.Marshal() if err != nil { log.Info("proto.Marshal() failed:", err) return err } log.Info("proto.Marshal() msg len", len(msg)) body, err := f.HttpPost("rm this", "patchset", msg) if err != nil { log.Info("httpPost() failed:", err) return err } log.Info("HTTP: proto.Marshal() sent", len(msg), "ok and got back", len(body)) newpb := NewPatches() if err := newpb.Unmarshal(body); err != nil { cfcheck := string(body[0:100]) if strings.Contains(cfcheck, "