Monorepo for Tangled tangled.org

appview: introduce UI for spindle registration

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

oppi.li 45882b6b 345b3621

verified
Changed files
+2826 -2017
api
appview
db
pages
templates
spindleresolver
spindles
state
cmd
lexicons
spindle
+1902 -1770
api/tangled/cbor_gen.go
··· 668 668 669 669 return nil 670 670 } 671 - func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) MarshalCBOR(w io.Writer) error { 671 + func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error { 672 672 if t == nil { 673 673 _, err := w.Write(cbg.CborNull) 674 674 return err ··· 676 676 677 677 cw := cbg.NewCborWriter(w) 678 678 679 - if _, err := cw.Write([]byte{162}); err != nil { 679 + if _, err := cw.Write([]byte{168}); err != nil { 680 680 return err 681 681 } 682 682 683 - // t.Count (int64) (int64) 684 - if len("count") > 1000000 { 685 - return xerrors.Errorf("Value in field \"count\" was too long") 683 + // t.Ref (string) (string) 684 + if len("ref") > 1000000 { 685 + return xerrors.Errorf("Value in field \"ref\" was too long") 686 686 } 687 687 688 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("count"))); err != nil { 688 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ref"))); err != nil { 689 689 return err 690 690 } 691 - if _, err := cw.WriteString(string("count")); err != nil { 691 + if _, err := cw.WriteString(string("ref")); err != nil { 692 692 return err 693 693 } 694 694 695 - if t.Count >= 0 { 696 - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Count)); err != nil { 697 - return err 698 - } 699 - } else { 700 - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Count-1)); err != nil { 701 - return err 702 - } 703 - } 704 - 705 - // t.Email (string) (string) 706 - if len("email") > 1000000 { 707 - return xerrors.Errorf("Value in field \"email\" was too long") 695 + if len(t.Ref) > 1000000 { 696 + return xerrors.Errorf("Value in field t.Ref was too long") 708 697 } 709 698 710 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("email"))); err != nil { 699 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Ref))); err != nil { 711 700 return err 712 701 } 713 - if _, err := cw.WriteString(string("email")); err != nil { 702 + if _, err := cw.WriteString(string(t.Ref)); err != nil { 714 703 return err 715 704 } 716 705 717 - if len(t.Email) > 1000000 { 718 - return xerrors.Errorf("Value in field t.Email was too long") 706 + // t.Meta (tangled.GitRefUpdate_Meta) (struct) 707 + if len("meta") > 1000000 { 708 + return xerrors.Errorf("Value in field \"meta\" was too long") 719 709 } 720 710 721 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Email))); err != nil { 711 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("meta"))); err != nil { 722 712 return err 723 713 } 724 - if _, err := cw.WriteString(string(t.Email)); err != nil { 714 + if _, err := cw.WriteString(string("meta")); err != nil { 725 715 return err 726 716 } 727 - return nil 728 - } 729 717 730 - func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) (err error) { 731 - *t = GitRefUpdate_Meta_CommitCount_ByEmail_Elem{} 718 + if err := t.Meta.MarshalCBOR(cw); err != nil { 719 + return err 720 + } 732 721 733 - cr := cbg.NewCborReader(r) 722 + // t.LexiconTypeID (string) (string) 723 + if len("$type") > 1000000 { 724 + return xerrors.Errorf("Value in field \"$type\" was too long") 725 + } 734 726 735 - maj, extra, err := cr.ReadHeader() 736 - if err != nil { 727 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 728 + return err 729 + } 730 + if _, err := cw.WriteString(string("$type")); err != nil { 737 731 return err 738 732 } 739 - defer func() { 740 - if err == io.EOF { 741 - err = io.ErrUnexpectedEOF 742 - } 743 - }() 744 733 745 - if maj != cbg.MajMap { 746 - return fmt.Errorf("cbor input should be of type map") 734 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.git.refUpdate"))); err != nil { 735 + return err 736 + } 737 + if _, err := cw.WriteString(string("sh.tangled.git.refUpdate")); err != nil { 738 + return err 747 739 } 748 740 749 - if extra > cbg.MaxLength { 750 - return fmt.Errorf("GitRefUpdate_Meta_CommitCount_ByEmail_Elem: map struct too large (%d)", extra) 741 + // t.NewSha (string) (string) 742 + if len("newSha") > 1000000 { 743 + return xerrors.Errorf("Value in field \"newSha\" was too long") 751 744 } 752 745 753 - n := extra 746 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("newSha"))); err != nil { 747 + return err 748 + } 749 + if _, err := cw.WriteString(string("newSha")); err != nil { 750 + return err 751 + } 754 752 755 - nameBuf := make([]byte, 5) 756 - for i := uint64(0); i < n; i++ { 757 - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 758 - if err != nil { 759 - return err 760 - } 753 + if len(t.NewSha) > 1000000 { 754 + return xerrors.Errorf("Value in field t.NewSha was too long") 755 + } 761 756 762 - if !ok { 763 - // Field doesn't exist on this type, so ignore it 764 - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 765 - return err 766 - } 767 - continue 768 - } 757 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.NewSha))); err != nil { 758 + return err 759 + } 760 + if _, err := cw.WriteString(string(t.NewSha)); err != nil { 761 + return err 762 + } 769 763 770 - switch string(nameBuf[:nameLen]) { 771 - // t.Count (int64) (int64) 772 - case "count": 773 - { 774 - maj, extra, err := cr.ReadHeader() 775 - if err != nil { 776 - return err 777 - } 778 - var extraI int64 779 - switch maj { 780 - case cbg.MajUnsignedInt: 781 - extraI = int64(extra) 782 - if extraI < 0 { 783 - return fmt.Errorf("int64 positive overflow") 784 - } 785 - case cbg.MajNegativeInt: 786 - extraI = int64(extra) 787 - if extraI < 0 { 788 - return fmt.Errorf("int64 negative overflow") 789 - } 790 - extraI = -1 - extraI 791 - default: 792 - return fmt.Errorf("wrong type for int64 field: %d", maj) 793 - } 764 + // t.OldSha (string) (string) 765 + if len("oldSha") > 1000000 { 766 + return xerrors.Errorf("Value in field \"oldSha\" was too long") 767 + } 794 768 795 - t.Count = int64(extraI) 796 - } 797 - // t.Email (string) (string) 798 - case "email": 769 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("oldSha"))); err != nil { 770 + return err 771 + } 772 + if _, err := cw.WriteString(string("oldSha")); err != nil { 773 + return err 774 + } 799 775 800 - { 801 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 802 - if err != nil { 803 - return err 804 - } 776 + if len(t.OldSha) > 1000000 { 777 + return xerrors.Errorf("Value in field t.OldSha was too long") 778 + } 805 779 806 - t.Email = string(sval) 807 - } 780 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.OldSha))); err != nil { 781 + return err 782 + } 783 + if _, err := cw.WriteString(string(t.OldSha)); err != nil { 784 + return err 785 + } 808 786 809 - default: 810 - // Field doesn't exist on this type, so ignore it 811 - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 812 - return err 813 - } 814 - } 787 + // t.RepoDid (string) (string) 788 + if len("repoDid") > 1000000 { 789 + return xerrors.Errorf("Value in field \"repoDid\" was too long") 815 790 } 816 791 817 - return nil 818 - } 819 - func (t *GitRefUpdate_Meta_CommitCount) MarshalCBOR(w io.Writer) error { 820 - if t == nil { 821 - _, err := w.Write(cbg.CborNull) 792 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repoDid"))); err != nil { 793 + return err 794 + } 795 + if _, err := cw.WriteString(string("repoDid")); err != nil { 822 796 return err 823 797 } 824 798 825 - cw := cbg.NewCborWriter(w) 826 - fieldCount := 1 799 + if len(t.RepoDid) > 1000000 { 800 + return xerrors.Errorf("Value in field t.RepoDid was too long") 801 + } 802 + 803 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RepoDid))); err != nil { 804 + return err 805 + } 806 + if _, err := cw.WriteString(string(t.RepoDid)); err != nil { 807 + return err 808 + } 827 809 828 - if t.ByEmail == nil { 829 - fieldCount-- 810 + // t.RepoName (string) (string) 811 + if len("repoName") > 1000000 { 812 + return xerrors.Errorf("Value in field \"repoName\" was too long") 830 813 } 831 814 832 - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 815 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repoName"))); err != nil { 816 + return err 817 + } 818 + if _, err := cw.WriteString(string("repoName")); err != nil { 833 819 return err 834 820 } 835 821 836 - // t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice) 837 - if t.ByEmail != nil { 822 + if len(t.RepoName) > 1000000 { 823 + return xerrors.Errorf("Value in field t.RepoName was too long") 824 + } 838 825 839 - if len("byEmail") > 1000000 { 840 - return xerrors.Errorf("Value in field \"byEmail\" was too long") 841 - } 826 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RepoName))); err != nil { 827 + return err 828 + } 829 + if _, err := cw.WriteString(string(t.RepoName)); err != nil { 830 + return err 831 + } 842 832 843 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("byEmail"))); err != nil { 844 - return err 845 - } 846 - if _, err := cw.WriteString(string("byEmail")); err != nil { 847 - return err 848 - } 833 + // t.CommitterDid (string) (string) 834 + if len("committerDid") > 1000000 { 835 + return xerrors.Errorf("Value in field \"committerDid\" was too long") 836 + } 849 837 850 - if len(t.ByEmail) > 8192 { 851 - return xerrors.Errorf("Slice value in field t.ByEmail was too long") 852 - } 838 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("committerDid"))); err != nil { 839 + return err 840 + } 841 + if _, err := cw.WriteString(string("committerDid")); err != nil { 842 + return err 843 + } 853 844 854 - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.ByEmail))); err != nil { 855 - return err 856 - } 857 - for _, v := range t.ByEmail { 858 - if err := v.MarshalCBOR(cw); err != nil { 859 - return err 860 - } 845 + if len(t.CommitterDid) > 1000000 { 846 + return xerrors.Errorf("Value in field t.CommitterDid was too long") 847 + } 861 848 862 - } 849 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CommitterDid))); err != nil { 850 + return err 851 + } 852 + if _, err := cw.WriteString(string(t.CommitterDid)); err != nil { 853 + return err 863 854 } 864 855 return nil 865 856 } 866 857 867 - func (t *GitRefUpdate_Meta_CommitCount) UnmarshalCBOR(r io.Reader) (err error) { 868 - *t = GitRefUpdate_Meta_CommitCount{} 858 + func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) { 859 + *t = GitRefUpdate{} 869 860 870 861 cr := cbg.NewCborReader(r) 871 862 ··· 884 875 } 885 876 886 877 if extra > cbg.MaxLength { 887 - return fmt.Errorf("GitRefUpdate_Meta_CommitCount: map struct too large (%d)", extra) 878 + return fmt.Errorf("GitRefUpdate: map struct too large (%d)", extra) 888 879 } 889 880 890 881 n := extra 891 882 892 - nameBuf := make([]byte, 7) 883 + nameBuf := make([]byte, 12) 893 884 for i := uint64(0); i < n; i++ { 894 885 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 895 886 if err != nil { ··· 905 896 } 906 897 907 898 switch string(nameBuf[:nameLen]) { 908 - // t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice) 909 - case "byEmail": 899 + // t.Ref (string) (string) 900 + case "ref": 901 + 902 + { 903 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 904 + if err != nil { 905 + return err 906 + } 907 + 908 + t.Ref = string(sval) 909 + } 910 + // t.Meta (tangled.GitRefUpdate_Meta) (struct) 911 + case "meta": 912 + 913 + { 914 + 915 + b, err := cr.ReadByte() 916 + if err != nil { 917 + return err 918 + } 919 + if b != cbg.CborNull[0] { 920 + if err := cr.UnreadByte(); err != nil { 921 + return err 922 + } 923 + t.Meta = new(GitRefUpdate_Meta) 924 + if err := t.Meta.UnmarshalCBOR(cr); err != nil { 925 + return xerrors.Errorf("unmarshaling t.Meta pointer: %w", err) 926 + } 927 + } 910 928 911 - maj, extra, err = cr.ReadHeader() 912 - if err != nil { 913 - return err 914 929 } 930 + // t.LexiconTypeID (string) (string) 931 + case "$type": 915 932 916 - if extra > 8192 { 917 - return fmt.Errorf("t.ByEmail: array too large (%d)", extra) 933 + { 934 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 935 + if err != nil { 936 + return err 937 + } 938 + 939 + t.LexiconTypeID = string(sval) 918 940 } 941 + // t.NewSha (string) (string) 942 + case "newSha": 919 943 920 - if maj != cbg.MajArray { 921 - return fmt.Errorf("expected cbor array") 944 + { 945 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 946 + if err != nil { 947 + return err 948 + } 949 + 950 + t.NewSha = string(sval) 922 951 } 952 + // t.OldSha (string) (string) 953 + case "oldSha": 923 954 924 - if extra > 0 { 925 - t.ByEmail = make([]*GitRefUpdate_Meta_CommitCount_ByEmail_Elem, extra) 955 + { 956 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 957 + if err != nil { 958 + return err 959 + } 960 + 961 + t.OldSha = string(sval) 926 962 } 963 + // t.RepoDid (string) (string) 964 + case "repoDid": 927 965 928 - for i := 0; i < int(extra); i++ { 929 - { 930 - var maj byte 931 - var extra uint64 932 - var err error 933 - _ = maj 934 - _ = extra 935 - _ = err 966 + { 967 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 968 + if err != nil { 969 + return err 970 + } 936 971 937 - { 972 + t.RepoDid = string(sval) 973 + } 974 + // t.RepoName (string) (string) 975 + case "repoName": 938 976 939 - b, err := cr.ReadByte() 940 - if err != nil { 941 - return err 942 - } 943 - if b != cbg.CborNull[0] { 944 - if err := cr.UnreadByte(); err != nil { 945 - return err 946 - } 947 - t.ByEmail[i] = new(GitRefUpdate_Meta_CommitCount_ByEmail_Elem) 948 - if err := t.ByEmail[i].UnmarshalCBOR(cr); err != nil { 949 - return xerrors.Errorf("unmarshaling t.ByEmail[i] pointer: %w", err) 950 - } 951 - } 977 + { 978 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 979 + if err != nil { 980 + return err 981 + } 952 982 953 - } 983 + t.RepoName = string(sval) 984 + } 985 + // t.CommitterDid (string) (string) 986 + case "committerDid": 954 987 988 + { 989 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 990 + if err != nil { 991 + return err 955 992 } 993 + 994 + t.CommitterDid = string(sval) 956 995 } 957 996 958 997 default: ··· 1101 1140 1102 1141 return nil 1103 1142 } 1104 - func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error { 1143 + func (t *GitRefUpdate_Meta_CommitCount) MarshalCBOR(w io.Writer) error { 1105 1144 if t == nil { 1106 1145 _, err := w.Write(cbg.CborNull) 1107 1146 return err 1108 1147 } 1109 1148 1110 1149 cw := cbg.NewCborWriter(w) 1150 + fieldCount := 1 1111 1151 1112 - if _, err := cw.Write([]byte{168}); err != nil { 1113 - return err 1114 - } 1115 - 1116 - // t.Ref (string) (string) 1117 - if len("ref") > 1000000 { 1118 - return xerrors.Errorf("Value in field \"ref\" was too long") 1152 + if t.ByEmail == nil { 1153 + fieldCount-- 1119 1154 } 1120 1155 1121 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ref"))); err != nil { 1122 - return err 1123 - } 1124 - if _, err := cw.WriteString(string("ref")); err != nil { 1156 + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 1125 1157 return err 1126 1158 } 1127 1159 1128 - if len(t.Ref) > 1000000 { 1129 - return xerrors.Errorf("Value in field t.Ref was too long") 1130 - } 1160 + // t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice) 1161 + if t.ByEmail != nil { 1131 1162 1132 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Ref))); err != nil { 1133 - return err 1134 - } 1135 - if _, err := cw.WriteString(string(t.Ref)); err != nil { 1136 - return err 1137 - } 1163 + if len("byEmail") > 1000000 { 1164 + return xerrors.Errorf("Value in field \"byEmail\" was too long") 1165 + } 1138 1166 1139 - // t.Meta (tangled.GitRefUpdate_Meta) (struct) 1140 - if len("meta") > 1000000 { 1141 - return xerrors.Errorf("Value in field \"meta\" was too long") 1142 - } 1167 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("byEmail"))); err != nil { 1168 + return err 1169 + } 1170 + if _, err := cw.WriteString(string("byEmail")); err != nil { 1171 + return err 1172 + } 1143 1173 1144 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("meta"))); err != nil { 1145 - return err 1146 - } 1147 - if _, err := cw.WriteString(string("meta")); err != nil { 1148 - return err 1149 - } 1174 + if len(t.ByEmail) > 8192 { 1175 + return xerrors.Errorf("Slice value in field t.ByEmail was too long") 1176 + } 1150 1177 1151 - if err := t.Meta.MarshalCBOR(cw); err != nil { 1152 - return err 1178 + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.ByEmail))); err != nil { 1179 + return err 1180 + } 1181 + for _, v := range t.ByEmail { 1182 + if err := v.MarshalCBOR(cw); err != nil { 1183 + return err 1184 + } 1185 + 1186 + } 1153 1187 } 1188 + return nil 1189 + } 1154 1190 1155 - // t.LexiconTypeID (string) (string) 1156 - if len("$type") > 1000000 { 1157 - return xerrors.Errorf("Value in field \"$type\" was too long") 1158 - } 1191 + func (t *GitRefUpdate_Meta_CommitCount) UnmarshalCBOR(r io.Reader) (err error) { 1192 + *t = GitRefUpdate_Meta_CommitCount{} 1159 1193 1160 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 1161 - return err 1162 - } 1163 - if _, err := cw.WriteString(string("$type")); err != nil { 1164 - return err 1165 - } 1194 + cr := cbg.NewCborReader(r) 1166 1195 1167 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.git.refUpdate"))); err != nil { 1168 - return err 1169 - } 1170 - if _, err := cw.WriteString(string("sh.tangled.git.refUpdate")); err != nil { 1196 + maj, extra, err := cr.ReadHeader() 1197 + if err != nil { 1171 1198 return err 1172 1199 } 1200 + defer func() { 1201 + if err == io.EOF { 1202 + err = io.ErrUnexpectedEOF 1203 + } 1204 + }() 1173 1205 1174 - // t.NewSha (string) (string) 1175 - if len("newSha") > 1000000 { 1176 - return xerrors.Errorf("Value in field \"newSha\" was too long") 1206 + if maj != cbg.MajMap { 1207 + return fmt.Errorf("cbor input should be of type map") 1177 1208 } 1178 1209 1179 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("newSha"))); err != nil { 1180 - return err 1181 - } 1182 - if _, err := cw.WriteString(string("newSha")); err != nil { 1183 - return err 1210 + if extra > cbg.MaxLength { 1211 + return fmt.Errorf("GitRefUpdate_Meta_CommitCount: map struct too large (%d)", extra) 1184 1212 } 1185 1213 1186 - if len(t.NewSha) > 1000000 { 1187 - return xerrors.Errorf("Value in field t.NewSha was too long") 1188 - } 1214 + n := extra 1189 1215 1190 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.NewSha))); err != nil { 1191 - return err 1192 - } 1193 - if _, err := cw.WriteString(string(t.NewSha)); err != nil { 1194 - return err 1195 - } 1216 + nameBuf := make([]byte, 7) 1217 + for i := uint64(0); i < n; i++ { 1218 + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 1219 + if err != nil { 1220 + return err 1221 + } 1196 1222 1197 - // t.OldSha (string) (string) 1198 - if len("oldSha") > 1000000 { 1199 - return xerrors.Errorf("Value in field \"oldSha\" was too long") 1200 - } 1223 + if !ok { 1224 + // Field doesn't exist on this type, so ignore it 1225 + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 1226 + return err 1227 + } 1228 + continue 1229 + } 1201 1230 1202 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("oldSha"))); err != nil { 1203 - return err 1204 - } 1205 - if _, err := cw.WriteString(string("oldSha")); err != nil { 1206 - return err 1207 - } 1231 + switch string(nameBuf[:nameLen]) { 1232 + // t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice) 1233 + case "byEmail": 1208 1234 1209 - if len(t.OldSha) > 1000000 { 1210 - return xerrors.Errorf("Value in field t.OldSha was too long") 1211 - } 1235 + maj, extra, err = cr.ReadHeader() 1236 + if err != nil { 1237 + return err 1238 + } 1212 1239 1213 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.OldSha))); err != nil { 1214 - return err 1215 - } 1216 - if _, err := cw.WriteString(string(t.OldSha)); err != nil { 1217 - return err 1218 - } 1240 + if extra > 8192 { 1241 + return fmt.Errorf("t.ByEmail: array too large (%d)", extra) 1242 + } 1219 1243 1220 - // t.RepoDid (string) (string) 1221 - if len("repoDid") > 1000000 { 1222 - return xerrors.Errorf("Value in field \"repoDid\" was too long") 1223 - } 1244 + if maj != cbg.MajArray { 1245 + return fmt.Errorf("expected cbor array") 1246 + } 1224 1247 1225 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repoDid"))); err != nil { 1226 - return err 1227 - } 1228 - if _, err := cw.WriteString(string("repoDid")); err != nil { 1229 - return err 1230 - } 1248 + if extra > 0 { 1249 + t.ByEmail = make([]*GitRefUpdate_Meta_CommitCount_ByEmail_Elem, extra) 1250 + } 1231 1251 1232 - if len(t.RepoDid) > 1000000 { 1233 - return xerrors.Errorf("Value in field t.RepoDid was too long") 1234 - } 1252 + for i := 0; i < int(extra); i++ { 1253 + { 1254 + var maj byte 1255 + var extra uint64 1256 + var err error 1257 + _ = maj 1258 + _ = extra 1259 + _ = err 1235 1260 1236 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RepoDid))); err != nil { 1237 - return err 1238 - } 1239 - if _, err := cw.WriteString(string(t.RepoDid)); err != nil { 1240 - return err 1241 - } 1261 + { 1242 1262 1243 - // t.RepoName (string) (string) 1244 - if len("repoName") > 1000000 { 1245 - return xerrors.Errorf("Value in field \"repoName\" was too long") 1263 + b, err := cr.ReadByte() 1264 + if err != nil { 1265 + return err 1266 + } 1267 + if b != cbg.CborNull[0] { 1268 + if err := cr.UnreadByte(); err != nil { 1269 + return err 1270 + } 1271 + t.ByEmail[i] = new(GitRefUpdate_Meta_CommitCount_ByEmail_Elem) 1272 + if err := t.ByEmail[i].UnmarshalCBOR(cr); err != nil { 1273 + return xerrors.Errorf("unmarshaling t.ByEmail[i] pointer: %w", err) 1274 + } 1275 + } 1276 + 1277 + } 1278 + 1279 + } 1280 + } 1281 + 1282 + default: 1283 + // Field doesn't exist on this type, so ignore it 1284 + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 1285 + return err 1286 + } 1287 + } 1246 1288 } 1247 1289 1248 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repoName"))); err != nil { 1290 + return nil 1291 + } 1292 + func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) MarshalCBOR(w io.Writer) error { 1293 + if t == nil { 1294 + _, err := w.Write(cbg.CborNull) 1249 1295 return err 1250 1296 } 1251 - if _, err := cw.WriteString(string("repoName")); err != nil { 1297 + 1298 + cw := cbg.NewCborWriter(w) 1299 + 1300 + if _, err := cw.Write([]byte{162}); err != nil { 1252 1301 return err 1253 1302 } 1254 1303 1255 - if len(t.RepoName) > 1000000 { 1256 - return xerrors.Errorf("Value in field t.RepoName was too long") 1304 + // t.Count (int64) (int64) 1305 + if len("count") > 1000000 { 1306 + return xerrors.Errorf("Value in field \"count\" was too long") 1257 1307 } 1258 1308 1259 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RepoName))); err != nil { 1309 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("count"))); err != nil { 1260 1310 return err 1261 1311 } 1262 - if _, err := cw.WriteString(string(t.RepoName)); err != nil { 1312 + if _, err := cw.WriteString(string("count")); err != nil { 1263 1313 return err 1264 1314 } 1265 1315 1266 - // t.CommitterDid (string) (string) 1267 - if len("committerDid") > 1000000 { 1268 - return xerrors.Errorf("Value in field \"committerDid\" was too long") 1316 + if t.Count >= 0 { 1317 + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Count)); err != nil { 1318 + return err 1319 + } 1320 + } else { 1321 + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Count-1)); err != nil { 1322 + return err 1323 + } 1324 + } 1325 + 1326 + // t.Email (string) (string) 1327 + if len("email") > 1000000 { 1328 + return xerrors.Errorf("Value in field \"email\" was too long") 1269 1329 } 1270 1330 1271 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("committerDid"))); err != nil { 1331 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("email"))); err != nil { 1272 1332 return err 1273 1333 } 1274 - if _, err := cw.WriteString(string("committerDid")); err != nil { 1334 + if _, err := cw.WriteString(string("email")); err != nil { 1275 1335 return err 1276 1336 } 1277 1337 1278 - if len(t.CommitterDid) > 1000000 { 1279 - return xerrors.Errorf("Value in field t.CommitterDid was too long") 1338 + if len(t.Email) > 1000000 { 1339 + return xerrors.Errorf("Value in field t.Email was too long") 1280 1340 } 1281 1341 1282 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CommitterDid))); err != nil { 1342 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Email))); err != nil { 1283 1343 return err 1284 1344 } 1285 - if _, err := cw.WriteString(string(t.CommitterDid)); err != nil { 1345 + if _, err := cw.WriteString(string(t.Email)); err != nil { 1286 1346 return err 1287 1347 } 1288 1348 return nil 1289 1349 } 1290 1350 1291 - func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) { 1292 - *t = GitRefUpdate{} 1351 + func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) (err error) { 1352 + *t = GitRefUpdate_Meta_CommitCount_ByEmail_Elem{} 1293 1353 1294 1354 cr := cbg.NewCborReader(r) 1295 1355 ··· 1308 1368 } 1309 1369 1310 1370 if extra > cbg.MaxLength { 1311 - return fmt.Errorf("GitRefUpdate: map struct too large (%d)", extra) 1371 + return fmt.Errorf("GitRefUpdate_Meta_CommitCount_ByEmail_Elem: map struct too large (%d)", extra) 1312 1372 } 1313 1373 1314 1374 n := extra 1315 1375 1316 - nameBuf := make([]byte, 12) 1376 + nameBuf := make([]byte, 5) 1317 1377 for i := uint64(0); i < n; i++ { 1318 1378 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 1319 1379 if err != nil { ··· 1329 1389 } 1330 1390 1331 1391 switch string(nameBuf[:nameLen]) { 1332 - // t.Ref (string) (string) 1333 - case "ref": 1334 - 1392 + // t.Count (int64) (int64) 1393 + case "count": 1335 1394 { 1336 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 1395 + maj, extra, err := cr.ReadHeader() 1337 1396 if err != nil { 1338 1397 return err 1339 1398 } 1340 - 1341 - t.Ref = string(sval) 1342 - } 1343 - // t.Meta (tangled.GitRefUpdate_Meta) (struct) 1344 - case "meta": 1345 - 1346 - { 1347 - 1348 - b, err := cr.ReadByte() 1349 - if err != nil { 1350 - return err 1351 - } 1352 - if b != cbg.CborNull[0] { 1353 - if err := cr.UnreadByte(); err != nil { 1354 - return err 1399 + var extraI int64 1400 + switch maj { 1401 + case cbg.MajUnsignedInt: 1402 + extraI = int64(extra) 1403 + if extraI < 0 { 1404 + return fmt.Errorf("int64 positive overflow") 1355 1405 } 1356 - t.Meta = new(GitRefUpdate_Meta) 1357 - if err := t.Meta.UnmarshalCBOR(cr); err != nil { 1358 - return xerrors.Errorf("unmarshaling t.Meta pointer: %w", err) 1406 + case cbg.MajNegativeInt: 1407 + extraI = int64(extra) 1408 + if extraI < 0 { 1409 + return fmt.Errorf("int64 negative overflow") 1359 1410 } 1411 + extraI = -1 - extraI 1412 + default: 1413 + return fmt.Errorf("wrong type for int64 field: %d", maj) 1360 1414 } 1361 1415 1416 + t.Count = int64(extraI) 1362 1417 } 1363 - // t.LexiconTypeID (string) (string) 1364 - case "$type": 1418 + // t.Email (string) (string) 1419 + case "email": 1365 1420 1366 1421 { 1367 1422 sval, err := cbg.ReadStringWithMax(cr, 1000000) ··· 1369 1424 return err 1370 1425 } 1371 1426 1372 - t.LexiconTypeID = string(sval) 1373 - } 1374 - // t.NewSha (string) (string) 1375 - case "newSha": 1376 - 1377 - { 1378 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 1379 - if err != nil { 1380 - return err 1381 - } 1382 - 1383 - t.NewSha = string(sval) 1384 - } 1385 - // t.OldSha (string) (string) 1386 - case "oldSha": 1387 - 1388 - { 1389 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 1390 - if err != nil { 1391 - return err 1392 - } 1393 - 1394 - t.OldSha = string(sval) 1395 - } 1396 - // t.RepoDid (string) (string) 1397 - case "repoDid": 1398 - 1399 - { 1400 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 1401 - if err != nil { 1402 - return err 1403 - } 1404 - 1405 - t.RepoDid = string(sval) 1406 - } 1407 - // t.RepoName (string) (string) 1408 - case "repoName": 1409 - 1410 - { 1411 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 1412 - if err != nil { 1413 - return err 1414 - } 1415 - 1416 - t.RepoName = string(sval) 1417 - } 1418 - // t.CommitterDid (string) (string) 1419 - case "committerDid": 1420 - 1421 - { 1422 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 1423 - if err != nil { 1424 - return err 1425 - } 1426 - 1427 - t.CommitterDid = string(sval) 1427 + t.Email = string(sval) 1428 1428 } 1429 1429 1430 1430 default: ··· 1799 1799 1800 1800 return nil 1801 1801 } 1802 - func (t *PipelineStatus) MarshalCBOR(w io.Writer) error { 1802 + func (t *Pipeline) MarshalCBOR(w io.Writer) error { 1803 1803 if t == nil { 1804 1804 _, err := w.Write(cbg.CborNull) 1805 1805 return err 1806 1806 } 1807 1807 1808 1808 cw := cbg.NewCborWriter(w) 1809 - fieldCount := 7 1810 - 1811 - if t.Error == nil { 1812 - fieldCount-- 1813 - } 1814 - 1815 - if t.ExitCode == nil { 1816 - fieldCount-- 1817 - } 1818 1809 1819 - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 1810 + if _, err := cw.Write([]byte{163}); err != nil { 1820 1811 return err 1821 1812 } 1822 1813 ··· 1832 1823 return err 1833 1824 } 1834 1825 1835 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline.status"))); err != nil { 1826 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline"))); err != nil { 1836 1827 return err 1837 1828 } 1838 - if _, err := cw.WriteString(string("sh.tangled.pipeline.status")); err != nil { 1829 + if _, err := cw.WriteString(string("sh.tangled.pipeline")); err != nil { 1839 1830 return err 1840 1831 } 1841 1832 1842 - // t.Error (string) (string) 1843 - if t.Error != nil { 1844 - 1845 - if len("error") > 1000000 { 1846 - return xerrors.Errorf("Value in field \"error\" was too long") 1847 - } 1848 - 1849 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("error"))); err != nil { 1850 - return err 1851 - } 1852 - if _, err := cw.WriteString(string("error")); err != nil { 1853 - return err 1854 - } 1855 - 1856 - if t.Error == nil { 1857 - if _, err := cw.Write(cbg.CborNull); err != nil { 1858 - return err 1859 - } 1860 - } else { 1861 - if len(*t.Error) > 1000000 { 1862 - return xerrors.Errorf("Value in field t.Error was too long") 1863 - } 1864 - 1865 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Error))); err != nil { 1866 - return err 1867 - } 1868 - if _, err := cw.WriteString(string(*t.Error)); err != nil { 1869 - return err 1870 - } 1871 - } 1872 - } 1873 - 1874 - // t.Status (string) (string) 1875 - if len("status") > 1000000 { 1876 - return xerrors.Errorf("Value in field \"status\" was too long") 1833 + // t.Workflows ([]*tangled.Pipeline_Workflow) (slice) 1834 + if len("workflows") > 1000000 { 1835 + return xerrors.Errorf("Value in field \"workflows\" was too long") 1877 1836 } 1878 1837 1879 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { 1838 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflows"))); err != nil { 1880 1839 return err 1881 1840 } 1882 - if _, err := cw.WriteString(string("status")); err != nil { 1841 + if _, err := cw.WriteString(string("workflows")); err != nil { 1883 1842 return err 1884 1843 } 1885 1844 1886 - if len(t.Status) > 1000000 { 1887 - return xerrors.Errorf("Value in field t.Status was too long") 1845 + if len(t.Workflows) > 8192 { 1846 + return xerrors.Errorf("Slice value in field t.Workflows was too long") 1888 1847 } 1889 1848 1890 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil { 1891 - return err 1892 - } 1893 - if _, err := cw.WriteString(string(t.Status)); err != nil { 1849 + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Workflows))); err != nil { 1894 1850 return err 1895 1851 } 1896 - 1897 - // t.ExitCode (int64) (int64) 1898 - if t.ExitCode != nil { 1899 - 1900 - if len("exitCode") > 1000000 { 1901 - return xerrors.Errorf("Value in field \"exitCode\" was too long") 1902 - } 1903 - 1904 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("exitCode"))); err != nil { 1905 - return err 1906 - } 1907 - if _, err := cw.WriteString(string("exitCode")); err != nil { 1852 + for _, v := range t.Workflows { 1853 + if err := v.MarshalCBOR(cw); err != nil { 1908 1854 return err 1909 1855 } 1910 1856 1911 - if t.ExitCode == nil { 1912 - if _, err := cw.Write(cbg.CborNull); err != nil { 1913 - return err 1914 - } 1915 - } else { 1916 - if *t.ExitCode >= 0 { 1917 - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.ExitCode)); err != nil { 1918 - return err 1919 - } 1920 - } else { 1921 - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.ExitCode-1)); err != nil { 1922 - return err 1923 - } 1924 - } 1925 - } 1926 - 1927 1857 } 1928 1858 1929 - // t.Pipeline (string) (string) 1930 - if len("pipeline") > 1000000 { 1931 - return xerrors.Errorf("Value in field \"pipeline\" was too long") 1932 - } 1933 - 1934 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pipeline"))); err != nil { 1935 - return err 1936 - } 1937 - if _, err := cw.WriteString(string("pipeline")); err != nil { 1938 - return err 1939 - } 1940 - 1941 - if len(t.Pipeline) > 1000000 { 1942 - return xerrors.Errorf("Value in field t.Pipeline was too long") 1943 - } 1944 - 1945 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pipeline))); err != nil { 1946 - return err 1947 - } 1948 - if _, err := cw.WriteString(string(t.Pipeline)); err != nil { 1949 - return err 1950 - } 1951 - 1952 - // t.Workflow (string) (string) 1953 - if len("workflow") > 1000000 { 1954 - return xerrors.Errorf("Value in field \"workflow\" was too long") 1955 - } 1956 - 1957 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflow"))); err != nil { 1958 - return err 1959 - } 1960 - if _, err := cw.WriteString(string("workflow")); err != nil { 1961 - return err 1962 - } 1963 - 1964 - if len(t.Workflow) > 1000000 { 1965 - return xerrors.Errorf("Value in field t.Workflow was too long") 1966 - } 1967 - 1968 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Workflow))); err != nil { 1969 - return err 1970 - } 1971 - if _, err := cw.WriteString(string(t.Workflow)); err != nil { 1972 - return err 1973 - } 1974 - 1975 - // t.CreatedAt (string) (string) 1976 - if len("createdAt") > 1000000 { 1977 - return xerrors.Errorf("Value in field \"createdAt\" was too long") 1859 + // t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct) 1860 + if len("triggerMetadata") > 1000000 { 1861 + return xerrors.Errorf("Value in field \"triggerMetadata\" was too long") 1978 1862 } 1979 1863 1980 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 1864 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("triggerMetadata"))); err != nil { 1981 1865 return err 1982 1866 } 1983 - if _, err := cw.WriteString(string("createdAt")); err != nil { 1867 + if _, err := cw.WriteString(string("triggerMetadata")); err != nil { 1984 1868 return err 1985 1869 } 1986 1870 1987 - if len(t.CreatedAt) > 1000000 { 1988 - return xerrors.Errorf("Value in field t.CreatedAt was too long") 1989 - } 1990 - 1991 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 1992 - return err 1993 - } 1994 - if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 1871 + if err := t.TriggerMetadata.MarshalCBOR(cw); err != nil { 1995 1872 return err 1996 1873 } 1997 1874 return nil 1998 1875 } 1999 1876 2000 - func (t *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) { 2001 - *t = PipelineStatus{} 1877 + func (t *Pipeline) UnmarshalCBOR(r io.Reader) (err error) { 1878 + *t = Pipeline{} 2002 1879 2003 1880 cr := cbg.NewCborReader(r) 2004 1881 ··· 2017 1894 } 2018 1895 2019 1896 if extra > cbg.MaxLength { 2020 - return fmt.Errorf("PipelineStatus: map struct too large (%d)", extra) 1897 + return fmt.Errorf("Pipeline: map struct too large (%d)", extra) 2021 1898 } 2022 1899 2023 1900 n := extra 2024 1901 2025 - nameBuf := make([]byte, 9) 1902 + nameBuf := make([]byte, 15) 2026 1903 for i := uint64(0); i < n; i++ { 2027 1904 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 2028 1905 if err != nil { ··· 2049 1926 2050 1927 t.LexiconTypeID = string(sval) 2051 1928 } 2052 - // t.Error (string) (string) 2053 - case "error": 2054 - 2055 - { 2056 - b, err := cr.ReadByte() 2057 - if err != nil { 2058 - return err 2059 - } 2060 - if b != cbg.CborNull[0] { 2061 - if err := cr.UnreadByte(); err != nil { 2062 - return err 2063 - } 1929 + // t.Workflows ([]*tangled.Pipeline_Workflow) (slice) 1930 + case "workflows": 2064 1931 2065 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 2066 - if err != nil { 2067 - return err 2068 - } 1932 + maj, extra, err = cr.ReadHeader() 1933 + if err != nil { 1934 + return err 1935 + } 2069 1936 2070 - t.Error = (*string)(&sval) 2071 - } 1937 + if extra > 8192 { 1938 + return fmt.Errorf("t.Workflows: array too large (%d)", extra) 2072 1939 } 2073 - // t.Status (string) (string) 2074 - case "status": 2075 1940 2076 - { 2077 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 2078 - if err != nil { 2079 - return err 2080 - } 1941 + if maj != cbg.MajArray { 1942 + return fmt.Errorf("expected cbor array") 1943 + } 2081 1944 2082 - t.Status = string(sval) 1945 + if extra > 0 { 1946 + t.Workflows = make([]*Pipeline_Workflow, extra) 2083 1947 } 2084 - // t.ExitCode (int64) (int64) 2085 - case "exitCode": 2086 - { 2087 1948 2088 - b, err := cr.ReadByte() 2089 - if err != nil { 2090 - return err 2091 - } 2092 - if b != cbg.CborNull[0] { 2093 - if err := cr.UnreadByte(); err != nil { 2094 - return err 2095 - } 2096 - maj, extra, err := cr.ReadHeader() 2097 - if err != nil { 2098 - return err 2099 - } 2100 - var extraI int64 2101 - switch maj { 2102 - case cbg.MajUnsignedInt: 2103 - extraI = int64(extra) 2104 - if extraI < 0 { 2105 - return fmt.Errorf("int64 positive overflow") 1949 + for i := 0; i < int(extra); i++ { 1950 + { 1951 + var maj byte 1952 + var extra uint64 1953 + var err error 1954 + _ = maj 1955 + _ = extra 1956 + _ = err 1957 + 1958 + { 1959 + 1960 + b, err := cr.ReadByte() 1961 + if err != nil { 1962 + return err 2106 1963 } 2107 - case cbg.MajNegativeInt: 2108 - extraI = int64(extra) 2109 - if extraI < 0 { 2110 - return fmt.Errorf("int64 negative overflow") 1964 + if b != cbg.CborNull[0] { 1965 + if err := cr.UnreadByte(); err != nil { 1966 + return err 1967 + } 1968 + t.Workflows[i] = new(Pipeline_Workflow) 1969 + if err := t.Workflows[i].UnmarshalCBOR(cr); err != nil { 1970 + return xerrors.Errorf("unmarshaling t.Workflows[i] pointer: %w", err) 1971 + } 2111 1972 } 2112 - extraI = -1 - extraI 2113 - default: 2114 - return fmt.Errorf("wrong type for int64 field: %d", maj) 1973 + 2115 1974 } 2116 1975 2117 - t.ExitCode = (*int64)(&extraI) 2118 1976 } 2119 1977 } 2120 - // t.Pipeline (string) (string) 2121 - case "pipeline": 1978 + // t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct) 1979 + case "triggerMetadata": 2122 1980 2123 1981 { 2124 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 2125 - if err != nil { 2126 - return err 2127 - } 2128 1982 2129 - t.Pipeline = string(sval) 2130 - } 2131 - // t.Workflow (string) (string) 2132 - case "workflow": 2133 - 2134 - { 2135 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 1983 + b, err := cr.ReadByte() 2136 1984 if err != nil { 2137 1985 return err 2138 1986 } 2139 - 2140 - t.Workflow = string(sval) 2141 - } 2142 - // t.CreatedAt (string) (string) 2143 - case "createdAt": 2144 - 2145 - { 2146 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 2147 - if err != nil { 2148 - return err 1987 + if b != cbg.CborNull[0] { 1988 + if err := cr.UnreadByte(); err != nil { 1989 + return err 1990 + } 1991 + t.TriggerMetadata = new(Pipeline_TriggerMetadata) 1992 + if err := t.TriggerMetadata.UnmarshalCBOR(cr); err != nil { 1993 + return xerrors.Errorf("unmarshaling t.TriggerMetadata pointer: %w", err) 1994 + } 2149 1995 } 2150 1996 2151 - t.CreatedAt = string(sval) 2152 1997 } 2153 1998 2154 1999 default: ··· 2516 2361 2517 2362 return nil 2518 2363 } 2519 - func (t *Pipeline_ManualTriggerData_Inputs_Elem) MarshalCBOR(w io.Writer) error { 2364 + func (t *Pipeline_ManualTriggerData) MarshalCBOR(w io.Writer) error { 2520 2365 if t == nil { 2521 2366 _, err := w.Write(cbg.CborNull) 2522 2367 return err 2523 2368 } 2524 2369 2525 2370 cw := cbg.NewCborWriter(w) 2526 - 2527 - if _, err := cw.Write([]byte{162}); err != nil { 2528 - return err 2529 - } 2371 + fieldCount := 1 2530 2372 2531 - // t.Key (string) (string) 2532 - if len("key") > 1000000 { 2533 - return xerrors.Errorf("Value in field \"key\" was too long") 2373 + if t.Inputs == nil { 2374 + fieldCount-- 2534 2375 } 2535 2376 2536 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil { 2537 - return err 2538 - } 2539 - if _, err := cw.WriteString(string("key")); err != nil { 2377 + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 2540 2378 return err 2541 2379 } 2542 2380 2543 - if len(t.Key) > 1000000 { 2544 - return xerrors.Errorf("Value in field t.Key was too long") 2545 - } 2381 + // t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice) 2382 + if t.Inputs != nil { 2546 2383 2547 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil { 2548 - return err 2549 - } 2550 - if _, err := cw.WriteString(string(t.Key)); err != nil { 2551 - return err 2552 - } 2384 + if len("inputs") > 1000000 { 2385 + return xerrors.Errorf("Value in field \"inputs\" was too long") 2386 + } 2553 2387 2554 - // t.Value (string) (string) 2555 - if len("value") > 1000000 { 2556 - return xerrors.Errorf("Value in field \"value\" was too long") 2557 - } 2388 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("inputs"))); err != nil { 2389 + return err 2390 + } 2391 + if _, err := cw.WriteString(string("inputs")); err != nil { 2392 + return err 2393 + } 2558 2394 2559 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil { 2560 - return err 2561 - } 2562 - if _, err := cw.WriteString(string("value")); err != nil { 2563 - return err 2564 - } 2395 + if len(t.Inputs) > 8192 { 2396 + return xerrors.Errorf("Slice value in field t.Inputs was too long") 2397 + } 2565 2398 2566 - if len(t.Value) > 1000000 { 2567 - return xerrors.Errorf("Value in field t.Value was too long") 2568 - } 2399 + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Inputs))); err != nil { 2400 + return err 2401 + } 2402 + for _, v := range t.Inputs { 2403 + if err := v.MarshalCBOR(cw); err != nil { 2404 + return err 2405 + } 2569 2406 2570 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil { 2571 - return err 2572 - } 2573 - if _, err := cw.WriteString(string(t.Value)); err != nil { 2574 - return err 2407 + } 2575 2408 } 2576 2409 return nil 2577 2410 } 2578 2411 2579 - func (t *Pipeline_ManualTriggerData_Inputs_Elem) UnmarshalCBOR(r io.Reader) (err error) { 2580 - *t = Pipeline_ManualTriggerData_Inputs_Elem{} 2412 + func (t *Pipeline_ManualTriggerData) UnmarshalCBOR(r io.Reader) (err error) { 2413 + *t = Pipeline_ManualTriggerData{} 2581 2414 2582 2415 cr := cbg.NewCborReader(r) 2583 2416 ··· 2596 2429 } 2597 2430 2598 2431 if extra > cbg.MaxLength { 2599 - return fmt.Errorf("Pipeline_ManualTriggerData_Inputs_Elem: map struct too large (%d)", extra) 2432 + return fmt.Errorf("Pipeline_ManualTriggerData: map struct too large (%d)", extra) 2600 2433 } 2601 2434 2602 2435 n := extra 2603 2436 2604 - nameBuf := make([]byte, 5) 2437 + nameBuf := make([]byte, 6) 2605 2438 for i := uint64(0); i < n; i++ { 2606 2439 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 2607 2440 if err != nil { ··· 2617 2450 } 2618 2451 2619 2452 switch string(nameBuf[:nameLen]) { 2620 - // t.Key (string) (string) 2621 - case "key": 2453 + // t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice) 2454 + case "inputs": 2622 2455 2623 - { 2624 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 2625 - if err != nil { 2626 - return err 2627 - } 2456 + maj, extra, err = cr.ReadHeader() 2457 + if err != nil { 2458 + return err 2459 + } 2628 2460 2629 - t.Key = string(sval) 2461 + if extra > 8192 { 2462 + return fmt.Errorf("t.Inputs: array too large (%d)", extra) 2463 + } 2464 + 2465 + if maj != cbg.MajArray { 2466 + return fmt.Errorf("expected cbor array") 2467 + } 2468 + 2469 + if extra > 0 { 2470 + t.Inputs = make([]*Pipeline_ManualTriggerData_Inputs_Elem, extra) 2630 2471 } 2631 - // t.Value (string) (string) 2632 - case "value": 2472 + 2473 + for i := 0; i < int(extra); i++ { 2474 + { 2475 + var maj byte 2476 + var extra uint64 2477 + var err error 2478 + _ = maj 2479 + _ = extra 2480 + _ = err 2481 + 2482 + { 2633 2483 2634 - { 2635 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 2636 - if err != nil { 2637 - return err 2638 - } 2484 + b, err := cr.ReadByte() 2485 + if err != nil { 2486 + return err 2487 + } 2488 + if b != cbg.CborNull[0] { 2489 + if err := cr.UnreadByte(); err != nil { 2490 + return err 2491 + } 2492 + t.Inputs[i] = new(Pipeline_ManualTriggerData_Inputs_Elem) 2493 + if err := t.Inputs[i].UnmarshalCBOR(cr); err != nil { 2494 + return xerrors.Errorf("unmarshaling t.Inputs[i] pointer: %w", err) 2495 + } 2496 + } 2639 2497 2640 - t.Value = string(sval) 2498 + } 2499 + 2500 + } 2641 2501 } 2642 2502 2643 2503 default: ··· 2650 2510 2651 2511 return nil 2652 2512 } 2653 - func (t *Pipeline_ManualTriggerData) MarshalCBOR(w io.Writer) error { 2513 + func (t *Pipeline_ManualTriggerData_Inputs_Elem) MarshalCBOR(w io.Writer) error { 2654 2514 if t == nil { 2655 2515 _, err := w.Write(cbg.CborNull) 2656 2516 return err 2657 2517 } 2658 2518 2659 2519 cw := cbg.NewCborWriter(w) 2660 - fieldCount := 1 2661 2520 2662 - if t.Inputs == nil { 2663 - fieldCount-- 2521 + if _, err := cw.Write([]byte{162}); err != nil { 2522 + return err 2664 2523 } 2665 2524 2666 - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 2525 + // t.Key (string) (string) 2526 + if len("key") > 1000000 { 2527 + return xerrors.Errorf("Value in field \"key\" was too long") 2528 + } 2529 + 2530 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil { 2531 + return err 2532 + } 2533 + if _, err := cw.WriteString(string("key")); err != nil { 2667 2534 return err 2668 2535 } 2669 2536 2670 - // t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice) 2671 - if t.Inputs != nil { 2537 + if len(t.Key) > 1000000 { 2538 + return xerrors.Errorf("Value in field t.Key was too long") 2539 + } 2672 2540 2673 - if len("inputs") > 1000000 { 2674 - return xerrors.Errorf("Value in field \"inputs\" was too long") 2675 - } 2541 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil { 2542 + return err 2543 + } 2544 + if _, err := cw.WriteString(string(t.Key)); err != nil { 2545 + return err 2546 + } 2676 2547 2677 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("inputs"))); err != nil { 2678 - return err 2679 - } 2680 - if _, err := cw.WriteString(string("inputs")); err != nil { 2681 - return err 2682 - } 2548 + // t.Value (string) (string) 2549 + if len("value") > 1000000 { 2550 + return xerrors.Errorf("Value in field \"value\" was too long") 2551 + } 2683 2552 2684 - if len(t.Inputs) > 8192 { 2685 - return xerrors.Errorf("Slice value in field t.Inputs was too long") 2686 - } 2553 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil { 2554 + return err 2555 + } 2556 + if _, err := cw.WriteString(string("value")); err != nil { 2557 + return err 2558 + } 2687 2559 2688 - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Inputs))); err != nil { 2689 - return err 2690 - } 2691 - for _, v := range t.Inputs { 2692 - if err := v.MarshalCBOR(cw); err != nil { 2693 - return err 2694 - } 2560 + if len(t.Value) > 1000000 { 2561 + return xerrors.Errorf("Value in field t.Value was too long") 2562 + } 2695 2563 2696 - } 2564 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil { 2565 + return err 2566 + } 2567 + if _, err := cw.WriteString(string(t.Value)); err != nil { 2568 + return err 2697 2569 } 2698 2570 return nil 2699 2571 } 2700 2572 2701 - func (t *Pipeline_ManualTriggerData) UnmarshalCBOR(r io.Reader) (err error) { 2702 - *t = Pipeline_ManualTriggerData{} 2573 + func (t *Pipeline_ManualTriggerData_Inputs_Elem) UnmarshalCBOR(r io.Reader) (err error) { 2574 + *t = Pipeline_ManualTriggerData_Inputs_Elem{} 2703 2575 2704 2576 cr := cbg.NewCborReader(r) 2705 2577 ··· 2718 2590 } 2719 2591 2720 2592 if extra > cbg.MaxLength { 2721 - return fmt.Errorf("Pipeline_ManualTriggerData: map struct too large (%d)", extra) 2593 + return fmt.Errorf("Pipeline_ManualTriggerData_Inputs_Elem: map struct too large (%d)", extra) 2722 2594 } 2723 2595 2724 2596 n := extra 2725 2597 2726 - nameBuf := make([]byte, 6) 2598 + nameBuf := make([]byte, 5) 2727 2599 for i := uint64(0); i < n; i++ { 2728 2600 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 2729 2601 if err != nil { ··· 2739 2611 } 2740 2612 2741 2613 switch string(nameBuf[:nameLen]) { 2742 - // t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice) 2743 - case "inputs": 2614 + // t.Key (string) (string) 2615 + case "key": 2744 2616 2745 - maj, extra, err = cr.ReadHeader() 2746 - if err != nil { 2747 - return err 2748 - } 2749 - 2750 - if extra > 8192 { 2751 - return fmt.Errorf("t.Inputs: array too large (%d)", extra) 2752 - } 2753 - 2754 - if maj != cbg.MajArray { 2755 - return fmt.Errorf("expected cbor array") 2756 - } 2617 + { 2618 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 2619 + if err != nil { 2620 + return err 2621 + } 2757 2622 2758 - if extra > 0 { 2759 - t.Inputs = make([]*Pipeline_ManualTriggerData_Inputs_Elem, extra) 2623 + t.Key = string(sval) 2760 2624 } 2625 + // t.Value (string) (string) 2626 + case "value": 2761 2627 2762 - for i := 0; i < int(extra); i++ { 2763 - { 2764 - var maj byte 2765 - var extra uint64 2766 - var err error 2767 - _ = maj 2768 - _ = extra 2769 - _ = err 2628 + { 2629 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 2630 + if err != nil { 2631 + return err 2632 + } 2770 2633 2771 - { 2772 - 2773 - b, err := cr.ReadByte() 2774 - if err != nil { 2775 - return err 2776 - } 2777 - if b != cbg.CborNull[0] { 2778 - if err := cr.UnreadByte(); err != nil { 2779 - return err 2780 - } 2781 - t.Inputs[i] = new(Pipeline_ManualTriggerData_Inputs_Elem) 2782 - if err := t.Inputs[i].UnmarshalCBOR(cr); err != nil { 2783 - return xerrors.Errorf("unmarshaling t.Inputs[i] pointer: %w", err) 2784 - } 2785 - } 2786 - 2787 - } 2788 - 2789 - } 2634 + t.Value = string(sval) 2790 2635 } 2791 2636 2792 2637 default: ··· 3169 3014 3170 3015 return nil 3171 3016 } 3017 + 3172 3018 func (t *Pipeline_Step_Environment_Elem) MarshalCBOR(w io.Writer) error { 3173 3019 if t == nil { 3174 3020 _, err := w.Write(cbg.CborNull) ··· 3303 3149 3304 3150 return nil 3305 3151 } 3152 + func (t *PipelineStatus) MarshalCBOR(w io.Writer) error { 3153 + if t == nil { 3154 + _, err := w.Write(cbg.CborNull) 3155 + return err 3156 + } 3157 + 3158 + cw := cbg.NewCborWriter(w) 3159 + fieldCount := 7 3160 + 3161 + if t.Error == nil { 3162 + fieldCount-- 3163 + } 3164 + 3165 + if t.ExitCode == nil { 3166 + fieldCount-- 3167 + } 3168 + 3169 + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 3170 + return err 3171 + } 3172 + 3173 + // t.LexiconTypeID (string) (string) 3174 + if len("$type") > 1000000 { 3175 + return xerrors.Errorf("Value in field \"$type\" was too long") 3176 + } 3177 + 3178 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 3179 + return err 3180 + } 3181 + if _, err := cw.WriteString(string("$type")); err != nil { 3182 + return err 3183 + } 3184 + 3185 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline.status"))); err != nil { 3186 + return err 3187 + } 3188 + if _, err := cw.WriteString(string("sh.tangled.pipeline.status")); err != nil { 3189 + return err 3190 + } 3191 + 3192 + // t.Error (string) (string) 3193 + if t.Error != nil { 3194 + 3195 + if len("error") > 1000000 { 3196 + return xerrors.Errorf("Value in field \"error\" was too long") 3197 + } 3198 + 3199 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("error"))); err != nil { 3200 + return err 3201 + } 3202 + if _, err := cw.WriteString(string("error")); err != nil { 3203 + return err 3204 + } 3205 + 3206 + if t.Error == nil { 3207 + if _, err := cw.Write(cbg.CborNull); err != nil { 3208 + return err 3209 + } 3210 + } else { 3211 + if len(*t.Error) > 1000000 { 3212 + return xerrors.Errorf("Value in field t.Error was too long") 3213 + } 3214 + 3215 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Error))); err != nil { 3216 + return err 3217 + } 3218 + if _, err := cw.WriteString(string(*t.Error)); err != nil { 3219 + return err 3220 + } 3221 + } 3222 + } 3223 + 3224 + // t.Status (string) (string) 3225 + if len("status") > 1000000 { 3226 + return xerrors.Errorf("Value in field \"status\" was too long") 3227 + } 3228 + 3229 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { 3230 + return err 3231 + } 3232 + if _, err := cw.WriteString(string("status")); err != nil { 3233 + return err 3234 + } 3235 + 3236 + if len(t.Status) > 1000000 { 3237 + return xerrors.Errorf("Value in field t.Status was too long") 3238 + } 3239 + 3240 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil { 3241 + return err 3242 + } 3243 + if _, err := cw.WriteString(string(t.Status)); err != nil { 3244 + return err 3245 + } 3246 + 3247 + // t.ExitCode (int64) (int64) 3248 + if t.ExitCode != nil { 3249 + 3250 + if len("exitCode") > 1000000 { 3251 + return xerrors.Errorf("Value in field \"exitCode\" was too long") 3252 + } 3253 + 3254 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("exitCode"))); err != nil { 3255 + return err 3256 + } 3257 + if _, err := cw.WriteString(string("exitCode")); err != nil { 3258 + return err 3259 + } 3260 + 3261 + if t.ExitCode == nil { 3262 + if _, err := cw.Write(cbg.CborNull); err != nil { 3263 + return err 3264 + } 3265 + } else { 3266 + if *t.ExitCode >= 0 { 3267 + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.ExitCode)); err != nil { 3268 + return err 3269 + } 3270 + } else { 3271 + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.ExitCode-1)); err != nil { 3272 + return err 3273 + } 3274 + } 3275 + } 3276 + 3277 + } 3278 + 3279 + // t.Pipeline (string) (string) 3280 + if len("pipeline") > 1000000 { 3281 + return xerrors.Errorf("Value in field \"pipeline\" was too long") 3282 + } 3283 + 3284 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pipeline"))); err != nil { 3285 + return err 3286 + } 3287 + if _, err := cw.WriteString(string("pipeline")); err != nil { 3288 + return err 3289 + } 3290 + 3291 + if len(t.Pipeline) > 1000000 { 3292 + return xerrors.Errorf("Value in field t.Pipeline was too long") 3293 + } 3294 + 3295 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pipeline))); err != nil { 3296 + return err 3297 + } 3298 + if _, err := cw.WriteString(string(t.Pipeline)); err != nil { 3299 + return err 3300 + } 3301 + 3302 + // t.Workflow (string) (string) 3303 + if len("workflow") > 1000000 { 3304 + return xerrors.Errorf("Value in field \"workflow\" was too long") 3305 + } 3306 + 3307 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflow"))); err != nil { 3308 + return err 3309 + } 3310 + if _, err := cw.WriteString(string("workflow")); err != nil { 3311 + return err 3312 + } 3313 + 3314 + if len(t.Workflow) > 1000000 { 3315 + return xerrors.Errorf("Value in field t.Workflow was too long") 3316 + } 3317 + 3318 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Workflow))); err != nil { 3319 + return err 3320 + } 3321 + if _, err := cw.WriteString(string(t.Workflow)); err != nil { 3322 + return err 3323 + } 3324 + 3325 + // t.CreatedAt (string) (string) 3326 + if len("createdAt") > 1000000 { 3327 + return xerrors.Errorf("Value in field \"createdAt\" was too long") 3328 + } 3329 + 3330 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 3331 + return err 3332 + } 3333 + if _, err := cw.WriteString(string("createdAt")); err != nil { 3334 + return err 3335 + } 3336 + 3337 + if len(t.CreatedAt) > 1000000 { 3338 + return xerrors.Errorf("Value in field t.CreatedAt was too long") 3339 + } 3340 + 3341 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 3342 + return err 3343 + } 3344 + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 3345 + return err 3346 + } 3347 + return nil 3348 + } 3349 + 3350 + func (t *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) { 3351 + *t = PipelineStatus{} 3352 + 3353 + cr := cbg.NewCborReader(r) 3354 + 3355 + maj, extra, err := cr.ReadHeader() 3356 + if err != nil { 3357 + return err 3358 + } 3359 + defer func() { 3360 + if err == io.EOF { 3361 + err = io.ErrUnexpectedEOF 3362 + } 3363 + }() 3364 + 3365 + if maj != cbg.MajMap { 3366 + return fmt.Errorf("cbor input should be of type map") 3367 + } 3368 + 3369 + if extra > cbg.MaxLength { 3370 + return fmt.Errorf("PipelineStatus: map struct too large (%d)", extra) 3371 + } 3372 + 3373 + n := extra 3374 + 3375 + nameBuf := make([]byte, 9) 3376 + for i := uint64(0); i < n; i++ { 3377 + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 3378 + if err != nil { 3379 + return err 3380 + } 3381 + 3382 + if !ok { 3383 + // Field doesn't exist on this type, so ignore it 3384 + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 3385 + return err 3386 + } 3387 + continue 3388 + } 3389 + 3390 + switch string(nameBuf[:nameLen]) { 3391 + // t.LexiconTypeID (string) (string) 3392 + case "$type": 3393 + 3394 + { 3395 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 3396 + if err != nil { 3397 + return err 3398 + } 3399 + 3400 + t.LexiconTypeID = string(sval) 3401 + } 3402 + // t.Error (string) (string) 3403 + case "error": 3404 + 3405 + { 3406 + b, err := cr.ReadByte() 3407 + if err != nil { 3408 + return err 3409 + } 3410 + if b != cbg.CborNull[0] { 3411 + if err := cr.UnreadByte(); err != nil { 3412 + return err 3413 + } 3414 + 3415 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 3416 + if err != nil { 3417 + return err 3418 + } 3419 + 3420 + t.Error = (*string)(&sval) 3421 + } 3422 + } 3423 + // t.Status (string) (string) 3424 + case "status": 3425 + 3426 + { 3427 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 3428 + if err != nil { 3429 + return err 3430 + } 3431 + 3432 + t.Status = string(sval) 3433 + } 3434 + // t.ExitCode (int64) (int64) 3435 + case "exitCode": 3436 + { 3437 + 3438 + b, err := cr.ReadByte() 3439 + if err != nil { 3440 + return err 3441 + } 3442 + if b != cbg.CborNull[0] { 3443 + if err := cr.UnreadByte(); err != nil { 3444 + return err 3445 + } 3446 + maj, extra, err := cr.ReadHeader() 3447 + if err != nil { 3448 + return err 3449 + } 3450 + var extraI int64 3451 + switch maj { 3452 + case cbg.MajUnsignedInt: 3453 + extraI = int64(extra) 3454 + if extraI < 0 { 3455 + return fmt.Errorf("int64 positive overflow") 3456 + } 3457 + case cbg.MajNegativeInt: 3458 + extraI = int64(extra) 3459 + if extraI < 0 { 3460 + return fmt.Errorf("int64 negative overflow") 3461 + } 3462 + extraI = -1 - extraI 3463 + default: 3464 + return fmt.Errorf("wrong type for int64 field: %d", maj) 3465 + } 3466 + 3467 + t.ExitCode = (*int64)(&extraI) 3468 + } 3469 + } 3470 + // t.Pipeline (string) (string) 3471 + case "pipeline": 3472 + 3473 + { 3474 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 3475 + if err != nil { 3476 + return err 3477 + } 3478 + 3479 + t.Pipeline = string(sval) 3480 + } 3481 + // t.Workflow (string) (string) 3482 + case "workflow": 3483 + 3484 + { 3485 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 3486 + if err != nil { 3487 + return err 3488 + } 3489 + 3490 + t.Workflow = string(sval) 3491 + } 3492 + // t.CreatedAt (string) (string) 3493 + case "createdAt": 3494 + 3495 + { 3496 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 3497 + if err != nil { 3498 + return err 3499 + } 3500 + 3501 + t.CreatedAt = string(sval) 3502 + } 3503 + 3504 + default: 3505 + // Field doesn't exist on this type, so ignore it 3506 + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 3507 + return err 3508 + } 3509 + } 3510 + } 3511 + 3512 + return nil 3513 + } 3514 + 3306 3515 func (t *Pipeline_Step) MarshalCBOR(w io.Writer) error { 3307 3516 if t == nil { 3308 3517 _, err := w.Write(cbg.CborNull) ··· 3988 4197 3989 4198 return nil 3990 4199 } 3991 - func (t *Pipeline_Workflow_Environment_Elem) MarshalCBOR(w io.Writer) error { 3992 - if t == nil { 3993 - _, err := w.Write(cbg.CborNull) 3994 - return err 3995 - } 3996 - 3997 - cw := cbg.NewCborWriter(w) 3998 - 3999 - if _, err := cw.Write([]byte{162}); err != nil { 4000 - return err 4001 - } 4002 - 4003 - // t.Key (string) (string) 4004 - if len("key") > 1000000 { 4005 - return xerrors.Errorf("Value in field \"key\" was too long") 4006 - } 4007 - 4008 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil { 4009 - return err 4010 - } 4011 - if _, err := cw.WriteString(string("key")); err != nil { 4012 - return err 4013 - } 4014 - 4015 - if len(t.Key) > 1000000 { 4016 - return xerrors.Errorf("Value in field t.Key was too long") 4017 - } 4018 - 4019 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil { 4020 - return err 4021 - } 4022 - if _, err := cw.WriteString(string(t.Key)); err != nil { 4023 - return err 4024 - } 4025 - 4026 - // t.Value (string) (string) 4027 - if len("value") > 1000000 { 4028 - return xerrors.Errorf("Value in field \"value\" was too long") 4029 - } 4030 - 4031 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil { 4032 - return err 4033 - } 4034 - if _, err := cw.WriteString(string("value")); err != nil { 4035 - return err 4036 - } 4037 - 4038 - if len(t.Value) > 1000000 { 4039 - return xerrors.Errorf("Value in field t.Value was too long") 4040 - } 4041 - 4042 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil { 4043 - return err 4044 - } 4045 - if _, err := cw.WriteString(string(t.Value)); err != nil { 4046 - return err 4047 - } 4048 - return nil 4049 - } 4050 - 4051 - func (t *Pipeline_Workflow_Environment_Elem) UnmarshalCBOR(r io.Reader) (err error) { 4052 - *t = Pipeline_Workflow_Environment_Elem{} 4053 - 4054 - cr := cbg.NewCborReader(r) 4055 - 4056 - maj, extra, err := cr.ReadHeader() 4057 - if err != nil { 4058 - return err 4059 - } 4060 - defer func() { 4061 - if err == io.EOF { 4062 - err = io.ErrUnexpectedEOF 4063 - } 4064 - }() 4065 - 4066 - if maj != cbg.MajMap { 4067 - return fmt.Errorf("cbor input should be of type map") 4068 - } 4069 - 4070 - if extra > cbg.MaxLength { 4071 - return fmt.Errorf("Pipeline_Workflow_Environment_Elem: map struct too large (%d)", extra) 4072 - } 4073 - 4074 - n := extra 4075 - 4076 - nameBuf := make([]byte, 5) 4077 - for i := uint64(0); i < n; i++ { 4078 - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 4079 - if err != nil { 4080 - return err 4081 - } 4082 - 4083 - if !ok { 4084 - // Field doesn't exist on this type, so ignore it 4085 - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 4086 - return err 4087 - } 4088 - continue 4089 - } 4090 - 4091 - switch string(nameBuf[:nameLen]) { 4092 - // t.Key (string) (string) 4093 - case "key": 4094 - 4095 - { 4096 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 4097 - if err != nil { 4098 - return err 4099 - } 4100 - 4101 - t.Key = string(sval) 4102 - } 4103 - // t.Value (string) (string) 4104 - case "value": 4105 - 4106 - { 4107 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 4108 - if err != nil { 4109 - return err 4110 - } 4111 - 4112 - t.Value = string(sval) 4113 - } 4114 - 4115 - default: 4116 - // Field doesn't exist on this type, so ignore it 4117 - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 4118 - return err 4119 - } 4120 - } 4121 - } 4122 - 4123 - return nil 4124 - } 4125 4200 func (t *Pipeline_Workflow) MarshalCBOR(w io.Writer) error { 4126 4201 if t == nil { 4127 4202 _, err := w.Write(cbg.CborNull) ··· 4473 4548 4474 4549 return nil 4475 4550 } 4476 - func (t *Pipeline) MarshalCBOR(w io.Writer) error { 4551 + func (t *Pipeline_Workflow_Environment_Elem) MarshalCBOR(w io.Writer) error { 4477 4552 if t == nil { 4478 4553 _, err := w.Write(cbg.CborNull) 4479 4554 return err ··· 4481 4556 4482 4557 cw := cbg.NewCborWriter(w) 4483 4558 4484 - if _, err := cw.Write([]byte{163}); err != nil { 4559 + if _, err := cw.Write([]byte{162}); err != nil { 4485 4560 return err 4486 4561 } 4487 4562 4488 - // t.LexiconTypeID (string) (string) 4489 - if len("$type") > 1000000 { 4490 - return xerrors.Errorf("Value in field \"$type\" was too long") 4563 + // t.Key (string) (string) 4564 + if len("key") > 1000000 { 4565 + return xerrors.Errorf("Value in field \"key\" was too long") 4491 4566 } 4492 4567 4493 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 4568 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil { 4494 4569 return err 4495 4570 } 4496 - if _, err := cw.WriteString(string("$type")); err != nil { 4571 + if _, err := cw.WriteString(string("key")); err != nil { 4497 4572 return err 4498 4573 } 4499 4574 4500 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline"))); err != nil { 4501 - return err 4502 - } 4503 - if _, err := cw.WriteString(string("sh.tangled.pipeline")); err != nil { 4504 - return err 4575 + if len(t.Key) > 1000000 { 4576 + return xerrors.Errorf("Value in field t.Key was too long") 4505 4577 } 4506 4578 4507 - // t.Workflows ([]*tangled.Pipeline_Workflow) (slice) 4508 - if len("workflows") > 1000000 { 4509 - return xerrors.Errorf("Value in field \"workflows\" was too long") 4510 - } 4511 - 4512 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflows"))); err != nil { 4579 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil { 4513 4580 return err 4514 4581 } 4515 - if _, err := cw.WriteString(string("workflows")); err != nil { 4582 + if _, err := cw.WriteString(string(t.Key)); err != nil { 4516 4583 return err 4517 4584 } 4518 4585 4519 - if len(t.Workflows) > 8192 { 4520 - return xerrors.Errorf("Slice value in field t.Workflows was too long") 4586 + // t.Value (string) (string) 4587 + if len("value") > 1000000 { 4588 + return xerrors.Errorf("Value in field \"value\" was too long") 4521 4589 } 4522 4590 4523 - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Workflows))); err != nil { 4591 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil { 4524 4592 return err 4525 4593 } 4526 - for _, v := range t.Workflows { 4527 - if err := v.MarshalCBOR(cw); err != nil { 4528 - return err 4529 - } 4530 - 4594 + if _, err := cw.WriteString(string("value")); err != nil { 4595 + return err 4531 4596 } 4532 4597 4533 - // t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct) 4534 - if len("triggerMetadata") > 1000000 { 4535 - return xerrors.Errorf("Value in field \"triggerMetadata\" was too long") 4598 + if len(t.Value) > 1000000 { 4599 + return xerrors.Errorf("Value in field t.Value was too long") 4536 4600 } 4537 4601 4538 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("triggerMetadata"))); err != nil { 4602 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil { 4539 4603 return err 4540 4604 } 4541 - if _, err := cw.WriteString(string("triggerMetadata")); err != nil { 4542 - return err 4543 - } 4544 - 4545 - if err := t.TriggerMetadata.MarshalCBOR(cw); err != nil { 4605 + if _, err := cw.WriteString(string(t.Value)); err != nil { 4546 4606 return err 4547 4607 } 4548 4608 return nil 4549 4609 } 4550 4610 4551 - func (t *Pipeline) UnmarshalCBOR(r io.Reader) (err error) { 4552 - *t = Pipeline{} 4611 + func (t *Pipeline_Workflow_Environment_Elem) UnmarshalCBOR(r io.Reader) (err error) { 4612 + *t = Pipeline_Workflow_Environment_Elem{} 4553 4613 4554 4614 cr := cbg.NewCborReader(r) 4555 4615 ··· 4568 4628 } 4569 4629 4570 4630 if extra > cbg.MaxLength { 4571 - return fmt.Errorf("Pipeline: map struct too large (%d)", extra) 4631 + return fmt.Errorf("Pipeline_Workflow_Environment_Elem: map struct too large (%d)", extra) 4572 4632 } 4573 4633 4574 4634 n := extra 4575 4635 4576 - nameBuf := make([]byte, 15) 4636 + nameBuf := make([]byte, 5) 4577 4637 for i := uint64(0); i < n; i++ { 4578 4638 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 4579 4639 if err != nil { ··· 4589 4649 } 4590 4650 4591 4651 switch string(nameBuf[:nameLen]) { 4592 - // t.LexiconTypeID (string) (string) 4593 - case "$type": 4652 + // t.Key (string) (string) 4653 + case "key": 4594 4654 4595 4655 { 4596 4656 sval, err := cbg.ReadStringWithMax(cr, 1000000) ··· 4598 4658 return err 4599 4659 } 4600 4660 4601 - t.LexiconTypeID = string(sval) 4602 - } 4603 - // t.Workflows ([]*tangled.Pipeline_Workflow) (slice) 4604 - case "workflows": 4605 - 4606 - maj, extra, err = cr.ReadHeader() 4607 - if err != nil { 4608 - return err 4609 - } 4610 - 4611 - if extra > 8192 { 4612 - return fmt.Errorf("t.Workflows: array too large (%d)", extra) 4613 - } 4614 - 4615 - if maj != cbg.MajArray { 4616 - return fmt.Errorf("expected cbor array") 4617 - } 4618 - 4619 - if extra > 0 { 4620 - t.Workflows = make([]*Pipeline_Workflow, extra) 4621 - } 4622 - 4623 - for i := 0; i < int(extra); i++ { 4624 - { 4625 - var maj byte 4626 - var extra uint64 4627 - var err error 4628 - _ = maj 4629 - _ = extra 4630 - _ = err 4631 - 4632 - { 4633 - 4634 - b, err := cr.ReadByte() 4635 - if err != nil { 4636 - return err 4637 - } 4638 - if b != cbg.CborNull[0] { 4639 - if err := cr.UnreadByte(); err != nil { 4640 - return err 4641 - } 4642 - t.Workflows[i] = new(Pipeline_Workflow) 4643 - if err := t.Workflows[i].UnmarshalCBOR(cr); err != nil { 4644 - return xerrors.Errorf("unmarshaling t.Workflows[i] pointer: %w", err) 4645 - } 4646 - } 4647 - 4648 - } 4649 - 4650 - } 4661 + t.Key = string(sval) 4651 4662 } 4652 - // t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct) 4653 - case "triggerMetadata": 4663 + // t.Value (string) (string) 4664 + case "value": 4654 4665 4655 4666 { 4656 - 4657 - b, err := cr.ReadByte() 4667 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4658 4668 if err != nil { 4659 4669 return err 4660 4670 } 4661 - if b != cbg.CborNull[0] { 4662 - if err := cr.UnreadByte(); err != nil { 4663 - return err 4664 - } 4665 - t.TriggerMetadata = new(Pipeline_TriggerMetadata) 4666 - if err := t.TriggerMetadata.UnmarshalCBOR(cr); err != nil { 4667 - return xerrors.Errorf("unmarshaling t.TriggerMetadata pointer: %w", err) 4668 - } 4669 - } 4670 4671 4672 + t.Value = string(sval) 4671 4673 } 4672 4674 4673 4675 default: ··· 4878 4880 4879 4881 return nil 4880 4882 } 4883 + func (t *Repo) MarshalCBOR(w io.Writer) error { 4884 + if t == nil { 4885 + _, err := w.Write(cbg.CborNull) 4886 + return err 4887 + } 4888 + 4889 + cw := cbg.NewCborWriter(w) 4890 + fieldCount := 8 4891 + 4892 + if t.Description == nil { 4893 + fieldCount-- 4894 + } 4895 + 4896 + if t.Source == nil { 4897 + fieldCount-- 4898 + } 4899 + 4900 + if t.Spindle == nil { 4901 + fieldCount-- 4902 + } 4903 + 4904 + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 4905 + return err 4906 + } 4907 + 4908 + // t.Knot (string) (string) 4909 + if len("knot") > 1000000 { 4910 + return xerrors.Errorf("Value in field \"knot\" was too long") 4911 + } 4912 + 4913 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("knot"))); err != nil { 4914 + return err 4915 + } 4916 + if _, err := cw.WriteString(string("knot")); err != nil { 4917 + return err 4918 + } 4919 + 4920 + if len(t.Knot) > 1000000 { 4921 + return xerrors.Errorf("Value in field t.Knot was too long") 4922 + } 4923 + 4924 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Knot))); err != nil { 4925 + return err 4926 + } 4927 + if _, err := cw.WriteString(string(t.Knot)); err != nil { 4928 + return err 4929 + } 4930 + 4931 + // t.Name (string) (string) 4932 + if len("name") > 1000000 { 4933 + return xerrors.Errorf("Value in field \"name\" was too long") 4934 + } 4935 + 4936 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { 4937 + return err 4938 + } 4939 + if _, err := cw.WriteString(string("name")); err != nil { 4940 + return err 4941 + } 4942 + 4943 + if len(t.Name) > 1000000 { 4944 + return xerrors.Errorf("Value in field t.Name was too long") 4945 + } 4946 + 4947 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { 4948 + return err 4949 + } 4950 + if _, err := cw.WriteString(string(t.Name)); err != nil { 4951 + return err 4952 + } 4953 + 4954 + // t.LexiconTypeID (string) (string) 4955 + if len("$type") > 1000000 { 4956 + return xerrors.Errorf("Value in field \"$type\" was too long") 4957 + } 4958 + 4959 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 4960 + return err 4961 + } 4962 + if _, err := cw.WriteString(string("$type")); err != nil { 4963 + return err 4964 + } 4965 + 4966 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo"))); err != nil { 4967 + return err 4968 + } 4969 + if _, err := cw.WriteString(string("sh.tangled.repo")); err != nil { 4970 + return err 4971 + } 4972 + 4973 + // t.Owner (string) (string) 4974 + if len("owner") > 1000000 { 4975 + return xerrors.Errorf("Value in field \"owner\" was too long") 4976 + } 4977 + 4978 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { 4979 + return err 4980 + } 4981 + if _, err := cw.WriteString(string("owner")); err != nil { 4982 + return err 4983 + } 4984 + 4985 + if len(t.Owner) > 1000000 { 4986 + return xerrors.Errorf("Value in field t.Owner was too long") 4987 + } 4988 + 4989 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil { 4990 + return err 4991 + } 4992 + if _, err := cw.WriteString(string(t.Owner)); err != nil { 4993 + return err 4994 + } 4995 + 4996 + // t.Source (string) (string) 4997 + if t.Source != nil { 4998 + 4999 + if len("source") > 1000000 { 5000 + return xerrors.Errorf("Value in field \"source\" was too long") 5001 + } 5002 + 5003 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil { 5004 + return err 5005 + } 5006 + if _, err := cw.WriteString(string("source")); err != nil { 5007 + return err 5008 + } 5009 + 5010 + if t.Source == nil { 5011 + if _, err := cw.Write(cbg.CborNull); err != nil { 5012 + return err 5013 + } 5014 + } else { 5015 + if len(*t.Source) > 1000000 { 5016 + return xerrors.Errorf("Value in field t.Source was too long") 5017 + } 5018 + 5019 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Source))); err != nil { 5020 + return err 5021 + } 5022 + if _, err := cw.WriteString(string(*t.Source)); err != nil { 5023 + return err 5024 + } 5025 + } 5026 + } 5027 + 5028 + // t.Spindle (string) (string) 5029 + if t.Spindle != nil { 5030 + 5031 + if len("spindle") > 1000000 { 5032 + return xerrors.Errorf("Value in field \"spindle\" was too long") 5033 + } 5034 + 5035 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("spindle"))); err != nil { 5036 + return err 5037 + } 5038 + if _, err := cw.WriteString(string("spindle")); err != nil { 5039 + return err 5040 + } 5041 + 5042 + if t.Spindle == nil { 5043 + if _, err := cw.Write(cbg.CborNull); err != nil { 5044 + return err 5045 + } 5046 + } else { 5047 + if len(*t.Spindle) > 1000000 { 5048 + return xerrors.Errorf("Value in field t.Spindle was too long") 5049 + } 5050 + 5051 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Spindle))); err != nil { 5052 + return err 5053 + } 5054 + if _, err := cw.WriteString(string(*t.Spindle)); err != nil { 5055 + return err 5056 + } 5057 + } 5058 + } 5059 + 5060 + // t.CreatedAt (string) (string) 5061 + if len("createdAt") > 1000000 { 5062 + return xerrors.Errorf("Value in field \"createdAt\" was too long") 5063 + } 5064 + 5065 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 5066 + return err 5067 + } 5068 + if _, err := cw.WriteString(string("createdAt")); err != nil { 5069 + return err 5070 + } 5071 + 5072 + if len(t.CreatedAt) > 1000000 { 5073 + return xerrors.Errorf("Value in field t.CreatedAt was too long") 5074 + } 5075 + 5076 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 5077 + return err 5078 + } 5079 + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 5080 + return err 5081 + } 5082 + 5083 + // t.Description (string) (string) 5084 + if t.Description != nil { 5085 + 5086 + if len("description") > 1000000 { 5087 + return xerrors.Errorf("Value in field \"description\" was too long") 5088 + } 5089 + 5090 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("description"))); err != nil { 5091 + return err 5092 + } 5093 + if _, err := cw.WriteString(string("description")); err != nil { 5094 + return err 5095 + } 5096 + 5097 + if t.Description == nil { 5098 + if _, err := cw.Write(cbg.CborNull); err != nil { 5099 + return err 5100 + } 5101 + } else { 5102 + if len(*t.Description) > 1000000 { 5103 + return xerrors.Errorf("Value in field t.Description was too long") 5104 + } 5105 + 5106 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Description))); err != nil { 5107 + return err 5108 + } 5109 + if _, err := cw.WriteString(string(*t.Description)); err != nil { 5110 + return err 5111 + } 5112 + } 5113 + } 5114 + return nil 5115 + } 5116 + 5117 + func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) { 5118 + *t = Repo{} 5119 + 5120 + cr := cbg.NewCborReader(r) 5121 + 5122 + maj, extra, err := cr.ReadHeader() 5123 + if err != nil { 5124 + return err 5125 + } 5126 + defer func() { 5127 + if err == io.EOF { 5128 + err = io.ErrUnexpectedEOF 5129 + } 5130 + }() 5131 + 5132 + if maj != cbg.MajMap { 5133 + return fmt.Errorf("cbor input should be of type map") 5134 + } 5135 + 5136 + if extra > cbg.MaxLength { 5137 + return fmt.Errorf("Repo: map struct too large (%d)", extra) 5138 + } 5139 + 5140 + n := extra 5141 + 5142 + nameBuf := make([]byte, 11) 5143 + for i := uint64(0); i < n; i++ { 5144 + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 5145 + if err != nil { 5146 + return err 5147 + } 5148 + 5149 + if !ok { 5150 + // Field doesn't exist on this type, so ignore it 5151 + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 5152 + return err 5153 + } 5154 + continue 5155 + } 5156 + 5157 + switch string(nameBuf[:nameLen]) { 5158 + // t.Knot (string) (string) 5159 + case "knot": 5160 + 5161 + { 5162 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5163 + if err != nil { 5164 + return err 5165 + } 5166 + 5167 + t.Knot = string(sval) 5168 + } 5169 + // t.Name (string) (string) 5170 + case "name": 5171 + 5172 + { 5173 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5174 + if err != nil { 5175 + return err 5176 + } 5177 + 5178 + t.Name = string(sval) 5179 + } 5180 + // t.LexiconTypeID (string) (string) 5181 + case "$type": 5182 + 5183 + { 5184 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5185 + if err != nil { 5186 + return err 5187 + } 5188 + 5189 + t.LexiconTypeID = string(sval) 5190 + } 5191 + // t.Owner (string) (string) 5192 + case "owner": 5193 + 5194 + { 5195 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5196 + if err != nil { 5197 + return err 5198 + } 5199 + 5200 + t.Owner = string(sval) 5201 + } 5202 + // t.Source (string) (string) 5203 + case "source": 5204 + 5205 + { 5206 + b, err := cr.ReadByte() 5207 + if err != nil { 5208 + return err 5209 + } 5210 + if b != cbg.CborNull[0] { 5211 + if err := cr.UnreadByte(); err != nil { 5212 + return err 5213 + } 5214 + 5215 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5216 + if err != nil { 5217 + return err 5218 + } 5219 + 5220 + t.Source = (*string)(&sval) 5221 + } 5222 + } 5223 + // t.Spindle (string) (string) 5224 + case "spindle": 5225 + 5226 + { 5227 + b, err := cr.ReadByte() 5228 + if err != nil { 5229 + return err 5230 + } 5231 + if b != cbg.CborNull[0] { 5232 + if err := cr.UnreadByte(); err != nil { 5233 + return err 5234 + } 5235 + 5236 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5237 + if err != nil { 5238 + return err 5239 + } 5240 + 5241 + t.Spindle = (*string)(&sval) 5242 + } 5243 + } 5244 + // t.CreatedAt (string) (string) 5245 + case "createdAt": 5246 + 5247 + { 5248 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5249 + if err != nil { 5250 + return err 5251 + } 5252 + 5253 + t.CreatedAt = string(sval) 5254 + } 5255 + // t.Description (string) (string) 5256 + case "description": 5257 + 5258 + { 5259 + b, err := cr.ReadByte() 5260 + if err != nil { 5261 + return err 5262 + } 5263 + if b != cbg.CborNull[0] { 5264 + if err := cr.UnreadByte(); err != nil { 5265 + return err 5266 + } 5267 + 5268 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5269 + if err != nil { 5270 + return err 5271 + } 5272 + 5273 + t.Description = (*string)(&sval) 5274 + } 5275 + } 5276 + 5277 + default: 5278 + // Field doesn't exist on this type, so ignore it 5279 + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 5280 + return err 5281 + } 5282 + } 5283 + } 5284 + 5285 + return nil 5286 + } 4881 5287 func (t *RepoArtifact) MarshalCBOR(w io.Writer) error { 4882 5288 if t == nil { 4883 5289 _, err := w.Write(cbg.CborNull) ··· 5168 5574 5169 5575 return nil 5170 5576 } 5577 + func (t *RepoIssue) MarshalCBOR(w io.Writer) error { 5578 + if t == nil { 5579 + _, err := w.Write(cbg.CborNull) 5580 + return err 5581 + } 5582 + 5583 + cw := cbg.NewCborWriter(w) 5584 + fieldCount := 7 5585 + 5586 + if t.Body == nil { 5587 + fieldCount-- 5588 + } 5589 + 5590 + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 5591 + return err 5592 + } 5593 + 5594 + // t.Body (string) (string) 5595 + if t.Body != nil { 5596 + 5597 + if len("body") > 1000000 { 5598 + return xerrors.Errorf("Value in field \"body\" was too long") 5599 + } 5600 + 5601 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { 5602 + return err 5603 + } 5604 + if _, err := cw.WriteString(string("body")); err != nil { 5605 + return err 5606 + } 5607 + 5608 + if t.Body == nil { 5609 + if _, err := cw.Write(cbg.CborNull); err != nil { 5610 + return err 5611 + } 5612 + } else { 5613 + if len(*t.Body) > 1000000 { 5614 + return xerrors.Errorf("Value in field t.Body was too long") 5615 + } 5616 + 5617 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil { 5618 + return err 5619 + } 5620 + if _, err := cw.WriteString(string(*t.Body)); err != nil { 5621 + return err 5622 + } 5623 + } 5624 + } 5625 + 5626 + // t.Repo (string) (string) 5627 + if len("repo") > 1000000 { 5628 + return xerrors.Errorf("Value in field \"repo\" was too long") 5629 + } 5630 + 5631 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { 5632 + return err 5633 + } 5634 + if _, err := cw.WriteString(string("repo")); err != nil { 5635 + return err 5636 + } 5637 + 5638 + if len(t.Repo) > 1000000 { 5639 + return xerrors.Errorf("Value in field t.Repo was too long") 5640 + } 5641 + 5642 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { 5643 + return err 5644 + } 5645 + if _, err := cw.WriteString(string(t.Repo)); err != nil { 5646 + return err 5647 + } 5648 + 5649 + // t.LexiconTypeID (string) (string) 5650 + if len("$type") > 1000000 { 5651 + return xerrors.Errorf("Value in field \"$type\" was too long") 5652 + } 5653 + 5654 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 5655 + return err 5656 + } 5657 + if _, err := cw.WriteString(string("$type")); err != nil { 5658 + return err 5659 + } 5660 + 5661 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue"))); err != nil { 5662 + return err 5663 + } 5664 + if _, err := cw.WriteString(string("sh.tangled.repo.issue")); err != nil { 5665 + return err 5666 + } 5667 + 5668 + // t.Owner (string) (string) 5669 + if len("owner") > 1000000 { 5670 + return xerrors.Errorf("Value in field \"owner\" was too long") 5671 + } 5672 + 5673 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { 5674 + return err 5675 + } 5676 + if _, err := cw.WriteString(string("owner")); err != nil { 5677 + return err 5678 + } 5679 + 5680 + if len(t.Owner) > 1000000 { 5681 + return xerrors.Errorf("Value in field t.Owner was too long") 5682 + } 5683 + 5684 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil { 5685 + return err 5686 + } 5687 + if _, err := cw.WriteString(string(t.Owner)); err != nil { 5688 + return err 5689 + } 5690 + 5691 + // t.Title (string) (string) 5692 + if len("title") > 1000000 { 5693 + return xerrors.Errorf("Value in field \"title\" was too long") 5694 + } 5695 + 5696 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil { 5697 + return err 5698 + } 5699 + if _, err := cw.WriteString(string("title")); err != nil { 5700 + return err 5701 + } 5702 + 5703 + if len(t.Title) > 1000000 { 5704 + return xerrors.Errorf("Value in field t.Title was too long") 5705 + } 5706 + 5707 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil { 5708 + return err 5709 + } 5710 + if _, err := cw.WriteString(string(t.Title)); err != nil { 5711 + return err 5712 + } 5713 + 5714 + // t.IssueId (int64) (int64) 5715 + if len("issueId") > 1000000 { 5716 + return xerrors.Errorf("Value in field \"issueId\" was too long") 5717 + } 5718 + 5719 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issueId"))); err != nil { 5720 + return err 5721 + } 5722 + if _, err := cw.WriteString(string("issueId")); err != nil { 5723 + return err 5724 + } 5725 + 5726 + if t.IssueId >= 0 { 5727 + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.IssueId)); err != nil { 5728 + return err 5729 + } 5730 + } else { 5731 + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.IssueId-1)); err != nil { 5732 + return err 5733 + } 5734 + } 5735 + 5736 + // t.CreatedAt (string) (string) 5737 + if len("createdAt") > 1000000 { 5738 + return xerrors.Errorf("Value in field \"createdAt\" was too long") 5739 + } 5740 + 5741 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 5742 + return err 5743 + } 5744 + if _, err := cw.WriteString(string("createdAt")); err != nil { 5745 + return err 5746 + } 5747 + 5748 + if len(t.CreatedAt) > 1000000 { 5749 + return xerrors.Errorf("Value in field t.CreatedAt was too long") 5750 + } 5751 + 5752 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 5753 + return err 5754 + } 5755 + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 5756 + return err 5757 + } 5758 + return nil 5759 + } 5760 + 5761 + func (t *RepoIssue) UnmarshalCBOR(r io.Reader) (err error) { 5762 + *t = RepoIssue{} 5763 + 5764 + cr := cbg.NewCborReader(r) 5765 + 5766 + maj, extra, err := cr.ReadHeader() 5767 + if err != nil { 5768 + return err 5769 + } 5770 + defer func() { 5771 + if err == io.EOF { 5772 + err = io.ErrUnexpectedEOF 5773 + } 5774 + }() 5775 + 5776 + if maj != cbg.MajMap { 5777 + return fmt.Errorf("cbor input should be of type map") 5778 + } 5779 + 5780 + if extra > cbg.MaxLength { 5781 + return fmt.Errorf("RepoIssue: map struct too large (%d)", extra) 5782 + } 5783 + 5784 + n := extra 5785 + 5786 + nameBuf := make([]byte, 9) 5787 + for i := uint64(0); i < n; i++ { 5788 + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 5789 + if err != nil { 5790 + return err 5791 + } 5792 + 5793 + if !ok { 5794 + // Field doesn't exist on this type, so ignore it 5795 + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 5796 + return err 5797 + } 5798 + continue 5799 + } 5800 + 5801 + switch string(nameBuf[:nameLen]) { 5802 + // t.Body (string) (string) 5803 + case "body": 5804 + 5805 + { 5806 + b, err := cr.ReadByte() 5807 + if err != nil { 5808 + return err 5809 + } 5810 + if b != cbg.CborNull[0] { 5811 + if err := cr.UnreadByte(); err != nil { 5812 + return err 5813 + } 5814 + 5815 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5816 + if err != nil { 5817 + return err 5818 + } 5819 + 5820 + t.Body = (*string)(&sval) 5821 + } 5822 + } 5823 + // t.Repo (string) (string) 5824 + case "repo": 5825 + 5826 + { 5827 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5828 + if err != nil { 5829 + return err 5830 + } 5831 + 5832 + t.Repo = string(sval) 5833 + } 5834 + // t.LexiconTypeID (string) (string) 5835 + case "$type": 5836 + 5837 + { 5838 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5839 + if err != nil { 5840 + return err 5841 + } 5842 + 5843 + t.LexiconTypeID = string(sval) 5844 + } 5845 + // t.Owner (string) (string) 5846 + case "owner": 5847 + 5848 + { 5849 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5850 + if err != nil { 5851 + return err 5852 + } 5853 + 5854 + t.Owner = string(sval) 5855 + } 5856 + // t.Title (string) (string) 5857 + case "title": 5858 + 5859 + { 5860 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5861 + if err != nil { 5862 + return err 5863 + } 5864 + 5865 + t.Title = string(sval) 5866 + } 5867 + // t.IssueId (int64) (int64) 5868 + case "issueId": 5869 + { 5870 + maj, extra, err := cr.ReadHeader() 5871 + if err != nil { 5872 + return err 5873 + } 5874 + var extraI int64 5875 + switch maj { 5876 + case cbg.MajUnsignedInt: 5877 + extraI = int64(extra) 5878 + if extraI < 0 { 5879 + return fmt.Errorf("int64 positive overflow") 5880 + } 5881 + case cbg.MajNegativeInt: 5882 + extraI = int64(extra) 5883 + if extraI < 0 { 5884 + return fmt.Errorf("int64 negative overflow") 5885 + } 5886 + extraI = -1 - extraI 5887 + default: 5888 + return fmt.Errorf("wrong type for int64 field: %d", maj) 5889 + } 5890 + 5891 + t.IssueId = int64(extraI) 5892 + } 5893 + // t.CreatedAt (string) (string) 5894 + case "createdAt": 5895 + 5896 + { 5897 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 5898 + if err != nil { 5899 + return err 5900 + } 5901 + 5902 + t.CreatedAt = string(sval) 5903 + } 5904 + 5905 + default: 5906 + // Field doesn't exist on this type, so ignore it 5907 + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 5908 + return err 5909 + } 5910 + } 5911 + } 5912 + 5913 + return nil 5914 + } 5171 5915 func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error { 5172 5916 if t == nil { 5173 5917 _, err := w.Write(cbg.CborNull) ··· 5717 6461 5718 6462 return nil 5719 6463 } 5720 - func (t *RepoIssue) MarshalCBOR(w io.Writer) error { 6464 + func (t *RepoPull) MarshalCBOR(w io.Writer) error { 5721 6465 if t == nil { 5722 6466 _, err := w.Write(cbg.CborNull) 5723 6467 return err 5724 6468 } 5725 6469 5726 6470 cw := cbg.NewCborWriter(w) 5727 - fieldCount := 7 6471 + fieldCount := 9 5728 6472 5729 6473 if t.Body == nil { 6474 + fieldCount-- 6475 + } 6476 + 6477 + if t.Source == nil { 5730 6478 fieldCount-- 5731 6479 } 5732 6480 ··· 5766 6514 } 5767 6515 } 5768 6516 5769 - // t.Repo (string) (string) 5770 - if len("repo") > 1000000 { 5771 - return xerrors.Errorf("Value in field \"repo\" was too long") 5772 - } 5773 - 5774 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { 5775 - return err 5776 - } 5777 - if _, err := cw.WriteString(string("repo")); err != nil { 5778 - return err 5779 - } 5780 - 5781 - if len(t.Repo) > 1000000 { 5782 - return xerrors.Errorf("Value in field t.Repo was too long") 5783 - } 5784 - 5785 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { 5786 - return err 5787 - } 5788 - if _, err := cw.WriteString(string(t.Repo)); err != nil { 5789 - return err 5790 - } 5791 - 5792 6517 // t.LexiconTypeID (string) (string) 5793 6518 if len("$type") > 1000000 { 5794 6519 return xerrors.Errorf("Value in field \"$type\" was too long") ··· 5801 6526 return err 5802 6527 } 5803 6528 5804 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue"))); err != nil { 6529 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull"))); err != nil { 5805 6530 return err 5806 6531 } 5807 - if _, err := cw.WriteString(string("sh.tangled.repo.issue")); err != nil { 6532 + if _, err := cw.WriteString(string("sh.tangled.repo.pull")); err != nil { 5808 6533 return err 5809 6534 } 5810 6535 5811 - // t.Owner (string) (string) 5812 - if len("owner") > 1000000 { 5813 - return xerrors.Errorf("Value in field \"owner\" was too long") 6536 + // t.Patch (string) (string) 6537 + if len("patch") > 1000000 { 6538 + return xerrors.Errorf("Value in field \"patch\" was too long") 5814 6539 } 5815 6540 5816 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { 6541 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patch"))); err != nil { 5817 6542 return err 5818 6543 } 5819 - if _, err := cw.WriteString(string("owner")); err != nil { 6544 + if _, err := cw.WriteString(string("patch")); err != nil { 5820 6545 return err 5821 6546 } 5822 6547 5823 - if len(t.Owner) > 1000000 { 5824 - return xerrors.Errorf("Value in field t.Owner was too long") 6548 + if len(t.Patch) > 1000000 { 6549 + return xerrors.Errorf("Value in field t.Patch was too long") 5825 6550 } 5826 6551 5827 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil { 6552 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Patch))); err != nil { 5828 6553 return err 5829 6554 } 5830 - if _, err := cw.WriteString(string(t.Owner)); err != nil { 6555 + if _, err := cw.WriteString(string(t.Patch)); err != nil { 5831 6556 return err 5832 6557 } 5833 6558 ··· 5854 6579 return err 5855 6580 } 5856 6581 5857 - // t.IssueId (int64) (int64) 5858 - if len("issueId") > 1000000 { 5859 - return xerrors.Errorf("Value in field \"issueId\" was too long") 6582 + // t.PullId (int64) (int64) 6583 + if len("pullId") > 1000000 { 6584 + return xerrors.Errorf("Value in field \"pullId\" was too long") 5860 6585 } 5861 6586 5862 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issueId"))); err != nil { 6587 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pullId"))); err != nil { 5863 6588 return err 5864 6589 } 5865 - if _, err := cw.WriteString(string("issueId")); err != nil { 6590 + if _, err := cw.WriteString(string("pullId")); err != nil { 5866 6591 return err 5867 6592 } 5868 6593 5869 - if t.IssueId >= 0 { 5870 - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.IssueId)); err != nil { 6594 + if t.PullId >= 0 { 6595 + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.PullId)); err != nil { 5871 6596 return err 5872 6597 } 5873 6598 } else { 5874 - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.IssueId-1)); err != nil { 6599 + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.PullId-1)); err != nil { 6600 + return err 6601 + } 6602 + } 6603 + 6604 + // t.Source (tangled.RepoPull_Source) (struct) 6605 + if t.Source != nil { 6606 + 6607 + if len("source") > 1000000 { 6608 + return xerrors.Errorf("Value in field \"source\" was too long") 6609 + } 6610 + 6611 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil { 6612 + return err 6613 + } 6614 + if _, err := cw.WriteString(string("source")); err != nil { 6615 + return err 6616 + } 6617 + 6618 + if err := t.Source.MarshalCBOR(cw); err != nil { 5875 6619 return err 5876 6620 } 5877 6621 } ··· 5898 6642 if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 5899 6643 return err 5900 6644 } 6645 + 6646 + // t.TargetRepo (string) (string) 6647 + if len("targetRepo") > 1000000 { 6648 + return xerrors.Errorf("Value in field \"targetRepo\" was too long") 6649 + } 6650 + 6651 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetRepo"))); err != nil { 6652 + return err 6653 + } 6654 + if _, err := cw.WriteString(string("targetRepo")); err != nil { 6655 + return err 6656 + } 6657 + 6658 + if len(t.TargetRepo) > 1000000 { 6659 + return xerrors.Errorf("Value in field t.TargetRepo was too long") 6660 + } 6661 + 6662 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetRepo))); err != nil { 6663 + return err 6664 + } 6665 + if _, err := cw.WriteString(string(t.TargetRepo)); err != nil { 6666 + return err 6667 + } 6668 + 6669 + // t.TargetBranch (string) (string) 6670 + if len("targetBranch") > 1000000 { 6671 + return xerrors.Errorf("Value in field \"targetBranch\" was too long") 6672 + } 6673 + 6674 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetBranch"))); err != nil { 6675 + return err 6676 + } 6677 + if _, err := cw.WriteString(string("targetBranch")); err != nil { 6678 + return err 6679 + } 6680 + 6681 + if len(t.TargetBranch) > 1000000 { 6682 + return xerrors.Errorf("Value in field t.TargetBranch was too long") 6683 + } 6684 + 6685 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetBranch))); err != nil { 6686 + return err 6687 + } 6688 + if _, err := cw.WriteString(string(t.TargetBranch)); err != nil { 6689 + return err 6690 + } 5901 6691 return nil 5902 6692 } 5903 6693 5904 - func (t *RepoIssue) UnmarshalCBOR(r io.Reader) (err error) { 5905 - *t = RepoIssue{} 6694 + func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) { 6695 + *t = RepoPull{} 5906 6696 5907 6697 cr := cbg.NewCborReader(r) 5908 6698 ··· 5921 6711 } 5922 6712 5923 6713 if extra > cbg.MaxLength { 5924 - return fmt.Errorf("RepoIssue: map struct too large (%d)", extra) 6714 + return fmt.Errorf("RepoPull: map struct too large (%d)", extra) 5925 6715 } 5926 6716 5927 6717 n := extra 5928 6718 5929 - nameBuf := make([]byte, 9) 6719 + nameBuf := make([]byte, 12) 5930 6720 for i := uint64(0); i < n; i++ { 5931 6721 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 5932 6722 if err != nil { ··· 5963 6753 t.Body = (*string)(&sval) 5964 6754 } 5965 6755 } 5966 - // t.Repo (string) (string) 5967 - case "repo": 5968 - 5969 - { 5970 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 5971 - if err != nil { 5972 - return err 5973 - } 5974 - 5975 - t.Repo = string(sval) 5976 - } 5977 6756 // t.LexiconTypeID (string) (string) 5978 6757 case "$type": 5979 6758 ··· 5985 6764 5986 6765 t.LexiconTypeID = string(sval) 5987 6766 } 5988 - // t.Owner (string) (string) 5989 - case "owner": 6767 + // t.Patch (string) (string) 6768 + case "patch": 5990 6769 5991 6770 { 5992 6771 sval, err := cbg.ReadStringWithMax(cr, 1000000) ··· 5994 6773 return err 5995 6774 } 5996 6775 5997 - t.Owner = string(sval) 6776 + t.Patch = string(sval) 5998 6777 } 5999 6778 // t.Title (string) (string) 6000 6779 case "title": ··· 6007 6786 6008 6787 t.Title = string(sval) 6009 6788 } 6010 - // t.IssueId (int64) (int64) 6011 - case "issueId": 6789 + // t.PullId (int64) (int64) 6790 + case "pullId": 6012 6791 { 6013 6792 maj, extra, err := cr.ReadHeader() 6014 6793 if err != nil { ··· 6031 6810 return fmt.Errorf("wrong type for int64 field: %d", maj) 6032 6811 } 6033 6812 6034 - t.IssueId = int64(extraI) 6813 + t.PullId = int64(extraI) 6814 + } 6815 + // t.Source (tangled.RepoPull_Source) (struct) 6816 + case "source": 6817 + 6818 + { 6819 + 6820 + b, err := cr.ReadByte() 6821 + if err != nil { 6822 + return err 6823 + } 6824 + if b != cbg.CborNull[0] { 6825 + if err := cr.UnreadByte(); err != nil { 6826 + return err 6827 + } 6828 + t.Source = new(RepoPull_Source) 6829 + if err := t.Source.UnmarshalCBOR(cr); err != nil { 6830 + return xerrors.Errorf("unmarshaling t.Source pointer: %w", err) 6831 + } 6832 + } 6833 + 6035 6834 } 6036 6835 // t.CreatedAt (string) (string) 6037 6836 case "createdAt": ··· 6043 6842 } 6044 6843 6045 6844 t.CreatedAt = string(sval) 6845 + } 6846 + // t.TargetRepo (string) (string) 6847 + case "targetRepo": 6848 + 6849 + { 6850 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 6851 + if err != nil { 6852 + return err 6853 + } 6854 + 6855 + t.TargetRepo = string(sval) 6856 + } 6857 + // t.TargetBranch (string) (string) 6858 + case "targetBranch": 6859 + 6860 + { 6861 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 6862 + if err != nil { 6863 + return err 6864 + } 6865 + 6866 + t.TargetBranch = string(sval) 6046 6867 } 6047 6868 6048 6869 default: ··· 6440 7261 6441 7262 return nil 6442 7263 } 6443 - func (t *RepoPullStatus) MarshalCBOR(w io.Writer) error { 6444 - if t == nil { 6445 - _, err := w.Write(cbg.CborNull) 6446 - return err 6447 - } 6448 - 6449 - cw := cbg.NewCborWriter(w) 6450 - 6451 - if _, err := cw.Write([]byte{163}); err != nil { 6452 - return err 6453 - } 6454 - 6455 - // t.Pull (string) (string) 6456 - if len("pull") > 1000000 { 6457 - return xerrors.Errorf("Value in field \"pull\" was too long") 6458 - } 6459 - 6460 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil { 6461 - return err 6462 - } 6463 - if _, err := cw.WriteString(string("pull")); err != nil { 6464 - return err 6465 - } 6466 - 6467 - if len(t.Pull) > 1000000 { 6468 - return xerrors.Errorf("Value in field t.Pull was too long") 6469 - } 6470 - 6471 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pull))); err != nil { 6472 - return err 6473 - } 6474 - if _, err := cw.WriteString(string(t.Pull)); err != nil { 6475 - return err 6476 - } 6477 - 6478 - // t.LexiconTypeID (string) (string) 6479 - if len("$type") > 1000000 { 6480 - return xerrors.Errorf("Value in field \"$type\" was too long") 6481 - } 6482 - 6483 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 6484 - return err 6485 - } 6486 - if _, err := cw.WriteString(string("$type")); err != nil { 6487 - return err 6488 - } 6489 - 6490 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.status"))); err != nil { 6491 - return err 6492 - } 6493 - if _, err := cw.WriteString(string("sh.tangled.repo.pull.status")); err != nil { 6494 - return err 6495 - } 6496 - 6497 - // t.Status (string) (string) 6498 - if len("status") > 1000000 { 6499 - return xerrors.Errorf("Value in field \"status\" was too long") 6500 - } 6501 - 6502 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { 6503 - return err 6504 - } 6505 - if _, err := cw.WriteString(string("status")); err != nil { 6506 - return err 6507 - } 6508 - 6509 - if len(t.Status) > 1000000 { 6510 - return xerrors.Errorf("Value in field t.Status was too long") 6511 - } 6512 - 6513 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil { 6514 - return err 6515 - } 6516 - if _, err := cw.WriteString(string(t.Status)); err != nil { 6517 - return err 6518 - } 6519 - return nil 6520 - } 6521 - 6522 - func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) { 6523 - *t = RepoPullStatus{} 6524 - 6525 - cr := cbg.NewCborReader(r) 6526 - 6527 - maj, extra, err := cr.ReadHeader() 6528 - if err != nil { 6529 - return err 6530 - } 6531 - defer func() { 6532 - if err == io.EOF { 6533 - err = io.ErrUnexpectedEOF 6534 - } 6535 - }() 6536 - 6537 - if maj != cbg.MajMap { 6538 - return fmt.Errorf("cbor input should be of type map") 6539 - } 6540 - 6541 - if extra > cbg.MaxLength { 6542 - return fmt.Errorf("RepoPullStatus: map struct too large (%d)", extra) 6543 - } 6544 - 6545 - n := extra 6546 - 6547 - nameBuf := make([]byte, 6) 6548 - for i := uint64(0); i < n; i++ { 6549 - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 6550 - if err != nil { 6551 - return err 6552 - } 6553 - 6554 - if !ok { 6555 - // Field doesn't exist on this type, so ignore it 6556 - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 6557 - return err 6558 - } 6559 - continue 6560 - } 6561 - 6562 - switch string(nameBuf[:nameLen]) { 6563 - // t.Pull (string) (string) 6564 - case "pull": 6565 - 6566 - { 6567 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 6568 - if err != nil { 6569 - return err 6570 - } 6571 - 6572 - t.Pull = string(sval) 6573 - } 6574 - // t.LexiconTypeID (string) (string) 6575 - case "$type": 6576 - 6577 - { 6578 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 6579 - if err != nil { 6580 - return err 6581 - } 6582 - 6583 - t.LexiconTypeID = string(sval) 6584 - } 6585 - // t.Status (string) (string) 6586 - case "status": 6587 - 6588 - { 6589 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 6590 - if err != nil { 6591 - return err 6592 - } 6593 - 6594 - t.Status = string(sval) 6595 - } 6596 - 6597 - default: 6598 - // Field doesn't exist on this type, so ignore it 6599 - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 6600 - return err 6601 - } 6602 - } 6603 - } 6604 - 6605 - return nil 6606 - } 6607 7264 func (t *RepoPull_Source) MarshalCBOR(w io.Writer) error { 6608 7265 if t == nil { 6609 7266 _, err := w.Write(cbg.CborNull) ··· 6762 7419 6763 7420 return nil 6764 7421 } 6765 - func (t *RepoPull) MarshalCBOR(w io.Writer) error { 7422 + func (t *RepoPullStatus) MarshalCBOR(w io.Writer) error { 6766 7423 if t == nil { 6767 7424 _, err := w.Write(cbg.CborNull) 6768 7425 return err 6769 7426 } 6770 7427 6771 7428 cw := cbg.NewCborWriter(w) 6772 - fieldCount := 9 6773 7429 6774 - if t.Body == nil { 6775 - fieldCount-- 6776 - } 6777 - 6778 - if t.Source == nil { 6779 - fieldCount-- 6780 - } 6781 - 6782 - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 7430 + if _, err := cw.Write([]byte{163}); err != nil { 6783 7431 return err 6784 7432 } 6785 7433 6786 - // t.Body (string) (string) 6787 - if t.Body != nil { 6788 - 6789 - if len("body") > 1000000 { 6790 - return xerrors.Errorf("Value in field \"body\" was too long") 6791 - } 6792 - 6793 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { 6794 - return err 6795 - } 6796 - if _, err := cw.WriteString(string("body")); err != nil { 6797 - return err 6798 - } 6799 - 6800 - if t.Body == nil { 6801 - if _, err := cw.Write(cbg.CborNull); err != nil { 6802 - return err 6803 - } 6804 - } else { 6805 - if len(*t.Body) > 1000000 { 6806 - return xerrors.Errorf("Value in field t.Body was too long") 6807 - } 6808 - 6809 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil { 6810 - return err 6811 - } 6812 - if _, err := cw.WriteString(string(*t.Body)); err != nil { 6813 - return err 6814 - } 6815 - } 7434 + // t.Pull (string) (string) 7435 + if len("pull") > 1000000 { 7436 + return xerrors.Errorf("Value in field \"pull\" was too long") 6816 7437 } 6817 7438 6818 - // t.LexiconTypeID (string) (string) 6819 - if len("$type") > 1000000 { 6820 - return xerrors.Errorf("Value in field \"$type\" was too long") 6821 - } 6822 - 6823 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 6824 - return err 6825 - } 6826 - if _, err := cw.WriteString(string("$type")); err != nil { 6827 - return err 6828 - } 6829 - 6830 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull"))); err != nil { 6831 - return err 6832 - } 6833 - if _, err := cw.WriteString(string("sh.tangled.repo.pull")); err != nil { 6834 - return err 6835 - } 6836 - 6837 - // t.Patch (string) (string) 6838 - if len("patch") > 1000000 { 6839 - return xerrors.Errorf("Value in field \"patch\" was too long") 6840 - } 6841 - 6842 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patch"))); err != nil { 6843 - return err 6844 - } 6845 - if _, err := cw.WriteString(string("patch")); err != nil { 6846 - return err 6847 - } 6848 - 6849 - if len(t.Patch) > 1000000 { 6850 - return xerrors.Errorf("Value in field t.Patch was too long") 6851 - } 6852 - 6853 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Patch))); err != nil { 6854 - return err 6855 - } 6856 - if _, err := cw.WriteString(string(t.Patch)); err != nil { 6857 - return err 6858 - } 6859 - 6860 - // t.Title (string) (string) 6861 - if len("title") > 1000000 { 6862 - return xerrors.Errorf("Value in field \"title\" was too long") 6863 - } 6864 - 6865 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil { 6866 - return err 6867 - } 6868 - if _, err := cw.WriteString(string("title")); err != nil { 6869 - return err 6870 - } 6871 - 6872 - if len(t.Title) > 1000000 { 6873 - return xerrors.Errorf("Value in field t.Title was too long") 6874 - } 6875 - 6876 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil { 6877 - return err 6878 - } 6879 - if _, err := cw.WriteString(string(t.Title)); err != nil { 6880 - return err 6881 - } 6882 - 6883 - // t.PullId (int64) (int64) 6884 - if len("pullId") > 1000000 { 6885 - return xerrors.Errorf("Value in field \"pullId\" was too long") 6886 - } 6887 - 6888 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pullId"))); err != nil { 7439 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil { 6889 7440 return err 6890 7441 } 6891 - if _, err := cw.WriteString(string("pullId")); err != nil { 6892 - return err 6893 - } 6894 - 6895 - if t.PullId >= 0 { 6896 - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.PullId)); err != nil { 6897 - return err 6898 - } 6899 - } else { 6900 - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.PullId-1)); err != nil { 6901 - return err 6902 - } 6903 - } 6904 - 6905 - // t.Source (tangled.RepoPull_Source) (struct) 6906 - if t.Source != nil { 6907 - 6908 - if len("source") > 1000000 { 6909 - return xerrors.Errorf("Value in field \"source\" was too long") 6910 - } 6911 - 6912 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil { 6913 - return err 6914 - } 6915 - if _, err := cw.WriteString(string("source")); err != nil { 6916 - return err 6917 - } 6918 - 6919 - if err := t.Source.MarshalCBOR(cw); err != nil { 6920 - return err 6921 - } 6922 - } 6923 - 6924 - // t.CreatedAt (string) (string) 6925 - if len("createdAt") > 1000000 { 6926 - return xerrors.Errorf("Value in field \"createdAt\" was too long") 6927 - } 6928 - 6929 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 6930 - return err 6931 - } 6932 - if _, err := cw.WriteString(string("createdAt")); err != nil { 7442 + if _, err := cw.WriteString(string("pull")); err != nil { 6933 7443 return err 6934 7444 } 6935 7445 6936 - if len(t.CreatedAt) > 1000000 { 6937 - return xerrors.Errorf("Value in field t.CreatedAt was too long") 7446 + if len(t.Pull) > 1000000 { 7447 + return xerrors.Errorf("Value in field t.Pull was too long") 6938 7448 } 6939 7449 6940 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 7450 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pull))); err != nil { 6941 7451 return err 6942 7452 } 6943 - if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 7453 + if _, err := cw.WriteString(string(t.Pull)); err != nil { 6944 7454 return err 6945 7455 } 6946 7456 6947 - // t.TargetRepo (string) (string) 6948 - if len("targetRepo") > 1000000 { 6949 - return xerrors.Errorf("Value in field \"targetRepo\" was too long") 7457 + // t.LexiconTypeID (string) (string) 7458 + if len("$type") > 1000000 { 7459 + return xerrors.Errorf("Value in field \"$type\" was too long") 6950 7460 } 6951 7461 6952 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetRepo"))); err != nil { 7462 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 6953 7463 return err 6954 7464 } 6955 - if _, err := cw.WriteString(string("targetRepo")); err != nil { 7465 + if _, err := cw.WriteString(string("$type")); err != nil { 6956 7466 return err 6957 7467 } 6958 7468 6959 - if len(t.TargetRepo) > 1000000 { 6960 - return xerrors.Errorf("Value in field t.TargetRepo was too long") 6961 - } 6962 - 6963 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetRepo))); err != nil { 7469 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.status"))); err != nil { 6964 7470 return err 6965 7471 } 6966 - if _, err := cw.WriteString(string(t.TargetRepo)); err != nil { 7472 + if _, err := cw.WriteString(string("sh.tangled.repo.pull.status")); err != nil { 6967 7473 return err 6968 7474 } 6969 7475 6970 - // t.TargetBranch (string) (string) 6971 - if len("targetBranch") > 1000000 { 6972 - return xerrors.Errorf("Value in field \"targetBranch\" was too long") 7476 + // t.Status (string) (string) 7477 + if len("status") > 1000000 { 7478 + return xerrors.Errorf("Value in field \"status\" was too long") 6973 7479 } 6974 7480 6975 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetBranch"))); err != nil { 7481 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { 6976 7482 return err 6977 7483 } 6978 - if _, err := cw.WriteString(string("targetBranch")); err != nil { 7484 + if _, err := cw.WriteString(string("status")); err != nil { 6979 7485 return err 6980 7486 } 6981 7487 6982 - if len(t.TargetBranch) > 1000000 { 6983 - return xerrors.Errorf("Value in field t.TargetBranch was too long") 7488 + if len(t.Status) > 1000000 { 7489 + return xerrors.Errorf("Value in field t.Status was too long") 6984 7490 } 6985 7491 6986 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetBranch))); err != nil { 7492 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil { 6987 7493 return err 6988 7494 } 6989 - if _, err := cw.WriteString(string(t.TargetBranch)); err != nil { 7495 + if _, err := cw.WriteString(string(t.Status)); err != nil { 6990 7496 return err 6991 7497 } 6992 7498 return nil 6993 7499 } 6994 7500 6995 - func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) { 6996 - *t = RepoPull{} 7501 + func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) { 7502 + *t = RepoPullStatus{} 6997 7503 6998 7504 cr := cbg.NewCborReader(r) 6999 7505 ··· 7012 7518 } 7013 7519 7014 7520 if extra > cbg.MaxLength { 7015 - return fmt.Errorf("RepoPull: map struct too large (%d)", extra) 7521 + return fmt.Errorf("RepoPullStatus: map struct too large (%d)", extra) 7016 7522 } 7017 7523 7018 7524 n := extra 7019 7525 7020 - nameBuf := make([]byte, 12) 7526 + nameBuf := make([]byte, 6) 7021 7527 for i := uint64(0); i < n; i++ { 7022 7528 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 7023 7529 if err != nil { ··· 7033 7539 } 7034 7540 7035 7541 switch string(nameBuf[:nameLen]) { 7036 - // t.Body (string) (string) 7037 - case "body": 7542 + // t.Pull (string) (string) 7543 + case "pull": 7038 7544 7039 7545 { 7040 - b, err := cr.ReadByte() 7546 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 7041 7547 if err != nil { 7042 7548 return err 7043 7549 } 7044 - if b != cbg.CborNull[0] { 7045 - if err := cr.UnreadByte(); err != nil { 7046 - return err 7047 - } 7048 7550 7049 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 7050 - if err != nil { 7051 - return err 7052 - } 7053 - 7054 - t.Body = (*string)(&sval) 7055 - } 7551 + t.Pull = string(sval) 7056 7552 } 7057 7553 // t.LexiconTypeID (string) (string) 7058 7554 case "$type": ··· 7065 7561 7066 7562 t.LexiconTypeID = string(sval) 7067 7563 } 7068 - // t.Patch (string) (string) 7069 - case "patch": 7070 - 7071 - { 7072 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 7073 - if err != nil { 7074 - return err 7075 - } 7076 - 7077 - t.Patch = string(sval) 7078 - } 7079 - // t.Title (string) (string) 7080 - case "title": 7081 - 7082 - { 7083 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 7084 - if err != nil { 7085 - return err 7086 - } 7087 - 7088 - t.Title = string(sval) 7089 - } 7090 - // t.PullId (int64) (int64) 7091 - case "pullId": 7092 - { 7093 - maj, extra, err := cr.ReadHeader() 7094 - if err != nil { 7095 - return err 7096 - } 7097 - var extraI int64 7098 - switch maj { 7099 - case cbg.MajUnsignedInt: 7100 - extraI = int64(extra) 7101 - if extraI < 0 { 7102 - return fmt.Errorf("int64 positive overflow") 7103 - } 7104 - case cbg.MajNegativeInt: 7105 - extraI = int64(extra) 7106 - if extraI < 0 { 7107 - return fmt.Errorf("int64 negative overflow") 7108 - } 7109 - extraI = -1 - extraI 7110 - default: 7111 - return fmt.Errorf("wrong type for int64 field: %d", maj) 7112 - } 7113 - 7114 - t.PullId = int64(extraI) 7115 - } 7116 - // t.Source (tangled.RepoPull_Source) (struct) 7117 - case "source": 7118 - 7119 - { 7120 - 7121 - b, err := cr.ReadByte() 7122 - if err != nil { 7123 - return err 7124 - } 7125 - if b != cbg.CborNull[0] { 7126 - if err := cr.UnreadByte(); err != nil { 7127 - return err 7128 - } 7129 - t.Source = new(RepoPull_Source) 7130 - if err := t.Source.UnmarshalCBOR(cr); err != nil { 7131 - return xerrors.Errorf("unmarshaling t.Source pointer: %w", err) 7132 - } 7133 - } 7134 - 7135 - } 7136 - // t.CreatedAt (string) (string) 7137 - case "createdAt": 7138 - 7139 - { 7140 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 7141 - if err != nil { 7142 - return err 7143 - } 7144 - 7145 - t.CreatedAt = string(sval) 7146 - } 7147 - // t.TargetRepo (string) (string) 7148 - case "targetRepo": 7564 + // t.Status (string) (string) 7565 + case "status": 7149 7566 7150 7567 { 7151 7568 sval, err := cbg.ReadStringWithMax(cr, 1000000) ··· 7153 7570 return err 7154 7571 } 7155 7572 7156 - t.TargetRepo = string(sval) 7157 - } 7158 - // t.TargetBranch (string) (string) 7159 - case "targetBranch": 7160 - 7161 - { 7162 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 7163 - if err != nil { 7164 - return err 7165 - } 7166 - 7167 - t.TargetBranch = string(sval) 7573 + t.Status = string(sval) 7168 7574 } 7169 7575 7170 7576 default: ··· 7177 7583 7178 7584 return nil 7179 7585 } 7180 - func (t *Repo) MarshalCBOR(w io.Writer) error { 7586 + func (t *Spindle) MarshalCBOR(w io.Writer) error { 7181 7587 if t == nil { 7182 7588 _, err := w.Write(cbg.CborNull) 7183 7589 return err 7184 7590 } 7185 7591 7186 7592 cw := cbg.NewCborWriter(w) 7187 - fieldCount := 8 7188 7593 7189 - if t.Description == nil { 7190 - fieldCount-- 7191 - } 7192 - 7193 - if t.Source == nil { 7194 - fieldCount-- 7195 - } 7196 - 7197 - if t.Spindle == nil { 7198 - fieldCount-- 7199 - } 7200 - 7201 - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 7202 - return err 7203 - } 7204 - 7205 - // t.Knot (string) (string) 7206 - if len("knot") > 1000000 { 7207 - return xerrors.Errorf("Value in field \"knot\" was too long") 7208 - } 7209 - 7210 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("knot"))); err != nil { 7211 - return err 7212 - } 7213 - if _, err := cw.WriteString(string("knot")); err != nil { 7214 - return err 7215 - } 7216 - 7217 - if len(t.Knot) > 1000000 { 7218 - return xerrors.Errorf("Value in field t.Knot was too long") 7219 - } 7220 - 7221 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Knot))); err != nil { 7222 - return err 7223 - } 7224 - if _, err := cw.WriteString(string(t.Knot)); err != nil { 7225 - return err 7226 - } 7227 - 7228 - // t.Name (string) (string) 7229 - if len("name") > 1000000 { 7230 - return xerrors.Errorf("Value in field \"name\" was too long") 7231 - } 7232 - 7233 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { 7234 - return err 7235 - } 7236 - if _, err := cw.WriteString(string("name")); err != nil { 7237 - return err 7238 - } 7239 - 7240 - if len(t.Name) > 1000000 { 7241 - return xerrors.Errorf("Value in field t.Name was too long") 7242 - } 7243 - 7244 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { 7245 - return err 7246 - } 7247 - if _, err := cw.WriteString(string(t.Name)); err != nil { 7594 + if _, err := cw.Write([]byte{162}); err != nil { 7248 7595 return err 7249 7596 } 7250 7597 ··· 7260 7607 return err 7261 7608 } 7262 7609 7263 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo"))); err != nil { 7610 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.spindle"))); err != nil { 7264 7611 return err 7265 7612 } 7266 - if _, err := cw.WriteString(string("sh.tangled.repo")); err != nil { 7613 + if _, err := cw.WriteString(string("sh.tangled.spindle")); err != nil { 7267 7614 return err 7268 7615 } 7269 7616 7270 - // t.Owner (string) (string) 7271 - if len("owner") > 1000000 { 7272 - return xerrors.Errorf("Value in field \"owner\" was too long") 7273 - } 7274 - 7275 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { 7276 - return err 7277 - } 7278 - if _, err := cw.WriteString(string("owner")); err != nil { 7279 - return err 7280 - } 7281 - 7282 - if len(t.Owner) > 1000000 { 7283 - return xerrors.Errorf("Value in field t.Owner was too long") 7284 - } 7285 - 7286 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil { 7287 - return err 7288 - } 7289 - if _, err := cw.WriteString(string(t.Owner)); err != nil { 7290 - return err 7291 - } 7292 - 7293 - // t.Source (string) (string) 7294 - if t.Source != nil { 7295 - 7296 - if len("source") > 1000000 { 7297 - return xerrors.Errorf("Value in field \"source\" was too long") 7298 - } 7299 - 7300 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil { 7301 - return err 7302 - } 7303 - if _, err := cw.WriteString(string("source")); err != nil { 7304 - return err 7305 - } 7306 - 7307 - if t.Source == nil { 7308 - if _, err := cw.Write(cbg.CborNull); err != nil { 7309 - return err 7310 - } 7311 - } else { 7312 - if len(*t.Source) > 1000000 { 7313 - return xerrors.Errorf("Value in field t.Source was too long") 7314 - } 7315 - 7316 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Source))); err != nil { 7317 - return err 7318 - } 7319 - if _, err := cw.WriteString(string(*t.Source)); err != nil { 7320 - return err 7321 - } 7322 - } 7323 - } 7324 - 7325 - // t.Spindle (string) (string) 7326 - if t.Spindle != nil { 7327 - 7328 - if len("spindle") > 1000000 { 7329 - return xerrors.Errorf("Value in field \"spindle\" was too long") 7330 - } 7331 - 7332 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("spindle"))); err != nil { 7333 - return err 7334 - } 7335 - if _, err := cw.WriteString(string("spindle")); err != nil { 7336 - return err 7337 - } 7338 - 7339 - if t.Spindle == nil { 7340 - if _, err := cw.Write(cbg.CborNull); err != nil { 7341 - return err 7342 - } 7343 - } else { 7344 - if len(*t.Spindle) > 1000000 { 7345 - return xerrors.Errorf("Value in field t.Spindle was too long") 7346 - } 7347 - 7348 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Spindle))); err != nil { 7349 - return err 7350 - } 7351 - if _, err := cw.WriteString(string(*t.Spindle)); err != nil { 7352 - return err 7353 - } 7354 - } 7355 - } 7356 - 7357 7617 // t.CreatedAt (string) (string) 7358 7618 if len("createdAt") > 1000000 { 7359 7619 return xerrors.Errorf("Value in field \"createdAt\" was too long") ··· 7376 7636 if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 7377 7637 return err 7378 7638 } 7379 - 7380 - // t.Description (string) (string) 7381 - if t.Description != nil { 7382 - 7383 - if len("description") > 1000000 { 7384 - return xerrors.Errorf("Value in field \"description\" was too long") 7385 - } 7386 - 7387 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("description"))); err != nil { 7388 - return err 7389 - } 7390 - if _, err := cw.WriteString(string("description")); err != nil { 7391 - return err 7392 - } 7393 - 7394 - if t.Description == nil { 7395 - if _, err := cw.Write(cbg.CborNull); err != nil { 7396 - return err 7397 - } 7398 - } else { 7399 - if len(*t.Description) > 1000000 { 7400 - return xerrors.Errorf("Value in field t.Description was too long") 7401 - } 7402 - 7403 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Description))); err != nil { 7404 - return err 7405 - } 7406 - if _, err := cw.WriteString(string(*t.Description)); err != nil { 7407 - return err 7408 - } 7409 - } 7410 - } 7411 7639 return nil 7412 7640 } 7413 7641 7414 - func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) { 7415 - *t = Repo{} 7642 + func (t *Spindle) UnmarshalCBOR(r io.Reader) (err error) { 7643 + *t = Spindle{} 7416 7644 7417 7645 cr := cbg.NewCborReader(r) 7418 7646 ··· 7431 7659 } 7432 7660 7433 7661 if extra > cbg.MaxLength { 7434 - return fmt.Errorf("Repo: map struct too large (%d)", extra) 7662 + return fmt.Errorf("Spindle: map struct too large (%d)", extra) 7435 7663 } 7436 7664 7437 7665 n := extra 7438 7666 7439 - nameBuf := make([]byte, 11) 7667 + nameBuf := make([]byte, 9) 7440 7668 for i := uint64(0); i < n; i++ { 7441 7669 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 7442 7670 if err != nil { ··· 7452 7680 } 7453 7681 7454 7682 switch string(nameBuf[:nameLen]) { 7455 - // t.Knot (string) (string) 7456 - case "knot": 7457 - 7458 - { 7459 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 7460 - if err != nil { 7461 - return err 7462 - } 7463 - 7464 - t.Knot = string(sval) 7465 - } 7466 - // t.Name (string) (string) 7467 - case "name": 7468 - 7469 - { 7470 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 7471 - if err != nil { 7472 - return err 7473 - } 7474 - 7475 - t.Name = string(sval) 7476 - } 7477 - // t.LexiconTypeID (string) (string) 7683 + // t.LexiconTypeID (string) (string) 7478 7684 case "$type": 7479 7685 7480 7686 { ··· 7485 7691 7486 7692 t.LexiconTypeID = string(sval) 7487 7693 } 7488 - // t.Owner (string) (string) 7489 - case "owner": 7490 - 7491 - { 7492 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 7493 - if err != nil { 7494 - return err 7495 - } 7496 - 7497 - t.Owner = string(sval) 7498 - } 7499 - // t.Source (string) (string) 7500 - case "source": 7501 - 7502 - { 7503 - b, err := cr.ReadByte() 7504 - if err != nil { 7505 - return err 7506 - } 7507 - if b != cbg.CborNull[0] { 7508 - if err := cr.UnreadByte(); err != nil { 7509 - return err 7510 - } 7511 - 7512 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 7513 - if err != nil { 7514 - return err 7515 - } 7516 - 7517 - t.Source = (*string)(&sval) 7518 - } 7519 - } 7520 - // t.Spindle (string) (string) 7521 - case "spindle": 7522 - 7523 - { 7524 - b, err := cr.ReadByte() 7525 - if err != nil { 7526 - return err 7527 - } 7528 - if b != cbg.CborNull[0] { 7529 - if err := cr.UnreadByte(); err != nil { 7530 - return err 7531 - } 7532 - 7533 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 7534 - if err != nil { 7535 - return err 7536 - } 7537 - 7538 - t.Spindle = (*string)(&sval) 7539 - } 7540 - } 7541 7694 // t.CreatedAt (string) (string) 7542 7695 case "createdAt": 7543 7696 ··· 7548 7701 } 7549 7702 7550 7703 t.CreatedAt = string(sval) 7551 - } 7552 - // t.Description (string) (string) 7553 - case "description": 7554 - 7555 - { 7556 - b, err := cr.ReadByte() 7557 - if err != nil { 7558 - return err 7559 - } 7560 - if b != cbg.CborNull[0] { 7561 - if err := cr.UnreadByte(); err != nil { 7562 - return err 7563 - } 7564 - 7565 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 7566 - if err != nil { 7567 - return err 7568 - } 7569 - 7570 - t.Description = (*string)(&sval) 7571 - } 7572 7704 } 7573 7705 7574 7706 default:
+1 -1
api/tangled/tangledpipeline.go
··· 91 91 // Pipeline_Workflow is a "workflow" in the sh.tangled.pipeline schema. 92 92 type Pipeline_Workflow struct { 93 93 Clone *Pipeline_CloneOpts `json:"clone" cborgen:"clone"` 94 - Dependencies []Pipeline_Dependencies_Elem `json:"dependencies" cborgen:"dependencies"` 94 + Dependencies []Pipeline_Dependencies_Elem `json:"dependencies" cborgen:"dependencies"` 95 95 Environment []*Pipeline_Workflow_Environment_Elem `json:"environment" cborgen:"environment"` 96 96 Name string `json:"name" cborgen:"name"` 97 97 Steps []*Pipeline_Step `json:"steps" cborgen:"steps"`
+22
api/tangled/tangledspindle.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package tangled 4 + 5 + // schema: sh.tangled.spindle 6 + 7 + import ( 8 + "github.com/bluesky-social/indigo/lex/util" 9 + ) 10 + 11 + const ( 12 + SpindleNSID = "sh.tangled.spindle" 13 + ) 14 + 15 + func init() { 16 + util.RegisterType("sh.tangled.spindle", &Spindle{}) 17 + } // 18 + // RECORDTYPE: Spindle 19 + type Spindle struct { 20 + LexiconTypeID string `json:"$type,const=sh.tangled.spindle" cborgen:"$type,const=sh.tangled.spindle"` 21 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 22 + }
+18 -25
appview/db/db.go
··· 321 321 primary key (did, date) 322 322 ); 323 323 324 + create table if not exists spindles ( 325 + id integer primary key autoincrement, 326 + owner text not null, 327 + instance text not null, 328 + verified text, -- time of verification 329 + created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')), 330 + 331 + unique(instance) 332 + ); 333 + 324 334 create table if not exists migrations ( 325 335 id integer primary key autoincrement, 326 336 name text unique ··· 515 525 cmp string 516 526 } 517 527 518 - func FilterEq(key string, arg any) filter { 528 + func newFilter(key, cmp string, arg any) filter { 519 529 return filter{ 520 530 key: key, 521 531 arg: arg, 522 - cmp: "=", 532 + cmp: cmp, 523 533 } 524 534 } 525 535 526 - func FilterNotEq(key string, arg any) filter { 527 - return filter{ 528 - key: key, 529 - arg: arg, 530 - cmp: "<>", 531 - } 532 - } 533 - 534 - func FilterGte(key string, arg any) filter { 535 - return filter{ 536 - key: key, 537 - arg: arg, 538 - cmp: ">=", 539 - } 540 - } 541 - 542 - func FilterLte(key string, arg any) filter { 543 - return filter{ 544 - key: key, 545 - arg: arg, 546 - cmp: "<=", 547 - } 548 - } 536 + func FilterEq(key string, arg any) filter { return newFilter(key, "=", arg) } 537 + func FilterNotEq(key string, arg any) filter { return newFilter(key, "<>", arg) } 538 + func FilterGte(key string, arg any) filter { return newFilter(key, ">=", arg) } 539 + func FilterLte(key string, arg any) filter { return newFilter(key, "<=", arg) } 540 + func FilterIs(key string, arg any) filter { return newFilter(key, "is", arg) } 541 + func FilterIsNot(key string, arg any) filter { return newFilter(key, "is not", arg) } 549 542 550 543 func (f filter) Condition() string { 551 544 return fmt.Sprintf("%s %s ?", f.key, f.cmp)
+131
appview/db/spindle.go
··· 1 + package db 2 + 3 + import ( 4 + "database/sql" 5 + "fmt" 6 + "strings" 7 + "time" 8 + 9 + "github.com/bluesky-social/indigo/atproto/syntax" 10 + ) 11 + 12 + type Spindle struct { 13 + Id int 14 + Owner syntax.DID 15 + Instance string 16 + Verified *time.Time 17 + Created time.Time 18 + } 19 + 20 + func GetSpindles(e Execer, filters ...filter) ([]Spindle, error) { 21 + var spindles []Spindle 22 + 23 + var conditions []string 24 + var args []any 25 + for _, filter := range filters { 26 + conditions = append(conditions, filter.Condition()) 27 + args = append(args, filter.arg) 28 + } 29 + 30 + whereClause := "" 31 + if conditions != nil { 32 + whereClause = " where " + strings.Join(conditions, " and ") 33 + } 34 + 35 + query := fmt.Sprintf( 36 + `select id, owner, instance, verified, created 37 + from spindles 38 + %s 39 + order by created 40 + `, 41 + whereClause, 42 + ) 43 + 44 + rows, err := e.Query(query, args...) 45 + 46 + if err != nil { 47 + return nil, err 48 + } 49 + defer rows.Close() 50 + 51 + for rows.Next() { 52 + var spindle Spindle 53 + var createdAt string 54 + var verified sql.NullTime 55 + 56 + if err := rows.Scan( 57 + &spindle.Id, 58 + &spindle.Owner, 59 + &spindle.Instance, 60 + &verified, 61 + &createdAt, 62 + ); err != nil { 63 + return nil, err 64 + } 65 + 66 + spindle.Created, err = time.Parse(time.RFC3339, createdAt) 67 + if err != nil { 68 + spindle.Created = time.Now() 69 + } 70 + 71 + if verified.Valid { 72 + spindle.Verified = &verified.Time 73 + } 74 + 75 + spindles = append(spindles, spindle) 76 + } 77 + 78 + return spindles, nil 79 + } 80 + 81 + // if there is an existing spindle with the same instance, this returns an error 82 + func AddSpindle(e Execer, spindle Spindle) error { 83 + _, err := e.Exec( 84 + `insert into spindles (owner, instance) values (?, ?)`, 85 + spindle.Owner, 86 + spindle.Instance, 87 + ) 88 + return err 89 + } 90 + 91 + func VerifySpindle(e Execer, filters ...filter) (int64, error) { 92 + var conditions []string 93 + var args []any 94 + for _, filter := range filters { 95 + conditions = append(conditions, filter.Condition()) 96 + args = append(args, filter.arg) 97 + } 98 + 99 + whereClause := "" 100 + if conditions != nil { 101 + whereClause = " where " + strings.Join(conditions, " and ") 102 + } 103 + 104 + query := fmt.Sprintf(`update spindles set verified = strftime('%%Y-%%m-%%dT%%H:%%M:%%SZ', 'now') %s`, whereClause) 105 + 106 + res, err := e.Exec(query, args...) 107 + if err != nil { 108 + return 0, err 109 + } 110 + 111 + return res.RowsAffected() 112 + } 113 + 114 + func DeleteSpindle(e Execer, filters ...filter) error { 115 + var conditions []string 116 + var args []any 117 + for _, filter := range filters { 118 + conditions = append(conditions, filter.Condition()) 119 + args = append(args, filter.arg) 120 + } 121 + 122 + whereClause := "" 123 + if conditions != nil { 124 + whereClause = " where " + strings.Join(conditions, " and ") 125 + } 126 + 127 + query := fmt.Sprintf(`delete from spindles %s`, whereClause) 128 + 129 + _, err := e.Exec(query, args...) 130 + return err 131 + }
+76 -1
appview/ingester.go
··· 3 3 import ( 4 4 "context" 5 5 "encoding/json" 6 + "errors" 6 7 "fmt" 8 + "io" 7 9 "log" 10 + "net/http" 11 + "strings" 8 12 "time" 9 13 10 14 "github.com/bluesky-social/indigo/atproto/syntax" ··· 46 50 ingestProfile(&d, e) 47 51 case tangled.SpindleMemberNSID: 48 52 ingestSpindleMember(&d, e, enforcer) 53 + case tangled.SpindleNSID: 54 + ingestSpindle(&d, e, true) // TODO: change this to dynamic 49 55 } 50 56 51 57 return err ··· 288 294 return nil 289 295 } 290 296 291 - func ingestSpindleMember(_ *db.DbWrapper, e *models.Event, enforcer *rbac.Enforcer) error { 297 + func ingestSpindleMember(d *db.DbWrapper, e *models.Event, enforcer *rbac.Enforcer) error { 292 298 did := e.Did 293 299 var err error 294 300 ··· 316 322 317 323 return nil 318 324 } 325 + 326 + func ingestSpindle(d *db.DbWrapper, e *models.Event, dev bool) error { 327 + did := e.Did 328 + var err error 329 + 330 + switch e.Commit.Operation { 331 + case models.CommitOperationCreate: 332 + raw := json.RawMessage(e.Commit.Record) 333 + record := tangled.Spindle{} 334 + err = json.Unmarshal(raw, &record) 335 + if err != nil { 336 + log.Printf("invalid record: %s", err) 337 + return err 338 + } 339 + 340 + // this is a special record whose rkey is the instance of the spindle itself 341 + domain := e.Commit.RKey 342 + 343 + owner, err := fetchOwner(context.TODO(), domain, true) 344 + if err != nil { 345 + log.Printf("failed to verify owner of %s: %w", domain, err) 346 + return err 347 + } 348 + 349 + // verify that the spindle owner points back to this did 350 + if owner != did { 351 + log.Printf("incorrect owner for domain: %s, %s != %s", domain, owner, did) 352 + return err 353 + } 354 + 355 + // mark this spindle as registered 356 + } 357 + 358 + return nil 359 + } 360 + 361 + func fetchOwner(ctx context.Context, domain string, dev bool) (string, error) { 362 + scheme := "https" 363 + if dev { 364 + scheme = "http" 365 + } 366 + 367 + url := fmt.Sprintf("%s://%s/owner", scheme, domain) 368 + req, err := http.NewRequest("GET", url, nil) 369 + if err != nil { 370 + return "", err 371 + } 372 + 373 + client := &http.Client{ 374 + Timeout: 1 * time.Second, 375 + } 376 + 377 + resp, err := client.Do(req.WithContext(ctx)) 378 + if err != nil || resp.StatusCode != 200 { 379 + return "", errors.New("failed to fetch /owner") 380 + } 381 + 382 + body, err := io.ReadAll(io.LimitReader(resp.Body, 1024)) // read atmost 1kb of data 383 + if err != nil { 384 + return "", fmt.Errorf("failed to read /owner response: %w", err) 385 + } 386 + 387 + did := strings.TrimSpace(string(body)) 388 + if did == "" { 389 + return "", errors.New("empty DID in /owner response") 390 + } 391 + 392 + return did, nil 393 + }
+18
appview/pages/pages.go
··· 291 291 return p.execute("knot", w, params) 292 292 } 293 293 294 + type SpindlesParams struct { 295 + LoggedInUser *oauth.User 296 + Spindles []db.Spindle 297 + } 298 + 299 + func (p *Pages) Spindles(w io.Writer, params SpindlesParams) error { 300 + return p.execute("spindles/index", w, params) 301 + } 302 + 303 + type SpindleListingParams struct { 304 + LoggedInUser *oauth.User 305 + Spindle db.Spindle 306 + } 307 + 308 + func (p *Pages) SpindleListing(w io.Writer, params SpindleListingParams) error { 309 + return p.execute("spindles/fragments/spindleListing", w, params) 310 + } 311 + 294 312 type NewRepoParams struct { 295 313 LoggedInUser *oauth.User 296 314 Knots []string
+2 -2
appview/pages/templates/knots.html
··· 20 20 required 21 21 class="w-full dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:placeholder-gray-400" 22 22 > 23 - <button class="btn dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 flex gap-2 items-center" type="submit"> 23 + <button class="btn dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 flex items-center" type="submit"> 24 24 <span>generate key</span> 25 25 <span id="generate-knot-key-spinner" class="group"> 26 - {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 26 + {{ i "loader-circle" "pl-2 w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 27 27 </span> 28 28 </button> 29 29 <div id="settings-knots-error" class="error dark:text-red-400"></div>
+1
appview/pages/templates/layouts/topbar.html
··· 45 45 > 46 46 <a href="/{{ didOrHandle .Did .Handle }}">profile</a> 47 47 <a href="/knots">knots</a> 48 + <a href="/spindles">spindles</a> 48 49 <a href="/settings">settings</a> 49 50 <a href="#" 50 51 hx-post="/logout"
+51
appview/pages/templates/spindles/fragments/spindleListing.html
··· 1 + {{ define "spindles/fragments/spindleListing" }} 2 + <div id="spindle-{{.Id}}" class="flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700"> 3 + <div id="left-side" class="flex items-center gap-2 min-w-0 max-w-[60%]"> 4 + {{ i "hard-drive" "w-4 h-4" }} 5 + {{ .Instance }} 6 + <span class="text-gray-500"> 7 + {{ .Created | shortTimeFmt }} ago 8 + </span> 9 + </div> 10 + <div id="right-side" class="flex gap-2"> 11 + {{ $style := "px-2 py-1 rounded flex items-center flex-shrink-0 gap-2 text-sm" }} 12 + {{ if .Verified }} 13 + <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> 14 + {{ else }} 15 + <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> 16 + {{ block "retryButton" . }} {{ end }} 17 + {{ end }} 18 + {{ block "deleteButton" . }} {{ end }} 19 + </div> 20 + </div> 21 + {{ end }} 22 + 23 + {{ define "deleteButton" }} 24 + <button 25 + class="btn text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 gap-2 group" 26 + title="Delete spindle" 27 + hx-delete="/spindles/{{ urlquery .Instance }}" 28 + hx-swap="outerHTML" 29 + hx-target="#spindle-{{.Id}}" 30 + hx-confirm="Are you sure you want to delete the spindle '{{ .Instance }}'?" 31 + > 32 + {{ i "trash-2" "w-5 h-5" }} 33 + <span class="hidden md:inline">delete</span> 34 + {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 35 + </button> 36 + {{ end }} 37 + 38 + 39 + {{ define "retryButton" }} 40 + <button 41 + class="btn gap-2 group" 42 + title="Retry spindle verification" 43 + hx-post="/spindles/{{ urlquery .Instance }}/retry" 44 + hx-swap="none" 45 + hx-target="#spindle-{{.Id}}" 46 + > 47 + {{ i "rotate-ccw" "w-5 h-5" }} 48 + <span class="hidden md:inline">retry</span> 49 + {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 50 + </button> 51 + {{ end }}
+69
appview/pages/templates/spindles/index.html
··· 1 + {{ define "title" }}spindles{{ end }} 2 + 3 + {{ define "content" }} 4 + <div class="px-6 py-4"> 5 + <h1 class="text-xl font-bold dark:text-white">Spindles</h1> 6 + </div> 7 + 8 + <section class="bg-white dark:bg-gray-800 p-6 rounded relative w-full mx-auto drop-shadow-sm dark:text-white"> 9 + <div class="flex flex-col gap-6"> 10 + {{ block "all" . }} {{ end }} 11 + {{ block "register" . }} {{ end }} 12 + </div> 13 + </section> 14 + {{ end }} 15 + 16 + {{ define "all" }} 17 + <section class="rounded bg-white dark:bg-gray-800 drop-shadow-sm w-full flex flex-col gap-2"> 18 + <h2 class="text-sm font-bold py-2 uppercase dark:text-gray-300">your spindles</h2> 19 + <div class="flex flex-col rounded border border-gray-200 dark:border-gray-700 w-full"> 20 + {{ range $spindle := .Spindles }} 21 + {{ template "spindles/fragments/spindleListing" . }} 22 + {{ else }} 23 + <div class="flex items-center justify-center p-2 border-b border-gray-200 dark:border-gray-700 text-gray-500"> 24 + no spindles registered yet 25 + </div> 26 + {{ end }} 27 + </div> 28 + <div id="operation-error" class="dark:text-red-400"></div> 29 + </section> 30 + {{ end }} 31 + 32 + {{ define "register" }} 33 + <section class="rounded bg-white dark:bg-gray-800 drop-shadow-sm w-full lg:w-fit flex flex-col gap-2"> 34 + <h2 class="text-sm font-bold py-2 uppercase dark:text-gray-300">register a spindle</h2> 35 + <p class="mb-2 dark:text-gray-300">Enter the hostname of your spindle to get started</p> 36 + <form 37 + hx-post="/spindles/register" 38 + class="max-w-2xl mb-2 space-y-4" 39 + hx-indicator="#register-spinner" 40 + hx-swap="none" 41 + > 42 + <div class="flex gap-2"> 43 + <input 44 + type="text" 45 + id="instance" 46 + name="instance" 47 + placeholder="spindle.example.com" 48 + required 49 + 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" 50 + > 51 + <button 52 + type="submit" 53 + class="btn rounded flex items-center py-2 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 group" 54 + > 55 + <span class="inline-flex items-center gap-2"> 56 + {{ i "plus" "w-4 h-4" }} 57 + register 58 + </span> 59 + <span id="register-spinner" class="pl-2 hidden group-[.htmx-request]:inline"> 60 + {{ i "loader-circle" "w-4 h-4 animate-spin" }} 61 + </span> 62 + </button> 63 + </div> 64 + 65 + <div id="register-error" class="dark:text-red-400"></div> 66 + </form> 67 + 68 + </section> 69 + {{ end }}
+176
appview/spindleresolver/resolver.go
··· 1 + package spindleresolver 2 + 3 + import ( 4 + "context" 5 + "encoding/json" 6 + "errors" 7 + "fmt" 8 + "io" 9 + "net/http" 10 + "strings" 11 + "time" 12 + 13 + "tangled.sh/tangled.sh/core/api/tangled" 14 + "tangled.sh/tangled.sh/core/appview/cache" 15 + "tangled.sh/tangled.sh/core/appview/idresolver" 16 + 17 + "github.com/bluesky-social/indigo/api/atproto" 18 + "github.com/bluesky-social/indigo/xrpc" 19 + ) 20 + 21 + type ResolutionStatus string 22 + 23 + const ( 24 + StatusOK ResolutionStatus = "ok" 25 + StatusError ResolutionStatus = "error" 26 + StatusInvalid ResolutionStatus = "invalid" 27 + ) 28 + 29 + type Resolution struct { 30 + Status ResolutionStatus `json:"status"` 31 + OwnerDID string `json:"ownerDid,omitempty"` 32 + VerifiedAt time.Time `json:"verifiedAt"` 33 + } 34 + 35 + type Resolver struct { 36 + cache *cache.Cache 37 + http *http.Client 38 + config Config 39 + idResolver *idresolver.Resolver 40 + } 41 + 42 + type Config struct { 43 + HitTTL time.Duration 44 + ErrTTL time.Duration 45 + InvalidTTL time.Duration 46 + Dev bool 47 + } 48 + 49 + func NewResolver(cache *cache.Cache, client *http.Client, config Config) *Resolver { 50 + if client == nil { 51 + client = &http.Client{ 52 + Timeout: 2 * time.Second, 53 + } 54 + } 55 + return &Resolver{ 56 + cache: cache, 57 + http: client, 58 + config: config, 59 + } 60 + } 61 + 62 + func DefaultResolver(cache *cache.Cache) *Resolver { 63 + return NewResolver( 64 + cache, 65 + &http.Client{ 66 + Timeout: 2 * time.Second, 67 + }, 68 + Config{ 69 + HitTTL: 24 * time.Hour, 70 + ErrTTL: 30 * time.Second, 71 + InvalidTTL: 1 * time.Minute, 72 + }, 73 + ) 74 + } 75 + 76 + func (r *Resolver) ResolveInstance(ctx context.Context, domain string) (*Resolution, error) { 77 + key := "spindle:" + domain 78 + 79 + val, err := r.cache.Get(ctx, key).Result() 80 + if err == nil { 81 + var cached Resolution 82 + if err := json.Unmarshal([]byte(val), &cached); err == nil { 83 + return &cached, nil 84 + } 85 + } 86 + 87 + resolution, ttl := r.verify(ctx, domain) 88 + 89 + data, _ := json.Marshal(resolution) 90 + r.cache.Set(ctx, key, data, ttl) 91 + 92 + if resolution.Status == StatusOK { 93 + return resolution, nil 94 + } 95 + 96 + return resolution, fmt.Errorf("verification failed: %s", resolution.Status) 97 + } 98 + 99 + func (r *Resolver) verify(ctx context.Context, domain string) (*Resolution, time.Duration) { 100 + owner, err := r.fetchOwner(ctx, domain) 101 + if err != nil { 102 + return &Resolution{Status: StatusError, VerifiedAt: time.Now()}, r.config.ErrTTL 103 + } 104 + 105 + record, err := r.fetchRecord(ctx, owner, domain) 106 + if err != nil { 107 + return &Resolution{Status: StatusError, VerifiedAt: time.Now()}, r.config.ErrTTL 108 + } 109 + 110 + if record.Instance == domain { 111 + return &Resolution{ 112 + Status: StatusOK, 113 + OwnerDID: owner, 114 + VerifiedAt: time.Now(), 115 + }, r.config.HitTTL 116 + } 117 + 118 + return &Resolution{ 119 + Status: StatusInvalid, 120 + OwnerDID: owner, 121 + VerifiedAt: time.Now(), 122 + }, r.config.InvalidTTL 123 + } 124 + 125 + func (r *Resolver) fetchOwner(ctx context.Context, domain string) (string, error) { 126 + scheme := "https" 127 + if r.config.Dev { 128 + scheme = "http" 129 + } 130 + 131 + url := fmt.Sprintf("%s://%s/owner", scheme, domain) 132 + req, err := http.NewRequest("GET", url, nil) 133 + if err != nil { 134 + return "", err 135 + } 136 + 137 + resp, err := r.http.Do(req.WithContext(ctx)) 138 + if err != nil || resp.StatusCode != 200 { 139 + return "", errors.New("failed to fetch /owner") 140 + } 141 + 142 + body, err := io.ReadAll(io.LimitReader(resp.Body, 1024)) // read atmost 1kb of data 143 + if err != nil { 144 + return "", fmt.Errorf("failed to read /owner response: %w", err) 145 + } 146 + 147 + did := strings.TrimSpace(string(body)) 148 + if did == "" { 149 + return "", errors.New("empty DID in /owner response") 150 + } 151 + 152 + return did, nil 153 + } 154 + 155 + func (r *Resolver) fetchRecord(ctx context.Context, did, rkey string) (*tangled.Spindle, error) { 156 + ident, err := r.idResolver.ResolveIdent(ctx, did) 157 + if err != nil { 158 + return nil, err 159 + } 160 + 161 + xrpcc := xrpc.Client{ 162 + Host: ident.PDSEndpoint(), 163 + } 164 + 165 + rec, err := atproto.RepoGetRecord(ctx, &xrpcc, "", tangled.SpindleNSID, did, rkey) 166 + if err != nil { 167 + return nil, err 168 + } 169 + 170 + out, ok := rec.Value.Val.(*tangled.Spindle) 171 + if !ok { 172 + return nil, fmt.Errorf("invalid record returned") 173 + } 174 + 175 + return out, nil 176 + }
+304
appview/spindles/spindles.go
··· 1 + package spindles 2 + 3 + import ( 4 + "context" 5 + "errors" 6 + "fmt" 7 + "io" 8 + "log/slog" 9 + "net/http" 10 + "strings" 11 + "time" 12 + 13 + "github.com/go-chi/chi/v5" 14 + "tangled.sh/tangled.sh/core/api/tangled" 15 + "tangled.sh/tangled.sh/core/appview/config" 16 + "tangled.sh/tangled.sh/core/appview/db" 17 + "tangled.sh/tangled.sh/core/appview/middleware" 18 + "tangled.sh/tangled.sh/core/appview/oauth" 19 + "tangled.sh/tangled.sh/core/appview/pages" 20 + "tangled.sh/tangled.sh/core/rbac" 21 + 22 + comatproto "github.com/bluesky-social/indigo/api/atproto" 23 + "github.com/bluesky-social/indigo/atproto/syntax" 24 + lexutil "github.com/bluesky-social/indigo/lex/util" 25 + ) 26 + 27 + type Spindles struct { 28 + Db *db.DB 29 + OAuth *oauth.OAuth 30 + Pages *pages.Pages 31 + Config *config.Config 32 + Enforcer *rbac.Enforcer 33 + Logger *slog.Logger 34 + } 35 + 36 + func (s *Spindles) Router() http.Handler { 37 + r := chi.NewRouter() 38 + 39 + r.Use(middleware.AuthMiddleware(s.OAuth)) 40 + 41 + r.Get("/", s.spindles) 42 + r.Post("/register", s.register) 43 + r.Delete("/{instance}", s.delete) 44 + r.Post("/{instance}/retry", s.retry) 45 + 46 + return r 47 + } 48 + 49 + func (s *Spindles) spindles(w http.ResponseWriter, r *http.Request) { 50 + user := s.OAuth.GetUser(r) 51 + all, err := db.GetSpindles( 52 + s.Db, 53 + db.FilterEq("owner", user.Did), 54 + ) 55 + if err != nil { 56 + s.Logger.Error("failed to fetch spindles", "err", err) 57 + } 58 + 59 + s.Pages.Spindles(w, pages.SpindlesParams{ 60 + LoggedInUser: user, 61 + Spindles: all, 62 + }) 63 + } 64 + 65 + // this endpoint inserts a record on behalf of the user to register that domain 66 + // 67 + // when registered, it also makes a request to see if the spindle declares this users as its owner, 68 + // and if so, marks the spindle as verified. 69 + // 70 + // if the spindle is not up yet, the user is free to retry verification at a later point 71 + func (s *Spindles) register(w http.ResponseWriter, r *http.Request) { 72 + user := s.OAuth.GetUser(r) 73 + l := s.Logger.With("handler", "register") 74 + 75 + noticeId := "register-error" 76 + defaultErr := "Failed to register spindle. Try again later." 77 + fail := func() { 78 + s.Pages.Notice(w, noticeId, defaultErr) 79 + } 80 + 81 + instance := r.FormValue("instance") 82 + if instance == "" { 83 + s.Pages.Notice(w, noticeId, "Incomplete form.") 84 + return 85 + } 86 + 87 + tx, err := s.Db.Begin() 88 + if err != nil { 89 + l.Error("failed to start transaction", "err", err) 90 + fail() 91 + return 92 + } 93 + defer tx.Rollback() 94 + 95 + err = db.AddSpindle(tx, db.Spindle{ 96 + Owner: syntax.DID(user.Did), 97 + Instance: instance, 98 + }) 99 + if err != nil { 100 + l.Error("failed to insert", "err", err) 101 + fail() 102 + return 103 + } 104 + 105 + // create record on pds 106 + client, err := s.OAuth.AuthorizedClient(r) 107 + if err != nil { 108 + l.Error("failed to authorize client", "err", err) 109 + fail() 110 + return 111 + } 112 + 113 + _, err = client.RepoPutRecord(r.Context(), &comatproto.RepoPutRecord_Input{ 114 + Collection: tangled.SpindleNSID, 115 + Repo: user.Did, 116 + Rkey: instance, 117 + Record: &lexutil.LexiconTypeDecoder{ 118 + Val: &tangled.Spindle{ 119 + CreatedAt: time.Now().Format(time.RFC3339), 120 + }, 121 + }, 122 + }) 123 + if err != nil { 124 + l.Error("failed to put record", "err", err) 125 + fail() 126 + return 127 + } 128 + 129 + err = tx.Commit() 130 + if err != nil { 131 + l.Error("failed to commit transaction", "err", err) 132 + fail() 133 + return 134 + } 135 + 136 + // begin verification 137 + expectedOwner, err := fetchOwner(r.Context(), instance, s.Config.Core.Dev) 138 + if err != nil { 139 + l.Error("verification failed", "err", err) 140 + 141 + // just refresh the page 142 + s.Pages.HxRefresh(w) 143 + return 144 + } 145 + 146 + if expectedOwner != user.Did { 147 + // verification failed 148 + l.Error("verification failed", "expectedOwner", expectedOwner, "observedOwner", user.Did) 149 + s.Pages.HxRefresh(w) 150 + return 151 + } 152 + 153 + // ok 154 + s.Pages.HxRefresh(w) 155 + return 156 + } 157 + 158 + func (s *Spindles) delete(w http.ResponseWriter, r *http.Request) { 159 + user := s.OAuth.GetUser(r) 160 + l := s.Logger.With("handler", "register") 161 + 162 + noticeId := "operation-error" 163 + defaultErr := "Failed to delete spindle. Try again later." 164 + fail := func() { 165 + s.Pages.Notice(w, noticeId, defaultErr) 166 + } 167 + 168 + instance := chi.URLParam(r, "instance") 169 + if instance == "" { 170 + l.Error("empty instance") 171 + fail() 172 + return 173 + } 174 + 175 + tx, err := s.Db.Begin() 176 + if err != nil { 177 + l.Error("failed to start txn", "err", err) 178 + fail() 179 + return 180 + } 181 + defer tx.Rollback() 182 + 183 + err = db.DeleteSpindle( 184 + tx, 185 + db.FilterEq("owner", user.Did), 186 + db.FilterEq("instance", instance), 187 + ) 188 + if err != nil { 189 + l.Error("failed to delete spindle", "err", err) 190 + fail() 191 + return 192 + } 193 + 194 + client, err := s.OAuth.AuthorizedClient(r) 195 + if err != nil { 196 + l.Error("failed to authorize client", "err", err) 197 + fail() 198 + return 199 + } 200 + 201 + _, err = client.RepoDeleteRecord(r.Context(), &comatproto.RepoDeleteRecord_Input{ 202 + Collection: tangled.SpindleNSID, 203 + Repo: user.Did, 204 + Rkey: instance, 205 + }) 206 + if err != nil { 207 + // non-fatal 208 + l.Error("failed to delete record", "err", err) 209 + } 210 + 211 + err = tx.Commit() 212 + if err != nil { 213 + l.Error("failed to delete spindle", "err", err) 214 + fail() 215 + return 216 + } 217 + 218 + w.Write([]byte{}) 219 + } 220 + 221 + func (s *Spindles) retry(w http.ResponseWriter, r *http.Request) { 222 + user := s.OAuth.GetUser(r) 223 + l := s.Logger.With("handler", "register") 224 + 225 + noticeId := "operation-error" 226 + defaultErr := "Failed to verify spindle. Try again later." 227 + fail := func() { 228 + s.Pages.Notice(w, noticeId, defaultErr) 229 + } 230 + 231 + instance := chi.URLParam(r, "instance") 232 + if instance == "" { 233 + l.Error("empty instance") 234 + fail() 235 + return 236 + } 237 + 238 + // begin verification 239 + expectedOwner, err := fetchOwner(r.Context(), instance, s.Config.Core.Dev) 240 + if err != nil { 241 + l.Error("verification failed", "err", err) 242 + fail() 243 + return 244 + } 245 + 246 + if expectedOwner != user.Did { 247 + l.Error("verification failed", "expectedOwner", expectedOwner, "observedOwner", user.Did) 248 + s.Pages.Notice(w, noticeId, fmt.Sprintf("Owner did not match, expected %s, got %s", expectedOwner, user.Did)) 249 + return 250 + } 251 + 252 + // mark this spindle as verified in the db 253 + rowId, err := db.VerifySpindle( 254 + s.Db, 255 + db.FilterEq("owner", user.Did), 256 + db.FilterEq("instance", instance), 257 + ) 258 + 259 + verifiedSpindle := db.Spindle{ 260 + Id: int(rowId), 261 + Owner: syntax.DID(user.Did), 262 + Instance: instance, 263 + } 264 + 265 + w.Header().Set("HX-Reswap", "outerHTML") 266 + s.Pages.SpindleListing(w, pages.SpindleListingParams{ 267 + LoggedInUser: user, 268 + Spindle: verifiedSpindle, 269 + }) 270 + } 271 + 272 + func fetchOwner(ctx context.Context, domain string, dev bool) (string, error) { 273 + scheme := "https" 274 + if dev { 275 + scheme = "http" 276 + } 277 + 278 + url := fmt.Sprintf("%s://%s/owner", scheme, domain) 279 + req, err := http.NewRequest("GET", url, nil) 280 + if err != nil { 281 + return "", err 282 + } 283 + 284 + client := &http.Client{ 285 + Timeout: 1 * time.Second, 286 + } 287 + 288 + resp, err := client.Do(req.WithContext(ctx)) 289 + if err != nil || resp.StatusCode != 200 { 290 + return "", errors.New("failed to fetch /owner") 291 + } 292 + 293 + body, err := io.ReadAll(io.LimitReader(resp.Body, 1024)) // read atmost 1kb of data 294 + if err != nil { 295 + return "", fmt.Errorf("failed to read /owner response: %w", err) 296 + } 297 + 298 + did := strings.TrimSpace(string(body)) 299 + if did == "" { 300 + return "", errors.New("empty DID in /owner response") 301 + } 302 + 303 + return did, nil 304 + }
+18
appview/state/router.go
··· 12 12 "tangled.sh/tangled.sh/core/appview/pulls" 13 13 "tangled.sh/tangled.sh/core/appview/repo" 14 14 "tangled.sh/tangled.sh/core/appview/settings" 15 + "tangled.sh/tangled.sh/core/appview/spindles" 15 16 "tangled.sh/tangled.sh/core/appview/state/userutil" 17 + "tangled.sh/tangled.sh/core/log" 16 18 ) 17 19 18 20 func (s *State) Router() http.Handler { ··· 142 144 }) 143 145 144 146 r.Mount("/settings", s.SettingsRouter()) 147 + r.Mount("/spindles", s.SpindlesRouter()) 145 148 r.Mount("/", s.OAuthRouter()) 146 149 147 150 r.Get("/keys/{user}", s.Keys) ··· 167 170 } 168 171 169 172 return settings.Router() 173 + } 174 + 175 + func (s *State) SpindlesRouter() http.Handler { 176 + logger := log.New("spindles") 177 + 178 + spindles := &spindles.Spindles{ 179 + Db: s.db, 180 + OAuth: s.oauth, 181 + Pages: s.pages, 182 + Config: s.config, 183 + Enforcer: s.enforcer, 184 + Logger: logger, 185 + } 186 + 187 + return spindles.Router() 170 188 } 171 189 172 190 func (s *State) IssuesRouter(mw *middleware.Middleware) http.Handler {
+12 -11
cmd/gen.go
··· 16 16 "tangled", 17 17 tangled.ActorProfile{}, 18 18 tangled.FeedStar{}, 19 - tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{}, 20 - tangled.GitRefUpdate_Meta_CommitCount{}, 21 - tangled.GitRefUpdate_Meta{}, 22 19 tangled.GitRefUpdate{}, 20 + tangled.GitRefUpdate_Meta{}, 21 + tangled.GitRefUpdate_Meta_CommitCount{}, 22 + tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{}, 23 23 tangled.GraphFollow{}, 24 24 tangled.KnotMember{}, 25 - tangled.PipelineStatus{}, 25 + tangled.Pipeline{}, 26 26 tangled.Pipeline_CloneOpts{}, 27 27 tangled.Pipeline_Dependencies_Elem{}, 28 - tangled.Pipeline_ManualTriggerData_Inputs_Elem{}, 29 28 tangled.Pipeline_ManualTriggerData{}, 29 + tangled.Pipeline_ManualTriggerData_Inputs_Elem{}, 30 30 tangled.Pipeline_PullRequestTriggerData{}, 31 31 tangled.Pipeline_PushTriggerData{}, 32 32 tangled.Pipeline_Step_Environment_Elem{}, 33 + tangled.PipelineStatus{}, 33 34 tangled.Pipeline_Step{}, 34 35 tangled.Pipeline_TriggerMetadata{}, 35 36 tangled.Pipeline_TriggerRepo{}, 37 + tangled.Pipeline_Workflow{}, 36 38 tangled.Pipeline_Workflow_Environment_Elem{}, 37 - tangled.Pipeline_Workflow{}, 38 - tangled.Pipeline{}, 39 39 tangled.PublicKey{}, 40 + tangled.Repo{}, 40 41 tangled.RepoArtifact{}, 42 + tangled.RepoIssue{}, 41 43 tangled.RepoIssueComment{}, 42 44 tangled.RepoIssueState{}, 43 - tangled.RepoIssue{}, 45 + tangled.RepoPull{}, 44 46 tangled.RepoPullComment{}, 47 + tangled.RepoPull_Source{}, 45 48 tangled.RepoPullStatus{}, 46 - tangled.RepoPull_Source{}, 47 - tangled.RepoPull{}, 48 - tangled.Repo{}, 49 + tangled.Spindle{}, 49 50 tangled.SpindleMember{}, 50 51 ); err != nil { 51 52 panic(err)
+25
lexicons/spindle.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "sh.tangled.spindle", 4 + "needsCbor": true, 5 + "needsType": true, 6 + "defs": { 7 + "main": { 8 + "type": "record", 9 + "key": "any", 10 + "record": { 11 + "type": "object", 12 + "required": [ 13 + "createdAt" 14 + ], 15 + "properties": { 16 + "createdAt": { 17 + "type": "string", 18 + "format": "datetime" 19 + } 20 + } 21 + } 22 + } 23 + } 24 + } 25 +
-207
spindle/db/pipelines.go
··· 1 - package db 2 - 3 - // 4 - // import ( 5 - // "database/sql" 6 - // "fmt" 7 - // "time" 8 - // 9 - // "tangled.sh/tangled.sh/core/api/tangled" 10 - // "tangled.sh/tangled.sh/core/notifier" 11 - // ) 12 - // 13 - // type PipelineRunStatus string 14 - // 15 - // var ( 16 - // PipelinePending PipelineRunStatus = "pending" 17 - // PipelineRunning PipelineRunStatus = "running" 18 - // PipelineFailed PipelineRunStatus = "failed" 19 - // PipelineTimeout PipelineRunStatus = "timeout" 20 - // PipelineCancelled PipelineRunStatus = "cancelled" 21 - // PipelineSuccess PipelineRunStatus = "success" 22 - // ) 23 - // 24 - // type PipelineStatus struct { 25 - // Rkey string `json:"rkey"` 26 - // Pipeline string `json:"pipeline"` 27 - // Status PipelineRunStatus `json:"status"` 28 - // 29 - // // only if Failed 30 - // Error string `json:"error"` 31 - // ExitCode int `json:"exit_code"` 32 - // 33 - // LastUpdate int64 `json:"last_update"` 34 - // StartedAt time.Time `json:"started_at"` 35 - // UpdatedAt time.Time `json:"updated_at"` 36 - // FinishedAt time.Time `json:"finished_at"` 37 - // } 38 - // 39 - // func (p PipelineStatus) AsRecord() *tangled.PipelineStatus { 40 - // exitCode64 := int64(p.ExitCode) 41 - // finishedAt := p.FinishedAt.String() 42 - // 43 - // return &tangled.PipelineStatus{ 44 - // LexiconTypeID: tangled.PipelineStatusNSID, 45 - // Pipeline: p.Pipeline, 46 - // Status: string(p.Status), 47 - // 48 - // ExitCode: &exitCode64, 49 - // Error: &p.Error, 50 - // 51 - // StartedAt: p.StartedAt.String(), 52 - // UpdatedAt: p.UpdatedAt.String(), 53 - // FinishedAt: &finishedAt, 54 - // } 55 - // } 56 - // 57 - // func pipelineAtUri(rkey, knot string) string { 58 - // return fmt.Sprintf("at://%s/did:web:%s/%s", tangled.PipelineStatusNSID, knot, rkey) 59 - // } 60 - // 61 - // func (db *DB) CreatePipeline(rkey, pipeline string, n *notifier.Notifier) error { 62 - // _, err := db.Exec(` 63 - // insert into pipeline_status (rkey, status, pipeline, last_update) 64 - // values (?, ?, ?, ?) 65 - // `, rkey, PipelinePending, pipeline, time.Now().UnixNano()) 66 - // 67 - // if err != nil { 68 - // return err 69 - // } 70 - // n.NotifyAll() 71 - // return nil 72 - // } 73 - // 74 - // func (db *DB) MarkPipelineRunning(rkey string, n *notifier.Notifier) error { 75 - // _, err := db.Exec(` 76 - // update pipeline_status 77 - // set status = ?, updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now'), last_update = ? 78 - // where rkey = ? 79 - // `, PipelineRunning, rkey, time.Now().UnixNano()) 80 - // 81 - // if err != nil { 82 - // return err 83 - // } 84 - // n.NotifyAll() 85 - // return nil 86 - // } 87 - // 88 - // func (db *DB) MarkPipelineFailed(rkey string, exitCode int, errorMsg string, n *notifier.Notifier) error { 89 - // _, err := db.Exec(` 90 - // update pipeline_status 91 - // set status = ?, 92 - // exit_code = ?, 93 - // error = ?, 94 - // updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now'), 95 - // finished_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now'), 96 - // last_update = ? 97 - // where rkey = ? 98 - // `, PipelineFailed, exitCode, errorMsg, rkey, time.Now().UnixNano()) 99 - // if err != nil { 100 - // return err 101 - // } 102 - // n.NotifyAll() 103 - // return nil 104 - // } 105 - // 106 - // func (db *DB) MarkPipelineTimeout(rkey string, n *notifier.Notifier) error { 107 - // _, err := db.Exec(` 108 - // update pipeline_status 109 - // set status = ?, updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now') 110 - // where rkey = ? 111 - // `, PipelineTimeout, rkey) 112 - // if err != nil { 113 - // return err 114 - // } 115 - // n.NotifyAll() 116 - // return nil 117 - // } 118 - // 119 - // func (db *DB) MarkPipelineSuccess(rkey string, n *notifier.Notifier) error { 120 - // _, err := db.Exec(` 121 - // update pipeline_status 122 - // set status = ?, updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now'), 123 - // finished_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now') 124 - // where rkey = ? 125 - // `, PipelineSuccess, rkey) 126 - // 127 - // if err != nil { 128 - // return err 129 - // } 130 - // n.NotifyAll() 131 - // return nil 132 - // } 133 - // 134 - // func (db *DB) GetPipelineStatus(rkey string) (PipelineStatus, error) { 135 - // var p PipelineStatus 136 - // err := db.QueryRow(` 137 - // select rkey, status, error, exit_code, started_at, updated_at, finished_at 138 - // from pipelines 139 - // where rkey = ? 140 - // `, rkey).Scan(&p.Rkey, &p.Status, &p.Error, &p.ExitCode, &p.StartedAt, &p.UpdatedAt, &p.FinishedAt) 141 - // return p, err 142 - // } 143 - // 144 - // func (db *DB) GetPipelineStatusAsRecords(cursor int64) ([]PipelineStatus, error) { 145 - // whereClause := "" 146 - // args := []any{} 147 - // if cursor != 0 { 148 - // whereClause = "where created_at > ?" 149 - // args = append(args, cursor) 150 - // } 151 - // 152 - // query := fmt.Sprintf(` 153 - // select rkey, status, error, exit_code, created_at, started_at, updated_at, finished_at 154 - // from pipeline_status 155 - // %s 156 - // order by created_at asc 157 - // limit 100 158 - // `, whereClause) 159 - // 160 - // rows, err := db.Query(query, args...) 161 - // if err != nil { 162 - // return nil, err 163 - // } 164 - // defer rows.Close() 165 - // 166 - // var pipelines []PipelineStatus 167 - // for rows.Next() { 168 - // var p PipelineStatus 169 - // var pipelineError sql.NullString 170 - // var exitCode sql.NullInt64 171 - // var startedAt, updatedAt string 172 - // var finishedAt sql.NullTime 173 - // 174 - // err := rows.Scan(&p.Rkey, &p.Status, &pipelineError, &exitCode, &p.LastUpdate, &startedAt, &updatedAt, &finishedAt) 175 - // if err != nil { 176 - // return nil, err 177 - // } 178 - // 179 - // if pipelineError.Valid { 180 - // p.Error = pipelineError.String 181 - // } 182 - // 183 - // if exitCode.Valid { 184 - // p.ExitCode = int(exitCode.Int64) 185 - // } 186 - // 187 - // if v, err := time.Parse(time.RFC3339, startedAt); err == nil { 188 - // p.StartedAt = v 189 - // } 190 - // 191 - // if v, err := time.Parse(time.RFC3339, updatedAt); err == nil { 192 - // p.UpdatedAt = v 193 - // } 194 - // 195 - // if finishedAt.Valid { 196 - // p.FinishedAt = finishedAt.Time 197 - // } 198 - // 199 - // pipelines = append(pipelines, p) 200 - // } 201 - // 202 - // if err := rows.Err(); err != nil { 203 - // return nil, err 204 - // } 205 - // 206 - // return pipelines, nil 207 - // }