forked from tangled.org/core
this repo has no description

appview: introduce UI for spindle registration

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li a1e86cf4 a6afe6f7

verified
Changed files
+2823 -2016
api
appview
db
pages
templates
spindleresolver
spindles
state
cmd
lexicons
spindle
+1900 -1770
api/tangled/cbor_gen.go
···
return nil
}
-
func (t *GitRefUpdate_Meta_CommitCount_ByEmail_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.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("count"))); err != nil {
return err
}
-
if _, err := cw.WriteString(string("count")); 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.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("email"))); err != nil {
return err
}
-
if _, err := cw.WriteString(string("email")); err != nil {
return err
}
-
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_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = GitRefUpdate_Meta_CommitCount_ByEmail_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("GitRefUpdate_Meta_CommitCount_ByEmail_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.Count (int64) (int64)
-
case "count":
-
{
-
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.Count = int64(extraI)
-
}
-
// t.Email (string) (string)
-
case "email":
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
t.Email = 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_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--
}
-
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
return err
}
-
// t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice)
-
if t.ByEmail != nil {
-
if len("byEmail") > 1000000 {
-
return xerrors.Errorf("Value in field \"byEmail\" was too long")
-
}
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("byEmail"))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string("byEmail")); err != nil {
-
return err
-
}
-
if len(t.ByEmail) > 8192 {
-
return xerrors.Errorf("Slice value in field t.ByEmail was too long")
-
}
-
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.ByEmail))); err != nil {
-
return err
-
}
-
for _, v := range t.ByEmail {
-
if err := v.MarshalCBOR(cw); err != nil {
-
return err
-
}
-
}
}
return nil
}
-
func (t *GitRefUpdate_Meta_CommitCount) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = GitRefUpdate_Meta_CommitCount{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
-
return fmt.Errorf("GitRefUpdate_Meta_CommitCount: map struct too large (%d)", extra)
}
n := extra
-
nameBuf := make([]byte, 7)
for i := uint64(0); i < n; i++ {
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
if err != nil {
···
}
switch string(nameBuf[:nameLen]) {
-
// t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice)
-
case "byEmail":
-
maj, extra, err = cr.ReadHeader()
-
if err != nil {
-
return err
}
-
if extra > 8192 {
-
return fmt.Errorf("t.ByEmail: array too large (%d)", extra)
}
-
if maj != cbg.MajArray {
-
return fmt.Errorf("expected cbor array")
}
-
if extra > 0 {
-
t.ByEmail = make([]*GitRefUpdate_Meta_CommitCount_ByEmail_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.ByEmail[i] = new(GitRefUpdate_Meta_CommitCount_ByEmail_Elem)
-
if err := t.ByEmail[i].UnmarshalCBOR(cr); err != nil {
-
return xerrors.Errorf("unmarshaling t.ByEmail[i] pointer: %w", err)
-
}
-
}
-
}
}
}
default:
···
return nil
}
-
func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
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 {
-
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.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) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = GitRefUpdate{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
-
return fmt.Errorf("GitRefUpdate: 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 {
···
}
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)
-
case "$type":
{
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
return err
}
-
t.LexiconTypeID = string(sval)
-
}
-
// t.NewSha (string) (string)
-
case "newSha":
-
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
-
t.NewSha = string(sval)
-
}
-
// t.OldSha (string) (string)
-
case "oldSha":
-
-
{
-
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:
···
return nil
}
-
func (t *PipelineStatus) 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 {
return err
}
···
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 {
return err
}
-
// 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
-
}
-
}
-
}
-
-
// 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("status")); err != nil {
return err
}
-
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.Status))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string(t.Status)); err != nil {
return err
}
-
-
// t.ExitCode (int64) (int64)
-
if t.ExitCode != nil {
-
-
if len("exitCode") > 1000000 {
-
return xerrors.Errorf("Value in field \"exitCode\" was too long")
-
}
-
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("exitCode"))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string("exitCode")); err != nil {
return err
}
-
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 *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = PipelineStatus{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
-
return fmt.Errorf("PipelineStatus: 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 {
···
t.LexiconTypeID = string(sval)
}
-
// 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)
-
}
}
-
// t.Status (string) (string)
-
case "status":
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
t.Status = string(sval)
-
}
-
// 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":
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
t.Pipeline = string(sval)
-
}
-
// t.Workflow (string) (string)
-
case "workflow":
-
-
{
-
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:
···
return nil
}
-
func (t *Pipeline_ManualTriggerData_Inputs_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.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("key"))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string("key")); err != nil {
return err
}
-
if len(t.Key) > 1000000 {
-
return xerrors.Errorf("Value in field t.Key was too long")
-
}
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string(t.Key)); 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_ManualTriggerData_Inputs_Elem) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = Pipeline_ManualTriggerData_Inputs_Elem{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
-
return fmt.Errorf("Pipeline_ManualTriggerData_Inputs_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 {
···
}
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:
···
return nil
}
-
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 t.Inputs == nil {
-
fieldCount--
}
-
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
return err
}
-
// t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice)
-
if t.Inputs != nil {
-
if len("inputs") > 1000000 {
-
return xerrors.Errorf("Value in field \"inputs\" 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 len(t.Inputs) > 8192 {
-
return xerrors.Errorf("Slice value in field t.Inputs 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
-
}
-
}
}
return nil
}
-
func (t *Pipeline_ManualTriggerData) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = Pipeline_ManualTriggerData{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
-
return fmt.Errorf("Pipeline_ManualTriggerData: 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 {
···
}
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:
···
return nil
}
func (t *Pipeline_Step) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
···
return nil
}
-
func (t *Pipeline_Workflow_Environment_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.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("key"))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string("key")); err != nil {
-
return err
-
}
-
-
if len(t.Key) > 1000000 {
-
return xerrors.Errorf("Value in field t.Key was too long")
-
}
-
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string(t.Key)); 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 nil
}
-
func (t *Pipeline) 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.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.pipeline"))); err != nil {
return err
}
-
if _, err := cw.WriteString(string("sh.tangled.pipeline")); 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 err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflows"))); err != nil {
return err
}
-
if _, err := cw.WriteString(string("workflows")); err != nil {
return err
}
-
if len(t.Workflows) > 8192 {
-
return xerrors.Errorf("Slice value in field t.Workflows was too long")
}
-
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
-
}
-
}
-
// 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("triggerMetadata"))); err != nil {
return err
}
-
if _, err := cw.WriteString(string("triggerMetadata")); err != nil {
-
return err
-
}
-
-
if err := t.TriggerMetadata.MarshalCBOR(cw); err != nil {
return err
}
return nil
}
-
func (t *Pipeline) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = Pipeline{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
-
return fmt.Errorf("Pipeline: map struct too large (%d)", extra)
}
n := extra
-
nameBuf := make([]byte, 15)
for i := uint64(0); i < n; i++ {
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
if err != nil {
···
}
switch string(nameBuf[:nameLen]) {
-
// t.LexiconTypeID (string) (string)
-
case "$type":
{
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
return err
}
-
t.LexiconTypeID = string(sval)
-
}
-
// t.Workflows ([]*tangled.Pipeline_Workflow) (slice)
-
case "workflows":
-
-
maj, extra, err = cr.ReadHeader()
-
if err != nil {
-
return err
}
-
-
if extra > 8192 {
-
return fmt.Errorf("t.Workflows: array too large (%d)", extra)
-
}
-
-
if maj != cbg.MajArray {
-
return fmt.Errorf("expected cbor array")
-
}
-
-
if extra > 0 {
-
t.Workflows = make([]*Pipeline_Workflow, 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.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:
···
return nil
}
func (t *RepoArtifact) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
···
return nil
}
func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
···
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--
}
···
}
}
-
// 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")
···
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 {
return err
}
-
// 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("owner"))); err != nil {
return err
}
-
if _, err := cw.WriteString(string("owner")); err != nil {
return err
}
-
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
}
···
return err
}
-
// t.IssueId (int64) (int64)
-
if len("issueId") > 1000000 {
-
return xerrors.Errorf("Value in field \"issueId\" was too long")
}
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issueId"))); err != nil {
return err
}
-
if _, err := cw.WriteString(string("issueId")); err != nil {
return err
}
-
if t.IssueId >= 0 {
-
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.IssueId)); err != nil {
return err
}
} else {
-
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.IssueId-1)); err != nil {
return err
}
}
···
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
return err
}
return nil
}
-
func (t *RepoIssue) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = RepoIssue{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
-
return fmt.Errorf("RepoIssue: 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 {
···
t.Body = (*string)(&sval)
}
}
-
// t.Repo (string) (string)
-
case "repo":
-
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
-
t.Repo = string(sval)
-
}
// t.LexiconTypeID (string) (string)
case "$type":
···
t.LexiconTypeID = string(sval)
}
-
// t.Owner (string) (string)
-
case "owner":
{
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
return err
}
-
t.Owner = string(sval)
}
// t.Title (string) (string)
case "title":
···
t.Title = string(sval)
}
-
// t.IssueId (int64) (int64)
-
case "issueId":
{
maj, extra, err := cr.ReadHeader()
if err != nil {
···
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
-
t.IssueId = int64(extraI)
}
// t.CreatedAt (string) (string)
case "createdAt":
···
}
t.CreatedAt = string(sval)
}
default:
···
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(t.Pull))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string(t.Pull)); 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.pull.status"))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string("sh.tangled.repo.pull.status")); err != nil {
-
return err
-
}
-
-
// 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("status")); err != nil {
-
return err
-
}
-
-
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.Status))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string(t.Status)); err != nil {
-
return err
-
}
-
return nil
-
}
-
-
func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = RepoPullStatus{}
-
-
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("RepoPullStatus: 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.Pull (string) (string)
-
case "pull":
-
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
-
t.Pull = string(sval)
-
}
-
// t.LexiconTypeID (string) (string)
-
case "$type":
-
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
-
t.LexiconTypeID = string(sval)
-
}
-
// t.Status (string) (string)
-
case "status":
-
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
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 nil
}
-
func (t *RepoPull) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
cw := cbg.NewCborWriter(w)
-
fieldCount := 9
-
if t.Body == nil {
-
fieldCount--
-
}
-
-
if t.Source == 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.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.pull"))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string("sh.tangled.repo.pull")); err != nil {
-
return err
}
-
// t.Patch (string) (string)
-
if len("patch") > 1000000 {
-
return xerrors.Errorf("Value in field \"patch\" was too long")
-
}
-
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patch"))); err != nil {
return err
}
-
if _, err := cw.WriteString(string("patch")); err != nil {
return err
}
-
if len(t.Patch) > 1000000 {
-
return xerrors.Errorf("Value in field t.Patch was too long")
}
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Patch))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string(t.Patch)); err != nil {
-
return err
-
}
-
-
// t.Title (string) (string)
-
if len("title") > 1000000 {
-
return xerrors.Errorf("Value in field \"title\" was too long")
-
}
-
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string("title")); err != nil {
-
return err
-
}
-
-
if len(t.Title) > 1000000 {
-
return xerrors.Errorf("Value in field t.Title was too long")
-
}
-
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil {
return err
}
-
if _, err := cw.WriteString(string(t.Title)); err != nil {
return err
}
-
// t.PullId (int64) (int64)
-
if len("pullId") > 1000000 {
-
return xerrors.Errorf("Value in field \"pullId\" was too long")
-
}
-
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pullId"))); err != nil {
return err
}
-
if _, err := cw.WriteString(string("pullId")); err != nil {
return err
}
-
if t.PullId >= 0 {
-
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.PullId)); err != nil {
-
return err
-
}
-
} else {
-
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.PullId-1)); err != nil {
-
return err
-
}
}
-
// t.Source (tangled.RepoPull_Source) (struct)
-
if t.Source != nil {
-
-
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 err := t.Source.MarshalCBOR(cw); 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
-
}
-
-
// t.TargetRepo (string) (string)
-
if len("targetRepo") > 1000000 {
-
return xerrors.Errorf("Value in field \"targetRepo\" was too long")
-
}
-
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetRepo"))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string("targetRepo")); err != nil {
-
return err
-
}
-
-
if len(t.TargetRepo) > 1000000 {
-
return xerrors.Errorf("Value in field t.TargetRepo was too long")
-
}
-
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetRepo))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string(t.TargetRepo)); err != nil {
-
return err
-
}
-
-
// 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
-
}
-
if _, err := cw.WriteString(string("targetBranch")); err != nil {
-
return err
-
}
-
-
if len(t.TargetBranch) > 1000000 {
-
return xerrors.Errorf("Value in field t.TargetBranch was too long")
-
}
-
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetBranch))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string(t.TargetBranch)); err != nil {
return err
}
return nil
}
-
func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = RepoPull{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
-
return fmt.Errorf("RepoPull: 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 {
···
}
switch string(nameBuf[:nameLen]) {
-
// t.Body (string) (string)
-
case "body":
{
-
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.Body = (*string)(&sval)
-
}
}
// t.LexiconTypeID (string) (string)
case "$type":
···
t.LexiconTypeID = string(sval)
}
-
// t.Patch (string) (string)
-
case "patch":
{
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
return err
}
-
t.Patch = string(sval)
-
}
-
// t.Title (string) (string)
-
case "title":
-
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
-
t.Title = string(sval)
-
}
-
// t.PullId (int64) (int64)
-
case "pullId":
-
{
-
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.PullId = int64(extraI)
-
}
-
// t.Source (tangled.RepoPull_Source) (struct)
-
case "source":
-
-
{
-
-
b, err := cr.ReadByte()
-
if err != nil {
-
return err
-
}
-
if b != cbg.CborNull[0] {
-
if err := cr.UnreadByte(); err != nil {
-
return err
-
}
-
t.Source = new(RepoPull_Source)
-
if err := t.Source.UnmarshalCBOR(cr); err != nil {
-
return xerrors.Errorf("unmarshaling t.Source pointer: %w", err)
-
}
-
}
-
-
}
-
// t.CreatedAt (string) (string)
-
case "createdAt":
-
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
-
t.CreatedAt = string(sval)
-
}
-
// t.TargetRepo (string) (string)
-
case "targetRepo":
-
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
-
t.TargetRepo = string(sval)
-
}
-
// t.TargetBranch (string) (string)
-
case "targetBranch":
-
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
-
t.TargetBranch = string(sval)
}
default:
···
return nil
}
-
func (t *Repo) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
cw := cbg.NewCborWriter(w)
-
fieldCount := 8
-
if t.Description == nil {
-
fieldCount--
-
}
-
-
if t.Source == nil {
-
fieldCount--
-
}
-
-
if t.Spindle == nil {
-
fieldCount--
-
}
-
-
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
-
return err
-
}
-
-
// t.Knot (string) (string)
-
if len("knot") > 1000000 {
-
return xerrors.Errorf("Value in field \"knot\" was too long")
-
}
-
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("knot"))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string("knot")); 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)
-
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
}
···
return err
}
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo"))); err != nil {
return err
}
-
if _, err := cw.WriteString(string("sh.tangled.repo")); err != nil {
return err
}
-
// 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("owner"))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string("owner")); err != nil {
-
return err
-
}
-
-
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.Source (string) (string)
-
if t.Source != nil {
-
-
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
-
}
-
}
-
}
-
-
// 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)
if len("createdAt") > 1000000 {
return xerrors.Errorf("Value in field \"createdAt\" was too long")
···
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 *Repo) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = Repo{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
-
return fmt.Errorf("Repo: 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 {
···
}
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":
-
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
-
t.Name = string(sval)
-
}
-
// t.LexiconTypeID (string) (string)
case "$type":
{
···
t.LexiconTypeID = string(sval)
}
-
// t.Owner (string) (string)
-
case "owner":
-
-
{
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
-
if err != nil {
-
return err
-
}
-
-
t.Owner = 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
-
}
-
-
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":
···
}
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:
···
return nil
}
+
func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
···
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 {
+
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.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) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = GitRefUpdate{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
+
return fmt.Errorf("GitRefUpdate: 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 {
···
}
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)
+
case "$type":
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.LexiconTypeID = string(sval)
}
+
// t.NewSha (string) (string)
+
case "newSha":
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.NewSha = string(sval)
}
+
// t.OldSha (string) (string)
+
case "oldSha":
+
{
+
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:
···
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--
}
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
return err
}
+
// t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice)
+
if t.ByEmail != nil {
+
if len("byEmail") > 1000000 {
+
return xerrors.Errorf("Value in field \"byEmail\" was too long")
+
}
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("byEmail"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("byEmail")); err != nil {
+
return err
+
}
+
if len(t.ByEmail) > 8192 {
+
return xerrors.Errorf("Slice value in field t.ByEmail was too long")
+
}
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.ByEmail))); err != nil {
+
return err
+
}
+
for _, v := range t.ByEmail {
+
if err := v.MarshalCBOR(cw); err != nil {
+
return err
+
}
+
+
}
}
+
return nil
+
}
+
func (t *GitRefUpdate_Meta_CommitCount) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = GitRefUpdate_Meta_CommitCount{}
+
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_CommitCount: map struct too large (%d)", extra)
}
+
n := extra
+
nameBuf := make([]byte, 7)
+
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.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice)
+
case "byEmail":
+
maj, extra, err = cr.ReadHeader()
+
if err != nil {
+
return err
+
}
+
if extra > 8192 {
+
return fmt.Errorf("t.ByEmail: array too large (%d)", extra)
+
}
+
if maj != cbg.MajArray {
+
return fmt.Errorf("expected cbor array")
+
}
+
if extra > 0 {
+
t.ByEmail = make([]*GitRefUpdate_Meta_CommitCount_ByEmail_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.ByEmail[i] = new(GitRefUpdate_Meta_CommitCount_ByEmail_Elem)
+
if err := t.ByEmail[i].UnmarshalCBOR(cr); err != nil {
+
return xerrors.Errorf("unmarshaling t.ByEmail[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 *GitRefUpdate_Meta_CommitCount_ByEmail_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.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("count"))); err != nil {
return err
}
+
if _, err := cw.WriteString(string("count")); 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.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("email"))); err != nil {
return err
}
+
if _, err := cw.WriteString(string("email")); err != nil {
return err
}
+
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_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = GitRefUpdate_Meta_CommitCount_ByEmail_Elem{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
+
return fmt.Errorf("GitRefUpdate_Meta_CommitCount_ByEmail_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 {
···
}
switch string(nameBuf[:nameLen]) {
+
// t.Count (int64) (int64)
+
case "count":
{
+
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.Count = int64(extraI)
}
+
// t.Email (string) (string)
+
case "email":
{
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
return err
}
+
t.Email = string(sval)
}
default:
···
return nil
}
+
func (t *Pipeline) 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
}
···
return err
}
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline"))); err != nil {
return err
}
+
if _, err := cw.WriteString(string("sh.tangled.pipeline")); 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 err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflows"))); err != nil {
return err
}
+
if _, err := cw.WriteString(string("workflows")); err != nil {
return err
}
+
if len(t.Workflows) > 8192 {
+
return xerrors.Errorf("Slice value in field t.Workflows was too long")
}
+
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
}
}
+
// 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("triggerMetadata"))); err != nil {
return err
}
+
if _, err := cw.WriteString(string("triggerMetadata")); err != nil {
return err
}
+
if err := t.TriggerMetadata.MarshalCBOR(cw); err != nil {
return err
}
return nil
}
+
func (t *Pipeline) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = Pipeline{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
+
return fmt.Errorf("Pipeline: map struct too large (%d)", extra)
}
n := extra
+
nameBuf := make([]byte, 15)
for i := uint64(0); i < n; i++ {
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
if err != nil {
···
t.LexiconTypeID = string(sval)
}
+
// t.Workflows ([]*tangled.Pipeline_Workflow) (slice)
+
case "workflows":
+
+
maj, extra, err = cr.ReadHeader()
+
if err != nil {
+
return err
+
}
+
if extra > 8192 {
+
return fmt.Errorf("t.Workflows: array too large (%d)", extra)
+
}
+
if maj != cbg.MajArray {
+
return fmt.Errorf("expected cbor array")
+
}
+
if extra > 0 {
+
t.Workflows = make([]*Pipeline_Workflow, 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.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:
···
return nil
}
+
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 t.Inputs == nil {
+
fieldCount--
}
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
return err
}
+
// t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice)
+
if t.Inputs != nil {
+
if len("inputs") > 1000000 {
+
return xerrors.Errorf("Value in field \"inputs\" 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 len(t.Inputs) > 8192 {
+
return xerrors.Errorf("Slice value in field t.Inputs 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
+
}
+
}
}
return nil
}
+
func (t *Pipeline_ManualTriggerData) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = Pipeline_ManualTriggerData{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
+
return fmt.Errorf("Pipeline_ManualTriggerData: 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 {
···
}
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:
···
return nil
}
+
func (t *Pipeline_ManualTriggerData_Inputs_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.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("key"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("key")); err != nil {
return err
}
+
if len(t.Key) > 1000000 {
+
return xerrors.Errorf("Value in field t.Key was too long")
+
}
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string(t.Key)); 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_ManualTriggerData_Inputs_Elem) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = Pipeline_ManualTriggerData_Inputs_Elem{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
+
return fmt.Errorf("Pipeline_ManualTriggerData_Inputs_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 {
···
}
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:
···
return nil
}
+
func (t *PipelineStatus) 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 {
+
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.pipeline.status"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("sh.tangled.pipeline.status")); err != nil {
+
return err
+
}
+
+
// 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
+
}
+
}
+
}
+
+
// 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("status")); err != nil {
+
return err
+
}
+
+
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.Status))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string(t.Status)); err != nil {
+
return err
+
}
+
+
// t.ExitCode (int64) (int64)
+
if t.ExitCode != nil {
+
+
if len("exitCode") > 1000000 {
+
return xerrors.Errorf("Value in field \"exitCode\" was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("exitCode"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("exitCode")); err != nil {
+
return err
+
}
+
+
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 *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = PipelineStatus{}
+
+
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("PipelineStatus: 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
+
}
+
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.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)
+
}
+
}
+
// t.Status (string) (string)
+
case "status":
+
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.Status = string(sval)
+
}
+
// 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":
+
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.Pipeline = string(sval)
+
}
+
// t.Workflow (string) (string)
+
case "workflow":
+
+
{
+
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:
+
// 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_Step) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
···
return nil
}
func (t *Pipeline_Workflow) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
···
return nil
}
+
func (t *Pipeline_Workflow_Environment_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.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("key"))); err != nil {
return err
}
+
if _, err := cw.WriteString(string("key")); err != nil {
return err
}
+
if len(t.Key) > 1000000 {
+
return xerrors.Errorf("Value in field t.Key was too long")
}
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
return err
}
+
if _, err := cw.WriteString(string(t.Key)); 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)
···
}
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 {
···
}
switch string(nameBuf[:nameLen]) {
+
// t.Key (string) (string)
+
case "key":
{
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
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:
···
return nil
}
+
func (t *Repo) MarshalCBOR(w io.Writer) error {
+
if t == nil {
+
_, err := w.Write(cbg.CborNull)
+
return err
+
}
+
+
cw := cbg.NewCborWriter(w)
+
fieldCount := 8
+
+
if t.Description == nil {
+
fieldCount--
+
}
+
+
if t.Source == nil {
+
fieldCount--
+
}
+
+
if t.Spindle == nil {
+
fieldCount--
+
}
+
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
+
return err
+
}
+
+
// t.Knot (string) (string)
+
if len("knot") > 1000000 {
+
return xerrors.Errorf("Value in field \"knot\" was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("knot"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("knot")); 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)
+
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.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"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("sh.tangled.repo")); err != nil {
+
return err
+
}
+
+
// 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("owner"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("owner")); err != nil {
+
return err
+
}
+
+
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.Source (string) (string)
+
if t.Source != nil {
+
+
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
+
}
+
}
+
}
+
+
// 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)
+
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
+
}
+
+
// 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 *Repo) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = Repo{}
+
+
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("Repo: 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.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":
+
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.Name = 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":
+
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.Owner = 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
+
}
+
+
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":
+
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
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
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
+
return err
+
}
+
}
+
}
+
+
return nil
+
}
func (t *RepoArtifact) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
···
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 {
+
return err
+
}
+
+
// 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("owner"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("owner")); err != nil {
+
return err
+
}
+
+
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.Title (string) (string)
+
if len("title") > 1000000 {
+
return xerrors.Errorf("Value in field \"title\" was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("title")); err != nil {
+
return err
+
}
+
+
if len(t.Title) > 1000000 {
+
return xerrors.Errorf("Value in field t.Title was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string(t.Title)); err != nil {
+
return err
+
}
+
+
// t.IssueId (int64) (int64)
+
if len("issueId") > 1000000 {
+
return xerrors.Errorf("Value in field \"issueId\" was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issueId"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("issueId")); err != nil {
+
return err
+
}
+
+
if t.IssueId >= 0 {
+
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.IssueId)); err != nil {
+
return err
+
}
+
} else {
+
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.IssueId-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 *RepoIssue) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = RepoIssue{}
+
+
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("RepoIssue: 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
+
}
+
continue
+
}
+
+
switch string(nameBuf[:nameLen]) {
+
// t.Body (string) (string)
+
case "body":
+
+
{
+
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.Body = (*string)(&sval)
+
}
+
}
+
// t.Repo (string) (string)
+
case "repo":
+
+
{
+
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":
+
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.Owner = string(sval)
+
}
+
// t.Title (string) (string)
+
case "title":
+
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.Title = string(sval)
+
}
+
// t.IssueId (int64) (int64)
+
case "issueId":
+
{
+
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.IssueId = 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
+
}
+
}
+
}
+
+
return nil
+
}
func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
···
return nil
}
+
func (t *RepoPull) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
cw := cbg.NewCborWriter(w)
+
fieldCount := 9
if t.Body == nil {
+
fieldCount--
+
}
+
+
if t.Source == nil {
fieldCount--
}
···
}
}
// t.LexiconTypeID (string) (string)
if len("$type") > 1000000 {
return xerrors.Errorf("Value in field \"$type\" was too long")
···
return err
}
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull"))); err != nil {
return err
}
+
if _, err := cw.WriteString(string("sh.tangled.repo.pull")); err != nil {
return err
}
+
// t.Patch (string) (string)
+
if len("patch") > 1000000 {
+
return xerrors.Errorf("Value in field \"patch\" was too long")
}
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patch"))); err != nil {
return err
}
+
if _, err := cw.WriteString(string("patch")); err != nil {
return err
}
+
if len(t.Patch) > 1000000 {
+
return xerrors.Errorf("Value in field t.Patch was too long")
}
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Patch))); err != nil {
return err
}
+
if _, err := cw.WriteString(string(t.Patch)); err != nil {
return err
}
···
return err
}
+
// t.PullId (int64) (int64)
+
if len("pullId") > 1000000 {
+
return xerrors.Errorf("Value in field \"pullId\" was too long")
}
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pullId"))); err != nil {
return err
}
+
if _, err := cw.WriteString(string("pullId")); err != nil {
return err
}
+
if t.PullId >= 0 {
+
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.PullId)); err != nil {
return err
}
} else {
+
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.PullId-1)); err != nil {
+
return err
+
}
+
}
+
+
// t.Source (tangled.RepoPull_Source) (struct)
+
if t.Source != nil {
+
+
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 err := t.Source.MarshalCBOR(cw); err != nil {
return err
}
}
···
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
return err
}
+
+
// t.TargetRepo (string) (string)
+
if len("targetRepo") > 1000000 {
+
return xerrors.Errorf("Value in field \"targetRepo\" was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetRepo"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("targetRepo")); err != nil {
+
return err
+
}
+
+
if len(t.TargetRepo) > 1000000 {
+
return xerrors.Errorf("Value in field t.TargetRepo was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetRepo))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string(t.TargetRepo)); err != nil {
+
return err
+
}
+
+
// 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
+
}
+
if _, err := cw.WriteString(string("targetBranch")); err != nil {
+
return err
+
}
+
+
if len(t.TargetBranch) > 1000000 {
+
return xerrors.Errorf("Value in field t.TargetBranch was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetBranch))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string(t.TargetBranch)); err != nil {
+
return err
+
}
return nil
}
+
func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = RepoPull{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
+
return fmt.Errorf("RepoPull: 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 {
···
t.Body = (*string)(&sval)
}
}
// t.LexiconTypeID (string) (string)
case "$type":
···
t.LexiconTypeID = string(sval)
}
+
// t.Patch (string) (string)
+
case "patch":
{
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
return err
}
+
t.Patch = string(sval)
}
// t.Title (string) (string)
case "title":
···
t.Title = string(sval)
}
+
// t.PullId (int64) (int64)
+
case "pullId":
{
maj, extra, err := cr.ReadHeader()
if err != nil {
···
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
+
t.PullId = int64(extraI)
+
}
+
// t.Source (tangled.RepoPull_Source) (struct)
+
case "source":
+
+
{
+
+
b, err := cr.ReadByte()
+
if err != nil {
+
return err
+
}
+
if b != cbg.CborNull[0] {
+
if err := cr.UnreadByte(); err != nil {
+
return err
+
}
+
t.Source = new(RepoPull_Source)
+
if err := t.Source.UnmarshalCBOR(cr); err != nil {
+
return xerrors.Errorf("unmarshaling t.Source pointer: %w", err)
+
}
+
}
+
}
// t.CreatedAt (string) (string)
case "createdAt":
···
}
t.CreatedAt = string(sval)
+
}
+
// t.TargetRepo (string) (string)
+
case "targetRepo":
+
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.TargetRepo = string(sval)
+
}
+
// t.TargetBranch (string) (string)
+
case "targetBranch":
+
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.TargetBranch = string(sval)
}
default:
···
return nil
}
func (t *RepoPull_Source) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
···
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(t.Pull))); err != nil {
return err
}
+
if _, err := cw.WriteString(string(t.Pull)); 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.pull.status"))); err != nil {
return err
}
+
if _, err := cw.WriteString(string("sh.tangled.repo.pull.status")); err != nil {
return err
}
+
// 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("status")); err != nil {
return err
}
+
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.Status))); err != nil {
return err
}
+
if _, err := cw.WriteString(string(t.Status)); err != nil {
return err
}
return nil
}
+
func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = RepoPullStatus{}
cr := cbg.NewCborReader(r)
···
}
if extra > cbg.MaxLength {
+
return fmt.Errorf("RepoPullStatus: 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 {
···
}
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)
case "$type":
···
t.LexiconTypeID = string(sval)
}
+
// t.Status (string) (string)
+
case "status":
{
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
return err
}
+
t.Status = string(sval)
}
default:
···
return nil
}
+
func (t *Spindle) 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
}
···
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.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)
···
}
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 {
···
}
switch string(nameBuf[:nameLen]) {
+
// t.LexiconTypeID (string) (string)
case "$type":
{
···
t.LexiconTypeID = string(sval)
}
// t.CreatedAt (string) (string)
case "createdAt":
···
}
t.CreatedAt = string(sval)
}
default:
+22
api/tangled/tangledspindle.go
···
···
+
// 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"`
+
}
+18 -25
appview/db/db.go
···
primary key (did, date)
);
create table if not exists migrations (
id integer primary key autoincrement,
name text unique
···
cmp string
}
-
func FilterEq(key string, arg any) filter {
return filter{
key: key,
arg: arg,
-
cmp: "=",
}
}
-
func FilterNotEq(key string, arg any) filter {
-
return filter{
-
key: key,
-
arg: arg,
-
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 (f filter) Condition() string {
return fmt.Sprintf("%s %s ?", f.key, f.cmp)
···
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
···
cmp string
}
+
func newFilter(key, cmp string, arg any) filter {
return filter{
key: key,
arg: arg,
+
cmp: 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)
+131
appview/db/spindle.go
···
···
+
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
+
}
+76 -1
appview/ingester.go
···
import (
"context"
"encoding/json"
"fmt"
"log"
"time"
"github.com/bluesky-social/indigo/atproto/syntax"
···
ingestProfile(&d, e)
case tangled.SpindleMemberNSID:
ingestSpindleMember(&d, e, enforcer)
}
return err
···
return nil
}
-
func ingestSpindleMember(_ *db.DbWrapper, e *models.Event, enforcer *rbac.Enforcer) error {
did := e.Did
var err error
···
return nil
}
···
import (
"context"
"encoding/json"
+
"errors"
"fmt"
+
"io"
"log"
+
"net/http"
+
"strings"
"time"
"github.com/bluesky-social/indigo/atproto/syntax"
···
ingestProfile(&d, e)
case tangled.SpindleMemberNSID:
ingestSpindleMember(&d, e, enforcer)
+
case tangled.SpindleNSID:
+
ingestSpindle(&d, e, true) // TODO: change this to dynamic
}
return err
···
return nil
}
+
func ingestSpindleMember(d *db.DbWrapper, e *models.Event, enforcer *rbac.Enforcer) error {
did := e.Did
var err error
···
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
+
}
+18
appview/pages/pages.go
···
return p.execute("knot", w, params)
}
type NewRepoParams struct {
LoggedInUser *oauth.User
Knots []string
···
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
+2 -2
appview/pages/templates/knots.html
···
required
class="w-full dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:placeholder-gray-400"
>
-
<button class="btn dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 flex gap-2 items-center" type="submit">
<span>generate key</span>
<span id="generate-knot-key-spinner" class="group">
-
{{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
</span>
</button>
<div id="settings-knots-error" class="error dark:text-red-400"></div>
···
required
class="w-full dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:placeholder-gray-400"
>
+
<button class="btn dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 flex items-center" type="submit">
<span>generate key</span>
<span id="generate-knot-key-spinner" class="group">
+
{{ i "loader-circle" "pl-2 w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
</span>
</button>
<div id="settings-knots-error" class="error dark:text-red-400"></div>
+1
appview/pages/templates/layouts/topbar.html
···
>
<a href="/{{ didOrHandle .Did .Handle }}">profile</a>
<a href="/knots">knots</a>
<a href="/settings">settings</a>
<a href="#"
hx-post="/logout"
···
>
<a href="/{{ didOrHandle .Did .Handle }}">profile</a>
<a href="/knots">knots</a>
+
<a href="/spindles">spindles</a>
<a href="/settings">settings</a>
<a href="#"
hx-post="/logout"
+51
appview/pages/templates/spindles/fragments/spindleListing.html
···
···
+
{{ define "spindles/fragments/spindleListing" }}
+
<div id="spindle-{{.Id}}" class="flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700">
+
<div id="left-side" class="flex items-center gap-2 min-w-0 max-w-[60%]">
+
{{ i "hard-drive" "w-4 h-4" }}
+
{{ .Instance }}
+
<span class="text-gray-500">
+
{{ .Created | shortTimeFmt }} ago
+
</span>
+
</div>
+
<div id="right-side" class="flex gap-2">
+
{{ $style := "px-2 py-1 rounded flex items-center flex-shrink-0 gap-2 text-sm" }}
+
{{ if .Verified }}
+
<span class="bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 {{$style}}">{{ i "shield-check" "w-4 h-4" }} verified</span>
+
{{ else }}
+
<span class="bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200 {{$style}}">{{ i "shield-off" "w-4 h-4" }} unverified</span>
+
{{ block "retryButton" . }} {{ end }}
+
{{ end }}
+
{{ block "deleteButton" . }} {{ end }}
+
</div>
+
</div>
+
{{ end }}
+
+
{{ define "deleteButton" }}
+
<button
+
class="btn text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 gap-2 group"
+
title="Delete spindle"
+
hx-delete="/spindles/{{ urlquery .Instance }}"
+
hx-swap="outerHTML"
+
hx-target="#spindle-{{.Id}}"
+
hx-confirm="Are you sure you want to delete the spindle '{{ .Instance }}'?"
+
>
+
{{ i "trash-2" "w-5 h-5" }}
+
<span class="hidden md:inline">delete</span>
+
{{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
+
</button>
+
{{ end }}
+
+
+
{{ define "retryButton" }}
+
<button
+
class="btn gap-2 group"
+
title="Retry spindle verification"
+
hx-post="/spindles/{{ urlquery .Instance }}/retry"
+
hx-swap="none"
+
hx-target="#spindle-{{.Id}}"
+
>
+
{{ i "rotate-ccw" "w-5 h-5" }}
+
<span class="hidden md:inline">retry</span>
+
{{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
+
</button>
+
{{ end }}
+69
appview/pages/templates/spindles/index.html
···
···
+
{{ define "title" }}spindles{{ end }}
+
+
{{ define "content" }}
+
<div class="px-6 py-4">
+
<h1 class="text-xl font-bold dark:text-white">Spindles</h1>
+
</div>
+
+
<section class="bg-white dark:bg-gray-800 p-6 rounded relative w-full mx-auto drop-shadow-sm dark:text-white">
+
<div class="flex flex-col gap-6">
+
{{ block "all" . }} {{ end }}
+
{{ block "register" . }} {{ end }}
+
</div>
+
</section>
+
{{ end }}
+
+
{{ define "all" }}
+
<section class="rounded bg-white dark:bg-gray-800 drop-shadow-sm w-full flex flex-col gap-2">
+
<h2 class="text-sm font-bold py-2 uppercase dark:text-gray-300">your spindles</h2>
+
<div class="flex flex-col rounded border border-gray-200 dark:border-gray-700 w-full">
+
{{ range $spindle := .Spindles }}
+
{{ template "spindles/fragments/spindleListing" . }}
+
{{ else }}
+
<div class="flex items-center justify-center p-2 border-b border-gray-200 dark:border-gray-700 text-gray-500">
+
no spindles registered yet
+
</div>
+
{{ end }}
+
</div>
+
<div id="operation-error" class="dark:text-red-400"></div>
+
</section>
+
{{ end }}
+
+
{{ define "register" }}
+
<section class="rounded bg-white dark:bg-gray-800 drop-shadow-sm w-full lg:w-fit flex flex-col gap-2">
+
<h2 class="text-sm font-bold py-2 uppercase dark:text-gray-300">register a spindle</h2>
+
<p class="mb-2 dark:text-gray-300">Enter the hostname of your spindle to get started</p>
+
<form
+
hx-post="/spindles/register"
+
class="max-w-2xl mb-2 space-y-4"
+
hx-indicator="#register-spinner"
+
hx-swap="none"
+
>
+
<div class="flex gap-2">
+
<input
+
type="text"
+
id="instance"
+
name="instance"
+
placeholder="spindle.example.com"
+
required
+
class="flex-1 w-full dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:placeholder-gray-400 px-3 py-2 border rounded"
+
>
+
<button
+
type="submit"
+
class="btn rounded flex items-center py-2 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 group"
+
>
+
<span class="inline-flex items-center gap-2">
+
{{ i "plus" "w-4 h-4" }}
+
register
+
</span>
+
<span id="register-spinner" class="pl-2 hidden group-[.htmx-request]:inline">
+
{{ i "loader-circle" "w-4 h-4 animate-spin" }}
+
</span>
+
</button>
+
</div>
+
+
<div id="register-error" class="dark:text-red-400"></div>
+
</form>
+
+
</section>
+
{{ end }}
+176
appview/spindleresolver/resolver.go
···
···
+
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
+
}
+304
appview/spindles/spindles.go
···
···
+
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
+
}
+18
appview/state/router.go
···
"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/state/userutil"
)
func (s *State) Router() http.Handler {
···
})
r.Mount("/settings", s.SettingsRouter())
r.Mount("/", s.OAuthRouter())
r.Get("/keys/{user}", s.Keys)
···
}
return settings.Router()
}
func (s *State) IssuesRouter(mw *middleware.Middleware) http.Handler {
···
"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 {
···
})
r.Mount("/settings", s.SettingsRouter())
+
r.Mount("/spindles", s.SpindlesRouter())
r.Mount("/", s.OAuthRouter())
r.Get("/keys/{user}", s.Keys)
···
}
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 {
+12 -11
cmd/gen.go
···
"tangled",
tangled.ActorProfile{},
tangled.FeedStar{},
-
tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{},
-
tangled.GitRefUpdate_Meta_CommitCount{},
-
tangled.GitRefUpdate_Meta{},
tangled.GitRefUpdate{},
tangled.GraphFollow{},
tangled.KnotMember{},
-
tangled.PipelineStatus{},
tangled.Pipeline_CloneOpts{},
tangled.Pipeline_Dependencies_Elem{},
-
tangled.Pipeline_ManualTriggerData_Inputs_Elem{},
tangled.Pipeline_ManualTriggerData{},
tangled.Pipeline_PullRequestTriggerData{},
tangled.Pipeline_PushTriggerData{},
tangled.Pipeline_Step{},
tangled.Pipeline_TriggerMetadata{},
tangled.Pipeline_TriggerRepo{},
tangled.Pipeline_Workflow_Environment_Elem{},
-
tangled.Pipeline_Workflow{},
-
tangled.Pipeline{},
tangled.PublicKey{},
tangled.RepoArtifact{},
tangled.RepoIssueComment{},
tangled.RepoIssueState{},
-
tangled.RepoIssue{},
tangled.RepoPullComment{},
tangled.RepoPullStatus{},
-
tangled.RepoPull_Source{},
-
tangled.RepoPull{},
-
tangled.Repo{},
tangled.SpindleMember{},
); err != nil {
panic(err)
···
"tangled",
tangled.ActorProfile{},
tangled.FeedStar{},
tangled.GitRefUpdate{},
+
tangled.GitRefUpdate_Meta{},
+
tangled.GitRefUpdate_Meta_CommitCount{},
+
tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{},
tangled.GraphFollow{},
tangled.KnotMember{},
+
tangled.Pipeline{},
tangled.Pipeline_CloneOpts{},
tangled.Pipeline_Dependencies_Elem{},
tangled.Pipeline_ManualTriggerData{},
+
tangled.Pipeline_ManualTriggerData_Inputs_Elem{},
tangled.Pipeline_PullRequestTriggerData{},
tangled.Pipeline_PushTriggerData{},
+
tangled.PipelineStatus{},
tangled.Pipeline_Step{},
tangled.Pipeline_TriggerMetadata{},
tangled.Pipeline_TriggerRepo{},
+
tangled.Pipeline_Workflow{},
tangled.Pipeline_Workflow_Environment_Elem{},
tangled.PublicKey{},
+
tangled.Repo{},
tangled.RepoArtifact{},
+
tangled.RepoIssue{},
tangled.RepoIssueComment{},
tangled.RepoIssueState{},
+
tangled.RepoPull{},
tangled.RepoPullComment{},
+
tangled.RepoPull_Source{},
tangled.RepoPullStatus{},
+
tangled.Spindle{},
tangled.SpindleMember{},
); err != nil {
panic(err)
+25
lexicons/spindle.json
···
···
+
{
+
"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"
+
}
+
}
+
}
+
}
+
}
+
}
+
-207
spindle/db/pipelines.go
···
-
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
-
// }
···