+1900
-1770
api/tangled/cbor_gen.go
+1900
-1770
api/tangled/cbor_gen.go
···
668
669
return nil
670
}
671
-
func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) MarshalCBOR(w io.Writer) error {
672
if t == nil {
673
_, err := w.Write(cbg.CborNull)
674
return err
···
676
677
cw := cbg.NewCborWriter(w)
678
679
-
if _, err := cw.Write([]byte{162}); err != nil {
680
return err
681
}
682
683
-
// t.Count (int64) (int64)
684
-
if len("count") > 1000000 {
685
-
return xerrors.Errorf("Value in field \"count\" was too long")
686
}
687
688
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("count"))); err != nil {
689
return err
690
}
691
-
if _, err := cw.WriteString(string("count")); err != nil {
692
return err
693
}
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")
708
}
709
710
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("email"))); err != nil {
711
return err
712
}
713
-
if _, err := cw.WriteString(string("email")); err != nil {
714
return err
715
}
716
717
-
if len(t.Email) > 1000000 {
718
-
return xerrors.Errorf("Value in field t.Email was too long")
719
}
720
721
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Email))); err != nil {
722
return err
723
}
724
-
if _, err := cw.WriteString(string(t.Email)); err != nil {
725
return err
726
}
727
-
return nil
728
-
}
729
730
-
func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) (err error) {
731
-
*t = GitRefUpdate_Meta_CommitCount_ByEmail_Elem{}
732
733
-
cr := cbg.NewCborReader(r)
734
735
-
maj, extra, err := cr.ReadHeader()
736
-
if err != nil {
737
return err
738
}
739
-
defer func() {
740
-
if err == io.EOF {
741
-
err = io.ErrUnexpectedEOF
742
-
}
743
-
}()
744
745
-
if maj != cbg.MajMap {
746
-
return fmt.Errorf("cbor input should be of type map")
747
}
748
749
-
if extra > cbg.MaxLength {
750
-
return fmt.Errorf("GitRefUpdate_Meta_CommitCount_ByEmail_Elem: map struct too large (%d)", extra)
751
}
752
753
-
n := extra
754
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
-
}
761
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
-
}
769
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
-
}
794
795
-
t.Count = int64(extraI)
796
-
}
797
-
// t.Email (string) (string)
798
-
case "email":
799
800
-
{
801
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
802
-
if err != nil {
803
-
return err
804
-
}
805
806
-
t.Email = string(sval)
807
-
}
808
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
-
}
815
}
816
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)
822
return err
823
}
824
825
-
cw := cbg.NewCborWriter(w)
826
-
fieldCount := 1
827
828
-
if t.ByEmail == nil {
829
-
fieldCount--
830
}
831
832
-
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
833
return err
834
}
835
836
-
// t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice)
837
-
if t.ByEmail != nil {
838
839
-
if len("byEmail") > 1000000 {
840
-
return xerrors.Errorf("Value in field \"byEmail\" was too long")
841
-
}
842
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
-
}
849
850
-
if len(t.ByEmail) > 8192 {
851
-
return xerrors.Errorf("Slice value in field t.ByEmail was too long")
852
-
}
853
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
-
}
861
862
-
}
863
}
864
return nil
865
}
866
867
-
func (t *GitRefUpdate_Meta_CommitCount) UnmarshalCBOR(r io.Reader) (err error) {
868
-
*t = GitRefUpdate_Meta_CommitCount{}
869
870
cr := cbg.NewCborReader(r)
871
···
884
}
885
886
if extra > cbg.MaxLength {
887
-
return fmt.Errorf("GitRefUpdate_Meta_CommitCount: map struct too large (%d)", extra)
888
}
889
890
n := extra
891
892
-
nameBuf := make([]byte, 7)
893
for i := uint64(0); i < n; i++ {
894
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
895
if err != nil {
···
905
}
906
907
switch string(nameBuf[:nameLen]) {
908
-
// t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice)
909
-
case "byEmail":
910
911
-
maj, extra, err = cr.ReadHeader()
912
-
if err != nil {
913
-
return err
914
}
915
916
-
if extra > 8192 {
917
-
return fmt.Errorf("t.ByEmail: array too large (%d)", extra)
918
}
919
920
-
if maj != cbg.MajArray {
921
-
return fmt.Errorf("expected cbor array")
922
}
923
924
-
if extra > 0 {
925
-
t.ByEmail = make([]*GitRefUpdate_Meta_CommitCount_ByEmail_Elem, extra)
926
}
927
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
936
937
-
{
938
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
-
}
952
953
-
}
954
955
}
956
}
957
958
default:
···
1101
1102
return nil
1103
}
1104
-
func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error {
1105
if t == nil {
1106
_, err := w.Write(cbg.CborNull)
1107
return err
1108
}
1109
1110
cw := cbg.NewCborWriter(w)
1111
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")
1119
}
1120
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 {
1125
return err
1126
}
1127
1128
-
if len(t.Ref) > 1000000 {
1129
-
return xerrors.Errorf("Value in field t.Ref was too long")
1130
-
}
1131
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
-
}
1138
1139
-
// t.Meta (tangled.GitRefUpdate_Meta) (struct)
1140
-
if len("meta") > 1000000 {
1141
-
return xerrors.Errorf("Value in field \"meta\" was too long")
1142
-
}
1143
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
-
}
1150
1151
-
if err := t.Meta.MarshalCBOR(cw); err != nil {
1152
-
return err
1153
}
1154
1155
-
// t.LexiconTypeID (string) (string)
1156
-
if len("$type") > 1000000 {
1157
-
return xerrors.Errorf("Value in field \"$type\" was too long")
1158
-
}
1159
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
-
}
1166
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 {
1171
return err
1172
}
1173
1174
-
// t.NewSha (string) (string)
1175
-
if len("newSha") > 1000000 {
1176
-
return xerrors.Errorf("Value in field \"newSha\" was too long")
1177
}
1178
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
1184
}
1185
1186
-
if len(t.NewSha) > 1000000 {
1187
-
return xerrors.Errorf("Value in field t.NewSha was too long")
1188
-
}
1189
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
-
}
1196
1197
-
// t.OldSha (string) (string)
1198
-
if len("oldSha") > 1000000 {
1199
-
return xerrors.Errorf("Value in field \"oldSha\" was too long")
1200
-
}
1201
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
-
}
1208
1209
-
if len(t.OldSha) > 1000000 {
1210
-
return xerrors.Errorf("Value in field t.OldSha was too long")
1211
-
}
1212
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
-
}
1219
1220
-
// t.RepoDid (string) (string)
1221
-
if len("repoDid") > 1000000 {
1222
-
return xerrors.Errorf("Value in field \"repoDid\" was too long")
1223
-
}
1224
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
-
}
1231
1232
-
if len(t.RepoDid) > 1000000 {
1233
-
return xerrors.Errorf("Value in field t.RepoDid was too long")
1234
-
}
1235
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
-
}
1242
1243
-
// t.RepoName (string) (string)
1244
-
if len("repoName") > 1000000 {
1245
-
return xerrors.Errorf("Value in field \"repoName\" was too long")
1246
}
1247
1248
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repoName"))); err != nil {
1249
return err
1250
}
1251
-
if _, err := cw.WriteString(string("repoName")); err != nil {
1252
return err
1253
}
1254
1255
-
if len(t.RepoName) > 1000000 {
1256
-
return xerrors.Errorf("Value in field t.RepoName was too long")
1257
}
1258
1259
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RepoName))); err != nil {
1260
return err
1261
}
1262
-
if _, err := cw.WriteString(string(t.RepoName)); err != nil {
1263
return err
1264
}
1265
1266
-
// t.CommitterDid (string) (string)
1267
-
if len("committerDid") > 1000000 {
1268
-
return xerrors.Errorf("Value in field \"committerDid\" was too long")
1269
}
1270
1271
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("committerDid"))); err != nil {
1272
return err
1273
}
1274
-
if _, err := cw.WriteString(string("committerDid")); err != nil {
1275
return err
1276
}
1277
1278
-
if len(t.CommitterDid) > 1000000 {
1279
-
return xerrors.Errorf("Value in field t.CommitterDid was too long")
1280
}
1281
1282
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CommitterDid))); err != nil {
1283
return err
1284
}
1285
-
if _, err := cw.WriteString(string(t.CommitterDid)); err != nil {
1286
return err
1287
}
1288
return nil
1289
}
1290
1291
-
func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) {
1292
-
*t = GitRefUpdate{}
1293
1294
cr := cbg.NewCborReader(r)
1295
···
1308
}
1309
1310
if extra > cbg.MaxLength {
1311
-
return fmt.Errorf("GitRefUpdate: map struct too large (%d)", extra)
1312
}
1313
1314
n := extra
1315
1316
-
nameBuf := make([]byte, 12)
1317
for i := uint64(0); i < n; i++ {
1318
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
1319
if err != nil {
···
1329
}
1330
1331
switch string(nameBuf[:nameLen]) {
1332
-
// t.Ref (string) (string)
1333
-
case "ref":
1334
-
1335
{
1336
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
1337
if err != nil {
1338
return err
1339
}
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
1355
}
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)
1359
}
1360
}
1361
1362
}
1363
-
// t.LexiconTypeID (string) (string)
1364
-
case "$type":
1365
1366
{
1367
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
1369
return err
1370
}
1371
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)
1428
}
1429
1430
default:
···
1799
1800
return nil
1801
}
1802
-
func (t *PipelineStatus) MarshalCBOR(w io.Writer) error {
1803
if t == nil {
1804
_, err := w.Write(cbg.CborNull)
1805
return err
1806
}
1807
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
1819
-
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
1820
return err
1821
}
1822
···
1832
return err
1833
}
1834
1835
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline.status"))); err != nil {
1836
return err
1837
}
1838
-
if _, err := cw.WriteString(string("sh.tangled.pipeline.status")); err != nil {
1839
return err
1840
}
1841
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")
1877
}
1878
1879
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil {
1880
return err
1881
}
1882
-
if _, err := cw.WriteString(string("status")); err != nil {
1883
return err
1884
}
1885
1886
-
if len(t.Status) > 1000000 {
1887
-
return xerrors.Errorf("Value in field t.Status was too long")
1888
}
1889
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 {
1894
return err
1895
}
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 {
1908
return err
1909
}
1910
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
}
1928
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")
1978
}
1979
1980
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
1981
return err
1982
}
1983
-
if _, err := cw.WriteString(string("createdAt")); err != nil {
1984
return err
1985
}
1986
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 {
1995
return err
1996
}
1997
return nil
1998
}
1999
2000
-
func (t *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) {
2001
-
*t = PipelineStatus{}
2002
2003
cr := cbg.NewCborReader(r)
2004
···
2017
}
2018
2019
if extra > cbg.MaxLength {
2020
-
return fmt.Errorf("PipelineStatus: map struct too large (%d)", extra)
2021
}
2022
2023
n := extra
2024
2025
-
nameBuf := make([]byte, 9)
2026
for i := uint64(0); i < n; i++ {
2027
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
2028
if err != nil {
···
2049
2050
t.LexiconTypeID = string(sval)
2051
}
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
-
}
2064
2065
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2066
-
if err != nil {
2067
-
return err
2068
-
}
2069
2070
-
t.Error = (*string)(&sval)
2071
-
}
2072
}
2073
-
// t.Status (string) (string)
2074
-
case "status":
2075
2076
-
{
2077
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2078
-
if err != nil {
2079
-
return err
2080
-
}
2081
2082
-
t.Status = string(sval)
2083
-
}
2084
-
// t.ExitCode (int64) (int64)
2085
-
case "exitCode":
2086
-
{
2087
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")
2106
}
2107
-
case cbg.MajNegativeInt:
2108
-
extraI = int64(extra)
2109
-
if extraI < 0 {
2110
-
return fmt.Errorf("int64 negative overflow")
2111
}
2112
-
extraI = -1 - extraI
2113
-
default:
2114
-
return fmt.Errorf("wrong type for int64 field: %d", maj)
2115
}
2116
2117
-
t.ExitCode = (*int64)(&extraI)
2118
}
2119
}
2120
-
// t.Pipeline (string) (string)
2121
-
case "pipeline":
2122
2123
{
2124
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2125
-
if err != nil {
2126
-
return err
2127
-
}
2128
2129
-
t.Pipeline = string(sval)
2130
-
}
2131
-
// t.Workflow (string) (string)
2132
-
case "workflow":
2133
-
2134
-
{
2135
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2136
if err != nil {
2137
return err
2138
}
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
2149
}
2150
2151
-
t.CreatedAt = string(sval)
2152
}
2153
2154
default:
···
2516
2517
return nil
2518
}
2519
-
func (t *Pipeline_ManualTriggerData_Inputs_Elem) MarshalCBOR(w io.Writer) error {
2520
if t == nil {
2521
_, err := w.Write(cbg.CborNull)
2522
return err
2523
}
2524
2525
cw := cbg.NewCborWriter(w)
2526
-
2527
-
if _, err := cw.Write([]byte{162}); err != nil {
2528
-
return err
2529
-
}
2530
2531
-
// t.Key (string) (string)
2532
-
if len("key") > 1000000 {
2533
-
return xerrors.Errorf("Value in field \"key\" was too long")
2534
}
2535
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 {
2540
return err
2541
}
2542
2543
-
if len(t.Key) > 1000000 {
2544
-
return xerrors.Errorf("Value in field t.Key was too long")
2545
-
}
2546
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
-
}
2553
2554
-
// t.Value (string) (string)
2555
-
if len("value") > 1000000 {
2556
-
return xerrors.Errorf("Value in field \"value\" was too long")
2557
-
}
2558
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
-
}
2565
2566
-
if len(t.Value) > 1000000 {
2567
-
return xerrors.Errorf("Value in field t.Value was too long")
2568
-
}
2569
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
2575
}
2576
return nil
2577
}
2578
2579
-
func (t *Pipeline_ManualTriggerData_Inputs_Elem) UnmarshalCBOR(r io.Reader) (err error) {
2580
-
*t = Pipeline_ManualTriggerData_Inputs_Elem{}
2581
2582
cr := cbg.NewCborReader(r)
2583
···
2596
}
2597
2598
if extra > cbg.MaxLength {
2599
-
return fmt.Errorf("Pipeline_ManualTriggerData_Inputs_Elem: map struct too large (%d)", extra)
2600
}
2601
2602
n := extra
2603
2604
-
nameBuf := make([]byte, 5)
2605
for i := uint64(0); i < n; i++ {
2606
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
2607
if err != nil {
···
2617
}
2618
2619
switch string(nameBuf[:nameLen]) {
2620
-
// t.Key (string) (string)
2621
-
case "key":
2622
2623
-
{
2624
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2625
-
if err != nil {
2626
-
return err
2627
-
}
2628
2629
-
t.Key = string(sval)
2630
}
2631
-
// t.Value (string) (string)
2632
-
case "value":
2633
2634
-
{
2635
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2636
-
if err != nil {
2637
-
return err
2638
-
}
2639
2640
-
t.Value = string(sval)
2641
}
2642
2643
default:
···
2650
2651
return nil
2652
}
2653
-
func (t *Pipeline_ManualTriggerData) MarshalCBOR(w io.Writer) error {
2654
if t == nil {
2655
_, err := w.Write(cbg.CborNull)
2656
return err
2657
}
2658
2659
cw := cbg.NewCborWriter(w)
2660
-
fieldCount := 1
2661
2662
-
if t.Inputs == nil {
2663
-
fieldCount--
2664
}
2665
2666
-
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
2667
return err
2668
}
2669
2670
-
// t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice)
2671
-
if t.Inputs != nil {
2672
2673
-
if len("inputs") > 1000000 {
2674
-
return xerrors.Errorf("Value in field \"inputs\" was too long")
2675
-
}
2676
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
-
}
2683
2684
-
if len(t.Inputs) > 8192 {
2685
-
return xerrors.Errorf("Slice value in field t.Inputs was too long")
2686
-
}
2687
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
-
}
2695
2696
-
}
2697
}
2698
return nil
2699
}
2700
2701
-
func (t *Pipeline_ManualTriggerData) UnmarshalCBOR(r io.Reader) (err error) {
2702
-
*t = Pipeline_ManualTriggerData{}
2703
2704
cr := cbg.NewCborReader(r)
2705
···
2718
}
2719
2720
if extra > cbg.MaxLength {
2721
-
return fmt.Errorf("Pipeline_ManualTriggerData: map struct too large (%d)", extra)
2722
}
2723
2724
n := extra
2725
2726
-
nameBuf := make([]byte, 6)
2727
for i := uint64(0); i < n; i++ {
2728
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
2729
if err != nil {
···
2739
}
2740
2741
switch string(nameBuf[:nameLen]) {
2742
-
// t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice)
2743
-
case "inputs":
2744
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
-
}
2757
2758
-
if extra > 0 {
2759
-
t.Inputs = make([]*Pipeline_ManualTriggerData_Inputs_Elem, extra)
2760
}
2761
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
2770
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
-
}
2790
}
2791
2792
default:
···
3169
3170
return nil
3171
}
3172
func (t *Pipeline_Step) MarshalCBOR(w io.Writer) error {
3173
if t == nil {
3174
_, err := w.Write(cbg.CborNull)
···
3771
3772
return nil
3773
}
3774
-
func (t *Pipeline_Workflow_Environment_Elem) MarshalCBOR(w io.Writer) error {
3775
-
if t == nil {
3776
-
_, err := w.Write(cbg.CborNull)
3777
-
return err
3778
-
}
3779
-
3780
-
cw := cbg.NewCborWriter(w)
3781
-
3782
-
if _, err := cw.Write([]byte{162}); err != nil {
3783
-
return err
3784
-
}
3785
-
3786
-
// t.Key (string) (string)
3787
-
if len("key") > 1000000 {
3788
-
return xerrors.Errorf("Value in field \"key\" was too long")
3789
-
}
3790
-
3791
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil {
3792
-
return err
3793
-
}
3794
-
if _, err := cw.WriteString(string("key")); err != nil {
3795
-
return err
3796
-
}
3797
-
3798
-
if len(t.Key) > 1000000 {
3799
-
return xerrors.Errorf("Value in field t.Key was too long")
3800
-
}
3801
-
3802
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
3803
-
return err
3804
-
}
3805
-
if _, err := cw.WriteString(string(t.Key)); err != nil {
3806
-
return err
3807
-
}
3808
-
3809
-
// t.Value (string) (string)
3810
-
if len("value") > 1000000 {
3811
-
return xerrors.Errorf("Value in field \"value\" was too long")
3812
-
}
3813
-
3814
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil {
3815
-
return err
3816
-
}
3817
-
if _, err := cw.WriteString(string("value")); err != nil {
3818
-
return err
3819
-
}
3820
-
3821
-
if len(t.Value) > 1000000 {
3822
-
return xerrors.Errorf("Value in field t.Value was too long")
3823
-
}
3824
-
3825
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil {
3826
-
return err
3827
-
}
3828
-
if _, err := cw.WriteString(string(t.Value)); err != nil {
3829
-
return err
3830
-
}
3831
-
return nil
3832
-
}
3833
-
3834
-
func (t *Pipeline_Workflow_Environment_Elem) UnmarshalCBOR(r io.Reader) (err error) {
3835
-
*t = Pipeline_Workflow_Environment_Elem{}
3836
-
3837
-
cr := cbg.NewCborReader(r)
3838
-
3839
-
maj, extra, err := cr.ReadHeader()
3840
-
if err != nil {
3841
-
return err
3842
-
}
3843
-
defer func() {
3844
-
if err == io.EOF {
3845
-
err = io.ErrUnexpectedEOF
3846
-
}
3847
-
}()
3848
-
3849
-
if maj != cbg.MajMap {
3850
-
return fmt.Errorf("cbor input should be of type map")
3851
-
}
3852
-
3853
-
if extra > cbg.MaxLength {
3854
-
return fmt.Errorf("Pipeline_Workflow_Environment_Elem: map struct too large (%d)", extra)
3855
-
}
3856
-
3857
-
n := extra
3858
-
3859
-
nameBuf := make([]byte, 5)
3860
-
for i := uint64(0); i < n; i++ {
3861
-
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
3862
-
if err != nil {
3863
-
return err
3864
-
}
3865
-
3866
-
if !ok {
3867
-
// Field doesn't exist on this type, so ignore it
3868
-
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
3869
-
return err
3870
-
}
3871
-
continue
3872
-
}
3873
-
3874
-
switch string(nameBuf[:nameLen]) {
3875
-
// t.Key (string) (string)
3876
-
case "key":
3877
-
3878
-
{
3879
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3880
-
if err != nil {
3881
-
return err
3882
-
}
3883
-
3884
-
t.Key = string(sval)
3885
-
}
3886
-
// t.Value (string) (string)
3887
-
case "value":
3888
-
3889
-
{
3890
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3891
-
if err != nil {
3892
-
return err
3893
-
}
3894
-
3895
-
t.Value = string(sval)
3896
-
}
3897
-
3898
-
default:
3899
-
// Field doesn't exist on this type, so ignore it
3900
-
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
3901
-
return err
3902
-
}
3903
-
}
3904
-
}
3905
-
3906
-
return nil
3907
-
}
3908
func (t *Pipeline_Workflow) MarshalCBOR(w io.Writer) error {
3909
if t == nil {
3910
_, err := w.Write(cbg.CborNull)
···
4256
4257
return nil
4258
}
4259
-
func (t *Pipeline) MarshalCBOR(w io.Writer) error {
4260
if t == nil {
4261
_, err := w.Write(cbg.CborNull)
4262
return err
···
4264
4265
cw := cbg.NewCborWriter(w)
4266
4267
-
if _, err := cw.Write([]byte{163}); err != nil {
4268
return err
4269
}
4270
4271
-
// t.LexiconTypeID (string) (string)
4272
-
if len("$type") > 1000000 {
4273
-
return xerrors.Errorf("Value in field \"$type\" was too long")
4274
-
}
4275
-
4276
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
4277
-
return err
4278
-
}
4279
-
if _, err := cw.WriteString(string("$type")); err != nil {
4280
-
return err
4281
}
4282
4283
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline"))); err != nil {
4284
return err
4285
}
4286
-
if _, err := cw.WriteString(string("sh.tangled.pipeline")); err != nil {
4287
return err
4288
}
4289
4290
-
// t.Workflows ([]*tangled.Pipeline_Workflow) (slice)
4291
-
if len("workflows") > 1000000 {
4292
-
return xerrors.Errorf("Value in field \"workflows\" was too long")
4293
}
4294
4295
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflows"))); err != nil {
4296
return err
4297
}
4298
-
if _, err := cw.WriteString(string("workflows")); err != nil {
4299
return err
4300
}
4301
4302
-
if len(t.Workflows) > 8192 {
4303
-
return xerrors.Errorf("Slice value in field t.Workflows was too long")
4304
}
4305
4306
-
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Workflows))); err != nil {
4307
return err
4308
}
4309
-
for _, v := range t.Workflows {
4310
-
if err := v.MarshalCBOR(cw); err != nil {
4311
-
return err
4312
-
}
4313
-
4314
}
4315
4316
-
// t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct)
4317
-
if len("triggerMetadata") > 1000000 {
4318
-
return xerrors.Errorf("Value in field \"triggerMetadata\" was too long")
4319
}
4320
4321
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("triggerMetadata"))); err != nil {
4322
return err
4323
}
4324
-
if _, err := cw.WriteString(string("triggerMetadata")); err != nil {
4325
-
return err
4326
-
}
4327
-
4328
-
if err := t.TriggerMetadata.MarshalCBOR(cw); err != nil {
4329
return err
4330
}
4331
return nil
4332
}
4333
4334
-
func (t *Pipeline) UnmarshalCBOR(r io.Reader) (err error) {
4335
-
*t = Pipeline{}
4336
4337
cr := cbg.NewCborReader(r)
4338
···
4351
}
4352
4353
if extra > cbg.MaxLength {
4354
-
return fmt.Errorf("Pipeline: map struct too large (%d)", extra)
4355
}
4356
4357
n := extra
4358
4359
-
nameBuf := make([]byte, 15)
4360
for i := uint64(0); i < n; i++ {
4361
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
4362
if err != nil {
···
4372
}
4373
4374
switch string(nameBuf[:nameLen]) {
4375
-
// t.LexiconTypeID (string) (string)
4376
-
case "$type":
4377
4378
{
4379
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
4381
return err
4382
}
4383
4384
-
t.LexiconTypeID = string(sval)
4385
-
}
4386
-
// t.Workflows ([]*tangled.Pipeline_Workflow) (slice)
4387
-
case "workflows":
4388
-
4389
-
maj, extra, err = cr.ReadHeader()
4390
-
if err != nil {
4391
-
return err
4392
}
4393
-
4394
-
if extra > 8192 {
4395
-
return fmt.Errorf("t.Workflows: array too large (%d)", extra)
4396
-
}
4397
-
4398
-
if maj != cbg.MajArray {
4399
-
return fmt.Errorf("expected cbor array")
4400
-
}
4401
-
4402
-
if extra > 0 {
4403
-
t.Workflows = make([]*Pipeline_Workflow, extra)
4404
-
}
4405
-
4406
-
for i := 0; i < int(extra); i++ {
4407
-
{
4408
-
var maj byte
4409
-
var extra uint64
4410
-
var err error
4411
-
_ = maj
4412
-
_ = extra
4413
-
_ = err
4414
-
4415
-
{
4416
-
4417
-
b, err := cr.ReadByte()
4418
-
if err != nil {
4419
-
return err
4420
-
}
4421
-
if b != cbg.CborNull[0] {
4422
-
if err := cr.UnreadByte(); err != nil {
4423
-
return err
4424
-
}
4425
-
t.Workflows[i] = new(Pipeline_Workflow)
4426
-
if err := t.Workflows[i].UnmarshalCBOR(cr); err != nil {
4427
-
return xerrors.Errorf("unmarshaling t.Workflows[i] pointer: %w", err)
4428
-
}
4429
-
}
4430
-
4431
-
}
4432
-
4433
-
}
4434
-
}
4435
-
// t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct)
4436
-
case "triggerMetadata":
4437
4438
{
4439
-
4440
-
b, err := cr.ReadByte()
4441
if err != nil {
4442
return err
4443
}
4444
-
if b != cbg.CborNull[0] {
4445
-
if err := cr.UnreadByte(); err != nil {
4446
-
return err
4447
-
}
4448
-
t.TriggerMetadata = new(Pipeline_TriggerMetadata)
4449
-
if err := t.TriggerMetadata.UnmarshalCBOR(cr); err != nil {
4450
-
return xerrors.Errorf("unmarshaling t.TriggerMetadata pointer: %w", err)
4451
-
}
4452
-
}
4453
4454
}
4455
4456
default:
···
4661
4662
return nil
4663
}
4664
func (t *RepoArtifact) MarshalCBOR(w io.Writer) error {
4665
if t == nil {
4666
_, err := w.Write(cbg.CborNull)
···
4951
4952
return nil
4953
}
4954
func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error {
4955
if t == nil {
4956
_, err := w.Write(cbg.CborNull)
···
5500
5501
return nil
5502
}
5503
-
func (t *RepoIssue) MarshalCBOR(w io.Writer) error {
5504
if t == nil {
5505
_, err := w.Write(cbg.CborNull)
5506
return err
5507
}
5508
5509
cw := cbg.NewCborWriter(w)
5510
-
fieldCount := 7
5511
5512
if t.Body == nil {
5513
fieldCount--
5514
}
5515
···
5549
}
5550
}
5551
5552
-
// t.Repo (string) (string)
5553
-
if len("repo") > 1000000 {
5554
-
return xerrors.Errorf("Value in field \"repo\" was too long")
5555
-
}
5556
-
5557
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil {
5558
-
return err
5559
-
}
5560
-
if _, err := cw.WriteString(string("repo")); err != nil {
5561
-
return err
5562
-
}
5563
-
5564
-
if len(t.Repo) > 1000000 {
5565
-
return xerrors.Errorf("Value in field t.Repo was too long")
5566
-
}
5567
-
5568
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil {
5569
-
return err
5570
-
}
5571
-
if _, err := cw.WriteString(string(t.Repo)); err != nil {
5572
-
return err
5573
-
}
5574
-
5575
// t.LexiconTypeID (string) (string)
5576
if len("$type") > 1000000 {
5577
return xerrors.Errorf("Value in field \"$type\" was too long")
···
5584
return err
5585
}
5586
5587
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue"))); err != nil {
5588
return err
5589
}
5590
-
if _, err := cw.WriteString(string("sh.tangled.repo.issue")); err != nil {
5591
return err
5592
}
5593
5594
-
// t.Owner (string) (string)
5595
-
if len("owner") > 1000000 {
5596
-
return xerrors.Errorf("Value in field \"owner\" was too long")
5597
}
5598
5599
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil {
5600
return err
5601
}
5602
-
if _, err := cw.WriteString(string("owner")); err != nil {
5603
return err
5604
}
5605
5606
-
if len(t.Owner) > 1000000 {
5607
-
return xerrors.Errorf("Value in field t.Owner was too long")
5608
}
5609
5610
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil {
5611
return err
5612
}
5613
-
if _, err := cw.WriteString(string(t.Owner)); err != nil {
5614
return err
5615
}
5616
···
5637
return err
5638
}
5639
5640
-
// t.IssueId (int64) (int64)
5641
-
if len("issueId") > 1000000 {
5642
-
return xerrors.Errorf("Value in field \"issueId\" was too long")
5643
}
5644
5645
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issueId"))); err != nil {
5646
return err
5647
}
5648
-
if _, err := cw.WriteString(string("issueId")); err != nil {
5649
return err
5650
}
5651
5652
-
if t.IssueId >= 0 {
5653
-
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.IssueId)); err != nil {
5654
return err
5655
}
5656
} else {
5657
-
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.IssueId-1)); err != nil {
5658
return err
5659
}
5660
}
···
5681
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
5682
return err
5683
}
5684
return nil
5685
}
5686
5687
-
func (t *RepoIssue) UnmarshalCBOR(r io.Reader) (err error) {
5688
-
*t = RepoIssue{}
5689
5690
cr := cbg.NewCborReader(r)
5691
···
5704
}
5705
5706
if extra > cbg.MaxLength {
5707
-
return fmt.Errorf("RepoIssue: map struct too large (%d)", extra)
5708
}
5709
5710
n := extra
5711
5712
-
nameBuf := make([]byte, 9)
5713
for i := uint64(0); i < n; i++ {
5714
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
5715
if err != nil {
···
5746
t.Body = (*string)(&sval)
5747
}
5748
}
5749
-
// t.Repo (string) (string)
5750
-
case "repo":
5751
-
5752
-
{
5753
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
5754
-
if err != nil {
5755
-
return err
5756
-
}
5757
-
5758
-
t.Repo = string(sval)
5759
-
}
5760
// t.LexiconTypeID (string) (string)
5761
case "$type":
5762
···
5768
5769
t.LexiconTypeID = string(sval)
5770
}
5771
-
// t.Owner (string) (string)
5772
-
case "owner":
5773
5774
{
5775
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
5777
return err
5778
}
5779
5780
-
t.Owner = string(sval)
5781
}
5782
// t.Title (string) (string)
5783
case "title":
···
5790
5791
t.Title = string(sval)
5792
}
5793
-
// t.IssueId (int64) (int64)
5794
-
case "issueId":
5795
{
5796
maj, extra, err := cr.ReadHeader()
5797
if err != nil {
···
5814
return fmt.Errorf("wrong type for int64 field: %d", maj)
5815
}
5816
5817
-
t.IssueId = int64(extraI)
5818
}
5819
// t.CreatedAt (string) (string)
5820
case "createdAt":
···
5826
}
5827
5828
t.CreatedAt = string(sval)
5829
}
5830
5831
default:
···
6223
6224
return nil
6225
}
6226
-
func (t *RepoPullStatus) MarshalCBOR(w io.Writer) error {
6227
-
if t == nil {
6228
-
_, err := w.Write(cbg.CborNull)
6229
-
return err
6230
-
}
6231
-
6232
-
cw := cbg.NewCborWriter(w)
6233
-
6234
-
if _, err := cw.Write([]byte{163}); err != nil {
6235
-
return err
6236
-
}
6237
-
6238
-
// t.Pull (string) (string)
6239
-
if len("pull") > 1000000 {
6240
-
return xerrors.Errorf("Value in field \"pull\" was too long")
6241
-
}
6242
-
6243
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil {
6244
-
return err
6245
-
}
6246
-
if _, err := cw.WriteString(string("pull")); err != nil {
6247
-
return err
6248
-
}
6249
-
6250
-
if len(t.Pull) > 1000000 {
6251
-
return xerrors.Errorf("Value in field t.Pull was too long")
6252
-
}
6253
-
6254
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pull))); err != nil {
6255
-
return err
6256
-
}
6257
-
if _, err := cw.WriteString(string(t.Pull)); err != nil {
6258
-
return err
6259
-
}
6260
-
6261
-
// t.LexiconTypeID (string) (string)
6262
-
if len("$type") > 1000000 {
6263
-
return xerrors.Errorf("Value in field \"$type\" was too long")
6264
-
}
6265
-
6266
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
6267
-
return err
6268
-
}
6269
-
if _, err := cw.WriteString(string("$type")); err != nil {
6270
-
return err
6271
-
}
6272
-
6273
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.status"))); err != nil {
6274
-
return err
6275
-
}
6276
-
if _, err := cw.WriteString(string("sh.tangled.repo.pull.status")); err != nil {
6277
-
return err
6278
-
}
6279
-
6280
-
// t.Status (string) (string)
6281
-
if len("status") > 1000000 {
6282
-
return xerrors.Errorf("Value in field \"status\" was too long")
6283
-
}
6284
-
6285
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil {
6286
-
return err
6287
-
}
6288
-
if _, err := cw.WriteString(string("status")); err != nil {
6289
-
return err
6290
-
}
6291
-
6292
-
if len(t.Status) > 1000000 {
6293
-
return xerrors.Errorf("Value in field t.Status was too long")
6294
-
}
6295
-
6296
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil {
6297
-
return err
6298
-
}
6299
-
if _, err := cw.WriteString(string(t.Status)); err != nil {
6300
-
return err
6301
-
}
6302
-
return nil
6303
-
}
6304
-
6305
-
func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) {
6306
-
*t = RepoPullStatus{}
6307
-
6308
-
cr := cbg.NewCborReader(r)
6309
-
6310
-
maj, extra, err := cr.ReadHeader()
6311
-
if err != nil {
6312
-
return err
6313
-
}
6314
-
defer func() {
6315
-
if err == io.EOF {
6316
-
err = io.ErrUnexpectedEOF
6317
-
}
6318
-
}()
6319
-
6320
-
if maj != cbg.MajMap {
6321
-
return fmt.Errorf("cbor input should be of type map")
6322
-
}
6323
-
6324
-
if extra > cbg.MaxLength {
6325
-
return fmt.Errorf("RepoPullStatus: map struct too large (%d)", extra)
6326
-
}
6327
-
6328
-
n := extra
6329
-
6330
-
nameBuf := make([]byte, 6)
6331
-
for i := uint64(0); i < n; i++ {
6332
-
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
6333
-
if err != nil {
6334
-
return err
6335
-
}
6336
-
6337
-
if !ok {
6338
-
// Field doesn't exist on this type, so ignore it
6339
-
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
6340
-
return err
6341
-
}
6342
-
continue
6343
-
}
6344
-
6345
-
switch string(nameBuf[:nameLen]) {
6346
-
// t.Pull (string) (string)
6347
-
case "pull":
6348
-
6349
-
{
6350
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
6351
-
if err != nil {
6352
-
return err
6353
-
}
6354
-
6355
-
t.Pull = string(sval)
6356
-
}
6357
-
// t.LexiconTypeID (string) (string)
6358
-
case "$type":
6359
-
6360
-
{
6361
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
6362
-
if err != nil {
6363
-
return err
6364
-
}
6365
-
6366
-
t.LexiconTypeID = string(sval)
6367
-
}
6368
-
// t.Status (string) (string)
6369
-
case "status":
6370
-
6371
-
{
6372
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
6373
-
if err != nil {
6374
-
return err
6375
-
}
6376
-
6377
-
t.Status = string(sval)
6378
-
}
6379
-
6380
-
default:
6381
-
// Field doesn't exist on this type, so ignore it
6382
-
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
6383
-
return err
6384
-
}
6385
-
}
6386
-
}
6387
-
6388
-
return nil
6389
-
}
6390
func (t *RepoPull_Source) MarshalCBOR(w io.Writer) error {
6391
if t == nil {
6392
_, err := w.Write(cbg.CborNull)
···
6545
6546
return nil
6547
}
6548
-
func (t *RepoPull) MarshalCBOR(w io.Writer) error {
6549
if t == nil {
6550
_, err := w.Write(cbg.CborNull)
6551
return err
6552
}
6553
6554
cw := cbg.NewCborWriter(w)
6555
-
fieldCount := 9
6556
6557
-
if t.Body == nil {
6558
-
fieldCount--
6559
-
}
6560
-
6561
-
if t.Source == nil {
6562
-
fieldCount--
6563
-
}
6564
-
6565
-
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
6566
return err
6567
}
6568
6569
-
// t.Body (string) (string)
6570
-
if t.Body != nil {
6571
-
6572
-
if len("body") > 1000000 {
6573
-
return xerrors.Errorf("Value in field \"body\" was too long")
6574
-
}
6575
-
6576
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil {
6577
-
return err
6578
-
}
6579
-
if _, err := cw.WriteString(string("body")); err != nil {
6580
-
return err
6581
-
}
6582
-
6583
-
if t.Body == nil {
6584
-
if _, err := cw.Write(cbg.CborNull); err != nil {
6585
-
return err
6586
-
}
6587
-
} else {
6588
-
if len(*t.Body) > 1000000 {
6589
-
return xerrors.Errorf("Value in field t.Body was too long")
6590
-
}
6591
-
6592
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil {
6593
-
return err
6594
-
}
6595
-
if _, err := cw.WriteString(string(*t.Body)); err != nil {
6596
-
return err
6597
-
}
6598
-
}
6599
}
6600
6601
-
// t.LexiconTypeID (string) (string)
6602
-
if len("$type") > 1000000 {
6603
-
return xerrors.Errorf("Value in field \"$type\" was too long")
6604
-
}
6605
-
6606
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
6607
return err
6608
}
6609
-
if _, err := cw.WriteString(string("$type")); err != nil {
6610
return err
6611
}
6612
6613
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull"))); err != nil {
6614
-
return err
6615
-
}
6616
-
if _, err := cw.WriteString(string("sh.tangled.repo.pull")); err != nil {
6617
-
return err
6618
}
6619
6620
-
// t.Patch (string) (string)
6621
-
if len("patch") > 1000000 {
6622
-
return xerrors.Errorf("Value in field \"patch\" was too long")
6623
-
}
6624
-
6625
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patch"))); err != nil {
6626
return err
6627
}
6628
-
if _, err := cw.WriteString(string("patch")); err != nil {
6629
return err
6630
}
6631
6632
-
if len(t.Patch) > 1000000 {
6633
-
return xerrors.Errorf("Value in field t.Patch was too long")
6634
}
6635
6636
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Patch))); err != nil {
6637
-
return err
6638
-
}
6639
-
if _, err := cw.WriteString(string(t.Patch)); err != nil {
6640
-
return err
6641
-
}
6642
-
6643
-
// t.Title (string) (string)
6644
-
if len("title") > 1000000 {
6645
-
return xerrors.Errorf("Value in field \"title\" was too long")
6646
-
}
6647
-
6648
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil {
6649
-
return err
6650
-
}
6651
-
if _, err := cw.WriteString(string("title")); err != nil {
6652
-
return err
6653
-
}
6654
-
6655
-
if len(t.Title) > 1000000 {
6656
-
return xerrors.Errorf("Value in field t.Title was too long")
6657
-
}
6658
-
6659
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil {
6660
return err
6661
}
6662
-
if _, err := cw.WriteString(string(t.Title)); err != nil {
6663
return err
6664
}
6665
6666
-
// t.PullId (int64) (int64)
6667
-
if len("pullId") > 1000000 {
6668
-
return xerrors.Errorf("Value in field \"pullId\" was too long")
6669
-
}
6670
-
6671
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pullId"))); err != nil {
6672
return err
6673
}
6674
-
if _, err := cw.WriteString(string("pullId")); err != nil {
6675
return err
6676
}
6677
6678
-
if t.PullId >= 0 {
6679
-
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.PullId)); err != nil {
6680
-
return err
6681
-
}
6682
-
} else {
6683
-
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.PullId-1)); err != nil {
6684
-
return err
6685
-
}
6686
}
6687
6688
-
// t.Source (tangled.RepoPull_Source) (struct)
6689
-
if t.Source != nil {
6690
-
6691
-
if len("source") > 1000000 {
6692
-
return xerrors.Errorf("Value in field \"source\" was too long")
6693
-
}
6694
-
6695
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil {
6696
-
return err
6697
-
}
6698
-
if _, err := cw.WriteString(string("source")); err != nil {
6699
-
return err
6700
-
}
6701
-
6702
-
if err := t.Source.MarshalCBOR(cw); err != nil {
6703
-
return err
6704
-
}
6705
-
}
6706
-
6707
-
// t.CreatedAt (string) (string)
6708
-
if len("createdAt") > 1000000 {
6709
-
return xerrors.Errorf("Value in field \"createdAt\" was too long")
6710
-
}
6711
-
6712
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
6713
return err
6714
}
6715
-
if _, err := cw.WriteString(string("createdAt")); err != nil {
6716
return err
6717
}
6718
6719
-
if len(t.CreatedAt) > 1000000 {
6720
-
return xerrors.Errorf("Value in field t.CreatedAt was too long")
6721
}
6722
6723
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
6724
return err
6725
}
6726
-
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
6727
-
return err
6728
-
}
6729
-
6730
-
// t.TargetRepo (string) (string)
6731
-
if len("targetRepo") > 1000000 {
6732
-
return xerrors.Errorf("Value in field \"targetRepo\" was too long")
6733
-
}
6734
-
6735
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetRepo"))); err != nil {
6736
-
return err
6737
-
}
6738
-
if _, err := cw.WriteString(string("targetRepo")); err != nil {
6739
-
return err
6740
-
}
6741
-
6742
-
if len(t.TargetRepo) > 1000000 {
6743
-
return xerrors.Errorf("Value in field t.TargetRepo was too long")
6744
-
}
6745
-
6746
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetRepo))); err != nil {
6747
-
return err
6748
-
}
6749
-
if _, err := cw.WriteString(string(t.TargetRepo)); err != nil {
6750
-
return err
6751
-
}
6752
-
6753
-
// t.TargetBranch (string) (string)
6754
-
if len("targetBranch") > 1000000 {
6755
-
return xerrors.Errorf("Value in field \"targetBranch\" was too long")
6756
-
}
6757
-
6758
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetBranch"))); err != nil {
6759
-
return err
6760
-
}
6761
-
if _, err := cw.WriteString(string("targetBranch")); err != nil {
6762
-
return err
6763
-
}
6764
-
6765
-
if len(t.TargetBranch) > 1000000 {
6766
-
return xerrors.Errorf("Value in field t.TargetBranch was too long")
6767
-
}
6768
-
6769
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetBranch))); err != nil {
6770
-
return err
6771
-
}
6772
-
if _, err := cw.WriteString(string(t.TargetBranch)); err != nil {
6773
return err
6774
}
6775
return nil
6776
}
6777
6778
-
func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) {
6779
-
*t = RepoPull{}
6780
6781
cr := cbg.NewCborReader(r)
6782
···
6795
}
6796
6797
if extra > cbg.MaxLength {
6798
-
return fmt.Errorf("RepoPull: map struct too large (%d)", extra)
6799
}
6800
6801
n := extra
6802
6803
-
nameBuf := make([]byte, 12)
6804
for i := uint64(0); i < n; i++ {
6805
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
6806
if err != nil {
···
6816
}
6817
6818
switch string(nameBuf[:nameLen]) {
6819
-
// t.Body (string) (string)
6820
-
case "body":
6821
6822
{
6823
-
b, err := cr.ReadByte()
6824
if err != nil {
6825
return err
6826
}
6827
-
if b != cbg.CborNull[0] {
6828
-
if err := cr.UnreadByte(); err != nil {
6829
-
return err
6830
-
}
6831
6832
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
6833
-
if err != nil {
6834
-
return err
6835
-
}
6836
-
6837
-
t.Body = (*string)(&sval)
6838
-
}
6839
}
6840
// t.LexiconTypeID (string) (string)
6841
case "$type":
···
6848
6849
t.LexiconTypeID = string(sval)
6850
}
6851
-
// t.Patch (string) (string)
6852
-
case "patch":
6853
6854
{
6855
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
6857
return err
6858
}
6859
6860
-
t.Patch = string(sval)
6861
-
}
6862
-
// t.Title (string) (string)
6863
-
case "title":
6864
-
6865
-
{
6866
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
6867
-
if err != nil {
6868
-
return err
6869
-
}
6870
-
6871
-
t.Title = string(sval)
6872
-
}
6873
-
// t.PullId (int64) (int64)
6874
-
case "pullId":
6875
-
{
6876
-
maj, extra, err := cr.ReadHeader()
6877
-
if err != nil {
6878
-
return err
6879
-
}
6880
-
var extraI int64
6881
-
switch maj {
6882
-
case cbg.MajUnsignedInt:
6883
-
extraI = int64(extra)
6884
-
if extraI < 0 {
6885
-
return fmt.Errorf("int64 positive overflow")
6886
-
}
6887
-
case cbg.MajNegativeInt:
6888
-
extraI = int64(extra)
6889
-
if extraI < 0 {
6890
-
return fmt.Errorf("int64 negative overflow")
6891
-
}
6892
-
extraI = -1 - extraI
6893
-
default:
6894
-
return fmt.Errorf("wrong type for int64 field: %d", maj)
6895
-
}
6896
-
6897
-
t.PullId = int64(extraI)
6898
-
}
6899
-
// t.Source (tangled.RepoPull_Source) (struct)
6900
-
case "source":
6901
-
6902
-
{
6903
-
6904
-
b, err := cr.ReadByte()
6905
-
if err != nil {
6906
-
return err
6907
-
}
6908
-
if b != cbg.CborNull[0] {
6909
-
if err := cr.UnreadByte(); err != nil {
6910
-
return err
6911
-
}
6912
-
t.Source = new(RepoPull_Source)
6913
-
if err := t.Source.UnmarshalCBOR(cr); err != nil {
6914
-
return xerrors.Errorf("unmarshaling t.Source pointer: %w", err)
6915
-
}
6916
-
}
6917
-
6918
-
}
6919
-
// t.CreatedAt (string) (string)
6920
-
case "createdAt":
6921
-
6922
-
{
6923
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
6924
-
if err != nil {
6925
-
return err
6926
-
}
6927
-
6928
-
t.CreatedAt = string(sval)
6929
-
}
6930
-
// t.TargetRepo (string) (string)
6931
-
case "targetRepo":
6932
-
6933
-
{
6934
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
6935
-
if err != nil {
6936
-
return err
6937
-
}
6938
-
6939
-
t.TargetRepo = string(sval)
6940
-
}
6941
-
// t.TargetBranch (string) (string)
6942
-
case "targetBranch":
6943
-
6944
-
{
6945
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
6946
-
if err != nil {
6947
-
return err
6948
-
}
6949
-
6950
-
t.TargetBranch = string(sval)
6951
}
6952
6953
default:
···
6960
6961
return nil
6962
}
6963
-
func (t *Repo) MarshalCBOR(w io.Writer) error {
6964
if t == nil {
6965
_, err := w.Write(cbg.CborNull)
6966
return err
6967
}
6968
6969
cw := cbg.NewCborWriter(w)
6970
-
fieldCount := 8
6971
6972
-
if t.Description == nil {
6973
-
fieldCount--
6974
-
}
6975
-
6976
-
if t.Source == nil {
6977
-
fieldCount--
6978
-
}
6979
-
6980
-
if t.Spindle == nil {
6981
-
fieldCount--
6982
-
}
6983
-
6984
-
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
6985
-
return err
6986
-
}
6987
-
6988
-
// t.Knot (string) (string)
6989
-
if len("knot") > 1000000 {
6990
-
return xerrors.Errorf("Value in field \"knot\" was too long")
6991
-
}
6992
-
6993
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("knot"))); err != nil {
6994
-
return err
6995
-
}
6996
-
if _, err := cw.WriteString(string("knot")); err != nil {
6997
-
return err
6998
-
}
6999
-
7000
-
if len(t.Knot) > 1000000 {
7001
-
return xerrors.Errorf("Value in field t.Knot was too long")
7002
-
}
7003
-
7004
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Knot))); err != nil {
7005
-
return err
7006
-
}
7007
-
if _, err := cw.WriteString(string(t.Knot)); err != nil {
7008
-
return err
7009
-
}
7010
-
7011
-
// t.Name (string) (string)
7012
-
if len("name") > 1000000 {
7013
-
return xerrors.Errorf("Value in field \"name\" was too long")
7014
-
}
7015
-
7016
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil {
7017
-
return err
7018
-
}
7019
-
if _, err := cw.WriteString(string("name")); err != nil {
7020
-
return err
7021
-
}
7022
-
7023
-
if len(t.Name) > 1000000 {
7024
-
return xerrors.Errorf("Value in field t.Name was too long")
7025
-
}
7026
-
7027
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil {
7028
-
return err
7029
-
}
7030
-
if _, err := cw.WriteString(string(t.Name)); err != nil {
7031
return err
7032
}
7033
···
7043
return err
7044
}
7045
7046
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo"))); err != nil {
7047
return err
7048
}
7049
-
if _, err := cw.WriteString(string("sh.tangled.repo")); err != nil {
7050
return err
7051
}
7052
7053
-
// t.Owner (string) (string)
7054
-
if len("owner") > 1000000 {
7055
-
return xerrors.Errorf("Value in field \"owner\" was too long")
7056
-
}
7057
-
7058
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil {
7059
-
return err
7060
-
}
7061
-
if _, err := cw.WriteString(string("owner")); err != nil {
7062
-
return err
7063
-
}
7064
-
7065
-
if len(t.Owner) > 1000000 {
7066
-
return xerrors.Errorf("Value in field t.Owner was too long")
7067
-
}
7068
-
7069
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil {
7070
-
return err
7071
-
}
7072
-
if _, err := cw.WriteString(string(t.Owner)); err != nil {
7073
-
return err
7074
-
}
7075
-
7076
-
// t.Source (string) (string)
7077
-
if t.Source != nil {
7078
-
7079
-
if len("source") > 1000000 {
7080
-
return xerrors.Errorf("Value in field \"source\" was too long")
7081
-
}
7082
-
7083
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil {
7084
-
return err
7085
-
}
7086
-
if _, err := cw.WriteString(string("source")); err != nil {
7087
-
return err
7088
-
}
7089
-
7090
-
if t.Source == nil {
7091
-
if _, err := cw.Write(cbg.CborNull); err != nil {
7092
-
return err
7093
-
}
7094
-
} else {
7095
-
if len(*t.Source) > 1000000 {
7096
-
return xerrors.Errorf("Value in field t.Source was too long")
7097
-
}
7098
-
7099
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Source))); err != nil {
7100
-
return err
7101
-
}
7102
-
if _, err := cw.WriteString(string(*t.Source)); err != nil {
7103
-
return err
7104
-
}
7105
-
}
7106
-
}
7107
-
7108
-
// t.Spindle (string) (string)
7109
-
if t.Spindle != nil {
7110
-
7111
-
if len("spindle") > 1000000 {
7112
-
return xerrors.Errorf("Value in field \"spindle\" was too long")
7113
-
}
7114
-
7115
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("spindle"))); err != nil {
7116
-
return err
7117
-
}
7118
-
if _, err := cw.WriteString(string("spindle")); err != nil {
7119
-
return err
7120
-
}
7121
-
7122
-
if t.Spindle == nil {
7123
-
if _, err := cw.Write(cbg.CborNull); err != nil {
7124
-
return err
7125
-
}
7126
-
} else {
7127
-
if len(*t.Spindle) > 1000000 {
7128
-
return xerrors.Errorf("Value in field t.Spindle was too long")
7129
-
}
7130
-
7131
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Spindle))); err != nil {
7132
-
return err
7133
-
}
7134
-
if _, err := cw.WriteString(string(*t.Spindle)); err != nil {
7135
-
return err
7136
-
}
7137
-
}
7138
-
}
7139
-
7140
// t.CreatedAt (string) (string)
7141
if len("createdAt") > 1000000 {
7142
return xerrors.Errorf("Value in field \"createdAt\" was too long")
···
7159
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
7160
return err
7161
}
7162
-
7163
-
// t.Description (string) (string)
7164
-
if t.Description != nil {
7165
-
7166
-
if len("description") > 1000000 {
7167
-
return xerrors.Errorf("Value in field \"description\" was too long")
7168
-
}
7169
-
7170
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("description"))); err != nil {
7171
-
return err
7172
-
}
7173
-
if _, err := cw.WriteString(string("description")); err != nil {
7174
-
return err
7175
-
}
7176
-
7177
-
if t.Description == nil {
7178
-
if _, err := cw.Write(cbg.CborNull); err != nil {
7179
-
return err
7180
-
}
7181
-
} else {
7182
-
if len(*t.Description) > 1000000 {
7183
-
return xerrors.Errorf("Value in field t.Description was too long")
7184
-
}
7185
-
7186
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Description))); err != nil {
7187
-
return err
7188
-
}
7189
-
if _, err := cw.WriteString(string(*t.Description)); err != nil {
7190
-
return err
7191
-
}
7192
-
}
7193
-
}
7194
return nil
7195
}
7196
7197
-
func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) {
7198
-
*t = Repo{}
7199
7200
cr := cbg.NewCborReader(r)
7201
···
7214
}
7215
7216
if extra > cbg.MaxLength {
7217
-
return fmt.Errorf("Repo: map struct too large (%d)", extra)
7218
}
7219
7220
n := extra
7221
7222
-
nameBuf := make([]byte, 11)
7223
for i := uint64(0); i < n; i++ {
7224
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
7225
if err != nil {
···
7235
}
7236
7237
switch string(nameBuf[:nameLen]) {
7238
-
// t.Knot (string) (string)
7239
-
case "knot":
7240
-
7241
-
{
7242
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
7243
-
if err != nil {
7244
-
return err
7245
-
}
7246
-
7247
-
t.Knot = string(sval)
7248
-
}
7249
-
// t.Name (string) (string)
7250
-
case "name":
7251
-
7252
-
{
7253
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
7254
-
if err != nil {
7255
-
return err
7256
-
}
7257
-
7258
-
t.Name = string(sval)
7259
-
}
7260
-
// t.LexiconTypeID (string) (string)
7261
case "$type":
7262
7263
{
···
7268
7269
t.LexiconTypeID = string(sval)
7270
}
7271
-
// t.Owner (string) (string)
7272
-
case "owner":
7273
-
7274
-
{
7275
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
7276
-
if err != nil {
7277
-
return err
7278
-
}
7279
-
7280
-
t.Owner = string(sval)
7281
-
}
7282
-
// t.Source (string) (string)
7283
-
case "source":
7284
-
7285
-
{
7286
-
b, err := cr.ReadByte()
7287
-
if err != nil {
7288
-
return err
7289
-
}
7290
-
if b != cbg.CborNull[0] {
7291
-
if err := cr.UnreadByte(); err != nil {
7292
-
return err
7293
-
}
7294
-
7295
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
7296
-
if err != nil {
7297
-
return err
7298
-
}
7299
-
7300
-
t.Source = (*string)(&sval)
7301
-
}
7302
-
}
7303
-
// t.Spindle (string) (string)
7304
-
case "spindle":
7305
-
7306
-
{
7307
-
b, err := cr.ReadByte()
7308
-
if err != nil {
7309
-
return err
7310
-
}
7311
-
if b != cbg.CborNull[0] {
7312
-
if err := cr.UnreadByte(); err != nil {
7313
-
return err
7314
-
}
7315
-
7316
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
7317
-
if err != nil {
7318
-
return err
7319
-
}
7320
-
7321
-
t.Spindle = (*string)(&sval)
7322
-
}
7323
-
}
7324
// t.CreatedAt (string) (string)
7325
case "createdAt":
7326
···
7331
}
7332
7333
t.CreatedAt = string(sval)
7334
-
}
7335
-
// t.Description (string) (string)
7336
-
case "description":
7337
-
7338
-
{
7339
-
b, err := cr.ReadByte()
7340
-
if err != nil {
7341
-
return err
7342
-
}
7343
-
if b != cbg.CborNull[0] {
7344
-
if err := cr.UnreadByte(); err != nil {
7345
-
return err
7346
-
}
7347
-
7348
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
7349
-
if err != nil {
7350
-
return err
7351
-
}
7352
-
7353
-
t.Description = (*string)(&sval)
7354
-
}
7355
}
7356
7357
default:
···
668
669
return nil
670
}
671
+
func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error {
672
if t == nil {
673
_, err := w.Write(cbg.CborNull)
674
return err
···
676
677
cw := cbg.NewCborWriter(w)
678
679
+
if _, err := cw.Write([]byte{168}); err != nil {
680
return err
681
}
682
683
+
// t.Ref (string) (string)
684
+
if len("ref") > 1000000 {
685
+
return xerrors.Errorf("Value in field \"ref\" was too long")
686
}
687
688
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ref"))); err != nil {
689
return err
690
}
691
+
if _, err := cw.WriteString(string("ref")); err != nil {
692
return err
693
}
694
695
+
if len(t.Ref) > 1000000 {
696
+
return xerrors.Errorf("Value in field t.Ref was too long")
697
}
698
699
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Ref))); err != nil {
700
return err
701
}
702
+
if _, err := cw.WriteString(string(t.Ref)); err != nil {
703
return err
704
}
705
706
+
// t.Meta (tangled.GitRefUpdate_Meta) (struct)
707
+
if len("meta") > 1000000 {
708
+
return xerrors.Errorf("Value in field \"meta\" was too long")
709
}
710
711
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("meta"))); err != nil {
712
return err
713
}
714
+
if _, err := cw.WriteString(string("meta")); err != nil {
715
return err
716
}
717
718
+
if err := t.Meta.MarshalCBOR(cw); err != nil {
719
+
return err
720
+
}
721
722
+
// t.LexiconTypeID (string) (string)
723
+
if len("$type") > 1000000 {
724
+
return xerrors.Errorf("Value in field \"$type\" was too long")
725
+
}
726
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 {
731
return err
732
}
733
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
739
}
740
741
+
// t.NewSha (string) (string)
742
+
if len("newSha") > 1000000 {
743
+
return xerrors.Errorf("Value in field \"newSha\" was too long")
744
}
745
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
+
}
752
753
+
if len(t.NewSha) > 1000000 {
754
+
return xerrors.Errorf("Value in field t.NewSha was too long")
755
+
}
756
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
+
}
763
764
+
// t.OldSha (string) (string)
765
+
if len("oldSha") > 1000000 {
766
+
return xerrors.Errorf("Value in field \"oldSha\" was too long")
767
+
}
768
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
+
}
775
776
+
if len(t.OldSha) > 1000000 {
777
+
return xerrors.Errorf("Value in field t.OldSha was too long")
778
+
}
779
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
+
}
786
787
+
// t.RepoDid (string) (string)
788
+
if len("repoDid") > 1000000 {
789
+
return xerrors.Errorf("Value in field \"repoDid\" was too long")
790
}
791
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 {
796
return err
797
}
798
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
+
}
809
810
+
// t.RepoName (string) (string)
811
+
if len("repoName") > 1000000 {
812
+
return xerrors.Errorf("Value in field \"repoName\" was too long")
813
}
814
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 {
819
return err
820
}
821
822
+
if len(t.RepoName) > 1000000 {
823
+
return xerrors.Errorf("Value in field t.RepoName was too long")
824
+
}
825
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
+
}
832
833
+
// t.CommitterDid (string) (string)
834
+
if len("committerDid") > 1000000 {
835
+
return xerrors.Errorf("Value in field \"committerDid\" was too long")
836
+
}
837
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
+
}
844
845
+
if len(t.CommitterDid) > 1000000 {
846
+
return xerrors.Errorf("Value in field t.CommitterDid was too long")
847
+
}
848
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
854
}
855
return nil
856
}
857
858
+
func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) {
859
+
*t = GitRefUpdate{}
860
861
cr := cbg.NewCborReader(r)
862
···
875
}
876
877
if extra > cbg.MaxLength {
878
+
return fmt.Errorf("GitRefUpdate: map struct too large (%d)", extra)
879
}
880
881
n := extra
882
883
+
nameBuf := make([]byte, 12)
884
for i := uint64(0); i < n; i++ {
885
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
886
if err != nil {
···
896
}
897
898
switch string(nameBuf[:nameLen]) {
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
+
}
928
929
}
930
+
// t.LexiconTypeID (string) (string)
931
+
case "$type":
932
933
+
{
934
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
935
+
if err != nil {
936
+
return err
937
+
}
938
+
939
+
t.LexiconTypeID = string(sval)
940
}
941
+
// t.NewSha (string) (string)
942
+
case "newSha":
943
944
+
{
945
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
946
+
if err != nil {
947
+
return err
948
+
}
949
+
950
+
t.NewSha = string(sval)
951
}
952
+
// t.OldSha (string) (string)
953
+
case "oldSha":
954
955
+
{
956
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
957
+
if err != nil {
958
+
return err
959
+
}
960
+
961
+
t.OldSha = string(sval)
962
}
963
+
// t.RepoDid (string) (string)
964
+
case "repoDid":
965
966
+
{
967
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
968
+
if err != nil {
969
+
return err
970
+
}
971
972
+
t.RepoDid = string(sval)
973
+
}
974
+
// t.RepoName (string) (string)
975
+
case "repoName":
976
977
+
{
978
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
979
+
if err != nil {
980
+
return err
981
+
}
982
983
+
t.RepoName = string(sval)
984
+
}
985
+
// t.CommitterDid (string) (string)
986
+
case "committerDid":
987
988
+
{
989
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
990
+
if err != nil {
991
+
return err
992
}
993
+
994
+
t.CommitterDid = string(sval)
995
}
996
997
default:
···
1140
1141
return nil
1142
}
1143
+
func (t *GitRefUpdate_Meta_CommitCount) MarshalCBOR(w io.Writer) error {
1144
if t == nil {
1145
_, err := w.Write(cbg.CborNull)
1146
return err
1147
}
1148
1149
cw := cbg.NewCborWriter(w)
1150
+
fieldCount := 1
1151
1152
+
if t.ByEmail == nil {
1153
+
fieldCount--
1154
}
1155
1156
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
1157
return err
1158
}
1159
1160
+
// t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice)
1161
+
if t.ByEmail != nil {
1162
1163
+
if len("byEmail") > 1000000 {
1164
+
return xerrors.Errorf("Value in field \"byEmail\" was too long")
1165
+
}
1166
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
+
}
1173
1174
+
if len(t.ByEmail) > 8192 {
1175
+
return xerrors.Errorf("Slice value in field t.ByEmail was too long")
1176
+
}
1177
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
+
}
1187
}
1188
+
return nil
1189
+
}
1190
1191
+
func (t *GitRefUpdate_Meta_CommitCount) UnmarshalCBOR(r io.Reader) (err error) {
1192
+
*t = GitRefUpdate_Meta_CommitCount{}
1193
1194
+
cr := cbg.NewCborReader(r)
1195
1196
+
maj, extra, err := cr.ReadHeader()
1197
+
if err != nil {
1198
return err
1199
}
1200
+
defer func() {
1201
+
if err == io.EOF {
1202
+
err = io.ErrUnexpectedEOF
1203
+
}
1204
+
}()
1205
1206
+
if maj != cbg.MajMap {
1207
+
return fmt.Errorf("cbor input should be of type map")
1208
}
1209
1210
+
if extra > cbg.MaxLength {
1211
+
return fmt.Errorf("GitRefUpdate_Meta_CommitCount: map struct too large (%d)", extra)
1212
}
1213
1214
+
n := extra
1215
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
+
}
1222
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
+
}
1230
1231
+
switch string(nameBuf[:nameLen]) {
1232
+
// t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice)
1233
+
case "byEmail":
1234
1235
+
maj, extra, err = cr.ReadHeader()
1236
+
if err != nil {
1237
+
return err
1238
+
}
1239
1240
+
if extra > 8192 {
1241
+
return fmt.Errorf("t.ByEmail: array too large (%d)", extra)
1242
+
}
1243
1244
+
if maj != cbg.MajArray {
1245
+
return fmt.Errorf("expected cbor array")
1246
+
}
1247
1248
+
if extra > 0 {
1249
+
t.ByEmail = make([]*GitRefUpdate_Meta_CommitCount_ByEmail_Elem, extra)
1250
+
}
1251
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
1260
1261
+
{
1262
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
+
}
1288
}
1289
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)
1295
return err
1296
}
1297
+
1298
+
cw := cbg.NewCborWriter(w)
1299
+
1300
+
if _, err := cw.Write([]byte{162}); err != nil {
1301
return err
1302
}
1303
1304
+
// t.Count (int64) (int64)
1305
+
if len("count") > 1000000 {
1306
+
return xerrors.Errorf("Value in field \"count\" was too long")
1307
}
1308
1309
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("count"))); err != nil {
1310
return err
1311
}
1312
+
if _, err := cw.WriteString(string("count")); err != nil {
1313
return err
1314
}
1315
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")
1329
}
1330
1331
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("email"))); err != nil {
1332
return err
1333
}
1334
+
if _, err := cw.WriteString(string("email")); err != nil {
1335
return err
1336
}
1337
1338
+
if len(t.Email) > 1000000 {
1339
+
return xerrors.Errorf("Value in field t.Email was too long")
1340
}
1341
1342
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Email))); err != nil {
1343
return err
1344
}
1345
+
if _, err := cw.WriteString(string(t.Email)); err != nil {
1346
return err
1347
}
1348
return nil
1349
}
1350
1351
+
func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) (err error) {
1352
+
*t = GitRefUpdate_Meta_CommitCount_ByEmail_Elem{}
1353
1354
cr := cbg.NewCborReader(r)
1355
···
1368
}
1369
1370
if extra > cbg.MaxLength {
1371
+
return fmt.Errorf("GitRefUpdate_Meta_CommitCount_ByEmail_Elem: map struct too large (%d)", extra)
1372
}
1373
1374
n := extra
1375
1376
+
nameBuf := make([]byte, 5)
1377
for i := uint64(0); i < n; i++ {
1378
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
1379
if err != nil {
···
1389
}
1390
1391
switch string(nameBuf[:nameLen]) {
1392
+
// t.Count (int64) (int64)
1393
+
case "count":
1394
{
1395
+
maj, extra, err := cr.ReadHeader()
1396
if err != nil {
1397
return err
1398
}
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")
1405
}
1406
+
case cbg.MajNegativeInt:
1407
+
extraI = int64(extra)
1408
+
if extraI < 0 {
1409
+
return fmt.Errorf("int64 negative overflow")
1410
}
1411
+
extraI = -1 - extraI
1412
+
default:
1413
+
return fmt.Errorf("wrong type for int64 field: %d", maj)
1414
}
1415
1416
+
t.Count = int64(extraI)
1417
}
1418
+
// t.Email (string) (string)
1419
+
case "email":
1420
1421
{
1422
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
1424
return err
1425
}
1426
1427
+
t.Email = string(sval)
1428
}
1429
1430
default:
···
1799
1800
return nil
1801
}
1802
+
func (t *Pipeline) MarshalCBOR(w io.Writer) error {
1803
if t == nil {
1804
_, err := w.Write(cbg.CborNull)
1805
return err
1806
}
1807
1808
cw := cbg.NewCborWriter(w)
1809
1810
+
if _, err := cw.Write([]byte{163}); err != nil {
1811
return err
1812
}
1813
···
1823
return err
1824
}
1825
1826
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline"))); err != nil {
1827
return err
1828
}
1829
+
if _, err := cw.WriteString(string("sh.tangled.pipeline")); err != nil {
1830
return err
1831
}
1832
1833
+
// t.Workflows ([]*tangled.Pipeline_Workflow) (slice)
1834
+
if len("workflows") > 1000000 {
1835
+
return xerrors.Errorf("Value in field \"workflows\" was too long")
1836
}
1837
1838
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflows"))); err != nil {
1839
return err
1840
}
1841
+
if _, err := cw.WriteString(string("workflows")); err != nil {
1842
return err
1843
}
1844
1845
+
if len(t.Workflows) > 8192 {
1846
+
return xerrors.Errorf("Slice value in field t.Workflows was too long")
1847
}
1848
1849
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Workflows))); err != nil {
1850
return err
1851
}
1852
+
for _, v := range t.Workflows {
1853
+
if err := v.MarshalCBOR(cw); err != nil {
1854
return err
1855
}
1856
1857
}
1858
1859
+
// t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct)
1860
+
if len("triggerMetadata") > 1000000 {
1861
+
return xerrors.Errorf("Value in field \"triggerMetadata\" was too long")
1862
}
1863
1864
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("triggerMetadata"))); err != nil {
1865
return err
1866
}
1867
+
if _, err := cw.WriteString(string("triggerMetadata")); err != nil {
1868
return err
1869
}
1870
1871
+
if err := t.TriggerMetadata.MarshalCBOR(cw); err != nil {
1872
return err
1873
}
1874
return nil
1875
}
1876
1877
+
func (t *Pipeline) UnmarshalCBOR(r io.Reader) (err error) {
1878
+
*t = Pipeline{}
1879
1880
cr := cbg.NewCborReader(r)
1881
···
1894
}
1895
1896
if extra > cbg.MaxLength {
1897
+
return fmt.Errorf("Pipeline: map struct too large (%d)", extra)
1898
}
1899
1900
n := extra
1901
1902
+
nameBuf := make([]byte, 15)
1903
for i := uint64(0); i < n; i++ {
1904
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
1905
if err != nil {
···
1926
1927
t.LexiconTypeID = string(sval)
1928
}
1929
+
// t.Workflows ([]*tangled.Pipeline_Workflow) (slice)
1930
+
case "workflows":
1931
+
1932
+
maj, extra, err = cr.ReadHeader()
1933
+
if err != nil {
1934
+
return err
1935
+
}
1936
1937
+
if extra > 8192 {
1938
+
return fmt.Errorf("t.Workflows: array too large (%d)", extra)
1939
+
}
1940
1941
+
if maj != cbg.MajArray {
1942
+
return fmt.Errorf("expected cbor array")
1943
+
}
1944
1945
+
if extra > 0 {
1946
+
t.Workflows = make([]*Pipeline_Workflow, extra)
1947
}
1948
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
1963
}
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
+
}
1972
}
1973
+
1974
}
1975
1976
}
1977
}
1978
+
// t.TriggerMetadata (tangled.Pipeline_TriggerMetadata) (struct)
1979
+
case "triggerMetadata":
1980
1981
{
1982
1983
+
b, err := cr.ReadByte()
1984
if err != nil {
1985
return err
1986
}
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
+
}
1995
}
1996
1997
}
1998
1999
default:
···
2361
2362
return nil
2363
}
2364
+
func (t *Pipeline_ManualTriggerData) MarshalCBOR(w io.Writer) error {
2365
if t == nil {
2366
_, err := w.Write(cbg.CborNull)
2367
return err
2368
}
2369
2370
cw := cbg.NewCborWriter(w)
2371
+
fieldCount := 1
2372
2373
+
if t.Inputs == nil {
2374
+
fieldCount--
2375
}
2376
2377
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
2378
return err
2379
}
2380
2381
+
// t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice)
2382
+
if t.Inputs != nil {
2383
2384
+
if len("inputs") > 1000000 {
2385
+
return xerrors.Errorf("Value in field \"inputs\" was too long")
2386
+
}
2387
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
+
}
2394
2395
+
if len(t.Inputs) > 8192 {
2396
+
return xerrors.Errorf("Slice value in field t.Inputs was too long")
2397
+
}
2398
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
+
}
2406
2407
+
}
2408
}
2409
return nil
2410
}
2411
2412
+
func (t *Pipeline_ManualTriggerData) UnmarshalCBOR(r io.Reader) (err error) {
2413
+
*t = Pipeline_ManualTriggerData{}
2414
2415
cr := cbg.NewCborReader(r)
2416
···
2429
}
2430
2431
if extra > cbg.MaxLength {
2432
+
return fmt.Errorf("Pipeline_ManualTriggerData: map struct too large (%d)", extra)
2433
}
2434
2435
n := extra
2436
2437
+
nameBuf := make([]byte, 6)
2438
for i := uint64(0); i < n; i++ {
2439
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
2440
if err != nil {
···
2450
}
2451
2452
switch string(nameBuf[:nameLen]) {
2453
+
// t.Inputs ([]*tangled.Pipeline_ManualTriggerData_Inputs_Elem) (slice)
2454
+
case "inputs":
2455
2456
+
maj, extra, err = cr.ReadHeader()
2457
+
if err != nil {
2458
+
return err
2459
+
}
2460
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)
2471
}
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
+
{
2483
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
+
}
2497
2498
+
}
2499
+
2500
+
}
2501
}
2502
2503
default:
···
2510
2511
return nil
2512
}
2513
+
func (t *Pipeline_ManualTriggerData_Inputs_Elem) MarshalCBOR(w io.Writer) error {
2514
if t == nil {
2515
_, err := w.Write(cbg.CborNull)
2516
return err
2517
}
2518
2519
cw := cbg.NewCborWriter(w)
2520
2521
+
if _, err := cw.Write([]byte{162}); err != nil {
2522
+
return err
2523
}
2524
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 {
2534
return err
2535
}
2536
2537
+
if len(t.Key) > 1000000 {
2538
+
return xerrors.Errorf("Value in field t.Key was too long")
2539
+
}
2540
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
+
}
2547
2548
+
// t.Value (string) (string)
2549
+
if len("value") > 1000000 {
2550
+
return xerrors.Errorf("Value in field \"value\" was too long")
2551
+
}
2552
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
+
}
2559
2560
+
if len(t.Value) > 1000000 {
2561
+
return xerrors.Errorf("Value in field t.Value was too long")
2562
+
}
2563
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
2569
}
2570
return nil
2571
}
2572
2573
+
func (t *Pipeline_ManualTriggerData_Inputs_Elem) UnmarshalCBOR(r io.Reader) (err error) {
2574
+
*t = Pipeline_ManualTriggerData_Inputs_Elem{}
2575
2576
cr := cbg.NewCborReader(r)
2577
···
2590
}
2591
2592
if extra > cbg.MaxLength {
2593
+
return fmt.Errorf("Pipeline_ManualTriggerData_Inputs_Elem: map struct too large (%d)", extra)
2594
}
2595
2596
n := extra
2597
2598
+
nameBuf := make([]byte, 5)
2599
for i := uint64(0); i < n; i++ {
2600
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
2601
if err != nil {
···
2611
}
2612
2613
switch string(nameBuf[:nameLen]) {
2614
+
// t.Key (string) (string)
2615
+
case "key":
2616
2617
+
{
2618
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2619
+
if err != nil {
2620
+
return err
2621
+
}
2622
2623
+
t.Key = string(sval)
2624
}
2625
+
// t.Value (string) (string)
2626
+
case "value":
2627
2628
+
{
2629
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2630
+
if err != nil {
2631
+
return err
2632
+
}
2633
2634
+
t.Value = string(sval)
2635
}
2636
2637
default:
···
3014
3015
return nil
3016
}
3017
+
func (t *PipelineStatus) MarshalCBOR(w io.Writer) error {
3018
+
if t == nil {
3019
+
_, err := w.Write(cbg.CborNull)
3020
+
return err
3021
+
}
3022
+
3023
+
cw := cbg.NewCborWriter(w)
3024
+
fieldCount := 7
3025
+
3026
+
if t.Error == nil {
3027
+
fieldCount--
3028
+
}
3029
+
3030
+
if t.ExitCode == nil {
3031
+
fieldCount--
3032
+
}
3033
+
3034
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
3035
+
return err
3036
+
}
3037
+
3038
+
// t.LexiconTypeID (string) (string)
3039
+
if len("$type") > 1000000 {
3040
+
return xerrors.Errorf("Value in field \"$type\" was too long")
3041
+
}
3042
+
3043
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
3044
+
return err
3045
+
}
3046
+
if _, err := cw.WriteString(string("$type")); err != nil {
3047
+
return err
3048
+
}
3049
+
3050
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pipeline.status"))); err != nil {
3051
+
return err
3052
+
}
3053
+
if _, err := cw.WriteString(string("sh.tangled.pipeline.status")); err != nil {
3054
+
return err
3055
+
}
3056
+
3057
+
// t.Error (string) (string)
3058
+
if t.Error != nil {
3059
+
3060
+
if len("error") > 1000000 {
3061
+
return xerrors.Errorf("Value in field \"error\" was too long")
3062
+
}
3063
+
3064
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("error"))); err != nil {
3065
+
return err
3066
+
}
3067
+
if _, err := cw.WriteString(string("error")); err != nil {
3068
+
return err
3069
+
}
3070
+
3071
+
if t.Error == nil {
3072
+
if _, err := cw.Write(cbg.CborNull); err != nil {
3073
+
return err
3074
+
}
3075
+
} else {
3076
+
if len(*t.Error) > 1000000 {
3077
+
return xerrors.Errorf("Value in field t.Error was too long")
3078
+
}
3079
+
3080
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Error))); err != nil {
3081
+
return err
3082
+
}
3083
+
if _, err := cw.WriteString(string(*t.Error)); err != nil {
3084
+
return err
3085
+
}
3086
+
}
3087
+
}
3088
+
3089
+
// t.Status (string) (string)
3090
+
if len("status") > 1000000 {
3091
+
return xerrors.Errorf("Value in field \"status\" was too long")
3092
+
}
3093
+
3094
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil {
3095
+
return err
3096
+
}
3097
+
if _, err := cw.WriteString(string("status")); err != nil {
3098
+
return err
3099
+
}
3100
+
3101
+
if len(t.Status) > 1000000 {
3102
+
return xerrors.Errorf("Value in field t.Status was too long")
3103
+
}
3104
+
3105
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil {
3106
+
return err
3107
+
}
3108
+
if _, err := cw.WriteString(string(t.Status)); err != nil {
3109
+
return err
3110
+
}
3111
+
3112
+
// t.ExitCode (int64) (int64)
3113
+
if t.ExitCode != nil {
3114
+
3115
+
if len("exitCode") > 1000000 {
3116
+
return xerrors.Errorf("Value in field \"exitCode\" was too long")
3117
+
}
3118
+
3119
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("exitCode"))); err != nil {
3120
+
return err
3121
+
}
3122
+
if _, err := cw.WriteString(string("exitCode")); err != nil {
3123
+
return err
3124
+
}
3125
+
3126
+
if t.ExitCode == nil {
3127
+
if _, err := cw.Write(cbg.CborNull); err != nil {
3128
+
return err
3129
+
}
3130
+
} else {
3131
+
if *t.ExitCode >= 0 {
3132
+
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.ExitCode)); err != nil {
3133
+
return err
3134
+
}
3135
+
} else {
3136
+
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.ExitCode-1)); err != nil {
3137
+
return err
3138
+
}
3139
+
}
3140
+
}
3141
+
3142
+
}
3143
+
3144
+
// t.Pipeline (string) (string)
3145
+
if len("pipeline") > 1000000 {
3146
+
return xerrors.Errorf("Value in field \"pipeline\" was too long")
3147
+
}
3148
+
3149
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pipeline"))); err != nil {
3150
+
return err
3151
+
}
3152
+
if _, err := cw.WriteString(string("pipeline")); err != nil {
3153
+
return err
3154
+
}
3155
+
3156
+
if len(t.Pipeline) > 1000000 {
3157
+
return xerrors.Errorf("Value in field t.Pipeline was too long")
3158
+
}
3159
+
3160
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pipeline))); err != nil {
3161
+
return err
3162
+
}
3163
+
if _, err := cw.WriteString(string(t.Pipeline)); err != nil {
3164
+
return err
3165
+
}
3166
+
3167
+
// t.Workflow (string) (string)
3168
+
if len("workflow") > 1000000 {
3169
+
return xerrors.Errorf("Value in field \"workflow\" was too long")
3170
+
}
3171
+
3172
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflow"))); err != nil {
3173
+
return err
3174
+
}
3175
+
if _, err := cw.WriteString(string("workflow")); err != nil {
3176
+
return err
3177
+
}
3178
+
3179
+
if len(t.Workflow) > 1000000 {
3180
+
return xerrors.Errorf("Value in field t.Workflow was too long")
3181
+
}
3182
+
3183
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Workflow))); err != nil {
3184
+
return err
3185
+
}
3186
+
if _, err := cw.WriteString(string(t.Workflow)); err != nil {
3187
+
return err
3188
+
}
3189
+
3190
+
// t.CreatedAt (string) (string)
3191
+
if len("createdAt") > 1000000 {
3192
+
return xerrors.Errorf("Value in field \"createdAt\" was too long")
3193
+
}
3194
+
3195
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
3196
+
return err
3197
+
}
3198
+
if _, err := cw.WriteString(string("createdAt")); err != nil {
3199
+
return err
3200
+
}
3201
+
3202
+
if len(t.CreatedAt) > 1000000 {
3203
+
return xerrors.Errorf("Value in field t.CreatedAt was too long")
3204
+
}
3205
+
3206
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
3207
+
return err
3208
+
}
3209
+
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
3210
+
return err
3211
+
}
3212
+
return nil
3213
+
}
3214
+
3215
+
func (t *PipelineStatus) UnmarshalCBOR(r io.Reader) (err error) {
3216
+
*t = PipelineStatus{}
3217
+
3218
+
cr := cbg.NewCborReader(r)
3219
+
3220
+
maj, extra, err := cr.ReadHeader()
3221
+
if err != nil {
3222
+
return err
3223
+
}
3224
+
defer func() {
3225
+
if err == io.EOF {
3226
+
err = io.ErrUnexpectedEOF
3227
+
}
3228
+
}()
3229
+
3230
+
if maj != cbg.MajMap {
3231
+
return fmt.Errorf("cbor input should be of type map")
3232
+
}
3233
+
3234
+
if extra > cbg.MaxLength {
3235
+
return fmt.Errorf("PipelineStatus: map struct too large (%d)", extra)
3236
+
}
3237
+
3238
+
n := extra
3239
+
3240
+
nameBuf := make([]byte, 9)
3241
+
for i := uint64(0); i < n; i++ {
3242
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
3243
+
if err != nil {
3244
+
return err
3245
+
}
3246
+
3247
+
if !ok {
3248
+
// Field doesn't exist on this type, so ignore it
3249
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
3250
+
return err
3251
+
}
3252
+
continue
3253
+
}
3254
+
3255
+
switch string(nameBuf[:nameLen]) {
3256
+
// t.LexiconTypeID (string) (string)
3257
+
case "$type":
3258
+
3259
+
{
3260
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3261
+
if err != nil {
3262
+
return err
3263
+
}
3264
+
3265
+
t.LexiconTypeID = string(sval)
3266
+
}
3267
+
// t.Error (string) (string)
3268
+
case "error":
3269
+
3270
+
{
3271
+
b, err := cr.ReadByte()
3272
+
if err != nil {
3273
+
return err
3274
+
}
3275
+
if b != cbg.CborNull[0] {
3276
+
if err := cr.UnreadByte(); err != nil {
3277
+
return err
3278
+
}
3279
+
3280
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3281
+
if err != nil {
3282
+
return err
3283
+
}
3284
+
3285
+
t.Error = (*string)(&sval)
3286
+
}
3287
+
}
3288
+
// t.Status (string) (string)
3289
+
case "status":
3290
+
3291
+
{
3292
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3293
+
if err != nil {
3294
+
return err
3295
+
}
3296
+
3297
+
t.Status = string(sval)
3298
+
}
3299
+
// t.ExitCode (int64) (int64)
3300
+
case "exitCode":
3301
+
{
3302
+
3303
+
b, err := cr.ReadByte()
3304
+
if err != nil {
3305
+
return err
3306
+
}
3307
+
if b != cbg.CborNull[0] {
3308
+
if err := cr.UnreadByte(); err != nil {
3309
+
return err
3310
+
}
3311
+
maj, extra, err := cr.ReadHeader()
3312
+
if err != nil {
3313
+
return err
3314
+
}
3315
+
var extraI int64
3316
+
switch maj {
3317
+
case cbg.MajUnsignedInt:
3318
+
extraI = int64(extra)
3319
+
if extraI < 0 {
3320
+
return fmt.Errorf("int64 positive overflow")
3321
+
}
3322
+
case cbg.MajNegativeInt:
3323
+
extraI = int64(extra)
3324
+
if extraI < 0 {
3325
+
return fmt.Errorf("int64 negative overflow")
3326
+
}
3327
+
extraI = -1 - extraI
3328
+
default:
3329
+
return fmt.Errorf("wrong type for int64 field: %d", maj)
3330
+
}
3331
+
3332
+
t.ExitCode = (*int64)(&extraI)
3333
+
}
3334
+
}
3335
+
// t.Pipeline (string) (string)
3336
+
case "pipeline":
3337
+
3338
+
{
3339
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3340
+
if err != nil {
3341
+
return err
3342
+
}
3343
+
3344
+
t.Pipeline = string(sval)
3345
+
}
3346
+
// t.Workflow (string) (string)
3347
+
case "workflow":
3348
+
3349
+
{
3350
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3351
+
if err != nil {
3352
+
return err
3353
+
}
3354
+
3355
+
t.Workflow = string(sval)
3356
+
}
3357
+
// t.CreatedAt (string) (string)
3358
+
case "createdAt":
3359
+
3360
+
{
3361
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3362
+
if err != nil {
3363
+
return err
3364
+
}
3365
+
3366
+
t.CreatedAt = string(sval)
3367
+
}
3368
+
3369
+
default:
3370
+
// Field doesn't exist on this type, so ignore it
3371
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
3372
+
return err
3373
+
}
3374
+
}
3375
+
}
3376
+
3377
+
return nil
3378
+
}
3379
func (t *Pipeline_Step) MarshalCBOR(w io.Writer) error {
3380
if t == nil {
3381
_, err := w.Write(cbg.CborNull)
···
3978
3979
return nil
3980
}
3981
func (t *Pipeline_Workflow) MarshalCBOR(w io.Writer) error {
3982
if t == nil {
3983
_, err := w.Write(cbg.CborNull)
···
4329
4330
return nil
4331
}
4332
+
func (t *Pipeline_Workflow_Environment_Elem) MarshalCBOR(w io.Writer) error {
4333
if t == nil {
4334
_, err := w.Write(cbg.CborNull)
4335
return err
···
4337
4338
cw := cbg.NewCborWriter(w)
4339
4340
+
if _, err := cw.Write([]byte{162}); err != nil {
4341
return err
4342
}
4343
4344
+
// t.Key (string) (string)
4345
+
if len("key") > 1000000 {
4346
+
return xerrors.Errorf("Value in field \"key\" was too long")
4347
}
4348
4349
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil {
4350
return err
4351
}
4352
+
if _, err := cw.WriteString(string("key")); err != nil {
4353
return err
4354
}
4355
4356
+
if len(t.Key) > 1000000 {
4357
+
return xerrors.Errorf("Value in field t.Key was too long")
4358
}
4359
4360
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
4361
return err
4362
}
4363
+
if _, err := cw.WriteString(string(t.Key)); err != nil {
4364
return err
4365
}
4366
4367
+
// t.Value (string) (string)
4368
+
if len("value") > 1000000 {
4369
+
return xerrors.Errorf("Value in field \"value\" was too long")
4370
}
4371
4372
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil {
4373
return err
4374
}
4375
+
if _, err := cw.WriteString(string("value")); err != nil {
4376
+
return err
4377
}
4378
4379
+
if len(t.Value) > 1000000 {
4380
+
return xerrors.Errorf("Value in field t.Value was too long")
4381
}
4382
4383
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil {
4384
return err
4385
}
4386
+
if _, err := cw.WriteString(string(t.Value)); err != nil {
4387
return err
4388
}
4389
return nil
4390
}
4391
4392
+
func (t *Pipeline_Workflow_Environment_Elem) UnmarshalCBOR(r io.Reader) (err error) {
4393
+
*t = Pipeline_Workflow_Environment_Elem{}
4394
4395
cr := cbg.NewCborReader(r)
4396
···
4409
}
4410
4411
if extra > cbg.MaxLength {
4412
+
return fmt.Errorf("Pipeline_Workflow_Environment_Elem: map struct too large (%d)", extra)
4413
}
4414
4415
n := extra
4416
4417
+
nameBuf := make([]byte, 5)
4418
for i := uint64(0); i < n; i++ {
4419
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
4420
if err != nil {
···
4430
}
4431
4432
switch string(nameBuf[:nameLen]) {
4433
+
// t.Key (string) (string)
4434
+
case "key":
4435
4436
{
4437
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
4439
return err
4440
}
4441
4442
+
t.Key = string(sval)
4443
}
4444
+
// t.Value (string) (string)
4445
+
case "value":
4446
4447
{
4448
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
4449
if err != nil {
4450
return err
4451
}
4452
4453
+
t.Value = string(sval)
4454
}
4455
4456
default:
···
4661
4662
return nil
4663
}
4664
+
func (t *Repo) MarshalCBOR(w io.Writer) error {
4665
+
if t == nil {
4666
+
_, err := w.Write(cbg.CborNull)
4667
+
return err
4668
+
}
4669
+
4670
+
cw := cbg.NewCborWriter(w)
4671
+
fieldCount := 8
4672
+
4673
+
if t.Description == nil {
4674
+
fieldCount--
4675
+
}
4676
+
4677
+
if t.Source == nil {
4678
+
fieldCount--
4679
+
}
4680
+
4681
+
if t.Spindle == nil {
4682
+
fieldCount--
4683
+
}
4684
+
4685
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
4686
+
return err
4687
+
}
4688
+
4689
+
// t.Knot (string) (string)
4690
+
if len("knot") > 1000000 {
4691
+
return xerrors.Errorf("Value in field \"knot\" was too long")
4692
+
}
4693
+
4694
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("knot"))); err != nil {
4695
+
return err
4696
+
}
4697
+
if _, err := cw.WriteString(string("knot")); err != nil {
4698
+
return err
4699
+
}
4700
+
4701
+
if len(t.Knot) > 1000000 {
4702
+
return xerrors.Errorf("Value in field t.Knot was too long")
4703
+
}
4704
+
4705
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Knot))); err != nil {
4706
+
return err
4707
+
}
4708
+
if _, err := cw.WriteString(string(t.Knot)); err != nil {
4709
+
return err
4710
+
}
4711
+
4712
+
// t.Name (string) (string)
4713
+
if len("name") > 1000000 {
4714
+
return xerrors.Errorf("Value in field \"name\" was too long")
4715
+
}
4716
+
4717
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil {
4718
+
return err
4719
+
}
4720
+
if _, err := cw.WriteString(string("name")); err != nil {
4721
+
return err
4722
+
}
4723
+
4724
+
if len(t.Name) > 1000000 {
4725
+
return xerrors.Errorf("Value in field t.Name was too long")
4726
+
}
4727
+
4728
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil {
4729
+
return err
4730
+
}
4731
+
if _, err := cw.WriteString(string(t.Name)); err != nil {
4732
+
return err
4733
+
}
4734
+
4735
+
// t.LexiconTypeID (string) (string)
4736
+
if len("$type") > 1000000 {
4737
+
return xerrors.Errorf("Value in field \"$type\" was too long")
4738
+
}
4739
+
4740
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
4741
+
return err
4742
+
}
4743
+
if _, err := cw.WriteString(string("$type")); err != nil {
4744
+
return err
4745
+
}
4746
+
4747
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo"))); err != nil {
4748
+
return err
4749
+
}
4750
+
if _, err := cw.WriteString(string("sh.tangled.repo")); err != nil {
4751
+
return err
4752
+
}
4753
+
4754
+
// t.Owner (string) (string)
4755
+
if len("owner") > 1000000 {
4756
+
return xerrors.Errorf("Value in field \"owner\" was too long")
4757
+
}
4758
+
4759
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil {
4760
+
return err
4761
+
}
4762
+
if _, err := cw.WriteString(string("owner")); err != nil {
4763
+
return err
4764
+
}
4765
+
4766
+
if len(t.Owner) > 1000000 {
4767
+
return xerrors.Errorf("Value in field t.Owner was too long")
4768
+
}
4769
+
4770
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil {
4771
+
return err
4772
+
}
4773
+
if _, err := cw.WriteString(string(t.Owner)); err != nil {
4774
+
return err
4775
+
}
4776
+
4777
+
// t.Source (string) (string)
4778
+
if t.Source != nil {
4779
+
4780
+
if len("source") > 1000000 {
4781
+
return xerrors.Errorf("Value in field \"source\" was too long")
4782
+
}
4783
+
4784
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil {
4785
+
return err
4786
+
}
4787
+
if _, err := cw.WriteString(string("source")); err != nil {
4788
+
return err
4789
+
}
4790
+
4791
+
if t.Source == nil {
4792
+
if _, err := cw.Write(cbg.CborNull); err != nil {
4793
+
return err
4794
+
}
4795
+
} else {
4796
+
if len(*t.Source) > 1000000 {
4797
+
return xerrors.Errorf("Value in field t.Source was too long")
4798
+
}
4799
+
4800
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Source))); err != nil {
4801
+
return err
4802
+
}
4803
+
if _, err := cw.WriteString(string(*t.Source)); err != nil {
4804
+
return err
4805
+
}
4806
+
}
4807
+
}
4808
+
4809
+
// t.Spindle (string) (string)
4810
+
if t.Spindle != nil {
4811
+
4812
+
if len("spindle") > 1000000 {
4813
+
return xerrors.Errorf("Value in field \"spindle\" was too long")
4814
+
}
4815
+
4816
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("spindle"))); err != nil {
4817
+
return err
4818
+
}
4819
+
if _, err := cw.WriteString(string("spindle")); err != nil {
4820
+
return err
4821
+
}
4822
+
4823
+
if t.Spindle == nil {
4824
+
if _, err := cw.Write(cbg.CborNull); err != nil {
4825
+
return err
4826
+
}
4827
+
} else {
4828
+
if len(*t.Spindle) > 1000000 {
4829
+
return xerrors.Errorf("Value in field t.Spindle was too long")
4830
+
}
4831
+
4832
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Spindle))); err != nil {
4833
+
return err
4834
+
}
4835
+
if _, err := cw.WriteString(string(*t.Spindle)); err != nil {
4836
+
return err
4837
+
}
4838
+
}
4839
+
}
4840
+
4841
+
// t.CreatedAt (string) (string)
4842
+
if len("createdAt") > 1000000 {
4843
+
return xerrors.Errorf("Value in field \"createdAt\" was too long")
4844
+
}
4845
+
4846
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
4847
+
return err
4848
+
}
4849
+
if _, err := cw.WriteString(string("createdAt")); err != nil {
4850
+
return err
4851
+
}
4852
+
4853
+
if len(t.CreatedAt) > 1000000 {
4854
+
return xerrors.Errorf("Value in field t.CreatedAt was too long")
4855
+
}
4856
+
4857
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
4858
+
return err
4859
+
}
4860
+
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
4861
+
return err
4862
+
}
4863
+
4864
+
// t.Description (string) (string)
4865
+
if t.Description != nil {
4866
+
4867
+
if len("description") > 1000000 {
4868
+
return xerrors.Errorf("Value in field \"description\" was too long")
4869
+
}
4870
+
4871
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("description"))); err != nil {
4872
+
return err
4873
+
}
4874
+
if _, err := cw.WriteString(string("description")); err != nil {
4875
+
return err
4876
+
}
4877
+
4878
+
if t.Description == nil {
4879
+
if _, err := cw.Write(cbg.CborNull); err != nil {
4880
+
return err
4881
+
}
4882
+
} else {
4883
+
if len(*t.Description) > 1000000 {
4884
+
return xerrors.Errorf("Value in field t.Description was too long")
4885
+
}
4886
+
4887
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Description))); err != nil {
4888
+
return err
4889
+
}
4890
+
if _, err := cw.WriteString(string(*t.Description)); err != nil {
4891
+
return err
4892
+
}
4893
+
}
4894
+
}
4895
+
return nil
4896
+
}
4897
+
4898
+
func (t *Repo) UnmarshalCBOR(r io.Reader) (err error) {
4899
+
*t = Repo{}
4900
+
4901
+
cr := cbg.NewCborReader(r)
4902
+
4903
+
maj, extra, err := cr.ReadHeader()
4904
+
if err != nil {
4905
+
return err
4906
+
}
4907
+
defer func() {
4908
+
if err == io.EOF {
4909
+
err = io.ErrUnexpectedEOF
4910
+
}
4911
+
}()
4912
+
4913
+
if maj != cbg.MajMap {
4914
+
return fmt.Errorf("cbor input should be of type map")
4915
+
}
4916
+
4917
+
if extra > cbg.MaxLength {
4918
+
return fmt.Errorf("Repo: map struct too large (%d)", extra)
4919
+
}
4920
+
4921
+
n := extra
4922
+
4923
+
nameBuf := make([]byte, 11)
4924
+
for i := uint64(0); i < n; i++ {
4925
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
4926
+
if err != nil {
4927
+
return err
4928
+
}
4929
+
4930
+
if !ok {
4931
+
// Field doesn't exist on this type, so ignore it
4932
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
4933
+
return err
4934
+
}
4935
+
continue
4936
+
}
4937
+
4938
+
switch string(nameBuf[:nameLen]) {
4939
+
// t.Knot (string) (string)
4940
+
case "knot":
4941
+
4942
+
{
4943
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
4944
+
if err != nil {
4945
+
return err
4946
+
}
4947
+
4948
+
t.Knot = string(sval)
4949
+
}
4950
+
// t.Name (string) (string)
4951
+
case "name":
4952
+
4953
+
{
4954
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
4955
+
if err != nil {
4956
+
return err
4957
+
}
4958
+
4959
+
t.Name = string(sval)
4960
+
}
4961
+
// t.LexiconTypeID (string) (string)
4962
+
case "$type":
4963
+
4964
+
{
4965
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
4966
+
if err != nil {
4967
+
return err
4968
+
}
4969
+
4970
+
t.LexiconTypeID = string(sval)
4971
+
}
4972
+
// t.Owner (string) (string)
4973
+
case "owner":
4974
+
4975
+
{
4976
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
4977
+
if err != nil {
4978
+
return err
4979
+
}
4980
+
4981
+
t.Owner = string(sval)
4982
+
}
4983
+
// t.Source (string) (string)
4984
+
case "source":
4985
+
4986
+
{
4987
+
b, err := cr.ReadByte()
4988
+
if err != nil {
4989
+
return err
4990
+
}
4991
+
if b != cbg.CborNull[0] {
4992
+
if err := cr.UnreadByte(); err != nil {
4993
+
return err
4994
+
}
4995
+
4996
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
4997
+
if err != nil {
4998
+
return err
4999
+
}
5000
+
5001
+
t.Source = (*string)(&sval)
5002
+
}
5003
+
}
5004
+
// t.Spindle (string) (string)
5005
+
case "spindle":
5006
+
5007
+
{
5008
+
b, err := cr.ReadByte()
5009
+
if err != nil {
5010
+
return err
5011
+
}
5012
+
if b != cbg.CborNull[0] {
5013
+
if err := cr.UnreadByte(); err != nil {
5014
+
return err
5015
+
}
5016
+
5017
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
5018
+
if err != nil {
5019
+
return err
5020
+
}
5021
+
5022
+
t.Spindle = (*string)(&sval)
5023
+
}
5024
+
}
5025
+
// t.CreatedAt (string) (string)
5026
+
case "createdAt":
5027
+
5028
+
{
5029
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
5030
+
if err != nil {
5031
+
return err
5032
+
}
5033
+
5034
+
t.CreatedAt = string(sval)
5035
+
}
5036
+
// t.Description (string) (string)
5037
+
case "description":
5038
+
5039
+
{
5040
+
b, err := cr.ReadByte()
5041
+
if err != nil {
5042
+
return err
5043
+
}
5044
+
if b != cbg.CborNull[0] {
5045
+
if err := cr.UnreadByte(); err != nil {
5046
+
return err
5047
+
}
5048
+
5049
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
5050
+
if err != nil {
5051
+
return err
5052
+
}
5053
+
5054
+
t.Description = (*string)(&sval)
5055
+
}
5056
+
}
5057
+
5058
+
default:
5059
+
// Field doesn't exist on this type, so ignore it
5060
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
5061
+
return err
5062
+
}
5063
+
}
5064
+
}
5065
+
5066
+
return nil
5067
+
}
5068
func (t *RepoArtifact) MarshalCBOR(w io.Writer) error {
5069
if t == nil {
5070
_, err := w.Write(cbg.CborNull)
···
5355
5356
return nil
5357
}
5358
+
func (t *RepoIssue) MarshalCBOR(w io.Writer) error {
5359
+
if t == nil {
5360
+
_, err := w.Write(cbg.CborNull)
5361
+
return err
5362
+
}
5363
+
5364
+
cw := cbg.NewCborWriter(w)
5365
+
fieldCount := 7
5366
+
5367
+
if t.Body == nil {
5368
+
fieldCount--
5369
+
}
5370
+
5371
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
5372
+
return err
5373
+
}
5374
+
5375
+
// t.Body (string) (string)
5376
+
if t.Body != nil {
5377
+
5378
+
if len("body") > 1000000 {
5379
+
return xerrors.Errorf("Value in field \"body\" was too long")
5380
+
}
5381
+
5382
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil {
5383
+
return err
5384
+
}
5385
+
if _, err := cw.WriteString(string("body")); err != nil {
5386
+
return err
5387
+
}
5388
+
5389
+
if t.Body == nil {
5390
+
if _, err := cw.Write(cbg.CborNull); err != nil {
5391
+
return err
5392
+
}
5393
+
} else {
5394
+
if len(*t.Body) > 1000000 {
5395
+
return xerrors.Errorf("Value in field t.Body was too long")
5396
+
}
5397
+
5398
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil {
5399
+
return err
5400
+
}
5401
+
if _, err := cw.WriteString(string(*t.Body)); err != nil {
5402
+
return err
5403
+
}
5404
+
}
5405
+
}
5406
+
5407
+
// t.Repo (string) (string)
5408
+
if len("repo") > 1000000 {
5409
+
return xerrors.Errorf("Value in field \"repo\" was too long")
5410
+
}
5411
+
5412
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil {
5413
+
return err
5414
+
}
5415
+
if _, err := cw.WriteString(string("repo")); err != nil {
5416
+
return err
5417
+
}
5418
+
5419
+
if len(t.Repo) > 1000000 {
5420
+
return xerrors.Errorf("Value in field t.Repo was too long")
5421
+
}
5422
+
5423
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil {
5424
+
return err
5425
+
}
5426
+
if _, err := cw.WriteString(string(t.Repo)); err != nil {
5427
+
return err
5428
+
}
5429
+
5430
+
// t.LexiconTypeID (string) (string)
5431
+
if len("$type") > 1000000 {
5432
+
return xerrors.Errorf("Value in field \"$type\" was too long")
5433
+
}
5434
+
5435
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
5436
+
return err
5437
+
}
5438
+
if _, err := cw.WriteString(string("$type")); err != nil {
5439
+
return err
5440
+
}
5441
+
5442
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue"))); err != nil {
5443
+
return err
5444
+
}
5445
+
if _, err := cw.WriteString(string("sh.tangled.repo.issue")); err != nil {
5446
+
return err
5447
+
}
5448
+
5449
+
// t.Owner (string) (string)
5450
+
if len("owner") > 1000000 {
5451
+
return xerrors.Errorf("Value in field \"owner\" was too long")
5452
+
}
5453
+
5454
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil {
5455
+
return err
5456
+
}
5457
+
if _, err := cw.WriteString(string("owner")); err != nil {
5458
+
return err
5459
+
}
5460
+
5461
+
if len(t.Owner) > 1000000 {
5462
+
return xerrors.Errorf("Value in field t.Owner was too long")
5463
+
}
5464
+
5465
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Owner))); err != nil {
5466
+
return err
5467
+
}
5468
+
if _, err := cw.WriteString(string(t.Owner)); err != nil {
5469
+
return err
5470
+
}
5471
+
5472
+
// t.Title (string) (string)
5473
+
if len("title") > 1000000 {
5474
+
return xerrors.Errorf("Value in field \"title\" was too long")
5475
+
}
5476
+
5477
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil {
5478
+
return err
5479
+
}
5480
+
if _, err := cw.WriteString(string("title")); err != nil {
5481
+
return err
5482
+
}
5483
+
5484
+
if len(t.Title) > 1000000 {
5485
+
return xerrors.Errorf("Value in field t.Title was too long")
5486
+
}
5487
+
5488
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil {
5489
+
return err
5490
+
}
5491
+
if _, err := cw.WriteString(string(t.Title)); err != nil {
5492
+
return err
5493
+
}
5494
+
5495
+
// t.IssueId (int64) (int64)
5496
+
if len("issueId") > 1000000 {
5497
+
return xerrors.Errorf("Value in field \"issueId\" was too long")
5498
+
}
5499
+
5500
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issueId"))); err != nil {
5501
+
return err
5502
+
}
5503
+
if _, err := cw.WriteString(string("issueId")); err != nil {
5504
+
return err
5505
+
}
5506
+
5507
+
if t.IssueId >= 0 {
5508
+
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.IssueId)); err != nil {
5509
+
return err
5510
+
}
5511
+
} else {
5512
+
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.IssueId-1)); err != nil {
5513
+
return err
5514
+
}
5515
+
}
5516
+
5517
+
// t.CreatedAt (string) (string)
5518
+
if len("createdAt") > 1000000 {
5519
+
return xerrors.Errorf("Value in field \"createdAt\" was too long")
5520
+
}
5521
+
5522
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
5523
+
return err
5524
+
}
5525
+
if _, err := cw.WriteString(string("createdAt")); err != nil {
5526
+
return err
5527
+
}
5528
+
5529
+
if len(t.CreatedAt) > 1000000 {
5530
+
return xerrors.Errorf("Value in field t.CreatedAt was too long")
5531
+
}
5532
+
5533
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
5534
+
return err
5535
+
}
5536
+
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
5537
+
return err
5538
+
}
5539
+
return nil
5540
+
}
5541
+
5542
+
func (t *RepoIssue) UnmarshalCBOR(r io.Reader) (err error) {
5543
+
*t = RepoIssue{}
5544
+
5545
+
cr := cbg.NewCborReader(r)
5546
+
5547
+
maj, extra, err := cr.ReadHeader()
5548
+
if err != nil {
5549
+
return err
5550
+
}
5551
+
defer func() {
5552
+
if err == io.EOF {
5553
+
err = io.ErrUnexpectedEOF
5554
+
}
5555
+
}()
5556
+
5557
+
if maj != cbg.MajMap {
5558
+
return fmt.Errorf("cbor input should be of type map")
5559
+
}
5560
+
5561
+
if extra > cbg.MaxLength {
5562
+
return fmt.Errorf("RepoIssue: map struct too large (%d)", extra)
5563
+
}
5564
+
5565
+
n := extra
5566
+
5567
+
nameBuf := make([]byte, 9)
5568
+
for i := uint64(0); i < n; i++ {
5569
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
5570
+
if err != nil {
5571
+
return err
5572
+
}
5573
+
5574
+
if !ok {
5575
+
// Field doesn't exist on this type, so ignore it
5576
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
5577
+
return err
5578
+
}
5579
+
continue
5580
+
}
5581
+
5582
+
switch string(nameBuf[:nameLen]) {
5583
+
// t.Body (string) (string)
5584
+
case "body":
5585
+
5586
+
{
5587
+
b, err := cr.ReadByte()
5588
+
if err != nil {
5589
+
return err
5590
+
}
5591
+
if b != cbg.CborNull[0] {
5592
+
if err := cr.UnreadByte(); err != nil {
5593
+
return err
5594
+
}
5595
+
5596
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
5597
+
if err != nil {
5598
+
return err
5599
+
}
5600
+
5601
+
t.Body = (*string)(&sval)
5602
+
}
5603
+
}
5604
+
// t.Repo (string) (string)
5605
+
case "repo":
5606
+
5607
+
{
5608
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
5609
+
if err != nil {
5610
+
return err
5611
+
}
5612
+
5613
+
t.Repo = string(sval)
5614
+
}
5615
+
// t.LexiconTypeID (string) (string)
5616
+
case "$type":
5617
+
5618
+
{
5619
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
5620
+
if err != nil {
5621
+
return err
5622
+
}
5623
+
5624
+
t.LexiconTypeID = string(sval)
5625
+
}
5626
+
// t.Owner (string) (string)
5627
+
case "owner":
5628
+
5629
+
{
5630
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
5631
+
if err != nil {
5632
+
return err
5633
+
}
5634
+
5635
+
t.Owner = string(sval)
5636
+
}
5637
+
// t.Title (string) (string)
5638
+
case "title":
5639
+
5640
+
{
5641
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
5642
+
if err != nil {
5643
+
return err
5644
+
}
5645
+
5646
+
t.Title = string(sval)
5647
+
}
5648
+
// t.IssueId (int64) (int64)
5649
+
case "issueId":
5650
+
{
5651
+
maj, extra, err := cr.ReadHeader()
5652
+
if err != nil {
5653
+
return err
5654
+
}
5655
+
var extraI int64
5656
+
switch maj {
5657
+
case cbg.MajUnsignedInt:
5658
+
extraI = int64(extra)
5659
+
if extraI < 0 {
5660
+
return fmt.Errorf("int64 positive overflow")
5661
+
}
5662
+
case cbg.MajNegativeInt:
5663
+
extraI = int64(extra)
5664
+
if extraI < 0 {
5665
+
return fmt.Errorf("int64 negative overflow")
5666
+
}
5667
+
extraI = -1 - extraI
5668
+
default:
5669
+
return fmt.Errorf("wrong type for int64 field: %d", maj)
5670
+
}
5671
+
5672
+
t.IssueId = int64(extraI)
5673
+
}
5674
+
// t.CreatedAt (string) (string)
5675
+
case "createdAt":
5676
+
5677
+
{
5678
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
5679
+
if err != nil {
5680
+
return err
5681
+
}
5682
+
5683
+
t.CreatedAt = string(sval)
5684
+
}
5685
+
5686
+
default:
5687
+
// Field doesn't exist on this type, so ignore it
5688
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
5689
+
return err
5690
+
}
5691
+
}
5692
+
}
5693
+
5694
+
return nil
5695
+
}
5696
func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error {
5697
if t == nil {
5698
_, err := w.Write(cbg.CborNull)
···
6242
6243
return nil
6244
}
6245
+
func (t *RepoPull) MarshalCBOR(w io.Writer) error {
6246
if t == nil {
6247
_, err := w.Write(cbg.CborNull)
6248
return err
6249
}
6250
6251
cw := cbg.NewCborWriter(w)
6252
+
fieldCount := 9
6253
6254
if t.Body == nil {
6255
+
fieldCount--
6256
+
}
6257
+
6258
+
if t.Source == nil {
6259
fieldCount--
6260
}
6261
···
6295
}
6296
}
6297
6298
// t.LexiconTypeID (string) (string)
6299
if len("$type") > 1000000 {
6300
return xerrors.Errorf("Value in field \"$type\" was too long")
···
6307
return err
6308
}
6309
6310
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull"))); err != nil {
6311
return err
6312
}
6313
+
if _, err := cw.WriteString(string("sh.tangled.repo.pull")); err != nil {
6314
return err
6315
}
6316
6317
+
// t.Patch (string) (string)
6318
+
if len("patch") > 1000000 {
6319
+
return xerrors.Errorf("Value in field \"patch\" was too long")
6320
}
6321
6322
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patch"))); err != nil {
6323
return err
6324
}
6325
+
if _, err := cw.WriteString(string("patch")); err != nil {
6326
return err
6327
}
6328
6329
+
if len(t.Patch) > 1000000 {
6330
+
return xerrors.Errorf("Value in field t.Patch was too long")
6331
}
6332
6333
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Patch))); err != nil {
6334
return err
6335
}
6336
+
if _, err := cw.WriteString(string(t.Patch)); err != nil {
6337
return err
6338
}
6339
···
6360
return err
6361
}
6362
6363
+
// t.PullId (int64) (int64)
6364
+
if len("pullId") > 1000000 {
6365
+
return xerrors.Errorf("Value in field \"pullId\" was too long")
6366
}
6367
6368
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pullId"))); err != nil {
6369
return err
6370
}
6371
+
if _, err := cw.WriteString(string("pullId")); err != nil {
6372
return err
6373
}
6374
6375
+
if t.PullId >= 0 {
6376
+
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.PullId)); err != nil {
6377
return err
6378
}
6379
} else {
6380
+
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.PullId-1)); err != nil {
6381
+
return err
6382
+
}
6383
+
}
6384
+
6385
+
// t.Source (tangled.RepoPull_Source) (struct)
6386
+
if t.Source != nil {
6387
+
6388
+
if len("source") > 1000000 {
6389
+
return xerrors.Errorf("Value in field \"source\" was too long")
6390
+
}
6391
+
6392
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil {
6393
+
return err
6394
+
}
6395
+
if _, err := cw.WriteString(string("source")); err != nil {
6396
+
return err
6397
+
}
6398
+
6399
+
if err := t.Source.MarshalCBOR(cw); err != nil {
6400
return err
6401
}
6402
}
···
6423
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
6424
return err
6425
}
6426
+
6427
+
// t.TargetRepo (string) (string)
6428
+
if len("targetRepo") > 1000000 {
6429
+
return xerrors.Errorf("Value in field \"targetRepo\" was too long")
6430
+
}
6431
+
6432
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetRepo"))); err != nil {
6433
+
return err
6434
+
}
6435
+
if _, err := cw.WriteString(string("targetRepo")); err != nil {
6436
+
return err
6437
+
}
6438
+
6439
+
if len(t.TargetRepo) > 1000000 {
6440
+
return xerrors.Errorf("Value in field t.TargetRepo was too long")
6441
+
}
6442
+
6443
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetRepo))); err != nil {
6444
+
return err
6445
+
}
6446
+
if _, err := cw.WriteString(string(t.TargetRepo)); err != nil {
6447
+
return err
6448
+
}
6449
+
6450
+
// t.TargetBranch (string) (string)
6451
+
if len("targetBranch") > 1000000 {
6452
+
return xerrors.Errorf("Value in field \"targetBranch\" was too long")
6453
+
}
6454
+
6455
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetBranch"))); err != nil {
6456
+
return err
6457
+
}
6458
+
if _, err := cw.WriteString(string("targetBranch")); err != nil {
6459
+
return err
6460
+
}
6461
+
6462
+
if len(t.TargetBranch) > 1000000 {
6463
+
return xerrors.Errorf("Value in field t.TargetBranch was too long")
6464
+
}
6465
+
6466
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetBranch))); err != nil {
6467
+
return err
6468
+
}
6469
+
if _, err := cw.WriteString(string(t.TargetBranch)); err != nil {
6470
+
return err
6471
+
}
6472
return nil
6473
}
6474
6475
+
func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) {
6476
+
*t = RepoPull{}
6477
6478
cr := cbg.NewCborReader(r)
6479
···
6492
}
6493
6494
if extra > cbg.MaxLength {
6495
+
return fmt.Errorf("RepoPull: map struct too large (%d)", extra)
6496
}
6497
6498
n := extra
6499
6500
+
nameBuf := make([]byte, 12)
6501
for i := uint64(0); i < n; i++ {
6502
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
6503
if err != nil {
···
6534
t.Body = (*string)(&sval)
6535
}
6536
}
6537
// t.LexiconTypeID (string) (string)
6538
case "$type":
6539
···
6545
6546
t.LexiconTypeID = string(sval)
6547
}
6548
+
// t.Patch (string) (string)
6549
+
case "patch":
6550
6551
{
6552
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
6554
return err
6555
}
6556
6557
+
t.Patch = string(sval)
6558
}
6559
// t.Title (string) (string)
6560
case "title":
···
6567
6568
t.Title = string(sval)
6569
}
6570
+
// t.PullId (int64) (int64)
6571
+
case "pullId":
6572
{
6573
maj, extra, err := cr.ReadHeader()
6574
if err != nil {
···
6591
return fmt.Errorf("wrong type for int64 field: %d", maj)
6592
}
6593
6594
+
t.PullId = int64(extraI)
6595
+
}
6596
+
// t.Source (tangled.RepoPull_Source) (struct)
6597
+
case "source":
6598
+
6599
+
{
6600
+
6601
+
b, err := cr.ReadByte()
6602
+
if err != nil {
6603
+
return err
6604
+
}
6605
+
if b != cbg.CborNull[0] {
6606
+
if err := cr.UnreadByte(); err != nil {
6607
+
return err
6608
+
}
6609
+
t.Source = new(RepoPull_Source)
6610
+
if err := t.Source.UnmarshalCBOR(cr); err != nil {
6611
+
return xerrors.Errorf("unmarshaling t.Source pointer: %w", err)
6612
+
}
6613
+
}
6614
+
6615
}
6616
// t.CreatedAt (string) (string)
6617
case "createdAt":
···
6623
}
6624
6625
t.CreatedAt = string(sval)
6626
+
}
6627
+
// t.TargetRepo (string) (string)
6628
+
case "targetRepo":
6629
+
6630
+
{
6631
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
6632
+
if err != nil {
6633
+
return err
6634
+
}
6635
+
6636
+
t.TargetRepo = string(sval)
6637
+
}
6638
+
// t.TargetBranch (string) (string)
6639
+
case "targetBranch":
6640
+
6641
+
{
6642
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
6643
+
if err != nil {
6644
+
return err
6645
+
}
6646
+
6647
+
t.TargetBranch = string(sval)
6648
}
6649
6650
default:
···
7042
7043
return nil
7044
}
7045
func (t *RepoPull_Source) MarshalCBOR(w io.Writer) error {
7046
if t == nil {
7047
_, err := w.Write(cbg.CborNull)
···
7200
7201
return nil
7202
}
7203
+
func (t *RepoPullStatus) MarshalCBOR(w io.Writer) error {
7204
if t == nil {
7205
_, err := w.Write(cbg.CborNull)
7206
return err
7207
}
7208
7209
cw := cbg.NewCborWriter(w)
7210
7211
+
if _, err := cw.Write([]byte{163}); err != nil {
7212
return err
7213
}
7214
7215
+
// t.Pull (string) (string)
7216
+
if len("pull") > 1000000 {
7217
+
return xerrors.Errorf("Value in field \"pull\" was too long")
7218
}
7219
7220
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil {
7221
return err
7222
}
7223
+
if _, err := cw.WriteString(string("pull")); err != nil {
7224
return err
7225
}
7226
7227
+
if len(t.Pull) > 1000000 {
7228
+
return xerrors.Errorf("Value in field t.Pull was too long")
7229
}
7230
7231
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pull))); err != nil {
7232
return err
7233
}
7234
+
if _, err := cw.WriteString(string(t.Pull)); err != nil {
7235
return err
7236
}
7237
7238
+
// t.LexiconTypeID (string) (string)
7239
+
if len("$type") > 1000000 {
7240
+
return xerrors.Errorf("Value in field \"$type\" was too long")
7241
}
7242
7243
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
7244
return err
7245
}
7246
+
if _, err := cw.WriteString(string("$type")); err != nil {
7247
return err
7248
}
7249
7250
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.status"))); err != nil {
7251
return err
7252
}
7253
+
if _, err := cw.WriteString(string("sh.tangled.repo.pull.status")); err != nil {
7254
return err
7255
}
7256
7257
+
// t.Status (string) (string)
7258
+
if len("status") > 1000000 {
7259
+
return xerrors.Errorf("Value in field \"status\" was too long")
7260
}
7261
7262
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil {
7263
return err
7264
}
7265
+
if _, err := cw.WriteString(string("status")); err != nil {
7266
return err
7267
}
7268
7269
+
if len(t.Status) > 1000000 {
7270
+
return xerrors.Errorf("Value in field t.Status was too long")
7271
}
7272
7273
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil {
7274
return err
7275
}
7276
+
if _, err := cw.WriteString(string(t.Status)); err != nil {
7277
return err
7278
}
7279
return nil
7280
}
7281
7282
+
func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) {
7283
+
*t = RepoPullStatus{}
7284
7285
cr := cbg.NewCborReader(r)
7286
···
7299
}
7300
7301
if extra > cbg.MaxLength {
7302
+
return fmt.Errorf("RepoPullStatus: map struct too large (%d)", extra)
7303
}
7304
7305
n := extra
7306
7307
+
nameBuf := make([]byte, 6)
7308
for i := uint64(0); i < n; i++ {
7309
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
7310
if err != nil {
···
7320
}
7321
7322
switch string(nameBuf[:nameLen]) {
7323
+
// t.Pull (string) (string)
7324
+
case "pull":
7325
7326
{
7327
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
7328
if err != nil {
7329
return err
7330
}
7331
7332
+
t.Pull = string(sval)
7333
}
7334
// t.LexiconTypeID (string) (string)
7335
case "$type":
···
7342
7343
t.LexiconTypeID = string(sval)
7344
}
7345
+
// t.Status (string) (string)
7346
+
case "status":
7347
7348
{
7349
sval, err := cbg.ReadStringWithMax(cr, 1000000)
···
7351
return err
7352
}
7353
7354
+
t.Status = string(sval)
7355
}
7356
7357
default:
···
7364
7365
return nil
7366
}
7367
+
func (t *Spindle) MarshalCBOR(w io.Writer) error {
7368
if t == nil {
7369
_, err := w.Write(cbg.CborNull)
7370
return err
7371
}
7372
7373
cw := cbg.NewCborWriter(w)
7374
7375
+
if _, err := cw.Write([]byte{162}); err != nil {
7376
return err
7377
}
7378
···
7388
return err
7389
}
7390
7391
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.spindle"))); err != nil {
7392
return err
7393
}
7394
+
if _, err := cw.WriteString(string("sh.tangled.spindle")); err != nil {
7395
return err
7396
}
7397
7398
// t.CreatedAt (string) (string)
7399
if len("createdAt") > 1000000 {
7400
return xerrors.Errorf("Value in field \"createdAt\" was too long")
···
7417
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
7418
return err
7419
}
7420
return nil
7421
}
7422
7423
+
func (t *Spindle) UnmarshalCBOR(r io.Reader) (err error) {
7424
+
*t = Spindle{}
7425
7426
cr := cbg.NewCborReader(r)
7427
···
7440
}
7441
7442
if extra > cbg.MaxLength {
7443
+
return fmt.Errorf("Spindle: map struct too large (%d)", extra)
7444
}
7445
7446
n := extra
7447
7448
+
nameBuf := make([]byte, 9)
7449
for i := uint64(0); i < n; i++ {
7450
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
7451
if err != nil {
···
7461
}
7462
7463
switch string(nameBuf[:nameLen]) {
7464
+
// t.LexiconTypeID (string) (string)
7465
case "$type":
7466
7467
{
···
7472
7473
t.LexiconTypeID = string(sval)
7474
}
7475
// t.CreatedAt (string) (string)
7476
case "createdAt":
7477
···
7482
}
7483
7484
t.CreatedAt = string(sval)
7485
}
7486
7487
default:
+22
api/tangled/tangledspindle.go
+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
+18
-25
appview/db/db.go
···
321
primary key (did, date)
322
);
323
324
create table if not exists migrations (
325
id integer primary key autoincrement,
326
name text unique
···
515
cmp string
516
}
517
518
-
func FilterEq(key string, arg any) filter {
519
return filter{
520
key: key,
521
arg: arg,
522
-
cmp: "=",
523
}
524
}
525
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
-
}
549
550
func (f filter) Condition() string {
551
return fmt.Sprintf("%s %s ?", f.key, f.cmp)
···
321
primary key (did, date)
322
);
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
+
334
create table if not exists migrations (
335
id integer primary key autoincrement,
336
name text unique
···
525
cmp string
526
}
527
528
+
func newFilter(key, cmp string, arg any) filter {
529
return filter{
530
key: key,
531
arg: arg,
532
+
cmp: cmp,
533
}
534
}
535
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) }
542
543
func (f filter) Condition() string {
544
return fmt.Sprintf("%s %s ?", f.key, f.cmp)
+131
appview/db/spindle.go
+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
+76
-1
appview/ingester.go
···
3
import (
4
"context"
5
"encoding/json"
6
"fmt"
7
"log"
8
"time"
9
10
"github.com/bluesky-social/indigo/atproto/syntax"
···
46
ingestProfile(&d, e)
47
case tangled.SpindleMemberNSID:
48
ingestSpindleMember(&d, e, enforcer)
49
}
50
51
return err
···
288
return nil
289
}
290
291
-
func ingestSpindleMember(_ *db.DbWrapper, e *models.Event, enforcer *rbac.Enforcer) error {
292
did := e.Did
293
var err error
294
···
316
317
return nil
318
}
···
3
import (
4
"context"
5
"encoding/json"
6
+
"errors"
7
"fmt"
8
+
"io"
9
"log"
10
+
"net/http"
11
+
"strings"
12
"time"
13
14
"github.com/bluesky-social/indigo/atproto/syntax"
···
50
ingestProfile(&d, e)
51
case tangled.SpindleMemberNSID:
52
ingestSpindleMember(&d, e, enforcer)
53
+
case tangled.SpindleNSID:
54
+
ingestSpindle(&d, e, true) // TODO: change this to dynamic
55
}
56
57
return err
···
294
return nil
295
}
296
297
+
func ingestSpindleMember(d *db.DbWrapper, e *models.Event, enforcer *rbac.Enforcer) error {
298
did := e.Did
299
var err error
300
···
322
323
return nil
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
+18
appview/pages/pages.go
···
291
return p.execute("knot", w, params)
292
}
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
+
312
type NewRepoParams struct {
313
LoggedInUser *oauth.User
314
Knots []string
+2
-2
appview/pages/templates/knots.html
+2
-2
appview/pages/templates/knots.html
···
20
required
21
class="w-full dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:placeholder-gray-400"
22
>
23
-
<button class="btn dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 flex gap-2 items-center" type="submit">
24
<span>generate key</span>
25
<span id="generate-knot-key-spinner" class="group">
26
-
{{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
27
</span>
28
</button>
29
<div id="settings-knots-error" class="error dark:text-red-400"></div>
···
20
required
21
class="w-full dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:placeholder-gray-400"
22
>
23
+
<button class="btn dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 flex items-center" type="submit">
24
<span>generate key</span>
25
<span id="generate-knot-key-spinner" class="group">
26
+
{{ i "loader-circle" "pl-2 w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
27
</span>
28
</button>
29
<div id="settings-knots-error" class="error dark:text-red-400"></div>
+1
appview/pages/templates/layouts/topbar.html
+1
appview/pages/templates/layouts/topbar.html
+51
appview/pages/templates/spindles/fragments/spindleListing.html
+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
+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
+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
+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
+18
appview/state/router.go
···
12
"tangled.sh/tangled.sh/core/appview/pulls"
13
"tangled.sh/tangled.sh/core/appview/repo"
14
"tangled.sh/tangled.sh/core/appview/settings"
15
"tangled.sh/tangled.sh/core/appview/state/userutil"
16
)
17
18
func (s *State) Router() http.Handler {
···
142
})
143
144
r.Mount("/settings", s.SettingsRouter())
145
r.Mount("/", s.OAuthRouter())
146
147
r.Get("/keys/{user}", s.Keys)
···
167
}
168
169
return settings.Router()
170
}
171
172
func (s *State) IssuesRouter(mw *middleware.Middleware) http.Handler {
···
12
"tangled.sh/tangled.sh/core/appview/pulls"
13
"tangled.sh/tangled.sh/core/appview/repo"
14
"tangled.sh/tangled.sh/core/appview/settings"
15
+
"tangled.sh/tangled.sh/core/appview/spindles"
16
"tangled.sh/tangled.sh/core/appview/state/userutil"
17
+
"tangled.sh/tangled.sh/core/log"
18
)
19
20
func (s *State) Router() http.Handler {
···
144
})
145
146
r.Mount("/settings", s.SettingsRouter())
147
+
r.Mount("/spindles", s.SpindlesRouter())
148
r.Mount("/", s.OAuthRouter())
149
150
r.Get("/keys/{user}", s.Keys)
···
170
}
171
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()
188
}
189
190
func (s *State) IssuesRouter(mw *middleware.Middleware) http.Handler {
+12
-11
cmd/gen.go
+12
-11
cmd/gen.go
···
16
"tangled",
17
tangled.ActorProfile{},
18
tangled.FeedStar{},
19
-
tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{},
20
-
tangled.GitRefUpdate_Meta_CommitCount{},
21
-
tangled.GitRefUpdate_Meta{},
22
tangled.GitRefUpdate{},
23
tangled.GraphFollow{},
24
tangled.KnotMember{},
25
-
tangled.PipelineStatus{},
26
tangled.Pipeline_CloneOpts{},
27
tangled.Pipeline_Dependencies_Elem{},
28
-
tangled.Pipeline_ManualTriggerData_Inputs_Elem{},
29
tangled.Pipeline_ManualTriggerData{},
30
tangled.Pipeline_PullRequestTriggerData{},
31
tangled.Pipeline_PushTriggerData{},
32
tangled.Pipeline_Step{},
33
tangled.Pipeline_TriggerMetadata{},
34
tangled.Pipeline_TriggerRepo{},
35
tangled.Pipeline_Workflow_Environment_Elem{},
36
-
tangled.Pipeline_Workflow{},
37
-
tangled.Pipeline{},
38
tangled.PublicKey{},
39
tangled.RepoArtifact{},
40
tangled.RepoIssueComment{},
41
tangled.RepoIssueState{},
42
-
tangled.RepoIssue{},
43
tangled.RepoPullComment{},
44
tangled.RepoPullStatus{},
45
-
tangled.RepoPull_Source{},
46
-
tangled.RepoPull{},
47
-
tangled.Repo{},
48
tangled.SpindleMember{},
49
); err != nil {
50
panic(err)
···
16
"tangled",
17
tangled.ActorProfile{},
18
tangled.FeedStar{},
19
tangled.GitRefUpdate{},
20
+
tangled.GitRefUpdate_Meta{},
21
+
tangled.GitRefUpdate_Meta_CommitCount{},
22
+
tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{},
23
tangled.GraphFollow{},
24
tangled.KnotMember{},
25
+
tangled.Pipeline{},
26
tangled.Pipeline_CloneOpts{},
27
tangled.Pipeline_Dependencies_Elem{},
28
tangled.Pipeline_ManualTriggerData{},
29
+
tangled.Pipeline_ManualTriggerData_Inputs_Elem{},
30
tangled.Pipeline_PullRequestTriggerData{},
31
tangled.Pipeline_PushTriggerData{},
32
+
tangled.PipelineStatus{},
33
tangled.Pipeline_Step{},
34
tangled.Pipeline_TriggerMetadata{},
35
tangled.Pipeline_TriggerRepo{},
36
+
tangled.Pipeline_Workflow{},
37
tangled.Pipeline_Workflow_Environment_Elem{},
38
tangled.PublicKey{},
39
+
tangled.Repo{},
40
tangled.RepoArtifact{},
41
+
tangled.RepoIssue{},
42
tangled.RepoIssueComment{},
43
tangled.RepoIssueState{},
44
+
tangled.RepoPull{},
45
tangled.RepoPullComment{},
46
+
tangled.RepoPull_Source{},
47
tangled.RepoPullStatus{},
48
+
tangled.Spindle{},
49
tangled.SpindleMember{},
50
); err != nil {
51
panic(err)
+25
lexicons/spindle.json
+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
-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
-
// }
···