···669669 }
670670671671 cw := cbg.NewCborWriter(w)
672672- fieldCount := 6
672672+ fieldCount := 7
673673674674 if t.CreatedAt == nil {
675675 fieldCount--
676676 }
677677678678 if t.Repo == nil {
679679+ fieldCount--
680680+ }
681681+682682+ if t.SourceRepo == nil {
679683 fieldCount--
680684 }
681685···834838 }
835839836840 }
841841+842842+ // t.SourceRepo (string) (string)
843843+ if t.SourceRepo != nil {
844844+845845+ if len("sourceRepo") > 1000000 {
846846+ return xerrors.Errorf("Value in field \"sourceRepo\" was too long")
847847+ }
848848+849849+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceRepo"))); err != nil {
850850+ return err
851851+ }
852852+ if _, err := cw.WriteString(string("sourceRepo")); err != nil {
853853+ return err
854854+ }
855855+856856+ if t.SourceRepo == nil {
857857+ if _, err := cw.Write(cbg.CborNull); err != nil {
858858+ return err
859859+ }
860860+ } else {
861861+ if len(*t.SourceRepo) > 1000000 {
862862+ return xerrors.Errorf("Value in field t.SourceRepo was too long")
863863+ }
864864+865865+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.SourceRepo))); err != nil {
866866+ return err
867867+ }
868868+ if _, err := cw.WriteString(string(*t.SourceRepo)); err != nil {
869869+ return err
870870+ }
871871+ }
872872+ }
837873 return nil
838874}
839875···862898863899 n := extra
864900865865- nameBuf := make([]byte, 9)
901901+ nameBuf := make([]byte, 10)
866902 for i := uint64(0); i < n; i++ {
867903 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
868904 if err != nil {
···1009104510101046 }
1011104710481048+ }
10491049+ }
10501050+ // t.SourceRepo (string) (string)
10511051+ case "sourceRepo":
10521052+10531053+ {
10541054+ b, err := cr.ReadByte()
10551055+ if err != nil {
10561056+ return err
10571057+ }
10581058+ if b != cbg.CborNull[0] {
10591059+ if err := cr.UnreadByte(); err != nil {
10601060+ return err
10611061+ }
10621062+10631063+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
10641064+ if err != nil {
10651065+ return err
10661066+ }
10671067+10681068+ t.SourceRepo = (*string)(&sval)
10121069 }
10131070 }
10141071···21812238 }
2182223921832240 cw := cbg.NewCborWriter(w)
22412241+ fieldCount := 5
2184224221852185- if _, err := cw.Write([]byte{161}); err != nil {
22432243+ if t.Inputs == nil {
22442244+ fieldCount--
22452245+ }
22462246+22472247+ if t.Ref == nil {
22482248+ fieldCount--
22492249+ }
22502250+22512251+ if t.SourceRepo == nil {
22522252+ fieldCount--
22532253+ }
22542254+22552255+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
22562256+ return err
22572257+ }
22582258+22592259+ // t.Ref (string) (string)
22602260+ if t.Ref != nil {
22612261+22622262+ if len("ref") > 1000000 {
22632263+ return xerrors.Errorf("Value in field \"ref\" was too long")
22642264+ }
22652265+22662266+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ref"))); err != nil {
22672267+ return err
22682268+ }
22692269+ if _, err := cw.WriteString(string("ref")); err != nil {
22702270+ return err
22712271+ }
22722272+22732273+ if t.Ref == nil {
22742274+ if _, err := cw.Write(cbg.CborNull); err != nil {
22752275+ return err
22762276+ }
22772277+ } else {
22782278+ if len(*t.Ref) > 1000000 {
22792279+ return xerrors.Errorf("Value in field t.Ref was too long")
22802280+ }
22812281+22822282+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Ref))); err != nil {
22832283+ return err
22842284+ }
22852285+ if _, err := cw.WriteString(string(*t.Ref)); err != nil {
22862286+ return err
22872287+ }
22882288+ }
22892289+ }
22902290+22912291+ // t.Sha (string) (string)
22922292+ if len("sha") > 1000000 {
22932293+ return xerrors.Errorf("Value in field \"sha\" was too long")
22942294+ }
22952295+22962296+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sha"))); err != nil {
22972297+ return err
22982298+ }
22992299+ if _, err := cw.WriteString(string("sha")); err != nil {
23002300+ return err
23012301+ }
23022302+23032303+ if len(t.Sha) > 1000000 {
23042304+ return xerrors.Errorf("Value in field t.Sha was too long")
23052305+ }
23062306+23072307+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Sha))); err != nil {
23082308+ return err
23092309+ }
23102310+ if _, err := cw.WriteString(string(t.Sha)); err != nil {
21862311 return err
21872312 }
21882313···22042329 if _, err := cw.WriteString(string("sh.tangled.ci.trigger#manual")); err != nil {
22052330 return err
22062331 }
23322332+23332333+ // t.Inputs ([]*tangled.CiTrigger_Pair) (slice)
23342334+ if t.Inputs != nil {
23352335+23362336+ if len("inputs") > 1000000 {
23372337+ return xerrors.Errorf("Value in field \"inputs\" was too long")
23382338+ }
23392339+23402340+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("inputs"))); err != nil {
23412341+ return err
23422342+ }
23432343+ if _, err := cw.WriteString(string("inputs")); err != nil {
23442344+ return err
23452345+ }
23462346+23472347+ if len(t.Inputs) > 8192 {
23482348+ return xerrors.Errorf("Slice value in field t.Inputs was too long")
23492349+ }
23502350+23512351+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Inputs))); err != nil {
23522352+ return err
23532353+ }
23542354+ for _, v := range t.Inputs {
23552355+ if err := v.MarshalCBOR(cw); err != nil {
23562356+ return err
23572357+ }
23582358+23592359+ }
23602360+ }
23612361+23622362+ // t.SourceRepo (string) (string)
23632363+ if t.SourceRepo != nil {
23642364+23652365+ if len("sourceRepo") > 1000000 {
23662366+ return xerrors.Errorf("Value in field \"sourceRepo\" was too long")
23672367+ }
23682368+23692369+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceRepo"))); err != nil {
23702370+ return err
23712371+ }
23722372+ if _, err := cw.WriteString(string("sourceRepo")); err != nil {
23732373+ return err
23742374+ }
23752375+23762376+ if t.SourceRepo == nil {
23772377+ if _, err := cw.Write(cbg.CborNull); err != nil {
23782378+ return err
23792379+ }
23802380+ } else {
23812381+ if len(*t.SourceRepo) > 1000000 {
23822382+ return xerrors.Errorf("Value in field t.SourceRepo was too long")
23832383+ }
23842384+23852385+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.SourceRepo))); err != nil {
23862386+ return err
23872387+ }
23882388+ if _, err := cw.WriteString(string(*t.SourceRepo)); err != nil {
23892389+ return err
23902390+ }
23912391+ }
23922392+ }
22072393 return nil
22082394}
22092395···2232241822332419 n := extra
2234242022352235- nameBuf := make([]byte, 5)
24212421+ nameBuf := make([]byte, 10)
22362422 for i := uint64(0); i < n; i++ {
22372423 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
22382424 if err != nil {
···22482434 }
2249243522502436 switch string(nameBuf[:nameLen]) {
22512251- // t.LexiconTypeID (string) (string)
24372437+ // t.Ref (string) (string)
24382438+ case "ref":
24392439+24402440+ {
24412441+ b, err := cr.ReadByte()
24422442+ if err != nil {
24432443+ return err
24442444+ }
24452445+ if b != cbg.CborNull[0] {
24462446+ if err := cr.UnreadByte(); err != nil {
24472447+ return err
24482448+ }
24492449+24502450+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
24512451+ if err != nil {
24522452+ return err
24532453+ }
24542454+24552455+ t.Ref = (*string)(&sval)
24562456+ }
24572457+ }
24582458+ // t.Sha (string) (string)
24592459+ case "sha":
24602460+24612461+ {
24622462+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
24632463+ if err != nil {
24642464+ return err
24652465+ }
24662466+24672467+ t.Sha = string(sval)
24682468+ }
24692469+ // t.LexiconTypeID (string) (string)
22522470 case "$type":
2253247122542472 {
···2259247722602478 t.LexiconTypeID = string(sval)
22612479 }
24802480+ // t.Inputs ([]*tangled.CiTrigger_Pair) (slice)
24812481+ case "inputs":
24822482+24832483+ maj, extra, err = cr.ReadHeader()
24842484+ if err != nil {
24852485+ return err
24862486+ }
24872487+24882488+ if extra > 8192 {
24892489+ return fmt.Errorf("t.Inputs: array too large (%d)", extra)
24902490+ }
24912491+24922492+ if maj != cbg.MajArray {
24932493+ return fmt.Errorf("expected cbor array")
24942494+ }
24952495+24962496+ if extra > 0 {
24972497+ t.Inputs = make([]*CiTrigger_Pair, extra)
24982498+ }
24992499+25002500+ for i := 0; i < int(extra); i++ {
25012501+ {
25022502+ var maj byte
25032503+ var extra uint64
25042504+ var err error
25052505+ _ = maj
25062506+ _ = extra
25072507+ _ = err
25082508+25092509+ {
25102510+25112511+ b, err := cr.ReadByte()
25122512+ if err != nil {
25132513+ return err
25142514+ }
25152515+ if b != cbg.CborNull[0] {
25162516+ if err := cr.UnreadByte(); err != nil {
25172517+ return err
25182518+ }
25192519+ t.Inputs[i] = new(CiTrigger_Pair)
25202520+ if err := t.Inputs[i].UnmarshalCBOR(cr); err != nil {
25212521+ return xerrors.Errorf("unmarshaling t.Inputs[i] pointer: %w", err)
25222522+ }
25232523+ }
25242524+25252525+ }
25262526+25272527+ }
25282528+ }
25292529+ // t.SourceRepo (string) (string)
25302530+ case "sourceRepo":
25312531+25322532+ {
25332533+ b, err := cr.ReadByte()
25342534+ if err != nil {
25352535+ return err
25362536+ }
25372537+ if b != cbg.CborNull[0] {
25382538+ if err := cr.UnreadByte(); err != nil {
25392539+ return err
25402540+ }
25412541+25422542+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
25432543+ if err != nil {
25442544+ return err
25452545+ }
25462546+25472547+ t.SourceRepo = (*string)(&sval)
25482548+ }
25492549+ }
2262255022632551 default:
22642552 // Field doesn't exist on this type, so ignore it
···2270255822712559 return nil
22722560}
22732273-func (t *CiTrigger_PullRequest) MarshalCBOR(w io.Writer) error {
25612561+func (t *CiTrigger_Pair) MarshalCBOR(w io.Writer) error {
22742562 if t == nil {
22752563 _, err := w.Write(cbg.CborNull)
22762564 return err
22772565 }
2278256622792567 cw := cbg.NewCborWriter(w)
22802280- fieldCount := 5
25682568+25692569+ if _, err := cw.Write([]byte{162}); err != nil {
25702570+ return err
25712571+ }
25722572+25732573+ // t.Key (string) (string)
25742574+ if len("key") > 1000000 {
25752575+ return xerrors.Errorf("Value in field \"key\" was too long")
25762576+ }
25772577+25782578+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil {
25792579+ return err
25802580+ }
25812581+ if _, err := cw.WriteString(string("key")); err != nil {
25822582+ return err
25832583+ }
2281258422822282- if t.SourceBranch == nil {
22832283- fieldCount--
25852585+ if len(t.Key) > 1000000 {
25862586+ return xerrors.Errorf("Value in field t.Key was too long")
22842587 }
2285258822862286- if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
25892589+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
25902590+ return err
25912591+ }
25922592+ if _, err := cw.WriteString(string(t.Key)); err != nil {
22872593 return err
22882594 }
2289259522902290- // t.LexiconTypeID (string) (string)
22912291- if len("$type") > 1000000 {
22922292- return xerrors.Errorf("Value in field \"$type\" was too long")
25962596+ // t.Value (string) (string)
25972597+ if len("value") > 1000000 {
25982598+ return xerrors.Errorf("Value in field \"value\" was too long")
22932599 }
2294260022952295- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
26012601+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil {
22962602 return err
22972603 }
22982298- if _, err := cw.WriteString(string("$type")); err != nil {
26042604+ if _, err := cw.WriteString(string("value")); err != nil {
22992605 return err
23002606 }
2301260723022302- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.ci.trigger#pullRequest"))); err != nil {
26082608+ if len(t.Value) > 1000000 {
26092609+ return xerrors.Errorf("Value in field t.Value was too long")
26102610+ }
26112611+26122612+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil {
23032613 return err
23042614 }
23052305- if _, err := cw.WriteString(string("sh.tangled.ci.trigger#pullRequest")); err != nil {
26152615+ if _, err := cw.WriteString(string(t.Value)); err != nil {
23062616 return err
23072617 }
26182618+ return nil
26192619+}
2308262023092309- // t.Action (string) (string)
23102310- if len("action") > 1000000 {
23112311- return xerrors.Errorf("Value in field \"action\" was too long")
26212621+func (t *CiTrigger_Pair) UnmarshalCBOR(r io.Reader) (err error) {
26222622+ *t = CiTrigger_Pair{}
26232623+26242624+ cr := cbg.NewCborReader(r)
26252625+26262626+ maj, extra, err := cr.ReadHeader()
26272627+ if err != nil {
26282628+ return err
26292629+ }
26302630+ defer func() {
26312631+ if err == io.EOF {
26322632+ err = io.ErrUnexpectedEOF
26332633+ }
26342634+ }()
26352635+26362636+ if maj != cbg.MajMap {
26372637+ return fmt.Errorf("cbor input should be of type map")
26382638+ }
26392639+26402640+ if extra > cbg.MaxLength {
26412641+ return fmt.Errorf("CiTrigger_Pair: map struct too large (%d)", extra)
26422642+ }
26432643+26442644+ n := extra
26452645+26462646+ nameBuf := make([]byte, 5)
26472647+ for i := uint64(0); i < n; i++ {
26482648+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
26492649+ if err != nil {
26502650+ return err
26512651+ }
26522652+26532653+ if !ok {
26542654+ // Field doesn't exist on this type, so ignore it
26552655+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
26562656+ return err
26572657+ }
26582658+ continue
26592659+ }
26602660+26612661+ switch string(nameBuf[:nameLen]) {
26622662+ // t.Key (string) (string)
26632663+ case "key":
26642664+26652665+ {
26662666+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
26672667+ if err != nil {
26682668+ return err
26692669+ }
26702670+26712671+ t.Key = string(sval)
26722672+ }
26732673+ // t.Value (string) (string)
26742674+ case "value":
26752675+26762676+ {
26772677+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
26782678+ if err != nil {
26792679+ return err
26802680+ }
26812681+26822682+ t.Value = string(sval)
26832683+ }
26842684+26852685+ default:
26862686+ // Field doesn't exist on this type, so ignore it
26872687+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
26882688+ return err
26892689+ }
26902690+ }
23122691 }
2313269223142314- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("action"))); err != nil {
26932693+ return nil
26942694+}
26952695+func (t *CiTrigger_PullRequest) MarshalCBOR(w io.Writer) error {
26962696+ if t == nil {
26972697+ _, err := w.Write(cbg.CborNull)
23152698 return err
23162699 }
23172317- if _, err := cw.WriteString(string("action")); err != nil {
27002700+27012701+ cw := cbg.NewCborWriter(w)
27022702+ fieldCount := 6
27032703+27042704+ if t.Pull == nil {
27052705+ fieldCount--
27062706+ }
27072707+27082708+ if t.SourceBranch == nil {
27092709+ fieldCount--
27102710+ }
27112711+27122712+ if t.SourceRepo == nil {
27132713+ fieldCount--
27142714+ }
27152715+27162716+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
23182717 return err
23192718 }
2320271923212321- if len(t.Action) > 1000000 {
23222322- return xerrors.Errorf("Value in field t.Action was too long")
27202720+ // t.Pull (string) (string)
27212721+ if t.Pull != nil {
27222722+27232723+ if len("pull") > 1000000 {
27242724+ return xerrors.Errorf("Value in field \"pull\" was too long")
27252725+ }
27262726+27272727+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil {
27282728+ return err
27292729+ }
27302730+ if _, err := cw.WriteString(string("pull")); err != nil {
27312731+ return err
27322732+ }
27332733+27342734+ if t.Pull == nil {
27352735+ if _, err := cw.Write(cbg.CborNull); err != nil {
27362736+ return err
27372737+ }
27382738+ } else {
27392739+ if len(*t.Pull) > 1000000 {
27402740+ return xerrors.Errorf("Value in field t.Pull was too long")
27412741+ }
27422742+27432743+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Pull))); err != nil {
27442744+ return err
27452745+ }
27462746+ if _, err := cw.WriteString(string(*t.Pull)); err != nil {
27472747+ return err
27482748+ }
27492749+ }
27502750+ }
27512751+27522752+ // t.LexiconTypeID (string) (string)
27532753+ if len("$type") > 1000000 {
27542754+ return xerrors.Errorf("Value in field \"$type\" was too long")
23232755 }
2324275623252325- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Action))); err != nil {
27572757+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
23262758 return err
23272759 }
23282328- if _, err := cw.WriteString(string(t.Action)); err != nil {
27602760+ if _, err := cw.WriteString(string("$type")); err != nil {
27612761+ return err
27622762+ }
27632763+27642764+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.ci.trigger#pullRequest"))); err != nil {
27652765+ return err
27662766+ }
27672767+ if _, err := cw.WriteString(string("sh.tangled.ci.trigger#pullRequest")); err != nil {
23292768 return err
23302769 }
23312770···23522791 return err
23532792 }
2354279327942794+ // t.SourceRepo (string) (string)
27952795+ if t.SourceRepo != nil {
27962796+27972797+ if len("sourceRepo") > 1000000 {
27982798+ return xerrors.Errorf("Value in field \"sourceRepo\" was too long")
27992799+ }
28002800+28012801+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceRepo"))); err != nil {
28022802+ return err
28032803+ }
28042804+ if _, err := cw.WriteString(string("sourceRepo")); err != nil {
28052805+ return err
28062806+ }
28072807+28082808+ if t.SourceRepo == nil {
28092809+ if _, err := cw.Write(cbg.CborNull); err != nil {
28102810+ return err
28112811+ }
28122812+ } else {
28132813+ if len(*t.SourceRepo) > 1000000 {
28142814+ return xerrors.Errorf("Value in field t.SourceRepo was too long")
28152815+ }
28162816+28172817+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.SourceRepo))); err != nil {
28182818+ return err
28192819+ }
28202820+ if _, err := cw.WriteString(string(*t.SourceRepo)); err != nil {
28212821+ return err
28222822+ }
28232823+ }
28242824+ }
28252825+23552826 // t.SourceBranch (string) (string)
23562827 if t.SourceBranch != nil {
23572828···24502921 }
2451292224522923 switch string(nameBuf[:nameLen]) {
24532453- // t.LexiconTypeID (string) (string)
24542454- case "$type":
29242924+ // t.Pull (string) (string)
29252925+ case "pull":
2455292624562927 {
24572457- sval, err := cbg.ReadStringWithMax(cr, 1000000)
29282928+ b, err := cr.ReadByte()
24582929 if err != nil {
24592930 return err
24602931 }
29322932+ if b != cbg.CborNull[0] {
29332933+ if err := cr.UnreadByte(); err != nil {
29342934+ return err
29352935+ }
2461293624622462- t.LexiconTypeID = string(sval)
29372937+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
29382938+ if err != nil {
29392939+ return err
29402940+ }
29412941+29422942+ t.Pull = (*string)(&sval)
29432943+ }
24632944 }
24642464- // t.Action (string) (string)
24652465- case "action":
29452945+ // t.LexiconTypeID (string) (string)
29462946+ case "$type":
2466294724672948 {
24682949 sval, err := cbg.ReadStringWithMax(cr, 1000000)
···24702951 return err
24712952 }
2472295324732473- t.Action = string(sval)
29542954+ t.LexiconTypeID = string(sval)
24742955 }
24752956 // t.SourceSha (string) (string)
24762957 case "sourceSha":
···24822963 }
2483296424842965 t.SourceSha = string(sval)
29662966+ }
29672967+ // t.SourceRepo (string) (string)
29682968+ case "sourceRepo":
29692969+29702970+ {
29712971+ b, err := cr.ReadByte()
29722972+ if err != nil {
29732973+ return err
29742974+ }
29752975+ if b != cbg.CborNull[0] {
29762976+ if err := cr.UnreadByte(); err != nil {
29772977+ return err
29782978+ }
29792979+29802980+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
29812981+ if err != nil {
29822982+ return err
29832983+ }
29842984+29852985+ t.SourceRepo = (*string)(&sval)
29862986+ }
24852987 }
24862988 // t.SourceBranch (string) (string)
24872989 case "sourceBranch":
···78858387 }
7886838878878389 cw := cbg.NewCborWriter(w)
83908390+ fieldCount := 4
7888839178897889- if _, err := cw.Write([]byte{164}); err != nil {
78907890- return err
83928392+ if t.Pull == nil {
83938393+ fieldCount--
78918394 }
7892839578937893- // t.Action (string) (string)
78947894- if len("action") > 1000000 {
78957895- return xerrors.Errorf("Value in field \"action\" was too long")
78967896- }
78977897-78987898- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("action"))); err != nil {
78997899- return err
79007900- }
79017901- if _, err := cw.WriteString(string("action")); err != nil {
83968396+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
79028397 return err
79038398 }
7904839979057905- if len(t.Action) > 1000000 {
79067906- return xerrors.Errorf("Value in field t.Action was too long")
79077907- }
84008400+ // t.Pull (string) (string)
84018401+ if t.Pull != nil {
7908840279097909- if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Action))); err != nil {
79107910- return err
79117911- }
79127912- if _, err := cw.WriteString(string(t.Action)); err != nil {
79137913- return err
84038403+ if len("pull") > 1000000 {
84048404+ return xerrors.Errorf("Value in field \"pull\" was too long")
84058405+ }
84068406+84078407+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil {
84088408+ return err
84098409+ }
84108410+ if _, err := cw.WriteString(string("pull")); err != nil {
84118411+ return err
84128412+ }
84138413+84148414+ if t.Pull == nil {
84158415+ if _, err := cw.Write(cbg.CborNull); err != nil {
84168416+ return err
84178417+ }
84188418+ } else {
84198419+ if len(*t.Pull) > 1000000 {
84208420+ return xerrors.Errorf("Value in field t.Pull was too long")
84218421+ }
84228422+84238423+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Pull))); err != nil {
84248424+ return err
84258425+ }
84268426+ if _, err := cw.WriteString(string(*t.Pull)); err != nil {
84278427+ return err
84288428+ }
84298429+ }
79148430 }
7915843179168432 // t.SourceSha (string) (string)
···80258541 }
8026854280278543 switch string(nameBuf[:nameLen]) {
80288028- // t.Action (string) (string)
80298029- case "action":
85448544+ // t.Pull (string) (string)
85458545+ case "pull":
8030854680318547 {
80328032- sval, err := cbg.ReadStringWithMax(cr, 1000000)
85488548+ b, err := cr.ReadByte()
80338549 if err != nil {
80348550 return err
80358551 }
85528552+ if b != cbg.CborNull[0] {
85538553+ if err := cr.UnreadByte(); err != nil {
85548554+ return err
85558555+ }
8036855680378037- t.Action = string(sval)
85578557+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
85588558+ if err != nil {
85598559+ return err
85608560+ }
85618561+85628562+ t.Pull = (*string)(&sval)
85638563+ }
80388564 }
80398565 // t.SourceSha (string) (string)
80408566 case "sourceSha":
···86179143 }
8618914486199145 cw := cbg.NewCborWriter(w)
86208620- fieldCount := 5
91469146+ fieldCount := 6
8621914786229148 if t.Manual == nil {
86239149 fieldCount--
···86289154 }
8629915586309156 if t.Push == nil {
91579157+ fieldCount--
91589158+ }
91599159+91609160+ if t.SourceRepo == nil {
86319161 fieldCount--
86329162 }
86339163···87129242 }
87139243 }
8714924492459245+ // t.SourceRepo (string) (string)
92469246+ if t.SourceRepo != nil {
92479247+92489248+ if len("sourceRepo") > 1000000 {
92499249+ return xerrors.Errorf("Value in field \"sourceRepo\" was too long")
92509250+ }
92519251+92529252+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceRepo"))); err != nil {
92539253+ return err
92549254+ }
92559255+ if _, err := cw.WriteString(string("sourceRepo")); err != nil {
92569256+ return err
92579257+ }
92589258+92599259+ if t.SourceRepo == nil {
92609260+ if _, err := cw.Write(cbg.CborNull); err != nil {
92619261+ return err
92629262+ }
92639263+ } else {
92649264+ if len(*t.SourceRepo) > 1000000 {
92659265+ return xerrors.Errorf("Value in field t.SourceRepo was too long")
92669266+ }
92679267+92689268+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.SourceRepo))); err != nil {
92699269+ return err
92709270+ }
92719271+ if _, err := cw.WriteString(string(*t.SourceRepo)); err != nil {
92729272+ return err
92739273+ }
92749274+ }
92759275+ }
92769276+87159277 // t.PullRequest (tangled.Pipeline_PullRequestTriggerData) (struct)
87169278 if t.PullRequest != nil {
87179279···88449406 }
88459407 }
8846940894099409+ }
94109410+ // t.SourceRepo (string) (string)
94119411+ case "sourceRepo":
94129412+94139413+ {
94149414+ b, err := cr.ReadByte()
94159415+ if err != nil {
94169416+ return err
94179417+ }
94189418+ if b != cbg.CborNull[0] {
94199419+ if err := cr.UnreadByte(); err != nil {
94209420+ return err
94219421+ }
94229422+94239423+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
94249424+ if err != nil {
94259425+ return err
94269426+ }
94279427+94289428+ t.SourceRepo = (*string)(&sval)
94299429+ }
88479430 }
88489431 // t.PullRequest (tangled.Pipeline_PullRequestTriggerData) (struct)
88499432 case "pullRequest":
+2
api/tangled/cipipeline.go
···2626 Id string `json:"id" cborgen:"id"`
2727 // repo: Repository DID
2828 Repo *string `json:"repo,omitempty" cborgen:"repo,omitempty"`
2929+ // sourceRepo: Repository DID that the commit was checked out from, if different from repo (e.g. a fork for a fork-based pull request)
3030+ SourceRepo *string `json:"sourceRepo,omitempty" cborgen:"sourceRepo,omitempty"`
2931 // trigger: Trigger event metadata
3032 Trigger *CiPipeline_Trigger `json:"trigger" cborgen:"trigger"`
3133 // workflows: Triggered workflows
+22-6
api/tangled/citrigger.go
···1010//
1111// RECORDTYPE: CiTrigger_Manual
1212type CiTrigger_Manual struct {
1313- LexiconTypeID string `json:"$type,const=sh.tangled.ci.trigger#manual" cborgen:"$type,const=sh.tangled.ci.trigger#manual"`
1313+ LexiconTypeID string `json:"$type,const=sh.tangled.ci.trigger#manual" cborgen:"$type,const=sh.tangled.ci.trigger#manual"`
1414+ Inputs []*CiTrigger_Pair `json:"inputs,omitempty" cborgen:"inputs,omitempty"`
1515+ // ref: optional ref the SHA was resolved from, for display and TANGLED_REF
1616+ Ref *string `json:"ref,omitempty" cborgen:"ref,omitempty"`
1717+ // sha: commit SHA the manual run targets
1818+ Sha string `json:"sha" cborgen:"sha"`
1919+ // sourceRepo: Repository DID to check out code and workflow definitions from, if different from the target repo.
2020+ SourceRepo *string `json:"sourceRepo,omitempty" cborgen:"sourceRepo,omitempty"`
2121+}
2222+2323+// CiTrigger_Pair is a "pair" in the sh.tangled.ci.trigger schema.
2424+type CiTrigger_Pair struct {
2525+ Key string `json:"key" cborgen:"key"`
2626+ Value string `json:"value" cborgen:"value"`
1427}
15281629// CiTrigger_PullRequest is a "pullRequest" in the sh.tangled.ci.trigger schema.
···1932//
2033// RECORDTYPE: CiTrigger_PullRequest
2134type CiTrigger_PullRequest struct {
2222- LexiconTypeID string `json:"$type,const=sh.tangled.ci.trigger#pullRequest" cborgen:"$type,const=sh.tangled.ci.trigger#pullRequest"`
2323- Action string `json:"action" cborgen:"action"`
2424- SourceBranch *string `json:"sourceBranch,omitempty" cborgen:"sourceBranch,omitempty"`
2525- SourceSha string `json:"sourceSha" cborgen:"sourceSha"`
2626- TargetBranch string `json:"targetBranch" cborgen:"targetBranch"`
3535+ LexiconTypeID string `json:"$type,const=sh.tangled.ci.trigger#pullRequest" cborgen:"$type,const=sh.tangled.ci.trigger#pullRequest"`
3636+ // pull: AT-URI of the sh.tangled.repo.pull record this run belongs to
3737+ Pull *string `json:"pull,omitempty" cborgen:"pull,omitempty"`
3838+ SourceBranch *string `json:"sourceBranch,omitempty" cborgen:"sourceBranch,omitempty"`
3939+ // sourceRepo: Repository DID to check out code and workflow definitions from, if different from the target repo.
4040+ SourceRepo *string `json:"sourceRepo,omitempty" cborgen:"sourceRepo,omitempty"`
4141+ SourceSha string `json:"sourceSha" cborgen:"sourceSha"`
4242+ TargetBranch string `json:"targetBranch" cborgen:"targetBranch"`
2743}
28442945// CiTrigger_Push is a "push" in the sh.tangled.ci.trigger schema.
+41-5
api/tangled/citriggerPipeline.go
···6677import (
88 "context"
99+ "encoding/json"
1010+ "fmt"
9111012 "github.com/bluesky-social/indigo/lex/util"
1113)
···16181719// CiTriggerPipeline_Input is the input argument to a sh.tangled.ci.triggerPipeline call.
1820type CiTriggerPipeline_Input struct {
1919- // ref: optional ref the SHA was resolved from, for display
2020- Ref *string `json:"ref,omitempty" cborgen:"ref,omitempty"`
2121- // repo: AT-URI of the sh.tangled.repo record
2121+ // repo: Target repository DID. Auth is checked against this repo.
2222 Repo string `json:"repo" cborgen:"repo"`
2323- // sha: commit SHA to run the pipeline at
2424- Sha string `json:"sha" cborgen:"sha"`
2323+ // trigger: Trigger metadata for this dispatch.
2424+ Trigger *CiTriggerPipeline_Input_Trigger `json:"trigger" cborgen:"trigger"`
2525 // workflows: Workflow names to run. When not provided, every dispatchable workflow is run.
2626 Workflows []string `json:"workflows,omitempty" cborgen:"workflows,omitempty"`
2727+}
2828+2929+// Trigger metadata for this dispatch.
3030+type CiTriggerPipeline_Input_Trigger struct {
3131+ CiTrigger_Manual *CiTrigger_Manual
3232+ CiTrigger_PullRequest *CiTrigger_PullRequest
3333+}
3434+3535+func (t *CiTriggerPipeline_Input_Trigger) MarshalJSON() ([]byte, error) {
3636+ if t.CiTrigger_Manual != nil {
3737+ t.CiTrigger_Manual.LexiconTypeID = "sh.tangled.ci.trigger#manual"
3838+ return json.Marshal(t.CiTrigger_Manual)
3939+ }
4040+ if t.CiTrigger_PullRequest != nil {
4141+ t.CiTrigger_PullRequest.LexiconTypeID = "sh.tangled.ci.trigger#pullRequest"
4242+ return json.Marshal(t.CiTrigger_PullRequest)
4343+ }
4444+ return nil, fmt.Errorf("cannot marshal empty enum")
4545+}
4646+func (t *CiTriggerPipeline_Input_Trigger) UnmarshalJSON(b []byte) error {
4747+ typ, err := util.TypeExtract(b)
4848+ if err != nil {
4949+ return err
5050+ }
5151+5252+ switch typ {
5353+ case "sh.tangled.ci.trigger#manual":
5454+ t.CiTrigger_Manual = new(CiTrigger_Manual)
5555+ return json.Unmarshal(b, t.CiTrigger_Manual)
5656+ case "sh.tangled.ci.trigger#pullRequest":
5757+ t.CiTrigger_PullRequest = new(CiTrigger_PullRequest)
5858+ return json.Unmarshal(b, t.CiTrigger_PullRequest)
5959+6060+ default:
6161+ return nil
6262+ }
2763}
28642965// CiTriggerPipeline_Output is the output of a sh.tangled.ci.triggerPipeline call.
+11-11
api/tangled/pipelinecancelPipeline.go
···2233package tangled
4455-// schema: sh.tangled.ci.pipeline.cancelPipeline
55+// schema: sh.tangled.pipeline.cancelPipeline
6677import (
88 "context"
···1111)
12121313const (
1414- CiPipelineCancelPipelineNSID = "sh.tangled.ci.pipeline.cancelPipeline"
1414+ PipelineCancelPipelineNSID = "sh.tangled.pipeline.cancelPipeline"
1515)
16161717-// CiPipelineCancelPipeline_Input is the input argument to a sh.tangled.ci.pipeline.cancelPipeline call.
1818-type CiPipelineCancelPipeline_Input struct {
1919- // pipeline: pipeline TID
1717+// PipelineCancelPipeline_Input is the input argument to a sh.tangled.pipeline.cancelPipeline call.
1818+type PipelineCancelPipeline_Input struct {
1919+ // pipeline: pipeline at-uri
2020 Pipeline string `json:"pipeline" cborgen:"pipeline"`
2121- // repo: git repository DID
2121+ // repo: repo at-uri, spindle can't resolve repo from pipeline at-uri yet
2222 Repo string `json:"repo" cborgen:"repo"`
2323- // workflows: Workflow names to filter. When not provided, entire pipeline will be canceled.
2424- Workflows []string `json:"workflows,omitempty" cborgen:"workflows,omitempty"`
2323+ // workflow: workflow name
2424+ Workflow string `json:"workflow" cborgen:"workflow"`
2525}
26262727-// CiPipelineCancelPipeline calls the XRPC method "sh.tangled.ci.pipeline.cancelPipeline".
2828-func CiPipelineCancelPipeline(ctx context.Context, c util.LexClient, input *CiPipelineCancelPipeline_Input) error {
2929- if err := c.LexDo(ctx, util.Procedure, "application/json", "sh.tangled.ci.pipeline.cancelPipeline", nil, input, nil); err != nil {
2727+// PipelineCancelPipeline calls the XRPC method "sh.tangled.pipeline.cancelPipeline".
2828+func PipelineCancelPipeline(ctx context.Context, c util.LexClient, input *PipelineCancelPipeline_Input) error {
2929+ if err := c.LexDo(ctx, util.Procedure, "application/json", "sh.tangled.pipeline.cancelPipeline", nil, input, nil); err != nil {
3030 return err
3131 }
3232
+7-4
api/tangled/tangledpipeline.go
···49495050// Pipeline_PullRequestTriggerData is a "pullRequestTriggerData" in the sh.tangled.pipeline schema.
5151type Pipeline_PullRequestTriggerData struct {
5252- Action string `json:"action" cborgen:"action"`
5353- SourceBranch string `json:"sourceBranch" cborgen:"sourceBranch"`
5454- SourceSha string `json:"sourceSha" cborgen:"sourceSha"`
5555- TargetBranch string `json:"targetBranch" cborgen:"targetBranch"`
5252+ // pull: AT-URI of the sh.tangled.repo.pull record this run belongs to
5353+ Pull *string `json:"pull,omitempty" cborgen:"pull,omitempty"`
5454+ SourceBranch string `json:"sourceBranch" cborgen:"sourceBranch"`
5555+ SourceSha string `json:"sourceSha" cborgen:"sourceSha"`
5656+ TargetBranch string `json:"targetBranch" cborgen:"targetBranch"`
5657}
57585859// Pipeline_PushTriggerData is a "pushTriggerData" in the sh.tangled.pipeline schema.
···6970 PullRequest *Pipeline_PullRequestTriggerData `json:"pullRequest,omitempty" cborgen:"pullRequest,omitempty"`
7071 Push *Pipeline_PushTriggerData `json:"push,omitempty" cborgen:"push,omitempty"`
7172 Repo *Pipeline_TriggerRepo `json:"repo" cborgen:"repo"`
7373+ // sourceRepo: Repository DID that code and workflow definitions are checked out from, when different from repo (e.g. a fork's commit for a fork-based manual trigger). If absent, source uses repo itself.
7474+ SourceRepo *string `json:"sourceRepo,omitempty" cborgen:"sourceRepo,omitempty"`
7275}
73767477// Pipeline_TriggerRepo is a "triggerRepo" in the sh.tangled.pipeline schema.
···524524 find api/tangled -maxdepth 1 -name '*.go' -not -name '*_ext.go' -exec \
525525 sed -i.bak 's/\tutil/\/\/\tutil/' {} +
526526 # lexgen generates incomplete Marshaler/Unmarshaler for union types
527527- find api/tangled/*.go -not -name "cbor_gen.go" -exec \
527527+ find api/tangled -maxdepth 1 -name '*.go' -not -name '*_ext.go' -not -name "cbor_gen.go" -exec \
528528 sed -i '/^func.*\(MarshalCBOR\|UnmarshalCBOR\)/,/^}/ s/^/\/\/ /' {} +
529529 for f in api/tangled/*_ext.go; do [ -e "''$f" ] && mv "''$f" "''$f.bak"; done
530530 ${pkgs.gotools}/bin/goimports -w api/tangled/*
+5
lexicons/ci/pipeline.json
···2929 "type": "string",
3030 "description": "Commit Id this pipeline is running on"
3131 },
3232+ "sourceRepo": {
3333+ "type": "string",
3434+ "format": "did",
3535+ "description": "Repository DID that the commit was checked out from, if different from repo (e.g. a fork for a fork-based pull request)"
3636+ },
3237 "createdAt": {
3338 "type": "string",
3439 "format": "datetime"
+47-4
lexicons/ci/trigger.json
···2323 },
2424 "pullRequest": {
2525 "type": "object",
2626- "required": ["targetBranch", "sourceSha", "action"],
2626+ "required": ["targetBranch", "sourceSha"],
2727 "description": "TODO: reference PR record with strongRef instead of embedding raw values",
2828 "properties": {
2929+ "sourceRepo": {
3030+ "type": "string",
3131+ "format": "did",
3232+ "description": "Repository DID to check out code and workflow definitions from, if different from the target repo."
3333+ },
2934 "sourceBranch": {
3035 "type": "string"
3136 },
···3742 "minLength": 40,
3843 "maxLength": 40
3944 },
4040- "action": {
4141- "type": "string"
4545+ "pull": {
4646+ "type": "string",
4747+ "format": "at-uri",
4848+ "description": "AT-URI of the sh.tangled.repo.pull record this run belongs to"
4249 }
4350 }
4451 },
4552 "manual": {
4653 "type": "object",
4747- "properties": {}
5454+ "required": ["sha"],
5555+ "properties": {
5656+ "sha": {
5757+ "type": "string",
5858+ "description": "commit SHA the manual run targets",
5959+ "minLength": 40,
6060+ "maxLength": 40
6161+ },
6262+ "ref": {
6363+ "type": "string",
6464+ "description": "optional ref the SHA was resolved from, for display and TANGLED_REF"
6565+ },
6666+ "sourceRepo": {
6767+ "type": "string",
6868+ "format": "did",
6969+ "description": "Repository DID to check out code and workflow definitions from, if different from the target repo."
7070+ },
7171+ "inputs": {
7272+ "type": "array",
7373+ "items": {
7474+ "type": "ref",
7575+ "ref": "#pair"
7676+ }
7777+ }
7878+ }
7979+ },
8080+ "pair": {
8181+ "type": "object",
8282+ "required": ["key", "value"],
8383+ "properties": {
8484+ "key": {
8585+ "type": "string"
8686+ },
8787+ "value": {
8888+ "type": "string"
8989+ }
9090+ }
4891 }
4992 }
5093}
+11-13
lexicons/ci/triggerPipeline.json
···44 "defs": {
55 "main": {
66 "type": "procedure",
77- "description": "Manually trigger a pipeline at an explicit commit. Runs the named workflows, or every workflow defined in the repo when none are named.",
77+ "description": "Trigger a pipeline at an explicit commit. Runs the named workflows, or every workflow defined in the repo when none are named.",
88 "input": {
99 "encoding": "application/json",
1010 "schema": {
1111 "type": "object",
1212- "required": ["repo", "sha"],
1212+ "required": ["repo", "trigger"],
1313 "properties": {
1414 "repo": {
1515 "type": "string",
1616- "format": "at-uri",
1717- "description": "AT-URI of the sh.tangled.repo record"
1818- },
1919- "sha": {
2020- "type": "string",
2121- "minLength": 40,
2222- "maxLength": 40,
2323- "description": "commit SHA to run the pipeline at"
1616+ "format": "did",
1717+ "description": "Target repository DID. Auth is checked against this repo."
2418 },
2525- "ref": {
2626- "type": "string",
2727- "description": "optional ref the SHA was resolved from, for display"
1919+ "trigger": {
2020+ "type": "union",
2121+ "refs": [
2222+ "sh.tangled.ci.trigger#manual",
2323+ "sh.tangled.ci.trigger#pullRequest"
2424+ ],
2525+ "description": "Trigger metadata for this dispatch."
2826 },
2927 "workflows": {
3028 "type": "array",
+10-4
lexicons/pipeline/pipeline.json
···5959 "manual": {
6060 "type": "ref",
6161 "ref": "#manualTriggerData"
6262+ },
6363+ "sourceRepo": {
6464+ "type": "string",
6565+ "format": "did",
6666+ "description": "Repository DID that code and workflow definitions are checked out from, when different from repo (e.g. a fork's commit for a fork-based manual trigger). If absent, source uses repo itself."
6267 }
6368 }
6469 },
···118123 "required": [
119124 "sourceBranch",
120125 "targetBranch",
121121- "sourceSha",
122122- "action"
126126+ "sourceSha"
123127 ],
124128 "properties": {
125129 "sourceBranch": {
···133137 "minLength": 40,
134138 "maxLength": 40
135139 },
136136- "action": {
137137- "type": "string"
140140+ "pull": {
141141+ "type": "string",
142142+ "format": "at-uri",
143143+ "description": "AT-URI of the sh.tangled.repo.pull record this run belongs to"
138144 }
139145 }
140146 },
···44 "encoding/json"
55 "fmt"
66 "net/http"
77- "strings"
8798 "github.com/bluesky-social/indigo/atproto/syntax"
109 "tangled.org/core/api/tangled"
···2625 return
2726 }
28272929- var input tangled.CiPipelineCancelPipeline_Input
2828+ var input tangled.CiCancelPipeline_Input
3029 if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
3130 fail(xrpcerr.GenericError(err))
3231 return
3332 }
34333535- aturi := syntax.ATURI(input.Pipeline)
3434+ pipelineTid, err := syntax.ParseTID(input.Pipeline)
3535+ if err != nil {
3636+ fail(xrpcerr.GenericError(fmt.Errorf("invalid pipeline TID %q: %w", input.Pipeline, err)))
3737+ return
3838+ }
3939+4040+ repoDid, xerr, ok := x.resolveOwnedRepo(r.Context(), actorDid, input.Repo)
4141+ if !ok {
4242+ fail(xerr)
4343+ return
4444+ }
4545+ repo, err := x.Db.GetRepoByDid(repoDid)
4646+ if err != nil {
4747+ fail(xrpcerr.GenericError(fmt.Errorf("failed to get repo: %w", err)))
4848+ return
4949+ }
5050+5151+ // the actor is only authorized against input.Repo, so make sure the
5252+ // pipeline actually belongs to it before cancelling anything
5353+ p, err := x.Db.GetPipeline(r.Context(), pipelineTid.String())
5454+ if err != nil {
5555+ fail(xrpcerr.GenericError(fmt.Errorf("failed to get pipeline: %w", err)))
5656+ return
5757+ }
5858+ if p.Repo == nil || *p.Repo != repoDid.String() {
5959+ fail(xrpcerr.AccessControlError(actorDid.String()))
6060+ return
6161+ }
6262+3663 pipelineId := models.PipelineId{
3737- Knot: strings.TrimPrefix(aturi.Authority().String(), "did:web:"),
3838- Rkey: aturi.RecordKey().String(),
6464+ Knot: repo.Knot,
6565+ Rkey: pipelineTid.String(),
3966 }
40674141- var workflows []string
4242- if len(input.Workflows) > 0 {
4343- workflows = input.Workflows
4444- } else {
4545- // fetch workflows from db if none are specified
4646- p, err := x.Db.GetPipeline(r.Context(), pipelineId.Rkey)
4747- if err != nil {
4848- fail(xrpcerr.GenericError(fmt.Errorf("failed to get pipeline: %w", err)))
4949- return
5050- }
6868+ workflows := input.Workflows
6969+ if len(workflows) == 0 {
7070+ // cancel every workflow when none are specified
5171 for _, w := range p.Workflows {
5272 workflows = append(workflows, w.Name)
5373 }
5454- }
5555-5656- if _, xerr, ok := x.resolveOwnedRepo(r.Context(), actorDid, input.Repo); !ok {
5757- fail(xerr)
5858- return
5974 }
60756176 for _, wName := range workflows {
+10-7
spindle/xrpc/xrpc.go
···25252626const ActorDid = serviceauth.ActorDid
27272828-// ErrNoMatchingWorkflows is returned when a manual dispatch resolves to no
2929-// workflows to run: the repo defines none at the requested commit, or none of
3030-// the requested workflow names exist.
3128var ErrNoMatchingWorkflows = errors.New("no workflows to run")
32293333-// PipelineTrigger builds and enqueues a manually-dispatched pipeline. It is
3434-// implemented by *spindle.Spindle, which owns the queue and engines; the xrpc
3535-// handler only does auth and input validation before delegating here.
3030+// this is to break an import cycle. spindle imports this package for Xrpc,
3131+// so this package can't import *spindle.Spindle back.
3632type PipelineTrigger interface {
3737- TriggerManual(ctx context.Context, repoDid syntax.DID, sha, ref string, workflows []string) (syntax.ATURI, error)
3333+ TriggerManual(ctx context.Context, repoDid syntax.DID, sha, ref string, workflows []string, sourceRepo syntax.DID, pull PullContext, inputs []*tangled.Pipeline_Pair) (syntax.ATURI, error)
3434+}
3535+3636+type PullContext struct {
3737+ IsPullRequest bool
3838+ Pull syntax.ATURI
3939+ SourceBranch string
4040+ TargetBranch string
3841}
39424043type Xrpc struct {
+23-4
types/pipeline.go
···106106 }
107107 if t.CiPipeline_Trigger.CiTrigger_Push != nil {
108108 ref := t.CiPipeline_Trigger.CiTrigger_Push.Ref
109109- if strings.HasPrefix(ref, "refs/heads/") {
110110- return strings.TrimPrefix(ref, "refs/heads/")
109109+ if after, ok := strings.CutPrefix(ref, "refs/heads/"); ok {
110110+ return after
111111 }
112112- if strings.HasPrefix(ref, "refs/tags/") {
113113- return strings.TrimPrefix(ref, "refs/tags/")
112112+ if after, ok := strings.CutPrefix(ref, "refs/tags/"); ok {
113113+ return after
114114 }
115115 return ref
116116 }
···129129 return ""
130130 }
131131 return *sb
132132+}
133133+134134+func (t Trigger) PRUri() string {
135135+ if t.CiPipeline_Trigger == nil || t.CiPipeline_Trigger.CiTrigger_PullRequest == nil {
136136+ return ""
137137+ }
138138+ pull := t.CiPipeline_Trigger.CiTrigger_PullRequest.Pull
139139+ if pull == nil {
140140+ return ""
141141+ }
142142+ return *pull
132143}
133144134145type Pipeline struct {
···240251 return ""
241252 }
242253 return p.CiPipeline.Commit
254254+}
255255+256256+// where the pipeline commit was checked out from, nil when checked out from repo itself
257257+func (p Pipeline) SourceRepo() *string {
258258+ if p.CiPipeline == nil {
259259+ return nil
260260+ }
261261+ return p.CiPipeline.SourceRepo
243262}
244263245264func (p Pipeline) Workflows() []string {