diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go index 118140d3..4554c74d 100644 --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -668,7 +668,7 @@ func (t *FeedStar) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) MarshalCBOR(w io.Writer) error { +func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -676,59 +676,187 @@ func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) MarshalCBOR(w io.Writer) er cw := cbg.NewCborWriter(w) - if _, err := cw.Write([]byte{162}); err != nil { + if _, err := cw.Write([]byte{168}); err != nil { return err } - // t.Count (int64) (int64) - if len("count") > 1000000 { - return xerrors.Errorf("Value in field \"count\" was too long") + // t.Ref (string) (string) + if len("ref") > 1000000 { + return xerrors.Errorf("Value in field \"ref\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("count"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ref"))); err != nil { return err } - if _, err := cw.WriteString(string("count")); err != nil { + if _, err := cw.WriteString(string("ref")); err != nil { return err } - if t.Count >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Count)); err != nil { - return err - } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Count-1)); err != nil { - return err - } + if len(t.Ref) > 1000000 { + return xerrors.Errorf("Value in field t.Ref was too long") } - // t.Email (string) (string) - if len("email") > 1000000 { - return xerrors.Errorf("Value in field \"email\" was too long") + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Ref))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Ref)); err != nil { + return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("email"))); err != nil { + // t.Meta (tangled.GitRefUpdate_Meta) (struct) + if len("meta") > 1000000 { + return xerrors.Errorf("Value in field \"meta\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("meta"))); err != nil { return err } - if _, err := cw.WriteString(string("email")); err != nil { + if _, err := cw.WriteString(string("meta")); err != nil { return err } - if len(t.Email) > 1000000 { - return xerrors.Errorf("Value in field t.Email was too long") + if err := t.Meta.MarshalCBOR(cw); err != nil { + return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Email))); err != nil { + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { return err } - if _, err := cw.WriteString(string(t.Email)); err != nil { + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.git.refUpdate"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sh.tangled.git.refUpdate")); err != nil { + return err + } + + // t.NewSha (string) (string) + if len("newSha") > 1000000 { + return xerrors.Errorf("Value in field \"newSha\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("newSha"))); err != nil { + return err + } + if _, err := cw.WriteString(string("newSha")); err != nil { + return err + } + + if len(t.NewSha) > 1000000 { + return xerrors.Errorf("Value in field t.NewSha was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.NewSha))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.NewSha)); err != nil { + return err + } + + // t.OldSha (string) (string) + if len("oldSha") > 1000000 { + return xerrors.Errorf("Value in field \"oldSha\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("oldSha"))); err != nil { + return err + } + if _, err := cw.WriteString(string("oldSha")); err != nil { + return err + } + + if len(t.OldSha) > 1000000 { + return xerrors.Errorf("Value in field t.OldSha was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.OldSha))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.OldSha)); err != nil { + return err + } + + // t.RepoDid (string) (string) + if len("repoDid") > 1000000 { + return xerrors.Errorf("Value in field \"repoDid\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repoDid"))); err != nil { + return err + } + if _, err := cw.WriteString(string("repoDid")); err != nil { + return err + } + + if len(t.RepoDid) > 1000000 { + return xerrors.Errorf("Value in field t.RepoDid was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RepoDid))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.RepoDid)); err != nil { + return err + } + + // t.RepoName (string) (string) + if len("repoName") > 1000000 { + return xerrors.Errorf("Value in field \"repoName\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repoName"))); err != nil { + return err + } + if _, err := cw.WriteString(string("repoName")); err != nil { + return err + } + + if len(t.RepoName) > 1000000 { + return xerrors.Errorf("Value in field t.RepoName was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RepoName))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.RepoName)); err != nil { + return err + } + + // t.CommitterDid (string) (string) + if len("committerDid") > 1000000 { + return xerrors.Errorf("Value in field \"committerDid\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("committerDid"))); err != nil { + return err + } + if _, err := cw.WriteString(string("committerDid")); err != nil { + return err + } + + if len(t.CommitterDid) > 1000000 { + return xerrors.Errorf("Value in field t.CommitterDid was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CommitterDid))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.CommitterDid)); err != nil { return err } return nil } -func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) (err error) { - *t = GitRefUpdate_Meta_CommitCount_ByEmail_Elem{} +func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) { + *t = GitRefUpdate{} cr := cbg.NewCborReader(r) @@ -747,12 +875,12 @@ func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) } if extra > cbg.MaxLength { - return fmt.Errorf("GitRefUpdate_Meta_CommitCount_ByEmail_Elem: map struct too large (%d)", extra) + return fmt.Errorf("GitRefUpdate: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 5) + nameBuf := make([]byte, 12) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -768,34 +896,39 @@ func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) } switch string(nameBuf[:nameLen]) { - // t.Count (int64) (int64) - case "count": + // t.Ref (string) (string) + case "ref": + { - maj, extra, err := cr.ReadHeader() + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") + + t.Ref = string(sval) + } + // t.Meta (tangled.GitRefUpdate_Meta) (struct) + case "meta": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") + t.Meta = new(GitRefUpdate_Meta) + if err := t.Meta.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Meta pointer: %w", err) } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) } - t.Count = int64(extraI) } - // t.Email (string) (string) - case "email": + // t.LexiconTypeID (string) (string) + case "$type": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -803,27 +936,218 @@ func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) return err } - t.Email = string(sval) + t.LexiconTypeID = string(sval) } + // t.NewSha (string) (string) + case "newSha": - default: - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { - return err - } - } - } + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } - return nil -} -func (t *GitRefUpdate_Meta_CommitCount) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } + t.NewSha = string(sval) + } + // t.OldSha (string) (string) + case "oldSha": - cw := cbg.NewCborWriter(w) - fieldCount := 1 + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.OldSha = string(sval) + } + // t.RepoDid (string) (string) + case "repoDid": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.RepoDid = string(sval) + } + // t.RepoName (string) (string) + case "repoName": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.RepoName = string(sval) + } + // t.CommitterDid (string) (string) + case "committerDid": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.CommitterDid = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *GitRefUpdate_Meta) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{162}); err != nil { + return err + } + + // t.CommitCount (tangled.GitRefUpdate_Meta_CommitCount) (struct) + if len("commitCount") > 1000000 { + return xerrors.Errorf("Value in field \"commitCount\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("commitCount"))); err != nil { + return err + } + if _, err := cw.WriteString(string("commitCount")); err != nil { + return err + } + + if err := t.CommitCount.MarshalCBOR(cw); err != nil { + return err + } + + // t.IsDefaultRef (bool) (bool) + if len("isDefaultRef") > 1000000 { + return xerrors.Errorf("Value in field \"isDefaultRef\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("isDefaultRef"))); err != nil { + return err + } + if _, err := cw.WriteString(string("isDefaultRef")); err != nil { + return err + } + + if err := cbg.WriteBool(w, t.IsDefaultRef); err != nil { + return err + } + return nil +} + +func (t *GitRefUpdate_Meta) UnmarshalCBOR(r io.Reader) (err error) { + *t = GitRefUpdate_Meta{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("GitRefUpdate_Meta: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 12) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.CommitCount (tangled.GitRefUpdate_Meta_CommitCount) (struct) + case "commitCount": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.CommitCount = new(GitRefUpdate_Meta_CommitCount) + if err := t.CommitCount.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.CommitCount pointer: %w", err) + } + } + + } + // t.IsDefaultRef (bool) (bool) + case "isDefaultRef": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.IsDefaultRef = false + case 21: + t.IsDefaultRef = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *GitRefUpdate_Meta_CommitCount) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + fieldCount := 1 if t.ByEmail == nil { fieldCount-- @@ -965,7 +1289,7 @@ func (t *GitRefUpdate_Meta_CommitCount) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *GitRefUpdate_Meta) MarshalCBOR(w io.Writer) error { +func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -977,42 +1301,55 @@ func (t *GitRefUpdate_Meta) MarshalCBOR(w io.Writer) error { return err } - // t.CommitCount (tangled.GitRefUpdate_Meta_CommitCount) (struct) - if len("commitCount") > 1000000 { - return xerrors.Errorf("Value in field \"commitCount\" was too long") + // t.Count (int64) (int64) + if len("count") > 1000000 { + return xerrors.Errorf("Value in field \"count\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("commitCount"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("count"))); err != nil { return err } - if _, err := cw.WriteString(string("commitCount")); err != nil { + if _, err := cw.WriteString(string("count")); err != nil { return err } - if err := t.CommitCount.MarshalCBOR(cw); err != nil { - return err + if t.Count >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Count)); err != nil { + return err + } + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Count-1)); err != nil { + return err + } } - // t.IsDefaultRef (bool) (bool) - if len("isDefaultRef") > 1000000 { - return xerrors.Errorf("Value in field \"isDefaultRef\" was too long") + // t.Email (string) (string) + if len("email") > 1000000 { + return xerrors.Errorf("Value in field \"email\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("isDefaultRef"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("email"))); err != nil { return err } - if _, err := cw.WriteString(string("isDefaultRef")); err != nil { + if _, err := cw.WriteString(string("email")); err != nil { return err } - if err := cbg.WriteBool(w, t.IsDefaultRef); err != nil { + if len(t.Email) > 1000000 { + return xerrors.Errorf("Value in field t.Email was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Email))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Email)); err != nil { return err } return nil } -func (t *GitRefUpdate_Meta) UnmarshalCBOR(r io.Reader) (err error) { - *t = GitRefUpdate_Meta{} +func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) (err error) { + *t = GitRefUpdate_Meta_CommitCount_ByEmail_Elem{} cr := cbg.NewCborReader(r) @@ -1031,12 +1368,12 @@ func (t *GitRefUpdate_Meta) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("GitRefUpdate_Meta: map struct too large (%d)", extra) + return fmt.Errorf("GitRefUpdate_Meta_CommitCount_ByEmail_Elem: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 12) + nameBuf := make([]byte, 5) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -1052,43 +1389,42 @@ func (t *GitRefUpdate_Meta) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.CommitCount (tangled.GitRefUpdate_Meta_CommitCount) (struct) - case "commitCount": - + // t.Count (int64) (int64) + case "count": { - - b, err := cr.ReadByte() + maj, extra, err := cr.ReadHeader() if err != nil { return err } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err + var extraI int64 + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") } - t.CommitCount = new(GitRefUpdate_Meta_CommitCount) - if err := t.CommitCount.UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.CommitCount pointer: %w", err) + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative overflow") } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) } + t.Count = int64(extraI) } - // t.IsDefaultRef (bool) (bool) - case "isDefaultRef": + // t.Email (string) (string) + case "email": - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - if maj != cbg.MajOther { - return fmt.Errorf("booleans must be major type 7") - } - switch extra { - case 20: - t.IsDefaultRef = false - case 21: - t.IsDefaultRef = true - default: - return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Email = string(sval) } default: @@ -1101,7 +1437,7 @@ func (t *GitRefUpdate_Meta) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error { +func (t *GraphFollow) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -1109,46 +1445,7 @@ func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write([]byte{168}); err != nil { - return err - } - - // t.Ref (string) (string) - if len("ref") > 1000000 { - return xerrors.Errorf("Value in field \"ref\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ref"))); err != nil { - return err - } - if _, err := cw.WriteString(string("ref")); err != nil { - return err - } - - if len(t.Ref) > 1000000 { - return xerrors.Errorf("Value in field t.Ref was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Ref))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Ref)); err != nil { - return err - } - - // t.Meta (tangled.GitRefUpdate_Meta) (struct) - if len("meta") > 1000000 { - return xerrors.Errorf("Value in field \"meta\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("meta"))); err != nil { - return err - } - if _, err := cw.WriteString(string("meta")); err != nil { - return err - } - - if err := t.Meta.MarshalCBOR(cw); err != nil { + if _, err := cw.Write([]byte{163}); err != nil { return err } @@ -1164,132 +1461,63 @@ func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.git.refUpdate"))); err != nil { - return err - } - if _, err := cw.WriteString(string("sh.tangled.git.refUpdate")); err != nil { - return err - } - - // t.NewSha (string) (string) - if len("newSha") > 1000000 { - return xerrors.Errorf("Value in field \"newSha\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("newSha"))); err != nil { - return err - } - if _, err := cw.WriteString(string("newSha")); err != nil { - return err - } - - if len(t.NewSha) > 1000000 { - return xerrors.Errorf("Value in field t.NewSha was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.NewSha))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.NewSha)); err != nil { - return err - } - - // t.OldSha (string) (string) - if len("oldSha") > 1000000 { - return xerrors.Errorf("Value in field \"oldSha\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("oldSha"))); err != nil { - return err - } - if _, err := cw.WriteString(string("oldSha")); err != nil { - return err - } - - if len(t.OldSha) > 1000000 { - return xerrors.Errorf("Value in field t.OldSha was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.OldSha))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.OldSha)); err != nil { - return err - } - - // t.RepoDid (string) (string) - if len("repoDid") > 1000000 { - return xerrors.Errorf("Value in field \"repoDid\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repoDid"))); err != nil { - return err - } - if _, err := cw.WriteString(string("repoDid")); err != nil { - return err - } - - if len(t.RepoDid) > 1000000 { - return xerrors.Errorf("Value in field t.RepoDid was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RepoDid))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.graph.follow"))); err != nil { return err } - if _, err := cw.WriteString(string(t.RepoDid)); err != nil { + if _, err := cw.WriteString(string("sh.tangled.graph.follow")); err != nil { return err } - // t.RepoName (string) (string) - if len("repoName") > 1000000 { - return xerrors.Errorf("Value in field \"repoName\" was too long") + // t.Subject (string) (string) + if len("subject") > 1000000 { + return xerrors.Errorf("Value in field \"subject\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repoName"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil { return err } - if _, err := cw.WriteString(string("repoName")); err != nil { + if _, err := cw.WriteString(string("subject")); err != nil { return err } - if len(t.RepoName) > 1000000 { - return xerrors.Errorf("Value in field t.RepoName was too long") + if len(t.Subject) > 1000000 { + return xerrors.Errorf("Value in field t.Subject was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RepoName))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Subject))); err != nil { return err } - if _, err := cw.WriteString(string(t.RepoName)); err != nil { + if _, err := cw.WriteString(string(t.Subject)); err != nil { return err } - // t.CommitterDid (string) (string) - if len("committerDid") > 1000000 { - return xerrors.Errorf("Value in field \"committerDid\" was too long") + // t.CreatedAt (string) (string) + if len("createdAt") > 1000000 { + return xerrors.Errorf("Value in field \"createdAt\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("committerDid"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { return err } - if _, err := cw.WriteString(string("committerDid")); err != nil { + if _, err := cw.WriteString(string("createdAt")); err != nil { return err } - if len(t.CommitterDid) > 1000000 { - return xerrors.Errorf("Value in field t.CommitterDid was too long") + if len(t.CreatedAt) > 1000000 { + return xerrors.Errorf("Value in field t.CreatedAt was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CommitterDid))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { return err } - if _, err := cw.WriteString(string(t.CommitterDid)); err != nil { + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { return err } return nil } -func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) { - *t = GitRefUpdate{} +func (t *GraphFollow) UnmarshalCBOR(r io.Reader) (err error) { + *t = GraphFollow{} cr := cbg.NewCborReader(r) @@ -1308,12 +1536,12 @@ func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("GitRefUpdate: map struct too large (%d)", extra) + return fmt.Errorf("GraphFollow: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 12) + nameBuf := make([]byte, 9) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -1329,38 +1557,7 @@ func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.Ref (string) (string) - case "ref": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Ref = string(sval) - } - // t.Meta (tangled.GitRefUpdate_Meta) (struct) - case "meta": - - { - - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - t.Meta = new(GitRefUpdate_Meta) - if err := t.Meta.UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.Meta pointer: %w", err) - } - } - - } - // t.LexiconTypeID (string) (string) + // t.LexiconTypeID (string) (string) case "$type": { @@ -1371,8 +1568,8 @@ func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) { t.LexiconTypeID = string(sval) } - // t.NewSha (string) (string) - case "newSha": + // t.Subject (string) (string) + case "subject": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -1380,10 +1577,10 @@ func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.NewSha = string(sval) + t.Subject = string(sval) } - // t.OldSha (string) (string) - case "oldSha": + // t.CreatedAt (string) (string) + case "createdAt": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -1391,40 +1588,7 @@ func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.OldSha = string(sval) - } - // t.RepoDid (string) (string) - case "repoDid": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.RepoDid = string(sval) - } - // t.RepoName (string) (string) - case "repoName": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.RepoName = string(sval) - } - // t.CommitterDid (string) (string) - case "committerDid": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.CommitterDid = string(sval) + t.CreatedAt = string(sval) } default: @@ -1437,7 +1601,7 @@ func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *GraphFollow) MarshalCBOR(w io.Writer) error { +func (t *KnotMember) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -1445,7 +1609,7 @@ func (t *GraphFollow) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write([]byte{163}); err != nil { + if _, err := cw.Write([]byte{164}); err != nil { return err } @@ -1461,10 +1625,33 @@ func (t *GraphFollow) MarshalCBOR(w io.Writer) error { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.graph.follow"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.knot.member"))); err != nil { return err } - if _, err := cw.WriteString(string("sh.tangled.graph.follow")); err != nil { + if _, err := cw.WriteString(string("sh.tangled.knot.member")); err != nil { + return err + } + + // t.Domain (string) (string) + if len("domain") > 1000000 { + return xerrors.Errorf("Value in field \"domain\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("domain"))); err != nil { + return err + } + if _, err := cw.WriteString(string("domain")); err != nil { + return err + } + + if len(t.Domain) > 1000000 { + return xerrors.Errorf("Value in field t.Domain was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Domain))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Domain)); err != nil { return err } @@ -1516,8 +1703,8 @@ func (t *GraphFollow) MarshalCBOR(w io.Writer) error { return nil } -func (t *GraphFollow) UnmarshalCBOR(r io.Reader) (err error) { - *t = GraphFollow{} +func (t *KnotMember) UnmarshalCBOR(r io.Reader) (err error) { + *t = KnotMember{} cr := cbg.NewCborReader(r) @@ -1536,7 +1723,7 @@ func (t *GraphFollow) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("GraphFollow: map struct too large (%d)", extra) + return fmt.Errorf("KnotMember: map struct too large (%d)", extra) } n := extra @@ -1568,6 +1755,17 @@ func (t *GraphFollow) UnmarshalCBOR(r io.Reader) (err error) { t.LexiconTypeID = string(sval) } + // t.Domain (string) (string) + case "domain": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Domain = string(sval) + } // t.Subject (string) (string) case "subject": @@ -1601,7 +1799,7 @@ func (t *GraphFollow) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *KnotMember) MarshalCBOR(w io.Writer) error { +func (t *Pipeline) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -1609,7 +1807,7 @@ func (t *KnotMember) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write([]byte{164}); err != nil { + if _, err := cw.Write([]byte{163}); err != nil { return err } @@ -1625,86 +1823,59 @@ func (t *KnotMember) MarshalCBOR(w io.Writer) error { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.knot.member"))); err != nil { - return err - } - if _, err := cw.WriteString(string("sh.tangled.knot.member")); err != nil { - return err - } - - // t.Domain (string) (string) - if len("domain") > 1000000 { - return xerrors.Errorf("Value in field \"domain\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("domain"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline"))); err != nil { return err } - if _, err := cw.WriteString(string("domain")); err != nil { + if _, err := cw.WriteString(string("sh.tangled.pipeline")); err != nil { return err } - if len(t.Domain) > 1000000 { - return xerrors.Errorf("Value in field t.Domain was too long") + // t.Workflows ([]*tangled.Pipeline_Workflow) (slice) + if len("workflows") > 1000000 { + return xerrors.Errorf("Value in field \"workflows\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Domain))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflows"))); err != nil { return err } - if _, err := cw.WriteString(string(t.Domain)); err != nil { + if _, err := cw.WriteString(string("workflows")); err != nil { return err } - // t.Subject (string) (string) - if len("subject") > 1000000 { - return xerrors.Errorf("Value in field \"subject\" was too long") + if len(t.Workflows) > 8192 { + return xerrors.Errorf("Slice value in field t.Workflows was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil { - return err - } - if _, err := cw.WriteString(string("subject")); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Workflows))); err != nil { return err } + for _, v := range t.Workflows { + if err := v.MarshalCBOR(cw); err != nil { + return err + } - if len(t.Subject) > 1000000 { - return xerrors.Errorf("Value in field t.Subject was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Subject))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Subject)); err != nil { - return err } - // t.CreatedAt (string) (string) - if len("createdAt") > 1000000 { - return xerrors.Errorf("Value in field \"createdAt\" was too long") + // t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct) + if len("triggerMetadata") > 1000000 { + return xerrors.Errorf("Value in field \"triggerMetadata\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("triggerMetadata"))); err != nil { return err } - if _, err := cw.WriteString(string("createdAt")); err != nil { + if _, err := cw.WriteString(string("triggerMetadata")); err != nil { return err } - if len(t.CreatedAt) > 1000000 { - return xerrors.Errorf("Value in field t.CreatedAt was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { + if err := t.TriggerMetadata.MarshalCBOR(cw); err != nil { return err } return nil } -func (t *KnotMember) UnmarshalCBOR(r io.Reader) (err error) { - *t = KnotMember{} +func (t *Pipeline) UnmarshalCBOR(r io.Reader) (err error) { + *t = Pipeline{} cr := cbg.NewCborReader(r) @@ -1723,12 +1894,12 @@ func (t *KnotMember) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("KnotMember: map struct too large (%d)", extra) + return fmt.Errorf("Pipeline: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 9) + nameBuf := make([]byte, 15) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -1755,38 +1926,74 @@ func (t *KnotMember) UnmarshalCBOR(r io.Reader) (err error) { t.LexiconTypeID = string(sval) } - // t.Domain (string) (string) - case "domain": + // t.Workflows ([]*tangled.Pipeline_Workflow) (slice) + case "workflows": - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } - t.Domain = string(sval) + if extra > 8192 { + return fmt.Errorf("t.Workflows: array too large (%d)", extra) } - // t.Subject (string) (string) - case "subject": - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } - t.Subject = string(sval) + if extra > 0 { + t.Workflows = make([]*Pipeline_Workflow, extra) } - // t.CreatedAt (string) (string) - case "createdAt": + + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Workflows[i] = new(Pipeline_Workflow) + if err := t.Workflows[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Workflows[i] pointer: %w", err) + } + } + + } + + } + } + // t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct) + case "triggerMetadata": { - sval, err := cbg.ReadStringWithMax(cr, 1000000) + + b, err := cr.ReadByte() if err != nil { return err } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.TriggerMetadata = new(Pipeline_TriggerMetadata) + if err := t.TriggerMetadata.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.TriggerMetadata pointer: %w", err) + } + } - t.CreatedAt = string(sval) } default: @@ -1799,206 +2006,260 @@ func (t *KnotMember) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *PipelineStatus) MarshalCBOR(w io.Writer) error { +func (t *Pipeline_CloneOpts) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) - fieldCount := 7 - - if t.Error == nil { - fieldCount-- - } - - if t.ExitCode == nil { - fieldCount-- - } - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + if _, err := cw.Write([]byte{163}); err != nil { return err } - // t.LexiconTypeID (string) (string) - if len("$type") > 1000000 { - return xerrors.Errorf("Value in field \"$type\" was too long") + // t.Skip (bool) (bool) + if len("skip") > 1000000 { + return xerrors.Errorf("Value in field \"skip\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("skip"))); err != nil { return err } - if _, err := cw.WriteString(string("$type")); err != nil { + if _, err := cw.WriteString(string("skip")); err != nil { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline.status"))); err != nil { - return err - } - if _, err := cw.WriteString(string("sh.tangled.pipeline.status")); err != nil { + if err := cbg.WriteBool(w, t.Skip); err != nil { return err } - // t.Error (string) (string) - if t.Error != nil { + // t.Depth (int64) (int64) + if len("depth") > 1000000 { + return xerrors.Errorf("Value in field \"depth\" was too long") + } - if len("error") > 1000000 { - return xerrors.Errorf("Value in field \"error\" was too long") - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("depth"))); err != nil { + return err + } + if _, err := cw.WriteString(string("depth")); err != nil { + return err + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("error"))); err != nil { + if t.Depth >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Depth)); err != nil { return err } - if _, err := cw.WriteString(string("error")); err != nil { + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Depth-1)); err != nil { return err } - - if t.Error == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.Error) > 1000000 { - return xerrors.Errorf("Value in field t.Error was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Error))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.Error)); err != nil { - return err - } - } } - // t.Status (string) (string) - if len("status") > 1000000 { - return xerrors.Errorf("Value in field \"status\" was too long") + // t.Submodules (bool) (bool) + if len("submodules") > 1000000 { + return xerrors.Errorf("Value in field \"submodules\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("submodules"))); err != nil { return err } - if _, err := cw.WriteString(string("status")); err != nil { + if _, err := cw.WriteString(string("submodules")); err != nil { return err } - if len(t.Status) > 1000000 { - return xerrors.Errorf("Value in field t.Status was too long") + if err := cbg.WriteBool(w, t.Submodules); err != nil { + return err } + return nil +} - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil { +func (t *Pipeline_CloneOpts) UnmarshalCBOR(r io.Reader) (err error) { + *t = Pipeline_CloneOpts{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { return err } - if _, err := cw.WriteString(string(t.Status)); err != nil { - return err + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") } - // t.ExitCode (int64) (int64) - if t.ExitCode != nil { + if extra > cbg.MaxLength { + return fmt.Errorf("Pipeline_CloneOpts: map struct too large (%d)", extra) + } - if len("exitCode") > 1000000 { - return xerrors.Errorf("Value in field \"exitCode\" was too long") - } + n := extra - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("exitCode"))); err != nil { + nameBuf := make([]byte, 10) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { return err } - if _, err := cw.WriteString(string("exitCode")); err != nil { - return err + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue } - if t.ExitCode == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { + switch string(nameBuf[:nameLen]) { + // t.Skip (bool) (bool) + case "skip": + + maj, extra, err = cr.ReadHeader() + if err != nil { return err } - } else { - if *t.ExitCode >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.ExitCode)); err != nil { + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.Skip = false + case 21: + t.Skip = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) + } + // t.Depth (int64) (int64) + case "depth": + { + maj, extra, err := cr.ReadHeader() + if err != nil { return err } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.ExitCode-1)); err != nil { - return err + var extraI int64 + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative overflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) } + + t.Depth = int64(extraI) } - } + // t.Submodules (bool) (bool) + case "submodules": - } + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.Submodules = false + case 21: + t.Submodules = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) + } - // t.Pipeline (string) (string) - if len("pipeline") > 1000000 { - return xerrors.Errorf("Value in field \"pipeline\" was too long") + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pipeline"))); err != nil { - return err - } - if _, err := cw.WriteString(string("pipeline")); err != nil { + return nil +} +func (t *Pipeline_Dependencies_Elem) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) return err } - if len(t.Pipeline) > 1000000 { - return xerrors.Errorf("Value in field t.Pipeline was too long") - } + cw := cbg.NewCborWriter(w) - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pipeline))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Pipeline)); err != nil { + if _, err := cw.Write([]byte{162}); err != nil { return err } - // t.Workflow (string) (string) - if len("workflow") > 1000000 { - return xerrors.Errorf("Value in field \"workflow\" was too long") + // t.Packages ([]string) (slice) + if len("packages") > 1000000 { + return xerrors.Errorf("Value in field \"packages\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflow"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("packages"))); err != nil { return err } - if _, err := cw.WriteString(string("workflow")); err != nil { + if _, err := cw.WriteString(string("packages")); err != nil { return err } - if len(t.Workflow) > 1000000 { - return xerrors.Errorf("Value in field t.Workflow was too long") + if len(t.Packages) > 8192 { + return xerrors.Errorf("Slice value in field t.Packages was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Workflow))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Packages))); err != nil { return err } - if _, err := cw.WriteString(string(t.Workflow)); err != nil { - return err + for _, v := range t.Packages { + if len(v) > 1000000 { + return xerrors.Errorf("Value in field v was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { + return err + } + if _, err := cw.WriteString(string(v)); err != nil { + return err + } + } - // t.CreatedAt (string) (string) - if len("createdAt") > 1000000 { - return xerrors.Errorf("Value in field \"createdAt\" was too long") + // t.Registry (string) (string) + if len("registry") > 1000000 { + return xerrors.Errorf("Value in field \"registry\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("registry"))); err != nil { return err } - if _, err := cw.WriteString(string("createdAt")); err != nil { + if _, err := cw.WriteString(string("registry")); err != nil { return err } - if len(t.CreatedAt) > 1000000 { - return xerrors.Errorf("Value in field t.CreatedAt was too long") + if len(t.Registry) > 1000000 { + return xerrors.Errorf("Value in field t.Registry was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Registry))); err != nil { return err } - if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { + if _, err := cw.WriteString(string(t.Registry)); err != nil { return err } return nil } -func (t *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) { - *t = PipelineStatus{} +func (t *Pipeline_Dependencies_Elem) UnmarshalCBOR(r io.Reader) (err error) { + *t = Pipeline_Dependencies_Elem{} cr := cbg.NewCborReader(r) @@ -2017,12 +2278,12 @@ func (t *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("PipelineStatus: map struct too large (%d)", extra) + return fmt.Errorf("Pipeline_Dependencies_Elem: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 9) + nameBuf := make([]byte, 8) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -2038,109 +2299,48 @@ func (t *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.LexiconTypeID (string) (string) - case "$type": + // t.Packages ([]string) (slice) + case "packages": - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } - t.LexiconTypeID = string(sval) + if extra > 8192 { + return fmt.Errorf("t.Packages: array too large (%d)", extra) } - // t.Error (string) (string) - case "error": - - { - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - t.Error = (*string)(&sval) - } + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") } - // t.Status (string) (string) - case "status": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - t.Status = string(sval) + if extra > 0 { + t.Packages = make([]string, extra) } - // t.ExitCode (int64) (int64) - case "exitCode": - { - - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") - } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") - } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) - } - t.ExitCode = (*int64)(&extraI) - } - } - // t.Pipeline (string) (string) - case "pipeline": + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } - t.Pipeline = string(sval) - } - // t.Workflow (string) (string) - case "workflow": + t.Packages[i] = string(sval) + } - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err } - - t.Workflow = string(sval) } - // t.CreatedAt (string) (string) - case "createdAt": + // t.Registry (string) (string) + case "registry": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -2148,7 +2348,7 @@ func (t *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.CreatedAt = string(sval) + t.Registry = string(sval) } default: @@ -2161,76 +2361,56 @@ func (t *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *Pipeline_CloneOpts) MarshalCBOR(w io.Writer) error { +func (t *Pipeline_ManualTriggerData) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) + fieldCount := 1 - if _, err := cw.Write([]byte{163}); err != nil { - return err - } - - // t.Skip (bool) (bool) - if len("skip") > 1000000 { - return xerrors.Errorf("Value in field \"skip\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("skip"))); err != nil { - return err - } - if _, err := cw.WriteString(string("skip")); err != nil { - return err + if t.Inputs == nil { + fieldCount-- } - if err := cbg.WriteBool(w, t.Skip); err != nil { + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { return err } - // t.Depth (int64) (int64) - if len("depth") > 1000000 { - return xerrors.Errorf("Value in field \"depth\" was too long") - } + // t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice) + if t.Inputs != nil { - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("depth"))); err != nil { - return err - } - if _, err := cw.WriteString(string("depth")); err != nil { - return err - } + if len("inputs") > 1000000 { + return xerrors.Errorf("Value in field \"inputs\" was too long") + } - if t.Depth >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Depth)); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("inputs"))); err != nil { return err } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Depth-1)); err != nil { + if _, err := cw.WriteString(string("inputs")); err != nil { return err } - } - // t.Submodules (bool) (bool) - if len("submodules") > 1000000 { - return xerrors.Errorf("Value in field \"submodules\" was too long") - } + if len(t.Inputs) > 8192 { + return xerrors.Errorf("Slice value in field t.Inputs was too long") + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("submodules"))); err != nil { - return err - } - if _, err := cw.WriteString(string("submodules")); err != nil { - return err - } + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Inputs))); err != nil { + return err + } + for _, v := range t.Inputs { + if err := v.MarshalCBOR(cw); err != nil { + return err + } - if err := cbg.WriteBool(w, t.Submodules); err != nil { - return err + } } return nil } -func (t *Pipeline_CloneOpts) UnmarshalCBOR(r io.Reader) (err error) { - *t = Pipeline_CloneOpts{} +func (t *Pipeline_ManualTriggerData) UnmarshalCBOR(r io.Reader) (err error) { + *t = Pipeline_ManualTriggerData{} cr := cbg.NewCborReader(r) @@ -2249,12 +2429,12 @@ func (t *Pipeline_CloneOpts) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("Pipeline_CloneOpts: map struct too large (%d)", extra) + return fmt.Errorf("Pipeline_ManualTriggerData: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 10) + nameBuf := make([]byte, 6) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -2270,208 +2450,24 @@ func (t *Pipeline_CloneOpts) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.Skip (bool) (bool) - case "skip": + // t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice) + case "inputs": maj, extra, err = cr.ReadHeader() if err != nil { return err } - if maj != cbg.MajOther { - return fmt.Errorf("booleans must be major type 7") - } - switch extra { - case 20: - t.Skip = false - case 21: - t.Skip = true - default: - return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) - } - // t.Depth (int64) (int64) - case "depth": - { - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") - } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") - } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) - } - t.Depth = int64(extraI) + if extra > 8192 { + return fmt.Errorf("t.Inputs: array too large (%d)", extra) } - // t.Submodules (bool) (bool) - case "submodules": - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - if maj != cbg.MajOther { - return fmt.Errorf("booleans must be major type 7") - } - switch extra { - case 20: - t.Submodules = false - case 21: - t.Submodules = true - default: - return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") } - default: - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { - return err - } - } - } - - return nil -} -func (t *Pipeline_Dependencies_Elem) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - - cw := cbg.NewCborWriter(w) - - if _, err := cw.Write([]byte{162}); err != nil { - return err - } - - // t.Packages ([]string) (slice) - if len("packages") > 1000000 { - return xerrors.Errorf("Value in field \"packages\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("packages"))); err != nil { - return err - } - if _, err := cw.WriteString(string("packages")); err != nil { - return err - } - - if len(t.Packages) > 8192 { - return xerrors.Errorf("Slice value in field t.Packages was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Packages))); err != nil { - return err - } - for _, v := range t.Packages { - if len(v) > 1000000 { - return xerrors.Errorf("Value in field v was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { - return err - } - if _, err := cw.WriteString(string(v)); err != nil { - return err - } - - } - - // t.Registry (string) (string) - if len("registry") > 1000000 { - return xerrors.Errorf("Value in field \"registry\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("registry"))); err != nil { - return err - } - if _, err := cw.WriteString(string("registry")); err != nil { - return err - } - - if len(t.Registry) > 1000000 { - return xerrors.Errorf("Value in field t.Registry was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Registry))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Registry)); err != nil { - return err - } - return nil -} - -func (t *Pipeline_Dependencies_Elem) UnmarshalCBOR(r io.Reader) (err error) { - *t = Pipeline_Dependencies_Elem{} - - cr := cbg.NewCborReader(r) - - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - defer func() { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - }() - - if maj != cbg.MajMap { - return fmt.Errorf("cbor input should be of type map") - } - - if extra > cbg.MaxLength { - return fmt.Errorf("Pipeline_Dependencies_Elem: map struct too large (%d)", extra) - } - - n := extra - - nameBuf := make([]byte, 8) - for i := uint64(0); i < n; i++ { - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) - if err != nil { - return err - } - - if !ok { - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { - return err - } - continue - } - - switch string(nameBuf[:nameLen]) { - // t.Packages ([]string) (slice) - case "packages": - - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - - if extra > 8192 { - return fmt.Errorf("t.Packages: array too large (%d)", extra) - } - - if maj != cbg.MajArray { - return fmt.Errorf("expected cbor array") - } - - if extra > 0 { - t.Packages = make([]string, extra) + if extra > 0 { + t.Inputs = make([]*Pipeline_ManualTriggerData_Inputs_Elem, extra) } for i := 0; i < int(extra); i++ { @@ -2484,27 +2480,25 @@ func (t *Pipeline_Dependencies_Elem) UnmarshalCBOR(r io.Reader) (err error) { _ = err { - sval, err := cbg.ReadStringWithMax(cr, 1000000) + + b, err := cr.ReadByte() if err != nil { return err } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Inputs[i] = new(Pipeline_ManualTriggerData_Inputs_Elem) + if err := t.Inputs[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Inputs[i] pointer: %w", err) + } + } - t.Packages[i] = string(sval) } } } - // t.Registry (string) (string) - case "registry": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Registry = string(sval) - } default: // Field doesn't exist on this type, so ignore it @@ -2650,240 +2644,91 @@ func (t *Pipeline_ManualTriggerData_Inputs_Elem) UnmarshalCBOR(r io.Reader) (err return nil } -func (t *Pipeline_ManualTriggerData) MarshalCBOR(w io.Writer) error { +func (t *Pipeline_PullRequestTriggerData) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) - fieldCount := 1 - if t.Inputs == nil { - fieldCount-- + if _, err := cw.Write([]byte{164}); err != nil { + return err } - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { - return err + // t.Action (string) (string) + if len("action") > 1000000 { + return xerrors.Errorf("Value in field \"action\" was too long") } - // t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice) - if t.Inputs != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("action"))); err != nil { + return err + } + if _, err := cw.WriteString(string("action")); err != nil { + return err + } - if len("inputs") > 1000000 { - return xerrors.Errorf("Value in field \"inputs\" was too long") - } + if len(t.Action) > 1000000 { + return xerrors.Errorf("Value in field t.Action was too long") + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("inputs"))); err != nil { - return err - } - if _, err := cw.WriteString(string("inputs")); err != nil { - return err - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Action))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Action)); err != nil { + return err + } - if len(t.Inputs) > 8192 { - return xerrors.Errorf("Slice value in field t.Inputs was too long") - } + // t.SourceSha (string) (string) + if len("sourceSha") > 1000000 { + return xerrors.Errorf("Value in field \"sourceSha\" was too long") + } - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Inputs))); err != nil { - return err - } - for _, v := range t.Inputs { - if err := v.MarshalCBOR(cw); err != nil { - return err - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceSha"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sourceSha")); err != nil { + return err + } - } + if len(t.SourceSha) > 1000000 { + return xerrors.Errorf("Value in field t.SourceSha was too long") } - return nil -} -func (t *Pipeline_ManualTriggerData) UnmarshalCBOR(r io.Reader) (err error) { - *t = Pipeline_ManualTriggerData{} + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.SourceSha))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.SourceSha)); err != nil { + return err + } - cr := cbg.NewCborReader(r) + // t.SourceBranch (string) (string) + if len("sourceBranch") > 1000000 { + return xerrors.Errorf("Value in field \"sourceBranch\" was too long") + } - maj, extra, err := cr.ReadHeader() - if err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceBranch"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sourceBranch")); err != nil { return err } - defer func() { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - }() - if maj != cbg.MajMap { - return fmt.Errorf("cbor input should be of type map") + if len(t.SourceBranch) > 1000000 { + return xerrors.Errorf("Value in field t.SourceBranch was too long") } - if extra > cbg.MaxLength { - return fmt.Errorf("Pipeline_ManualTriggerData: map struct too large (%d)", extra) + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.SourceBranch))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.SourceBranch)); err != nil { + return err } - n := extra - - nameBuf := make([]byte, 6) - for i := uint64(0); i < n; i++ { - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) - if err != nil { - return err - } - - if !ok { - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { - return err - } - continue - } - - switch string(nameBuf[:nameLen]) { - // t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice) - case "inputs": - - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - - if extra > 8192 { - return fmt.Errorf("t.Inputs: array too large (%d)", extra) - } - - if maj != cbg.MajArray { - return fmt.Errorf("expected cbor array") - } - - if extra > 0 { - t.Inputs = make([]*Pipeline_ManualTriggerData_Inputs_Elem, extra) - } - - for i := 0; i < int(extra); i++ { - { - var maj byte - var extra uint64 - var err error - _ = maj - _ = extra - _ = err - - { - - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - t.Inputs[i] = new(Pipeline_ManualTriggerData_Inputs_Elem) - if err := t.Inputs[i].UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.Inputs[i] pointer: %w", err) - } - } - - } - - } - } - - default: - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { - return err - } - } - } - - return nil -} -func (t *Pipeline_PullRequestTriggerData) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - - cw := cbg.NewCborWriter(w) - - if _, err := cw.Write([]byte{164}); err != nil { - return err - } - - // t.Action (string) (string) - if len("action") > 1000000 { - return xerrors.Errorf("Value in field \"action\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("action"))); err != nil { - return err - } - if _, err := cw.WriteString(string("action")); err != nil { - return err - } - - if len(t.Action) > 1000000 { - return xerrors.Errorf("Value in field t.Action was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Action))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Action)); err != nil { - return err - } - - // t.SourceSha (string) (string) - if len("sourceSha") > 1000000 { - return xerrors.Errorf("Value in field \"sourceSha\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceSha"))); err != nil { - return err - } - if _, err := cw.WriteString(string("sourceSha")); err != nil { - return err - } - - if len(t.SourceSha) > 1000000 { - return xerrors.Errorf("Value in field t.SourceSha was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.SourceSha))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.SourceSha)); err != nil { - return err - } - - // t.SourceBranch (string) (string) - if len("sourceBranch") > 1000000 { - return xerrors.Errorf("Value in field \"sourceBranch\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceBranch"))); err != nil { - return err - } - if _, err := cw.WriteString(string("sourceBranch")); err != nil { - return err - } - - if len(t.SourceBranch) > 1000000 { - return xerrors.Errorf("Value in field t.SourceBranch was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.SourceBranch))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.SourceBranch)); err != nil { - return err - } - - // t.TargetBranch (string) (string) - if len("targetBranch") > 1000000 { - return xerrors.Errorf("Value in field \"targetBranch\" was too long") - } + // t.TargetBranch (string) (string) + if len("targetBranch") > 1000000 { + return xerrors.Errorf("Value in field \"targetBranch\" was too long") + } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetBranch"))); err != nil { return err @@ -3169,6 +3014,7 @@ func (t *Pipeline_PushTriggerData) UnmarshalCBOR(r io.Reader) (err error) { return nil } + func (t *Pipeline_Step_Environment_Elem) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) @@ -3303,16 +3149,20 @@ func (t *Pipeline_Step_Environment_Elem) UnmarshalCBOR(r io.Reader) (err error) return nil } -func (t *Pipeline_Step) MarshalCBOR(w io.Writer) error { +func (t *PipelineStatus) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) - fieldCount := 3 + fieldCount := 7 - if t.Environment == nil { + if t.Error == nil { + fieldCount-- + } + + if t.ExitCode == nil { fieldCount-- } @@ -3320,85 +3170,185 @@ func (t *Pipeline_Step) MarshalCBOR(w io.Writer) error { return err } - // t.Name (string) (string) - if len("name") > 1000000 { - return xerrors.Errorf("Value in field \"name\" was too long") + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { return err } - if _, err := cw.WriteString(string("name")); err != nil { + if _, err := cw.WriteString(string("$type")); err != nil { return err } - if len(t.Name) > 1000000 { - return xerrors.Errorf("Value in field t.Name was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline.status"))); err != nil { return err } - if _, err := cw.WriteString(string(t.Name)); err != nil { + if _, err := cw.WriteString(string("sh.tangled.pipeline.status")); err != nil { return err } - // t.Command (string) (string) - if len("command") > 1000000 { - return xerrors.Errorf("Value in field \"command\" was too long") + // t.Error (string) (string) + if t.Error != nil { + + if len("error") > 1000000 { + return xerrors.Errorf("Value in field \"error\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("error"))); err != nil { + return err + } + if _, err := cw.WriteString(string("error")); err != nil { + return err + } + + if t.Error == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Error) > 1000000 { + return xerrors.Errorf("Value in field t.Error was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Error))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Error)); err != nil { + return err + } + } } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("command"))); err != nil { + // t.Status (string) (string) + if len("status") > 1000000 { + return xerrors.Errorf("Value in field \"status\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { return err } - if _, err := cw.WriteString(string("command")); err != nil { + if _, err := cw.WriteString(string("status")); err != nil { return err } - if len(t.Command) > 1000000 { - return xerrors.Errorf("Value in field t.Command was too long") + if len(t.Status) > 1000000 { + return xerrors.Errorf("Value in field t.Status was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Command))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil { return err } - if _, err := cw.WriteString(string(t.Command)); err != nil { + if _, err := cw.WriteString(string(t.Status)); err != nil { return err } - // t.Environment ([]*tangled.Pipeline_Step_Environment_Elem) (slice) - if t.Environment != nil { + // t.ExitCode (int64) (int64) + if t.ExitCode != nil { - if len("environment") > 1000000 { - return xerrors.Errorf("Value in field \"environment\" was too long") + if len("exitCode") > 1000000 { + return xerrors.Errorf("Value in field \"exitCode\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("environment"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("exitCode"))); err != nil { return err } - if _, err := cw.WriteString(string("environment")); err != nil { + if _, err := cw.WriteString(string("exitCode")); err != nil { return err } - if len(t.Environment) > 8192 { - return xerrors.Errorf("Slice value in field t.Environment was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Environment))); err != nil { - return err - } - for _, v := range t.Environment { - if err := v.MarshalCBOR(cw); err != nil { + if t.ExitCode == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { return err } - + } else { + if *t.ExitCode >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.ExitCode)); err != nil { + return err + } + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.ExitCode-1)); err != nil { + return err + } + } } + + } + + // t.Pipeline (string) (string) + if len("pipeline") > 1000000 { + return xerrors.Errorf("Value in field \"pipeline\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pipeline"))); err != nil { + return err + } + if _, err := cw.WriteString(string("pipeline")); err != nil { + return err + } + + if len(t.Pipeline) > 1000000 { + return xerrors.Errorf("Value in field t.Pipeline was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pipeline))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Pipeline)); err != nil { + return err + } + + // t.Workflow (string) (string) + if len("workflow") > 1000000 { + return xerrors.Errorf("Value in field \"workflow\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflow"))); err != nil { + return err + } + if _, err := cw.WriteString(string("workflow")); err != nil { + return err + } + + if len(t.Workflow) > 1000000 { + return xerrors.Errorf("Value in field t.Workflow was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Workflow))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Workflow)); err != nil { + return err + } + + // t.CreatedAt (string) (string) + if len("createdAt") > 1000000 { + return xerrors.Errorf("Value in field \"createdAt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { + return err + } + if _, err := cw.WriteString(string("createdAt")); err != nil { + return err + } + + if len(t.CreatedAt) > 1000000 { + return xerrors.Errorf("Value in field t.CreatedAt was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { + return err } return nil } -func (t *Pipeline_Step) UnmarshalCBOR(r io.Reader) (err error) { - *t = Pipeline_Step{} +func (t *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) { + *t = PipelineStatus{} cr := cbg.NewCborReader(r) @@ -3417,12 +3367,12 @@ func (t *Pipeline_Step) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("Pipeline_Step: map struct too large (%d)", extra) + return fmt.Errorf("PipelineStatus: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 11) + nameBuf := make([]byte, 9) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -3438,8 +3388,8 @@ func (t *Pipeline_Step) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.Name (string) (string) - case "name": + // t.LexiconTypeID (string) (string) + case "$type": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -3447,67 +3397,108 @@ func (t *Pipeline_Step) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.Name = string(sval) + t.LexiconTypeID = string(sval) } - // t.Command (string) (string) - case "command": + // t.Error (string) (string) + case "error": { - sval, err := cbg.ReadStringWithMax(cr, 1000000) + b, err := cr.ReadByte() if err != nil { return err } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } - t.Command = string(sval) - } - // t.Environment ([]*tangled.Pipeline_Step_Environment_Elem) (slice) - case "environment": + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } - maj, extra, err = cr.ReadHeader() - if err != nil { - return err + t.Error = (*string)(&sval) + } } + // t.Status (string) (string) + case "status": - if extra > 8192 { - return fmt.Errorf("t.Environment: array too large (%d)", extra) - } + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } - if maj != cbg.MajArray { - return fmt.Errorf("expected cbor array") + t.Status = string(sval) } + // t.ExitCode (int64) (int64) + case "exitCode": + { - if extra > 0 { - t.Environment = make([]*Pipeline_Step_Environment_Elem, extra) + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + var extraI int64 + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative overflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) + } + + t.ExitCode = (*int64)(&extraI) + } } + // t.Pipeline (string) (string) + case "pipeline": - for i := 0; i < int(extra); i++ { - { - var maj byte - var extra uint64 - var err error - _ = maj - _ = extra - _ = err + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } - { + t.Pipeline = string(sval) + } + // t.Workflow (string) (string) + case "workflow": - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - t.Environment[i] = new(Pipeline_Step_Environment_Elem) - if err := t.Environment[i].UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.Environment[i] pointer: %w", err) - } - } + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } - } + t.Workflow = string(sval) + } + // t.CreatedAt (string) (string) + case "createdAt": + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err } + + t.CreatedAt = string(sval) } default: @@ -3520,24 +3511,17 @@ func (t *Pipeline_Step) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *Pipeline_TriggerMetadata) MarshalCBOR(w io.Writer) error { + +func (t *Pipeline_Step) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) - fieldCount := 5 - - if t.Manual == nil { - fieldCount-- - } - - if t.PullRequest == nil { - fieldCount-- - } + fieldCount := 3 - if t.Push == nil { + if t.Environment == nil { fieldCount-- } @@ -3545,31 +3529,256 @@ func (t *Pipeline_TriggerMetadata) MarshalCBOR(w io.Writer) error { return err } - // t.Kind (string) (string) - if len("kind") > 1000000 { - return xerrors.Errorf("Value in field \"kind\" was too long") + // t.Name (string) (string) + if len("name") > 1000000 { + return xerrors.Errorf("Value in field \"name\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("kind"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { return err } - if _, err := cw.WriteString(string("kind")); err != nil { + if _, err := cw.WriteString(string("name")); err != nil { return err } - if len(t.Kind) > 1000000 { - return xerrors.Errorf("Value in field t.Kind was too long") + if len(t.Name) > 1000000 { + return xerrors.Errorf("Value in field t.Name was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Kind))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { return err } - if _, err := cw.WriteString(string(t.Kind)); err != nil { + if _, err := cw.WriteString(string(t.Name)); err != nil { return err } - // t.Push (tangled.Pipeline_PushTriggerData) (struct) - if t.Push != nil { + // t.Command (string) (string) + if len("command") > 1000000 { + return xerrors.Errorf("Value in field \"command\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("command"))); err != nil { + return err + } + if _, err := cw.WriteString(string("command")); err != nil { + return err + } + + if len(t.Command) > 1000000 { + return xerrors.Errorf("Value in field t.Command was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Command))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Command)); err != nil { + return err + } + + // t.Environment ([]*tangled.Pipeline_Step_Environment_Elem) (slice) + if t.Environment != nil { + + if len("environment") > 1000000 { + return xerrors.Errorf("Value in field \"environment\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("environment"))); err != nil { + return err + } + if _, err := cw.WriteString(string("environment")); err != nil { + return err + } + + if len(t.Environment) > 8192 { + return xerrors.Errorf("Slice value in field t.Environment was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Environment))); err != nil { + return err + } + for _, v := range t.Environment { + if err := v.MarshalCBOR(cw); err != nil { + return err + } + + } + } + return nil +} + +func (t *Pipeline_Step) UnmarshalCBOR(r io.Reader) (err error) { + *t = Pipeline_Step{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("Pipeline_Step: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 11) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.Name (string) (string) + case "name": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Name = string(sval) + } + // t.Command (string) (string) + case "command": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Command = string(sval) + } + // t.Environment ([]*tangled.Pipeline_Step_Environment_Elem) (slice) + case "environment": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 8192 { + return fmt.Errorf("t.Environment: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.Environment = make([]*Pipeline_Step_Environment_Elem, extra) + } + + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Environment[i] = new(Pipeline_Step_Environment_Elem) + if err := t.Environment[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Environment[i] pointer: %w", err) + } + } + + } + + } + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *Pipeline_TriggerMetadata) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + fieldCount := 5 + + if t.Manual == nil { + fieldCount-- + } + + if t.PullRequest == nil { + fieldCount-- + } + + if t.Push == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err + } + + // t.Kind (string) (string) + if len("kind") > 1000000 { + return xerrors.Errorf("Value in field \"kind\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("kind"))); err != nil { + return err + } + if _, err := cw.WriteString(string("kind")); err != nil { + return err + } + + if len(t.Kind) > 1000000 { + return xerrors.Errorf("Value in field t.Kind was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Kind))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Kind)); err != nil { + return err + } + + // t.Push (tangled.Pipeline_PushTriggerData) (struct) + if t.Push != nil { if len("push") > 1000000 { return xerrors.Errorf("Value in field \"push\" was too long") @@ -3988,7 +4197,7 @@ func (t *Pipeline_TriggerRepo) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *Pipeline_Workflow_Environment_Elem) MarshalCBOR(w io.Writer) error { +func (t *Pipeline_Workflow) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -3996,170 +4205,36 @@ func (t *Pipeline_Workflow_Environment_Elem) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write([]byte{162}); err != nil { + if _, err := cw.Write([]byte{165}); err != nil { return err } - // t.Key (string) (string) - if len("key") > 1000000 { - return xerrors.Errorf("Value in field \"key\" was too long") + // t.Name (string) (string) + if len("name") > 1000000 { + return xerrors.Errorf("Value in field \"name\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { return err } - if _, err := cw.WriteString(string("key")); err != nil { + if _, err := cw.WriteString(string("name")); err != nil { return err } - if len(t.Key) > 1000000 { - return xerrors.Errorf("Value in field t.Key was too long") + if len(t.Name) > 1000000 { + return xerrors.Errorf("Value in field t.Name was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { return err } - if _, err := cw.WriteString(string(t.Key)); err != nil { + if _, err := cw.WriteString(string(t.Name)); err != nil { return err } - // t.Value (string) (string) - if len("value") > 1000000 { - return xerrors.Errorf("Value in field \"value\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil { - return err - } - if _, err := cw.WriteString(string("value")); err != nil { - return err - } - - if len(t.Value) > 1000000 { - return xerrors.Errorf("Value in field t.Value was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Value)); err != nil { - return err - } - return nil -} - -func (t *Pipeline_Workflow_Environment_Elem) UnmarshalCBOR(r io.Reader) (err error) { - *t = Pipeline_Workflow_Environment_Elem{} - - cr := cbg.NewCborReader(r) - - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - defer func() { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - }() - - if maj != cbg.MajMap { - return fmt.Errorf("cbor input should be of type map") - } - - if extra > cbg.MaxLength { - return fmt.Errorf("Pipeline_Workflow_Environment_Elem: map struct too large (%d)", extra) - } - - n := extra - - nameBuf := make([]byte, 5) - for i := uint64(0); i < n; i++ { - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) - if err != nil { - return err - } - - if !ok { - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { - return err - } - continue - } - - switch string(nameBuf[:nameLen]) { - // t.Key (string) (string) - case "key": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Key = string(sval) - } - // t.Value (string) (string) - case "value": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Value = string(sval) - } - - default: - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { - return err - } - } - } - - return nil -} -func (t *Pipeline_Workflow) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - - cw := cbg.NewCborWriter(w) - - if _, err := cw.Write([]byte{165}); err != nil { - return err - } - - // t.Name (string) (string) - if len("name") > 1000000 { - return xerrors.Errorf("Value in field \"name\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { - return err - } - if _, err := cw.WriteString(string("name")); err != nil { - return err - } - - if len(t.Name) > 1000000 { - return xerrors.Errorf("Value in field t.Name was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Name)); err != nil { - return err - } - - // t.Clone (tangled.Pipeline_CloneOpts) (struct) - if len("clone") > 1000000 { - return xerrors.Errorf("Value in field \"clone\" was too long") + // t.Clone (tangled.Pipeline_CloneOpts) (struct) + if len("clone") > 1000000 { + return xerrors.Errorf("Value in field \"clone\" was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("clone"))); err != nil { @@ -4473,7 +4548,7 @@ func (t *Pipeline_Workflow) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *Pipeline) MarshalCBOR(w io.Writer) error { +func (t *Pipeline_Workflow_Environment_Elem) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -4481,75 +4556,60 @@ func (t *Pipeline) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write([]byte{163}); err != nil { + if _, err := cw.Write([]byte{162}); err != nil { return err } - // t.LexiconTypeID (string) (string) - if len("$type") > 1000000 { - return xerrors.Errorf("Value in field \"$type\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { - return err - } - if _, err := cw.WriteString(string("$type")); err != nil { - return err + // t.Key (string) (string) + if len("key") > 1000000 { + return xerrors.Errorf("Value in field \"key\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil { return err } - if _, err := cw.WriteString(string("sh.tangled.pipeline")); err != nil { + if _, err := cw.WriteString(string("key")); err != nil { return err } - // t.Workflows ([]*tangled.Pipeline_Workflow) (slice) - if len("workflows") > 1000000 { - return xerrors.Errorf("Value in field \"workflows\" was too long") + if len(t.Key) > 1000000 { + return xerrors.Errorf("Value in field t.Key was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflows"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil { return err } - if _, err := cw.WriteString(string("workflows")); err != nil { + if _, err := cw.WriteString(string(t.Key)); err != nil { return err } - if len(t.Workflows) > 8192 { - return xerrors.Errorf("Slice value in field t.Workflows was too long") + // t.Value (string) (string) + if len("value") > 1000000 { + return xerrors.Errorf("Value in field \"value\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Workflows))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil { return err } - for _, v := range t.Workflows { - if err := v.MarshalCBOR(cw); err != nil { - return err - } - + if _, err := cw.WriteString(string("value")); err != nil { + return err } - // t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct) - if len("triggerMetadata") > 1000000 { - return xerrors.Errorf("Value in field \"triggerMetadata\" was too long") + if len(t.Value) > 1000000 { + return xerrors.Errorf("Value in field t.Value was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("triggerMetadata"))); err != nil { - return err - } - if _, err := cw.WriteString(string("triggerMetadata")); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil { return err } - - if err := t.TriggerMetadata.MarshalCBOR(cw); err != nil { + if _, err := cw.WriteString(string(t.Value)); err != nil { return err } return nil } -func (t *Pipeline) UnmarshalCBOR(r io.Reader) (err error) { - *t = Pipeline{} +func (t *Pipeline_Workflow_Environment_Elem) UnmarshalCBOR(r io.Reader) (err error) { + *t = Pipeline_Workflow_Environment_Elem{} cr := cbg.NewCborReader(r) @@ -4568,12 +4628,12 @@ func (t *Pipeline) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("Pipeline: map struct too large (%d)", extra) + return fmt.Errorf("Pipeline_Workflow_Environment_Elem: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 15) + nameBuf := make([]byte, 5) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -4589,8 +4649,8 @@ func (t *Pipeline) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.LexiconTypeID (string) (string) - case "$type": + // t.Key (string) (string) + case "key": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -4598,99 +4658,41 @@ func (t *Pipeline) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.LexiconTypeID = string(sval) + t.Key = string(sval) } - // t.Workflows ([]*tangled.Pipeline_Workflow) (slice) - case "workflows": + // t.Value (string) (string) + case "value": - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } - if extra > 8192 { - return fmt.Errorf("t.Workflows: array too large (%d)", extra) + t.Value = string(sval) } - if maj != cbg.MajArray { - return fmt.Errorf("expected cbor array") + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err } + } + } - if extra > 0 { - t.Workflows = make([]*Pipeline_Workflow, extra) - } + return nil +} +func (t *PublicKey) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } - for i := 0; i < int(extra); i++ { - { - var maj byte - var extra uint64 - var err error - _ = maj - _ = extra - _ = err + cw := cbg.NewCborWriter(w) - { - - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - t.Workflows[i] = new(Pipeline_Workflow) - if err := t.Workflows[i].UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.Workflows[i] pointer: %w", err) - } - } - - } - - } - } - // t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct) - case "triggerMetadata": - - { - - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - t.TriggerMetadata = new(Pipeline_TriggerMetadata) - if err := t.TriggerMetadata.UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.TriggerMetadata pointer: %w", err) - } - } - - } - - default: - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { - return err - } - } - } - - return nil -} -func (t *PublicKey) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - - cw := cbg.NewCborWriter(w) - - if _, err := cw.Write([]byte{164}); err != nil { - return err - } + if _, err := cw.Write([]byte{164}); err != nil { + return err + } // t.Key (string) (string) if len("key") > 1000000 { @@ -4878,49 +4880,52 @@ func (t *PublicKey) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *RepoArtifact) MarshalCBOR(w io.Writer) error { +func (t *Repo) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) - fieldCount := 6 + fieldCount := 8 - if t.Tag == nil { + if t.Description == nil { fieldCount-- } - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { - return err + if t.Source == nil { + fieldCount-- } - // t.Tag (util.LexBytes) (slice) - if t.Tag != nil { - - if len("tag") > 1000000 { - return xerrors.Errorf("Value in field \"tag\" was too long") - } + if t.Spindle == nil { + fieldCount-- + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("tag"))); err != nil { - return err - } - if _, err := cw.WriteString(string("tag")); err != nil { - return err - } + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err + } - if len(t.Tag) > 2097152 { - return xerrors.Errorf("Byte array in field t.Tag was too long") - } + // t.Knot (string) (string) + if len("knot") > 1000000 { + return xerrors.Errorf("Value in field \"knot\" was too long") + } - if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.Tag))); err != nil { - return err - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("knot"))); err != nil { + return err + } + if _, err := cw.WriteString(string("knot")); err != nil { + return err + } - if _, err := cw.Write(t.Tag); err != nil { - return err - } + if len(t.Knot) > 1000000 { + return xerrors.Errorf("Value in field t.Knot was too long") + } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Knot))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Knot)); err != nil { + return err } // t.Name (string) (string) @@ -4946,62 +4951,110 @@ func (t *RepoArtifact) MarshalCBOR(w io.Writer) error { return err } - // t.Repo (string) (string) - if len("repo") > 1000000 { - return xerrors.Errorf("Value in field \"repo\" was too long") + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { return err } - if _, err := cw.WriteString(string("repo")); err != nil { + if _, err := cw.WriteString(string("$type")); err != nil { return err } - if len(t.Repo) > 1000000 { - return xerrors.Errorf("Value in field t.Repo was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo"))); err != nil { return err } - if _, err := cw.WriteString(string(t.Repo)); err != nil { + if _, err := cw.WriteString(string("sh.tangled.repo")); err != nil { return err } - // t.LexiconTypeID (string) (string) - if len("$type") > 1000000 { - return xerrors.Errorf("Value in field \"$type\" was too long") + // t.Owner (string) (string) + if len("owner") > 1000000 { + return xerrors.Errorf("Value in field \"owner\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { return err } - if _, err := cw.WriteString(string("$type")); err != nil { + if _, err := cw.WriteString(string("owner")); err != nil { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.artifact"))); err != nil { + if len(t.Owner) > 1000000 { + return xerrors.Errorf("Value in field t.Owner was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil { return err } - if _, err := cw.WriteString(string("sh.tangled.repo.artifact")); err != nil { + if _, err := cw.WriteString(string(t.Owner)); err != nil { return err } - // t.Artifact (util.LexBlob) (struct) - if len("artifact") > 1000000 { - return xerrors.Errorf("Value in field \"artifact\" was too long") - } + // t.Source (string) (string) + if t.Source != nil { - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("artifact"))); err != nil { - return err - } - if _, err := cw.WriteString(string("artifact")); err != nil { - return err + if len("source") > 1000000 { + return xerrors.Errorf("Value in field \"source\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil { + return err + } + if _, err := cw.WriteString(string("source")); err != nil { + return err + } + + if t.Source == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Source) > 1000000 { + return xerrors.Errorf("Value in field t.Source was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Source))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Source)); err != nil { + return err + } + } } - if err := t.Artifact.MarshalCBOR(cw); err != nil { - return err + // t.Spindle (string) (string) + if t.Spindle != nil { + + if len("spindle") > 1000000 { + return xerrors.Errorf("Value in field \"spindle\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("spindle"))); err != nil { + return err + } + if _, err := cw.WriteString(string("spindle")); err != nil { + return err + } + + if t.Spindle == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Spindle) > 1000000 { + return xerrors.Errorf("Value in field t.Spindle was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Spindle))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Spindle)); err != nil { + return err + } + } } // t.CreatedAt (string) (string) @@ -5026,11 +5079,43 @@ func (t *RepoArtifact) MarshalCBOR(w io.Writer) error { if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { return err } + + // t.Description (string) (string) + if t.Description != nil { + + if len("description") > 1000000 { + return xerrors.Errorf("Value in field \"description\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("description"))); err != nil { + return err + } + if _, err := cw.WriteString(string("description")); err != nil { + return err + } + + if t.Description == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Description) > 1000000 { + return xerrors.Errorf("Value in field t.Description was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Description))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Description)); err != nil { + return err + } + } + } return nil } -func (t *RepoArtifact) UnmarshalCBOR(r io.Reader) (err error) { - *t = RepoArtifact{} +func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) { + *t = Repo{} cr := cbg.NewCborReader(r) @@ -5049,12 +5134,12 @@ func (t *RepoArtifact) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("RepoArtifact: map struct too large (%d)", extra) + return fmt.Errorf("Repo: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 9) + nameBuf := make([]byte, 11) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -5070,29 +5155,17 @@ func (t *RepoArtifact) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.Tag (util.LexBytes) (slice) - case "tag": - - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - - if extra > 2097152 { - return fmt.Errorf("t.Tag: byte array too large (%d)", extra) - } - if maj != cbg.MajByteString { - return fmt.Errorf("expected byte array") - } + // t.Knot (string) (string) + case "knot": - if extra > 0 { - t.Tag = make([]uint8, extra) - } + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } - if _, err := io.ReadFull(cr, t.Tag); err != nil { - return err + t.Knot = string(sval) } - // t.Name (string) (string) case "name": @@ -5104,8 +5177,8 @@ func (t *RepoArtifact) UnmarshalCBOR(r io.Reader) (err error) { t.Name = string(sval) } - // t.Repo (string) (string) - case "repo": + // t.LexiconTypeID (string) (string) + case "$type": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -5113,10 +5186,10 @@ func (t *RepoArtifact) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.Repo = string(sval) + t.LexiconTypeID = string(sval) } - // t.LexiconTypeID (string) (string) - case "$type": + // t.Owner (string) (string) + case "owner": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -5124,13 +5197,12 @@ func (t *RepoArtifact) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.LexiconTypeID = string(sval) + t.Owner = string(sval) } - // t.Artifact (util.LexBlob) (struct) - case "artifact": + // t.Source (string) (string) + case "source": { - b, err := cr.ReadByte() if err != nil { return err @@ -5139,12 +5211,35 @@ func (t *RepoArtifact) UnmarshalCBOR(r io.Reader) (err error) { if err := cr.UnreadByte(); err != nil { return err } - t.Artifact = new(util.LexBlob) - if err := t.Artifact.UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.Artifact pointer: %w", err) + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err } + + t.Source = (*string)(&sval) + } + } + // t.Spindle (string) (string) + case "spindle": + + { + b, err := cr.ReadByte() + if err != nil { + return err } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + t.Spindle = (*string)(&sval) + } } // t.CreatedAt (string) (string) case "createdAt": @@ -5157,6 +5252,27 @@ func (t *RepoArtifact) UnmarshalCBOR(r io.Reader) (err error) { t.CreatedAt = string(sval) } + // t.Description (string) (string) + case "description": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Description = (*string)(&sval) + } + } default: // Field doesn't exist on this type, so ignore it @@ -5168,84 +5284,95 @@ func (t *RepoArtifact) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error { +func (t *RepoArtifact) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) - fieldCount := 7 + fieldCount := 6 - if t.CommentId == nil { + if t.Tag == nil { fieldCount-- } - if t.Owner == nil { - fieldCount-- + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err } - if t.Repo == nil { - fieldCount-- - } + // t.Tag (util.LexBytes) (slice) + if t.Tag != nil { + + if len("tag") > 1000000 { + return xerrors.Errorf("Value in field \"tag\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("tag"))); err != nil { + return err + } + if _, err := cw.WriteString(string("tag")); err != nil { + return err + } + + if len(t.Tag) > 2097152 { + return xerrors.Errorf("Byte array in field t.Tag was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.Tag))); err != nil { + return err + } + + if _, err := cw.Write(t.Tag); err != nil { + return err + } - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { - return err } - // t.Body (string) (string) - if len("body") > 1000000 { - return xerrors.Errorf("Value in field \"body\" was too long") + // t.Name (string) (string) + if len("name") > 1000000 { + return xerrors.Errorf("Value in field \"name\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { return err } - if _, err := cw.WriteString(string("body")); err != nil { + if _, err := cw.WriteString(string("name")); err != nil { return err } - if len(t.Body) > 1000000 { - return xerrors.Errorf("Value in field t.Body was too long") + if len(t.Name) > 1000000 { + return xerrors.Errorf("Value in field t.Name was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Body))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { return err } - if _, err := cw.WriteString(string(t.Body)); err != nil { + if _, err := cw.WriteString(string(t.Name)); err != nil { return err } // t.Repo (string) (string) - if t.Repo != nil { - - if len("repo") > 1000000 { - return xerrors.Errorf("Value in field \"repo\" was too long") - } + if len("repo") > 1000000 { + return xerrors.Errorf("Value in field \"repo\" was too long") + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { - return err - } - if _, err := cw.WriteString(string("repo")); err != nil { - return err - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { + return err + } + if _, err := cw.WriteString(string("repo")); err != nil { + return err + } - if t.Repo == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.Repo) > 1000000 { - return xerrors.Errorf("Value in field t.Repo was too long") - } + if len(t.Repo) > 1000000 { + return xerrors.Errorf("Value in field t.Repo was too long") + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Repo))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.Repo)); err != nil { - return err - } - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Repo)); err != nil { + return err } // t.LexiconTypeID (string) (string) @@ -5260,127 +5387,56 @@ func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue.comment"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.artifact"))); err != nil { return err } - if _, err := cw.WriteString(string("sh.tangled.repo.issue.comment")); err != nil { + if _, err := cw.WriteString(string("sh.tangled.repo.artifact")); err != nil { return err } - // t.Issue (string) (string) - if len("issue") > 1000000 { - return xerrors.Errorf("Value in field \"issue\" was too long") + // t.Artifact (util.LexBlob) (struct) + if len("artifact") > 1000000 { + return xerrors.Errorf("Value in field \"artifact\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issue"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("artifact"))); err != nil { return err } - if _, err := cw.WriteString(string("issue")); err != nil { + if _, err := cw.WriteString(string("artifact")); err != nil { return err } - if len(t.Issue) > 1000000 { - return xerrors.Errorf("Value in field t.Issue was too long") + if err := t.Artifact.MarshalCBOR(cw); err != nil { + return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Issue))); err != nil { + // t.CreatedAt (string) (string) + if len("createdAt") > 1000000 { + return xerrors.Errorf("Value in field \"createdAt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { return err } - if _, err := cw.WriteString(string(t.Issue)); err != nil { + if _, err := cw.WriteString(string("createdAt")); err != nil { return err } - // t.Owner (string) (string) - if t.Owner != nil { + if len(t.CreatedAt) > 1000000 { + return xerrors.Errorf("Value in field t.CreatedAt was too long") + } - if len("owner") > 1000000 { - return xerrors.Errorf("Value in field \"owner\" was too long") - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { + return err + } + return nil +} - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { - return err - } - if _, err := cw.WriteString(string("owner")); err != nil { - return err - } - - if t.Owner == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.Owner) > 1000000 { - return xerrors.Errorf("Value in field t.Owner was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Owner))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.Owner)); err != nil { - return err - } - } - } - - // t.CommentId (int64) (int64) - if t.CommentId != nil { - - if len("commentId") > 1000000 { - return xerrors.Errorf("Value in field \"commentId\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("commentId"))); err != nil { - return err - } - if _, err := cw.WriteString(string("commentId")); err != nil { - return err - } - - if t.CommentId == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if *t.CommentId >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.CommentId)); err != nil { - return err - } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.CommentId-1)); err != nil { - return err - } - } - } - - } - - // t.CreatedAt (string) (string) - if len("createdAt") > 1000000 { - return xerrors.Errorf("Value in field \"createdAt\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { - return err - } - if _, err := cw.WriteString(string("createdAt")); err != nil { - return err - } - - if len(t.CreatedAt) > 1000000 { - return xerrors.Errorf("Value in field t.CreatedAt was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { - return err - } - return nil -} - -func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { - *t = RepoIssueComment{} +func (t *RepoArtifact) UnmarshalCBOR(r io.Reader) (err error) { + *t = RepoArtifact{} cr := cbg.NewCborReader(r) @@ -5399,7 +5455,7 @@ func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("RepoIssueComment: map struct too large (%d)", extra) + return fmt.Errorf("RepoArtifact: map struct too large (%d)", extra) } n := extra @@ -5420,8 +5476,31 @@ func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.Body (string) (string) - case "body": + // t.Tag (util.LexBytes) (slice) + case "tag": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 2097152 { + return fmt.Errorf("t.Tag: byte array too large (%d)", extra) + } + if maj != cbg.MajByteString { + return fmt.Errorf("expected byte array") + } + + if extra > 0 { + t.Tag = make([]uint8, extra) + } + + if _, err := io.ReadFull(cr, t.Tag); err != nil { + return err + } + + // t.Name (string) (string) + case "name": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -5429,28 +5508,18 @@ func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.Body = string(sval) + t.Name = string(sval) } // t.Repo (string) (string) case "repo": { - b, err := cr.ReadByte() + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - t.Repo = (*string)(&sval) - } + t.Repo = string(sval) } // t.LexiconTypeID (string) (string) case "$type": @@ -5463,21 +5532,11 @@ func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { t.LexiconTypeID = string(sval) } - // t.Issue (string) (string) - case "issue": + // t.Artifact (util.LexBlob) (struct) + case "artifact": { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Issue = string(sval) - } - // t.Owner (string) (string) - case "owner": - { b, err := cr.ReadByte() if err != nil { return err @@ -5486,50 +5545,12 @@ func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { if err := cr.UnreadByte(); err != nil { return err } - - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err + t.Artifact = new(util.LexBlob) + if err := t.Artifact.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Artifact pointer: %w", err) } - - t.Owner = (*string)(&sval) - } - } - // t.CommentId (int64) (int64) - case "commentId": - { - - b, err := cr.ReadByte() - if err != nil { - return err } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") - } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") - } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) - } - t.CommentId = (*int64)(&extraI) - } } // t.CreatedAt (string) (string) case "createdAt": @@ -5553,258 +5574,94 @@ func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *RepoIssueState) MarshalCBOR(w io.Writer) error { +func (t *RepoIssue) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) + fieldCount := 7 - if _, err := cw.Write([]byte{163}); err != nil { - return err + if t.Body == nil { + fieldCount-- } - // t.LexiconTypeID (string) (string) - if len("$type") > 1000000 { - return xerrors.Errorf("Value in field \"$type\" was too long") + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { - return err + // t.Body (string) (string) + if t.Body != nil { + + if len("body") > 1000000 { + return xerrors.Errorf("Value in field \"body\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { + return err + } + if _, err := cw.WriteString(string("body")); err != nil { + return err + } + + if t.Body == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Body) > 1000000 { + return xerrors.Errorf("Value in field t.Body was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Body)); err != nil { + return err + } + } } - if _, err := cw.WriteString(string("$type")); err != nil { - return err + + // t.Repo (string) (string) + if len("repo") > 1000000 { + return xerrors.Errorf("Value in field \"repo\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue.state"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { return err } - if _, err := cw.WriteString(string("sh.tangled.repo.issue.state")); err != nil { + if _, err := cw.WriteString(string("repo")); err != nil { return err } - // t.Issue (string) (string) - if len("issue") > 1000000 { - return xerrors.Errorf("Value in field \"issue\" was too long") + if len(t.Repo) > 1000000 { + return xerrors.Errorf("Value in field t.Repo was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issue"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { return err } - if _, err := cw.WriteString(string("issue")); err != nil { + if _, err := cw.WriteString(string(t.Repo)); err != nil { return err } - if len(t.Issue) > 1000000 { - return xerrors.Errorf("Value in field t.Issue was too long") + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Issue))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { return err } - if _, err := cw.WriteString(string(t.Issue)); err != nil { + if _, err := cw.WriteString(string("$type")); err != nil { return err } - // t.State (string) (string) - if len("state") > 1000000 { - return xerrors.Errorf("Value in field \"state\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("state"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue"))); err != nil { return err } - if _, err := cw.WriteString(string("state")); err != nil { - return err - } - - if len(t.State) > 1000000 { - return xerrors.Errorf("Value in field t.State was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.State))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.State)); err != nil { - return err - } - return nil -} - -func (t *RepoIssueState) UnmarshalCBOR(r io.Reader) (err error) { - *t = RepoIssueState{} - - cr := cbg.NewCborReader(r) - - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - defer func() { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - }() - - if maj != cbg.MajMap { - return fmt.Errorf("cbor input should be of type map") - } - - if extra > cbg.MaxLength { - return fmt.Errorf("RepoIssueState: map struct too large (%d)", extra) - } - - n := extra - - nameBuf := make([]byte, 5) - for i := uint64(0); i < n; i++ { - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) - if err != nil { - return err - } - - if !ok { - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { - return err - } - continue - } - - switch string(nameBuf[:nameLen]) { - // t.LexiconTypeID (string) (string) - case "$type": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.LexiconTypeID = string(sval) - } - // t.Issue (string) (string) - case "issue": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Issue = string(sval) - } - // t.State (string) (string) - case "state": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.State = string(sval) - } - - default: - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { - return err - } - } - } - - return nil -} -func (t *RepoIssue) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - - cw := cbg.NewCborWriter(w) - fieldCount := 7 - - if t.Body == nil { - fieldCount-- - } - - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { - return err - } - - // t.Body (string) (string) - if t.Body != nil { - - if len("body") > 1000000 { - return xerrors.Errorf("Value in field \"body\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { - return err - } - if _, err := cw.WriteString(string("body")); err != nil { - return err - } - - if t.Body == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.Body) > 1000000 { - return xerrors.Errorf("Value in field t.Body was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.Body)); err != nil { - return err - } - } - } - - // t.Repo (string) (string) - if len("repo") > 1000000 { - return xerrors.Errorf("Value in field \"repo\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { - return err - } - if _, err := cw.WriteString(string("repo")); err != nil { - return err - } - - if len(t.Repo) > 1000000 { - return xerrors.Errorf("Value in field t.Repo was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Repo)); err != nil { - return err - } - - // t.LexiconTypeID (string) (string) - if len("$type") > 1000000 { - return xerrors.Errorf("Value in field \"$type\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { - return err - } - if _, err := cw.WriteString(string("$type")); err != nil { - return err - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue"))); err != nil { - return err - } - if _, err := cw.WriteString(string("sh.tangled.repo.issue")); err != nil { + if _, err := cw.WriteString(string("sh.tangled.repo.issue")); err != nil { return err } @@ -6055,7 +5912,7 @@ func (t *RepoIssue) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *RepoPullComment) MarshalCBOR(w io.Writer) error { +func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -6103,29 +5960,6 @@ func (t *RepoPullComment) MarshalCBOR(w io.Writer) error { return err } - // t.Pull (string) (string) - if len("pull") > 1000000 { - return xerrors.Errorf("Value in field \"pull\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil { - return err - } - if _, err := cw.WriteString(string("pull")); err != nil { - return err - } - - if len(t.Pull) > 1000000 { - return xerrors.Errorf("Value in field t.Pull was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pull))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Pull)); err != nil { - return err - } - // t.Repo (string) (string) if t.Repo != nil { @@ -6170,10 +6004,33 @@ func (t *RepoPullComment) MarshalCBOR(w io.Writer) error { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.comment"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue.comment"))); err != nil { return err } - if _, err := cw.WriteString(string("sh.tangled.repo.pull.comment")); err != nil { + if _, err := cw.WriteString(string("sh.tangled.repo.issue.comment")); err != nil { + return err + } + + // t.Issue (string) (string) + if len("issue") > 1000000 { + return xerrors.Errorf("Value in field \"issue\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issue"))); err != nil { + return err + } + if _, err := cw.WriteString(string("issue")); err != nil { + return err + } + + if len(t.Issue) > 1000000 { + return xerrors.Errorf("Value in field t.Issue was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Issue))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Issue)); err != nil { return err } @@ -6266,8 +6123,8 @@ func (t *RepoPullComment) MarshalCBOR(w io.Writer) error { return nil } -func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { - *t = RepoPullComment{} +func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { + *t = RepoIssueComment{} cr := cbg.NewCborReader(r) @@ -6286,7 +6143,7 @@ func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("RepoPullComment: map struct too large (%d)", extra) + return fmt.Errorf("RepoIssueComment: map struct too large (%d)", extra) } n := extra @@ -6318,17 +6175,6 @@ func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { t.Body = string(sval) } - // t.Pull (string) (string) - case "pull": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Pull = string(sval) - } // t.Repo (string) (string) case "repo": @@ -6361,6 +6207,17 @@ func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { t.LexiconTypeID = string(sval) } + // t.Issue (string) (string) + case "issue": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Issue = string(sval) + } // t.Owner (string) (string) case "owner": @@ -6440,7 +6297,7 @@ func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *RepoPullStatus) MarshalCBOR(w io.Writer) error { +func (t *RepoIssueState) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -6452,75 +6309,75 @@ func (t *RepoPullStatus) MarshalCBOR(w io.Writer) error { return err } - // t.Pull (string) (string) - if len("pull") > 1000000 { - return xerrors.Errorf("Value in field \"pull\" was too long") + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { return err } - if _, err := cw.WriteString(string("pull")); err != nil { + if _, err := cw.WriteString(string("$type")); err != nil { return err } - if len(t.Pull) > 1000000 { - return xerrors.Errorf("Value in field t.Pull was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pull))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue.state"))); err != nil { return err } - if _, err := cw.WriteString(string(t.Pull)); err != nil { + if _, err := cw.WriteString(string("sh.tangled.repo.issue.state")); err != nil { return err } - // t.LexiconTypeID (string) (string) - if len("$type") > 1000000 { - return xerrors.Errorf("Value in field \"$type\" was too long") + // t.Issue (string) (string) + if len("issue") > 1000000 { + return xerrors.Errorf("Value in field \"issue\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issue"))); err != nil { return err } - if _, err := cw.WriteString(string("$type")); err != nil { + if _, err := cw.WriteString(string("issue")); err != nil { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.status"))); err != nil { + if len(t.Issue) > 1000000 { + return xerrors.Errorf("Value in field t.Issue was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Issue))); err != nil { return err } - if _, err := cw.WriteString(string("sh.tangled.repo.pull.status")); err != nil { + if _, err := cw.WriteString(string(t.Issue)); err != nil { return err } - // t.Status (string) (string) - if len("status") > 1000000 { - return xerrors.Errorf("Value in field \"status\" was too long") + // t.State (string) (string) + if len("state") > 1000000 { + return xerrors.Errorf("Value in field \"state\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("state"))); err != nil { return err } - if _, err := cw.WriteString(string("status")); err != nil { + if _, err := cw.WriteString(string("state")); err != nil { return err } - if len(t.Status) > 1000000 { - return xerrors.Errorf("Value in field t.Status was too long") + if len(t.State) > 1000000 { + return xerrors.Errorf("Value in field t.State was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.State))); err != nil { return err } - if _, err := cw.WriteString(string(t.Status)); err != nil { + if _, err := cw.WriteString(string(t.State)); err != nil { return err } return nil } -func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) { - *t = RepoPullStatus{} +func (t *RepoIssueState) UnmarshalCBOR(r io.Reader) (err error) { + *t = RepoIssueState{} cr := cbg.NewCborReader(r) @@ -6539,12 +6396,12 @@ func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("RepoPullStatus: map struct too large (%d)", extra) + return fmt.Errorf("RepoIssueState: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 6) + nameBuf := make([]byte, 5) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -6560,18 +6417,7 @@ func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.Pull (string) (string) - case "pull": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Pull = string(sval) - } - // t.LexiconTypeID (string) (string) + // t.LexiconTypeID (string) (string) case "$type": { @@ -6582,8 +6428,8 @@ func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) { t.LexiconTypeID = string(sval) } - // t.Status (string) (string) - case "status": + // t.Issue (string) (string) + case "issue": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -6591,157 +6437,10 @@ func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.Status = string(sval) - } - - default: - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { - return err - } - } - } - - return nil -} -func (t *RepoPull_Source) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - - cw := cbg.NewCborWriter(w) - fieldCount := 2 - - if t.Repo == nil { - fieldCount-- - } - - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { - return err - } - - // t.Repo (string) (string) - if t.Repo != nil { - - if len("repo") > 1000000 { - return xerrors.Errorf("Value in field \"repo\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { - return err - } - if _, err := cw.WriteString(string("repo")); err != nil { - return err - } - - if t.Repo == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.Repo) > 1000000 { - return xerrors.Errorf("Value in field t.Repo was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Repo))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.Repo)); err != nil { - return err - } - } - } - - // t.Branch (string) (string) - if len("branch") > 1000000 { - return xerrors.Errorf("Value in field \"branch\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("branch"))); err != nil { - return err - } - if _, err := cw.WriteString(string("branch")); err != nil { - return err - } - - if len(t.Branch) > 1000000 { - return xerrors.Errorf("Value in field t.Branch was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Branch))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Branch)); err != nil { - return err - } - return nil -} - -func (t *RepoPull_Source) UnmarshalCBOR(r io.Reader) (err error) { - *t = RepoPull_Source{} - - cr := cbg.NewCborReader(r) - - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - defer func() { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - }() - - if maj != cbg.MajMap { - return fmt.Errorf("cbor input should be of type map") - } - - if extra > cbg.MaxLength { - return fmt.Errorf("RepoPull_Source: map struct too large (%d)", extra) - } - - n := extra - - nameBuf := make([]byte, 6) - for i := uint64(0); i < n; i++ { - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) - if err != nil { - return err - } - - if !ok { - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { - return err - } - continue - } - - switch string(nameBuf[:nameLen]) { - // t.Repo (string) (string) - case "repo": - - { - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Repo = (*string)(&sval) - } + t.Issue = string(sval) } - // t.Branch (string) (string) - case "branch": + // t.State (string) (string) + case "state": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -6749,7 +6448,7 @@ func (t *RepoPull_Source) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.Branch = string(sval) + t.State = string(sval) } default: @@ -7177,24 +6876,24 @@ func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *Repo) MarshalCBOR(w io.Writer) error { +func (t *RepoPullComment) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) - fieldCount := 8 + fieldCount := 7 - if t.Description == nil { + if t.CommentId == nil { fieldCount-- } - if t.Source == nil { + if t.Owner == nil { fieldCount-- } - if t.Spindle == nil { + if t.Repo == nil { fieldCount-- } @@ -7202,52 +6901,84 @@ func (t *Repo) MarshalCBOR(w io.Writer) error { return err } - // t.Knot (string) (string) - if len("knot") > 1000000 { - return xerrors.Errorf("Value in field \"knot\" was too long") + // t.Body (string) (string) + if len("body") > 1000000 { + return xerrors.Errorf("Value in field \"body\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("knot"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { return err } - if _, err := cw.WriteString(string("knot")); err != nil { + if _, err := cw.WriteString(string("body")); err != nil { return err } - if len(t.Knot) > 1000000 { - return xerrors.Errorf("Value in field t.Knot was too long") + if len(t.Body) > 1000000 { + return xerrors.Errorf("Value in field t.Body was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Knot))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Body))); err != nil { return err } - if _, err := cw.WriteString(string(t.Knot)); err != nil { + if _, err := cw.WriteString(string(t.Body)); err != nil { return err } - // t.Name (string) (string) - if len("name") > 1000000 { - return xerrors.Errorf("Value in field \"name\" was too long") + // t.Pull (string) (string) + if len("pull") > 1000000 { + return xerrors.Errorf("Value in field \"pull\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil { return err } - if _, err := cw.WriteString(string("name")); err != nil { + if _, err := cw.WriteString(string("pull")); err != nil { return err } - if len(t.Name) > 1000000 { - return xerrors.Errorf("Value in field t.Name was too long") + if len(t.Pull) > 1000000 { + return xerrors.Errorf("Value in field t.Pull was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pull))); err != nil { return err } - if _, err := cw.WriteString(string(t.Name)); err != nil { + if _, err := cw.WriteString(string(t.Pull)); err != nil { return err } + // t.Repo (string) (string) + if t.Repo != nil { + + if len("repo") > 1000000 { + return xerrors.Errorf("Value in field \"repo\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { + return err + } + if _, err := cw.WriteString(string("repo")); err != nil { + return err + } + + if t.Repo == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Repo) > 1000000 { + return xerrors.Errorf("Value in field t.Repo was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Repo))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Repo)); err != nil { + return err + } + } + } + // t.LexiconTypeID (string) (string) if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") @@ -7260,159 +6991,515 @@ func (t *Repo) MarshalCBOR(w io.Writer) error { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.comment"))); err != nil { return err } - if _, err := cw.WriteString(string("sh.tangled.repo")); err != nil { + if _, err := cw.WriteString(string("sh.tangled.repo.pull.comment")); err != nil { return err } // t.Owner (string) (string) - if len("owner") > 1000000 { - return xerrors.Errorf("Value in field \"owner\" was too long") + if t.Owner != nil { + + if len("owner") > 1000000 { + return xerrors.Errorf("Value in field \"owner\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { + return err + } + if _, err := cw.WriteString(string("owner")); err != nil { + return err + } + + if t.Owner == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Owner) > 1000000 { + return xerrors.Errorf("Value in field t.Owner was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Owner))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Owner)); err != nil { + return err + } + } } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { + // t.CommentId (int64) (int64) + if t.CommentId != nil { + + if len("commentId") > 1000000 { + return xerrors.Errorf("Value in field \"commentId\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("commentId"))); err != nil { + return err + } + if _, err := cw.WriteString(string("commentId")); err != nil { + return err + } + + if t.CommentId == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if *t.CommentId >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.CommentId)); err != nil { + return err + } + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.CommentId-1)); err != nil { + return err + } + } + } + + } + + // t.CreatedAt (string) (string) + if len("createdAt") > 1000000 { + return xerrors.Errorf("Value in field \"createdAt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { return err } - if _, err := cw.WriteString(string("owner")); err != nil { + if _, err := cw.WriteString(string("createdAt")); err != nil { return err } - if len(t.Owner) > 1000000 { - return xerrors.Errorf("Value in field t.Owner was too long") + if len(t.CreatedAt) > 1000000 { + return xerrors.Errorf("Value in field t.CreatedAt was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { return err } - if _, err := cw.WriteString(string(t.Owner)); err != nil { + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { return err } + return nil +} - // t.Source (string) (string) - if t.Source != nil { +func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { + *t = RepoPullComment{} - if len("source") > 1000000 { - return xerrors.Errorf("Value in field \"source\" was too long") - } + cr := cbg.NewCborReader(r) - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil { - return err + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF } - if _, err := cw.WriteString(string("source")); err != nil { + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("RepoPullComment: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 9) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { return err } - if t.Source == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { return err } - } else { - if len(*t.Source) > 1000000 { - return xerrors.Errorf("Value in field t.Source was too long") + continue + } + + switch string(nameBuf[:nameLen]) { + // t.Body (string) (string) + case "body": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Body = string(sval) } + // t.Pull (string) (string) + case "pull": - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Source))); err != nil { - return err + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Pull = string(sval) } - if _, err := cw.WriteString(string(*t.Source)); err != nil { + // t.Repo (string) (string) + case "repo": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Repo = (*string)(&sval) + } + } + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + // t.Owner (string) (string) + case "owner": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Owner = (*string)(&sval) + } + } + // t.CommentId (int64) (int64) + case "commentId": + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + var extraI int64 + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative overflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) + } + + t.CommentId = (*int64)(&extraI) + } + } + // t.CreatedAt (string) (string) + case "createdAt": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.CreatedAt = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { return err } } } - // t.Spindle (string) (string) - if t.Spindle != nil { + return nil +} +func (t *RepoPull_Source) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } - if len("spindle") > 1000000 { - return xerrors.Errorf("Value in field \"spindle\" was too long") + cw := cbg.NewCborWriter(w) + fieldCount := 2 + + if t.Repo == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err + } + + // t.Repo (string) (string) + if t.Repo != nil { + + if len("repo") > 1000000 { + return xerrors.Errorf("Value in field \"repo\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("spindle"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { return err } - if _, err := cw.WriteString(string("spindle")); err != nil { + if _, err := cw.WriteString(string("repo")); err != nil { return err } - if t.Spindle == nil { + if t.Repo == nil { if _, err := cw.Write(cbg.CborNull); err != nil { return err } } else { - if len(*t.Spindle) > 1000000 { - return xerrors.Errorf("Value in field t.Spindle was too long") + if len(*t.Repo) > 1000000 { + return xerrors.Errorf("Value in field t.Repo was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Spindle))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Repo))); err != nil { return err } - if _, err := cw.WriteString(string(*t.Spindle)); err != nil { + if _, err := cw.WriteString(string(*t.Repo)); err != nil { return err } } } - // t.CreatedAt (string) (string) - if len("createdAt") > 1000000 { - return xerrors.Errorf("Value in field \"createdAt\" was too long") + // t.Branch (string) (string) + if len("branch") > 1000000 { + return xerrors.Errorf("Value in field \"branch\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("branch"))); err != nil { + return err + } + if _, err := cw.WriteString(string("branch")); err != nil { + return err + } + + if len(t.Branch) > 1000000 { + return xerrors.Errorf("Value in field t.Branch was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Branch))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Branch)); err != nil { + return err + } + return nil +} + +func (t *RepoPull_Source) UnmarshalCBOR(r io.Reader) (err error) { + *t = RepoPull_Source{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("RepoPull_Source: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 6) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.Repo (string) (string) + case "repo": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Repo = (*string)(&sval) + } + } + // t.Branch (string) (string) + case "branch": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Branch = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *RepoPullStatus) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{163}); err != nil { + return err + } + + // t.Pull (string) (string) + if len("pull") > 1000000 { + return xerrors.Errorf("Value in field \"pull\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil { + return err + } + if _, err := cw.WriteString(string("pull")); err != nil { + return err + } + + if len(t.Pull) > 1000000 { + return xerrors.Errorf("Value in field t.Pull was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pull))); err != nil { return err } - if _, err := cw.WriteString(string("createdAt")); err != nil { + if _, err := cw.WriteString(string(t.Pull)); err != nil { return err } - if len(t.CreatedAt) > 1000000 { - return xerrors.Errorf("Value in field t.CreatedAt was too long") + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { return err } - if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { + if _, err := cw.WriteString(string("$type")); err != nil { return err } - // t.Description (string) (string) - if t.Description != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.status"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sh.tangled.repo.pull.status")); err != nil { + return err + } - if len("description") > 1000000 { - return xerrors.Errorf("Value in field \"description\" was too long") - } + // t.Status (string) (string) + if len("status") > 1000000 { + return xerrors.Errorf("Value in field \"status\" was too long") + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("description"))); err != nil { - return err - } - if _, err := cw.WriteString(string("description")); err != nil { - return err - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { + return err + } + if _, err := cw.WriteString(string("status")); err != nil { + return err + } - if t.Description == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.Description) > 1000000 { - return xerrors.Errorf("Value in field t.Description was too long") - } + if len(t.Status) > 1000000 { + return xerrors.Errorf("Value in field t.Status was too long") + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Description))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.Description)); err != nil { - return err - } - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Status)); err != nil { + return err } return nil } -func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) { - *t = Repo{} +func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) { + *t = RepoPullStatus{} cr := cbg.NewCborReader(r) @@ -7431,12 +7518,12 @@ func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("Repo: map struct too large (%d)", extra) + return fmt.Errorf("RepoPullStatus: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 11) + nameBuf := make([]byte, 6) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -7452,19 +7539,8 @@ func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.Knot (string) (string) - case "knot": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Knot = string(sval) - } - // t.Name (string) (string) - case "name": + // t.Pull (string) (string) + case "pull": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -7472,7 +7548,7 @@ func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.Name = string(sval) + t.Pull = string(sval) } // t.LexiconTypeID (string) (string) case "$type": @@ -7485,8 +7561,8 @@ func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) { t.LexiconTypeID = string(sval) } - // t.Owner (string) (string) - case "owner": + // t.Status (string) (string) + case "status": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -7494,52 +7570,118 @@ func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.Owner = string(sval) + t.Status = string(sval) } - // t.Source (string) (string) - case "source": - { - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } + return nil +} +func (t *Spindle) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } - t.Source = (*string)(&sval) - } - } - // t.Spindle (string) (string) - case "spindle": + cw := cbg.NewCborWriter(w) - { - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } + if _, err := cw.Write([]byte{162}); err != nil { + return err + } - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") + } - t.Spindle = (*string)(&sval) - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.spindle"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sh.tangled.spindle")); err != nil { + return err + } + + // t.CreatedAt (string) (string) + if len("createdAt") > 1000000 { + return xerrors.Errorf("Value in field \"createdAt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { + return err + } + if _, err := cw.WriteString(string("createdAt")); err != nil { + return err + } + + if len(t.CreatedAt) > 1000000 { + return xerrors.Errorf("Value in field t.CreatedAt was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { + return err + } + return nil +} + +func (t *Spindle) UnmarshalCBOR(r io.Reader) (err error) { + *t = Spindle{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("Spindle: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 9) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err } - // t.CreatedAt (string) (string) - case "createdAt": + continue + } + + switch string(nameBuf[:nameLen]) { + // t.LexiconTypeID (string) (string) + case "$type": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -7547,28 +7689,18 @@ func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.CreatedAt = string(sval) + t.LexiconTypeID = string(sval) } - // t.Description (string) (string) - case "description": + // t.CreatedAt (string) (string) + case "createdAt": { - b, err := cr.ReadByte() + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Description = (*string)(&sval) - } + t.CreatedAt = string(sval) } default: diff --git a/api/tangled/tangledpipeline.go b/api/tangled/tangledpipeline.go index 208795e0..3fd67766 100644 --- a/api/tangled/tangledpipeline.go +++ b/api/tangled/tangledpipeline.go @@ -91,7 +91,7 @@ type Pipeline_TriggerRepo struct { // Pipeline_Workflow is a "workflow" in the sh.tangled.pipeline schema. type Pipeline_Workflow struct { Clone *Pipeline_CloneOpts `json:"clone" cborgen:"clone"` - Dependencies []Pipeline_Dependencies_Elem `json:"dependencies" cborgen:"dependencies"` + Dependencies []Pipeline_Dependencies_Elem `json:"dependencies" cborgen:"dependencies"` Environment []*Pipeline_Workflow_Environment_Elem `json:"environment" cborgen:"environment"` Name string `json:"name" cborgen:"name"` Steps []*Pipeline_Step `json:"steps" cborgen:"steps"` diff --git a/api/tangled/tangledspindle.go b/api/tangled/tangledspindle.go new file mode 100644 index 00000000..89bf5e19 --- /dev/null +++ b/api/tangled/tangledspindle.go @@ -0,0 +1,22 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.spindle + +import ( + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + SpindleNSID = "sh.tangled.spindle" +) + +func init() { + util.RegisterType("sh.tangled.spindle", &Spindle{}) +} // +// RECORDTYPE: Spindle +type Spindle struct { + LexiconTypeID string `json:"$type,const=sh.tangled.spindle" cborgen:"$type,const=sh.tangled.spindle"` + CreatedAt string `json:"createdAt" cborgen:"createdAt"` +} diff --git a/appview/db/db.go b/appview/db/db.go index a9f45a12..3447d850 100644 --- a/appview/db/db.go +++ b/appview/db/db.go @@ -321,6 +321,16 @@ func Make(dbPath string) (*DB, error) { primary key (did, date) ); + create table if not exists spindles ( + id integer primary key autoincrement, + owner text not null, + instance text not null, + verified text, -- time of verification + created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')), + + unique(instance) + ); + create table if not exists migrations ( id integer primary key autoincrement, name text unique @@ -515,37 +525,20 @@ type filter struct { cmp string } -func FilterEq(key string, arg any) filter { - return filter{ - key: key, - arg: arg, - cmp: "=", - } -} - -func FilterNotEq(key string, arg any) filter { +func newFilter(key, cmp string, arg any) filter { return filter{ key: key, arg: arg, - cmp: "<>", + cmp: cmp, } } -func FilterGte(key string, arg any) filter { - return filter{ - key: key, - arg: arg, - cmp: ">=", - } -} - -func FilterLte(key string, arg any) filter { - return filter{ - key: key, - arg: arg, - cmp: "<=", - } -} +func FilterEq(key string, arg any) filter { return newFilter(key, "=", arg) } +func FilterNotEq(key string, arg any) filter { return newFilter(key, "<>", arg) } +func FilterGte(key string, arg any) filter { return newFilter(key, ">=", arg) } +func FilterLte(key string, arg any) filter { return newFilter(key, "<=", arg) } +func FilterIs(key string, arg any) filter { return newFilter(key, "is", arg) } +func FilterIsNot(key string, arg any) filter { return newFilter(key, "is not", arg) } func (f filter) Condition() string { return fmt.Sprintf("%s %s ?", f.key, f.cmp) diff --git a/appview/db/spindle.go b/appview/db/spindle.go new file mode 100644 index 00000000..c995c30b --- /dev/null +++ b/appview/db/spindle.go @@ -0,0 +1,131 @@ +package db + +import ( + "database/sql" + "fmt" + "strings" + "time" + + "github.com/bluesky-social/indigo/atproto/syntax" +) + +type Spindle struct { + Id int + Owner syntax.DID + Instance string + Verified *time.Time + Created time.Time +} + +func GetSpindles(e Execer, filters ...filter) ([]Spindle, error) { + var spindles []Spindle + + var conditions []string + var args []any + for _, filter := range filters { + conditions = append(conditions, filter.Condition()) + args = append(args, filter.arg) + } + + whereClause := "" + if conditions != nil { + whereClause = " where " + strings.Join(conditions, " and ") + } + + query := fmt.Sprintf( + `select id, owner, instance, verified, created + from spindles + %s + order by created + `, + whereClause, + ) + + rows, err := e.Query(query, args...) + + if err != nil { + return nil, err + } + defer rows.Close() + + for rows.Next() { + var spindle Spindle + var createdAt string + var verified sql.NullTime + + if err := rows.Scan( + &spindle.Id, + &spindle.Owner, + &spindle.Instance, + &verified, + &createdAt, + ); err != nil { + return nil, err + } + + spindle.Created, err = time.Parse(time.RFC3339, createdAt) + if err != nil { + spindle.Created = time.Now() + } + + if verified.Valid { + spindle.Verified = &verified.Time + } + + spindles = append(spindles, spindle) + } + + return spindles, nil +} + +// if there is an existing spindle with the same instance, this returns an error +func AddSpindle(e Execer, spindle Spindle) error { + _, err := e.Exec( + `insert into spindles (owner, instance) values (?, ?)`, + spindle.Owner, + spindle.Instance, + ) + return err +} + +func VerifySpindle(e Execer, filters ...filter) (int64, error) { + var conditions []string + var args []any + for _, filter := range filters { + conditions = append(conditions, filter.Condition()) + args = append(args, filter.arg) + } + + whereClause := "" + if conditions != nil { + whereClause = " where " + strings.Join(conditions, " and ") + } + + query := fmt.Sprintf(`update spindles set verified = strftime('%%Y-%%m-%%dT%%H:%%M:%%SZ', 'now') %s`, whereClause) + + res, err := e.Exec(query, args...) + if err != nil { + return 0, err + } + + return res.RowsAffected() +} + +func DeleteSpindle(e Execer, filters ...filter) error { + var conditions []string + var args []any + for _, filter := range filters { + conditions = append(conditions, filter.Condition()) + args = append(args, filter.arg) + } + + whereClause := "" + if conditions != nil { + whereClause = " where " + strings.Join(conditions, " and ") + } + + query := fmt.Sprintf(`delete from spindles %s`, whereClause) + + _, err := e.Exec(query, args...) + return err +} diff --git a/appview/ingester.go b/appview/ingester.go index 5d74943d..8d078ea6 100644 --- a/appview/ingester.go +++ b/appview/ingester.go @@ -3,8 +3,12 @@ package appview import ( "context" "encoding/json" + "errors" "fmt" + "io" "log" + "net/http" + "strings" "time" "github.com/bluesky-social/indigo/atproto/syntax" @@ -46,6 +50,8 @@ func Ingest(d db.DbWrapper, enforcer *rbac.Enforcer) Ingester { ingestProfile(&d, e) case tangled.SpindleMemberNSID: ingestSpindleMember(&d, e, enforcer) + case tangled.SpindleNSID: + ingestSpindle(&d, e, true) // TODO: change this to dynamic } return err @@ -288,7 +294,7 @@ func ingestProfile(d *db.DbWrapper, e *models.Event) error { return nil } -func ingestSpindleMember(_ *db.DbWrapper, e *models.Event, enforcer *rbac.Enforcer) error { +func ingestSpindleMember(d *db.DbWrapper, e *models.Event, enforcer *rbac.Enforcer) error { did := e.Did var err error @@ -316,3 +322,72 @@ func ingestSpindleMember(_ *db.DbWrapper, e *models.Event, enforcer *rbac.Enforc return nil } + +func ingestSpindle(d *db.DbWrapper, e *models.Event, dev bool) error { + did := e.Did + var err error + + switch e.Commit.Operation { + case models.CommitOperationCreate: + raw := json.RawMessage(e.Commit.Record) + record := tangled.Spindle{} + err = json.Unmarshal(raw, &record) + if err != nil { + log.Printf("invalid record: %s", err) + return err + } + + // this is a special record whose rkey is the instance of the spindle itself + domain := e.Commit.RKey + + owner, err := fetchOwner(context.TODO(), domain, true) + if err != nil { + log.Printf("failed to verify owner of %s: %w", domain, err) + return err + } + + // verify that the spindle owner points back to this did + if owner != did { + log.Printf("incorrect owner for domain: %s, %s != %s", domain, owner, did) + return err + } + + // mark this spindle as registered + } + + return nil +} + +func fetchOwner(ctx context.Context, domain string, dev bool) (string, error) { + scheme := "https" + if dev { + scheme = "http" + } + + url := fmt.Sprintf("%s://%s/owner", scheme, domain) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return "", err + } + + client := &http.Client{ + Timeout: 1 * time.Second, + } + + resp, err := client.Do(req.WithContext(ctx)) + if err != nil || resp.StatusCode != 200 { + return "", errors.New("failed to fetch /owner") + } + + body, err := io.ReadAll(io.LimitReader(resp.Body, 1024)) // read atmost 1kb of data + if err != nil { + return "", fmt.Errorf("failed to read /owner response: %w", err) + } + + did := strings.TrimSpace(string(body)) + if did == "" { + return "", errors.New("empty DID in /owner response") + } + + return did, nil +} diff --git a/appview/pages/pages.go b/appview/pages/pages.go index f3e752a7..694cea9c 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -291,6 +291,24 @@ func (p *Pages) Knot(w io.Writer, params KnotParams) error { return p.execute("knot", w, params) } +type SpindlesParams struct { + LoggedInUser *oauth.User + Spindles []db.Spindle +} + +func (p *Pages) Spindles(w io.Writer, params SpindlesParams) error { + return p.execute("spindles/index", w, params) +} + +type SpindleListingParams struct { + LoggedInUser *oauth.User + Spindle db.Spindle +} + +func (p *Pages) SpindleListing(w io.Writer, params SpindleListingParams) error { + return p.execute("spindles/fragments/spindleListing", w, params) +} + type NewRepoParams struct { LoggedInUser *oauth.User Knots []string diff --git a/appview/pages/templates/knots.html b/appview/pages/templates/knots.html index 29d0ce8b..3a21bf98 100644 --- a/appview/pages/templates/knots.html +++ b/appview/pages/templates/knots.html @@ -20,10 +20,10 @@ required class="w-full dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:placeholder-gray-400" > -
diff --git a/appview/pages/templates/layouts/topbar.html b/appview/pages/templates/layouts/topbar.html index bd4cdcf4..b945fa4e 100644 --- a/appview/pages/templates/layouts/topbar.html +++ b/appview/pages/templates/layouts/topbar.html @@ -45,6 +45,7 @@ > profile knots + spindles settings +
+ {{ i "hard-drive" "w-4 h-4" }} + {{ .Instance }} + + {{ .Created | shortTimeFmt }} ago + +
+
+ {{ $style := "px-2 py-1 rounded flex items-center flex-shrink-0 gap-2 text-sm" }} + {{ if .Verified }} + {{ i "shield-check" "w-4 h-4" }} verified + {{ else }} + {{ i "shield-off" "w-4 h-4" }} unverified + {{ block "retryButton" . }} {{ end }} + {{ end }} + {{ block "deleteButton" . }} {{ end }} +
+ +{{ end }} + +{{ define "deleteButton" }} + +{{ end }} + + +{{ define "retryButton" }} + +{{ end }} diff --git a/appview/pages/templates/spindles/index.html b/appview/pages/templates/spindles/index.html new file mode 100644 index 00000000..416357bb --- /dev/null +++ b/appview/pages/templates/spindles/index.html @@ -0,0 +1,69 @@ +{{ define "title" }}spindles{{ end }} + +{{ define "content" }} +
+

Spindles

+
+ +
+
+ {{ block "all" . }} {{ end }} + {{ block "register" . }} {{ end }} +
+
+{{ end }} + +{{ define "all" }} +
+

your spindles

+
+ {{ range $spindle := .Spindles }} + {{ template "spindles/fragments/spindleListing" . }} + {{ else }} +
+ no spindles registered yet +
+ {{ end }} +
+
+
+{{ end }} + +{{ define "register" }} +
+

register a spindle

+

Enter the hostname of your spindle to get started

+
+
+ + +
+ +
+
+ +
+{{ end }} diff --git a/appview/spindleresolver/resolver.go b/appview/spindleresolver/resolver.go new file mode 100644 index 00000000..3d403125 --- /dev/null +++ b/appview/spindleresolver/resolver.go @@ -0,0 +1,176 @@ +package spindleresolver + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "strings" + "time" + + "tangled.sh/tangled.sh/core/api/tangled" + "tangled.sh/tangled.sh/core/appview/cache" + "tangled.sh/tangled.sh/core/appview/idresolver" + + "github.com/bluesky-social/indigo/api/atproto" + "github.com/bluesky-social/indigo/xrpc" +) + +type ResolutionStatus string + +const ( + StatusOK ResolutionStatus = "ok" + StatusError ResolutionStatus = "error" + StatusInvalid ResolutionStatus = "invalid" +) + +type Resolution struct { + Status ResolutionStatus `json:"status"` + OwnerDID string `json:"ownerDid,omitempty"` + VerifiedAt time.Time `json:"verifiedAt"` +} + +type Resolver struct { + cache *cache.Cache + http *http.Client + config Config + idResolver *idresolver.Resolver +} + +type Config struct { + HitTTL time.Duration + ErrTTL time.Duration + InvalidTTL time.Duration + Dev bool +} + +func NewResolver(cache *cache.Cache, client *http.Client, config Config) *Resolver { + if client == nil { + client = &http.Client{ + Timeout: 2 * time.Second, + } + } + return &Resolver{ + cache: cache, + http: client, + config: config, + } +} + +func DefaultResolver(cache *cache.Cache) *Resolver { + return NewResolver( + cache, + &http.Client{ + Timeout: 2 * time.Second, + }, + Config{ + HitTTL: 24 * time.Hour, + ErrTTL: 30 * time.Second, + InvalidTTL: 1 * time.Minute, + }, + ) +} + +func (r *Resolver) ResolveInstance(ctx context.Context, domain string) (*Resolution, error) { + key := "spindle:" + domain + + val, err := r.cache.Get(ctx, key).Result() + if err == nil { + var cached Resolution + if err := json.Unmarshal([]byte(val), &cached); err == nil { + return &cached, nil + } + } + + resolution, ttl := r.verify(ctx, domain) + + data, _ := json.Marshal(resolution) + r.cache.Set(ctx, key, data, ttl) + + if resolution.Status == StatusOK { + return resolution, nil + } + + return resolution, fmt.Errorf("verification failed: %s", resolution.Status) +} + +func (r *Resolver) verify(ctx context.Context, domain string) (*Resolution, time.Duration) { + owner, err := r.fetchOwner(ctx, domain) + if err != nil { + return &Resolution{Status: StatusError, VerifiedAt: time.Now()}, r.config.ErrTTL + } + + record, err := r.fetchRecord(ctx, owner, domain) + if err != nil { + return &Resolution{Status: StatusError, VerifiedAt: time.Now()}, r.config.ErrTTL + } + + if record.Instance == domain { + return &Resolution{ + Status: StatusOK, + OwnerDID: owner, + VerifiedAt: time.Now(), + }, r.config.HitTTL + } + + return &Resolution{ + Status: StatusInvalid, + OwnerDID: owner, + VerifiedAt: time.Now(), + }, r.config.InvalidTTL +} + +func (r *Resolver) fetchOwner(ctx context.Context, domain string) (string, error) { + scheme := "https" + if r.config.Dev { + scheme = "http" + } + + url := fmt.Sprintf("%s://%s/owner", scheme, domain) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return "", err + } + + resp, err := r.http.Do(req.WithContext(ctx)) + if err != nil || resp.StatusCode != 200 { + return "", errors.New("failed to fetch /owner") + } + + body, err := io.ReadAll(io.LimitReader(resp.Body, 1024)) // read atmost 1kb of data + if err != nil { + return "", fmt.Errorf("failed to read /owner response: %w", err) + } + + did := strings.TrimSpace(string(body)) + if did == "" { + return "", errors.New("empty DID in /owner response") + } + + return did, nil +} + +func (r *Resolver) fetchRecord(ctx context.Context, did, rkey string) (*tangled.Spindle, error) { + ident, err := r.idResolver.ResolveIdent(ctx, did) + if err != nil { + return nil, err + } + + xrpcc := xrpc.Client{ + Host: ident.PDSEndpoint(), + } + + rec, err := atproto.RepoGetRecord(ctx, &xrpcc, "", tangled.SpindleNSID, did, rkey) + if err != nil { + return nil, err + } + + out, ok := rec.Value.Val.(*tangled.Spindle) + if !ok { + return nil, fmt.Errorf("invalid record returned") + } + + return out, nil +} diff --git a/appview/spindles/spindles.go b/appview/spindles/spindles.go new file mode 100644 index 00000000..a480a6eb --- /dev/null +++ b/appview/spindles/spindles.go @@ -0,0 +1,304 @@ +package spindles + +import ( + "context" + "errors" + "fmt" + "io" + "log/slog" + "net/http" + "strings" + "time" + + "github.com/go-chi/chi/v5" + "tangled.sh/tangled.sh/core/api/tangled" + "tangled.sh/tangled.sh/core/appview/config" + "tangled.sh/tangled.sh/core/appview/db" + "tangled.sh/tangled.sh/core/appview/middleware" + "tangled.sh/tangled.sh/core/appview/oauth" + "tangled.sh/tangled.sh/core/appview/pages" + "tangled.sh/tangled.sh/core/rbac" + + comatproto "github.com/bluesky-social/indigo/api/atproto" + "github.com/bluesky-social/indigo/atproto/syntax" + lexutil "github.com/bluesky-social/indigo/lex/util" +) + +type Spindles struct { + Db *db.DB + OAuth *oauth.OAuth + Pages *pages.Pages + Config *config.Config + Enforcer *rbac.Enforcer + Logger *slog.Logger +} + +func (s *Spindles) Router() http.Handler { + r := chi.NewRouter() + + r.Use(middleware.AuthMiddleware(s.OAuth)) + + r.Get("/", s.spindles) + r.Post("/register", s.register) + r.Delete("/{instance}", s.delete) + r.Post("/{instance}/retry", s.retry) + + return r +} + +func (s *Spindles) spindles(w http.ResponseWriter, r *http.Request) { + user := s.OAuth.GetUser(r) + all, err := db.GetSpindles( + s.Db, + db.FilterEq("owner", user.Did), + ) + if err != nil { + s.Logger.Error("failed to fetch spindles", "err", err) + } + + s.Pages.Spindles(w, pages.SpindlesParams{ + LoggedInUser: user, + Spindles: all, + }) +} + +// this endpoint inserts a record on behalf of the user to register that domain +// +// when registered, it also makes a request to see if the spindle declares this users as its owner, +// and if so, marks the spindle as verified. +// +// if the spindle is not up yet, the user is free to retry verification at a later point +func (s *Spindles) register(w http.ResponseWriter, r *http.Request) { + user := s.OAuth.GetUser(r) + l := s.Logger.With("handler", "register") + + noticeId := "register-error" + defaultErr := "Failed to register spindle. Try again later." + fail := func() { + s.Pages.Notice(w, noticeId, defaultErr) + } + + instance := r.FormValue("instance") + if instance == "" { + s.Pages.Notice(w, noticeId, "Incomplete form.") + return + } + + tx, err := s.Db.Begin() + if err != nil { + l.Error("failed to start transaction", "err", err) + fail() + return + } + defer tx.Rollback() + + err = db.AddSpindle(tx, db.Spindle{ + Owner: syntax.DID(user.Did), + Instance: instance, + }) + if err != nil { + l.Error("failed to insert", "err", err) + fail() + return + } + + // create record on pds + client, err := s.OAuth.AuthorizedClient(r) + if err != nil { + l.Error("failed to authorize client", "err", err) + fail() + return + } + + _, err = client.RepoPutRecord(r.Context(), &comatproto.RepoPutRecord_Input{ + Collection: tangled.SpindleNSID, + Repo: user.Did, + Rkey: instance, + Record: &lexutil.LexiconTypeDecoder{ + Val: &tangled.Spindle{ + CreatedAt: time.Now().Format(time.RFC3339), + }, + }, + }) + if err != nil { + l.Error("failed to put record", "err", err) + fail() + return + } + + err = tx.Commit() + if err != nil { + l.Error("failed to commit transaction", "err", err) + fail() + return + } + + // begin verification + expectedOwner, err := fetchOwner(r.Context(), instance, s.Config.Core.Dev) + if err != nil { + l.Error("verification failed", "err", err) + + // just refresh the page + s.Pages.HxRefresh(w) + return + } + + if expectedOwner != user.Did { + // verification failed + l.Error("verification failed", "expectedOwner", expectedOwner, "observedOwner", user.Did) + s.Pages.HxRefresh(w) + return + } + + // ok + s.Pages.HxRefresh(w) + return +} + +func (s *Spindles) delete(w http.ResponseWriter, r *http.Request) { + user := s.OAuth.GetUser(r) + l := s.Logger.With("handler", "register") + + noticeId := "operation-error" + defaultErr := "Failed to delete spindle. Try again later." + fail := func() { + s.Pages.Notice(w, noticeId, defaultErr) + } + + instance := chi.URLParam(r, "instance") + if instance == "" { + l.Error("empty instance") + fail() + return + } + + tx, err := s.Db.Begin() + if err != nil { + l.Error("failed to start txn", "err", err) + fail() + return + } + defer tx.Rollback() + + err = db.DeleteSpindle( + tx, + db.FilterEq("owner", user.Did), + db.FilterEq("instance", instance), + ) + if err != nil { + l.Error("failed to delete spindle", "err", err) + fail() + return + } + + client, err := s.OAuth.AuthorizedClient(r) + if err != nil { + l.Error("failed to authorize client", "err", err) + fail() + return + } + + _, err = client.RepoDeleteRecord(r.Context(), &comatproto.RepoDeleteRecord_Input{ + Collection: tangled.SpindleNSID, + Repo: user.Did, + Rkey: instance, + }) + if err != nil { + // non-fatal + l.Error("failed to delete record", "err", err) + } + + err = tx.Commit() + if err != nil { + l.Error("failed to delete spindle", "err", err) + fail() + return + } + + w.Write([]byte{}) +} + +func (s *Spindles) retry(w http.ResponseWriter, r *http.Request) { + user := s.OAuth.GetUser(r) + l := s.Logger.With("handler", "register") + + noticeId := "operation-error" + defaultErr := "Failed to verify spindle. Try again later." + fail := func() { + s.Pages.Notice(w, noticeId, defaultErr) + } + + instance := chi.URLParam(r, "instance") + if instance == "" { + l.Error("empty instance") + fail() + return + } + + // begin verification + expectedOwner, err := fetchOwner(r.Context(), instance, s.Config.Core.Dev) + if err != nil { + l.Error("verification failed", "err", err) + fail() + return + } + + if expectedOwner != user.Did { + l.Error("verification failed", "expectedOwner", expectedOwner, "observedOwner", user.Did) + s.Pages.Notice(w, noticeId, fmt.Sprintf("Owner did not match, expected %s, got %s", expectedOwner, user.Did)) + return + } + + // mark this spindle as verified in the db + rowId, err := db.VerifySpindle( + s.Db, + db.FilterEq("owner", user.Did), + db.FilterEq("instance", instance), + ) + + verifiedSpindle := db.Spindle{ + Id: int(rowId), + Owner: syntax.DID(user.Did), + Instance: instance, + } + + w.Header().Set("HX-Reswap", "outerHTML") + s.Pages.SpindleListing(w, pages.SpindleListingParams{ + LoggedInUser: user, + Spindle: verifiedSpindle, + }) +} + +func fetchOwner(ctx context.Context, domain string, dev bool) (string, error) { + scheme := "https" + if dev { + scheme = "http" + } + + url := fmt.Sprintf("%s://%s/owner", scheme, domain) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return "", err + } + + client := &http.Client{ + Timeout: 1 * time.Second, + } + + resp, err := client.Do(req.WithContext(ctx)) + if err != nil || resp.StatusCode != 200 { + return "", errors.New("failed to fetch /owner") + } + + body, err := io.ReadAll(io.LimitReader(resp.Body, 1024)) // read atmost 1kb of data + if err != nil { + return "", fmt.Errorf("failed to read /owner response: %w", err) + } + + did := strings.TrimSpace(string(body)) + if did == "" { + return "", errors.New("empty DID in /owner response") + } + + return did, nil +} diff --git a/appview/state/router.go b/appview/state/router.go index e20d0568..6eeb6d41 100644 --- a/appview/state/router.go +++ b/appview/state/router.go @@ -12,7 +12,9 @@ import ( "tangled.sh/tangled.sh/core/appview/pulls" "tangled.sh/tangled.sh/core/appview/repo" "tangled.sh/tangled.sh/core/appview/settings" + "tangled.sh/tangled.sh/core/appview/spindles" "tangled.sh/tangled.sh/core/appview/state/userutil" + "tangled.sh/tangled.sh/core/log" ) func (s *State) Router() http.Handler { @@ -142,6 +144,7 @@ func (s *State) StandardRouter(mw *middleware.Middleware) http.Handler { }) r.Mount("/settings", s.SettingsRouter()) + r.Mount("/spindles", s.SpindlesRouter()) r.Mount("/", s.OAuthRouter()) r.Get("/keys/{user}", s.Keys) @@ -169,6 +172,21 @@ func (s *State) SettingsRouter() http.Handler { return settings.Router() } +func (s *State) SpindlesRouter() http.Handler { + logger := log.New("spindles") + + spindles := &spindles.Spindles{ + Db: s.db, + OAuth: s.oauth, + Pages: s.pages, + Config: s.config, + Enforcer: s.enforcer, + Logger: logger, + } + + return spindles.Router() +} + func (s *State) IssuesRouter(mw *middleware.Middleware) http.Handler { issues := issues.New(s.oauth, s.repoResolver, s.pages, s.idResolver, s.db, s.config, s.posthog) return issues.Router(mw) diff --git a/cmd/gen.go b/cmd/gen.go index 06be4495..7fc422eb 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -16,36 +16,37 @@ func main() { "tangled", tangled.ActorProfile{}, tangled.FeedStar{}, - tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{}, - tangled.GitRefUpdate_Meta_CommitCount{}, - tangled.GitRefUpdate_Meta{}, tangled.GitRefUpdate{}, + tangled.GitRefUpdate_Meta{}, + tangled.GitRefUpdate_Meta_CommitCount{}, + tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{}, tangled.GraphFollow{}, tangled.KnotMember{}, - tangled.PipelineStatus{}, + tangled.Pipeline{}, tangled.Pipeline_CloneOpts{}, tangled.Pipeline_Dependencies_Elem{}, - tangled.Pipeline_ManualTriggerData_Inputs_Elem{}, tangled.Pipeline_ManualTriggerData{}, + tangled.Pipeline_ManualTriggerData_Inputs_Elem{}, tangled.Pipeline_PullRequestTriggerData{}, tangled.Pipeline_PushTriggerData{}, tangled.Pipeline_Step_Environment_Elem{}, + tangled.PipelineStatus{}, tangled.Pipeline_Step{}, tangled.Pipeline_TriggerMetadata{}, tangled.Pipeline_TriggerRepo{}, - tangled.Pipeline_Workflow_Environment_Elem{}, tangled.Pipeline_Workflow{}, - tangled.Pipeline{}, + tangled.Pipeline_Workflow_Environment_Elem{}, tangled.PublicKey{}, + tangled.Repo{}, tangled.RepoArtifact{}, + tangled.RepoIssue{}, tangled.RepoIssueComment{}, tangled.RepoIssueState{}, - tangled.RepoIssue{}, + tangled.RepoPull{}, tangled.RepoPullComment{}, - tangled.RepoPullStatus{}, tangled.RepoPull_Source{}, - tangled.RepoPull{}, - tangled.Repo{}, + tangled.RepoPullStatus{}, + tangled.Spindle{}, tangled.SpindleMember{}, ); err != nil { panic(err) diff --git a/lexicons/spindle.json b/lexicons/spindle.json new file mode 100644 index 00000000..4fb08ecb --- /dev/null +++ b/lexicons/spindle.json @@ -0,0 +1,25 @@ +{ + "lexicon": 1, + "id": "sh.tangled.spindle", + "needsCbor": true, + "needsType": true, + "defs": { + "main": { + "type": "record", + "key": "any", + "record": { + "type": "object", + "required": [ + "createdAt" + ], + "properties": { + "createdAt": { + "type": "string", + "format": "datetime" + } + } + } + } + } +} + diff --git a/spindle/db/pipelines.go b/spindle/db/pipelines.go deleted file mode 100644 index 454ddf2a..00000000 --- a/spindle/db/pipelines.go +++ /dev/null @@ -1,207 +0,0 @@ -package db - -// -// import ( -// "database/sql" -// "fmt" -// "time" -// -// "tangled.sh/tangled.sh/core/api/tangled" -// "tangled.sh/tangled.sh/core/notifier" -// ) -// -// type PipelineRunStatus string -// -// var ( -// PipelinePending PipelineRunStatus = "pending" -// PipelineRunning PipelineRunStatus = "running" -// PipelineFailed PipelineRunStatus = "failed" -// PipelineTimeout PipelineRunStatus = "timeout" -// PipelineCancelled PipelineRunStatus = "cancelled" -// PipelineSuccess PipelineRunStatus = "success" -// ) -// -// type PipelineStatus struct { -// Rkey string `json:"rkey"` -// Pipeline string `json:"pipeline"` -// Status PipelineRunStatus `json:"status"` -// -// // only if Failed -// Error string `json:"error"` -// ExitCode int `json:"exit_code"` -// -// LastUpdate int64 `json:"last_update"` -// StartedAt time.Time `json:"started_at"` -// UpdatedAt time.Time `json:"updated_at"` -// FinishedAt time.Time `json:"finished_at"` -// } -// -// func (p PipelineStatus) AsRecord() *tangled.PipelineStatus { -// exitCode64 := int64(p.ExitCode) -// finishedAt := p.FinishedAt.String() -// -// return &tangled.PipelineStatus{ -// LexiconTypeID: tangled.PipelineStatusNSID, -// Pipeline: p.Pipeline, -// Status: string(p.Status), -// -// ExitCode: &exitCode64, -// Error: &p.Error, -// -// StartedAt: p.StartedAt.String(), -// UpdatedAt: p.UpdatedAt.String(), -// FinishedAt: &finishedAt, -// } -// } -// -// func pipelineAtUri(rkey, knot string) string { -// return fmt.Sprintf("at://%s/did:web:%s/%s", tangled.PipelineStatusNSID, knot, rkey) -// } -// -// func (db *DB) CreatePipeline(rkey, pipeline string, n *notifier.Notifier) error { -// _, err := db.Exec(` -// insert into pipeline_status (rkey, status, pipeline, last_update) -// values (?, ?, ?, ?) -// `, rkey, PipelinePending, pipeline, time.Now().UnixNano()) -// -// if err != nil { -// return err -// } -// n.NotifyAll() -// return nil -// } -// -// func (db *DB) MarkPipelineRunning(rkey string, n *notifier.Notifier) error { -// _, err := db.Exec(` -// update pipeline_status -// set status = ?, updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now'), last_update = ? -// where rkey = ? -// `, PipelineRunning, rkey, time.Now().UnixNano()) -// -// if err != nil { -// return err -// } -// n.NotifyAll() -// return nil -// } -// -// func (db *DB) MarkPipelineFailed(rkey string, exitCode int, errorMsg string, n *notifier.Notifier) error { -// _, err := db.Exec(` -// update pipeline_status -// set status = ?, -// exit_code = ?, -// error = ?, -// updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now'), -// finished_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now'), -// last_update = ? -// where rkey = ? -// `, PipelineFailed, exitCode, errorMsg, rkey, time.Now().UnixNano()) -// if err != nil { -// return err -// } -// n.NotifyAll() -// return nil -// } -// -// func (db *DB) MarkPipelineTimeout(rkey string, n *notifier.Notifier) error { -// _, err := db.Exec(` -// update pipeline_status -// set status = ?, updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now') -// where rkey = ? -// `, PipelineTimeout, rkey) -// if err != nil { -// return err -// } -// n.NotifyAll() -// return nil -// } -// -// func (db *DB) MarkPipelineSuccess(rkey string, n *notifier.Notifier) error { -// _, err := db.Exec(` -// update pipeline_status -// set status = ?, updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now'), -// finished_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now') -// where rkey = ? -// `, PipelineSuccess, rkey) -// -// if err != nil { -// return err -// } -// n.NotifyAll() -// return nil -// } -// -// func (db *DB) GetPipelineStatus(rkey string) (PipelineStatus, error) { -// var p PipelineStatus -// err := db.QueryRow(` -// select rkey, status, error, exit_code, started_at, updated_at, finished_at -// from pipelines -// where rkey = ? -// `, rkey).Scan(&p.Rkey, &p.Status, &p.Error, &p.ExitCode, &p.StartedAt, &p.UpdatedAt, &p.FinishedAt) -// return p, err -// } -// -// func (db *DB) GetPipelineStatusAsRecords(cursor int64) ([]PipelineStatus, error) { -// whereClause := "" -// args := []any{} -// if cursor != 0 { -// whereClause = "where created_at > ?" -// args = append(args, cursor) -// } -// -// query := fmt.Sprintf(` -// select rkey, status, error, exit_code, created_at, started_at, updated_at, finished_at -// from pipeline_status -// %s -// order by created_at asc -// limit 100 -// `, whereClause) -// -// rows, err := db.Query(query, args...) -// if err != nil { -// return nil, err -// } -// defer rows.Close() -// -// var pipelines []PipelineStatus -// for rows.Next() { -// var p PipelineStatus -// var pipelineError sql.NullString -// var exitCode sql.NullInt64 -// var startedAt, updatedAt string -// var finishedAt sql.NullTime -// -// err := rows.Scan(&p.Rkey, &p.Status, &pipelineError, &exitCode, &p.LastUpdate, &startedAt, &updatedAt, &finishedAt) -// if err != nil { -// return nil, err -// } -// -// if pipelineError.Valid { -// p.Error = pipelineError.String -// } -// -// if exitCode.Valid { -// p.ExitCode = int(exitCode.Int64) -// } -// -// if v, err := time.Parse(time.RFC3339, startedAt); err == nil { -// p.StartedAt = v -// } -// -// if v, err := time.Parse(time.RFC3339, updatedAt); err == nil { -// p.UpdatedAt = v -// } -// -// if finishedAt.Valid { -// p.FinishedAt = finishedAt.Time -// } -// -// pipelines = append(pipelines, p) -// } -// -// if err := rows.Err(); err != nil { -// return nil, err -// } -// -// return pipelines, nil -// }