From 30f451da2f78fff155287b3a4b8a1a275bb6da56 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Fri, 5 Jun 2026 18:18:55 +0900 Subject: [PATCH] lexicons/ci: introduce pipeline query xrpc lexicons Using `sh.tangled.ci.*` instead of `sh.tangled.pipeline.*` following lexicon style guidelines. Since we need both 'pipeline' and 'workflow' objects, we use different group namespace 'ci'. I would prefer `ci.temp.*` to be more explicit, but that's not possible with current lexgen's behavior. It sets filename using last two words which allows duplicates. Signed-off-by: Seongmin Lee --- api/tangled/cbor_gen.go | 2005 ++++++++++++++++++++++ api/tangled/cidefs.go | 85 + api/tangled/cigetPipeline.go | 30 + api/tangled/ciqueryPipelines.go | 50 + api/tangled/citrigger.go | 37 + api/tangled/pipelinestatus.go | 2 + api/tangled/pipelinesubscribeLogs.go | 36 + api/tangled/tangledpipeline.go | 2 + cmd/cborgen/cborgen.go | 8 + lexicons/ci/defs.json | 84 + lexicons/ci/getPipeline.json | 37 + lexicons/ci/pipeline/cancelPipeline.json | 37 + lexicons/ci/pipeline/subscribeLogs.json | 77 + lexicons/ci/queryPipelines.json | 64 + lexicons/ci/trigger.json | 50 + lexicons/pipeline/cancelPipeline.json | 2 +- lexicons/pipeline/pipeline.json | 1 + lexicons/pipeline/status.json | 1 + 18 files changed, 2607 insertions(+), 1 deletion(-) create mode 100644 api/tangled/cidefs.go create mode 100644 api/tangled/cigetPipeline.go create mode 100644 api/tangled/ciqueryPipelines.go create mode 100644 api/tangled/citrigger.go create mode 100644 api/tangled/pipelinesubscribeLogs.go create mode 100644 lexicons/ci/defs.json create mode 100644 lexicons/ci/getPipeline.json create mode 100644 lexicons/ci/pipeline/cancelPipeline.json create mode 100644 lexicons/ci/pipeline/subscribeLogs.json create mode 100644 lexicons/ci/queryPipelines.json create mode 100644 lexicons/ci/trigger.json diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go index b1351655..460a49ff 100644 --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -662,6 +662,2011 @@ func (t *ActorProfile) UnmarshalCBOR(r io.Reader) (err error) { return nil } +func (t *CiDefs_Pipeline) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + fieldCount := 6 + + if t.CreatedAt == nil { + fieldCount-- + } + + if t.Repo == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err + } + + // t.Id (string) (string) + if len("id") > 1000000 { + return xerrors.Errorf("Value in field \"id\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("id"))); err != nil { + return err + } + if _, err := cw.WriteString(string("id")); err != nil { + return err + } + + if len(t.Id) > 1000000 { + return xerrors.Errorf("Value in field t.Id was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Id))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Id)); err != nil { + return err + } + + // t.Repo (string) (string) + if t.Repo != nil { + + if len("repo") > 1000000 { + return xerrors.Errorf("Value in field \"repo\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { + return err + } + if _, err := cw.WriteString(string("repo")); err != nil { + return err + } + + if t.Repo == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Repo) > 1000000 { + return xerrors.Errorf("Value in field t.Repo was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Repo))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Repo)); err != nil { + return err + } + } + } + + // t.Commit (string) (string) + if len("commit") > 1000000 { + return xerrors.Errorf("Value in field \"commit\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("commit"))); err != nil { + return err + } + if _, err := cw.WriteString(string("commit")); err != nil { + return err + } + + if len(t.Commit) > 1000000 { + return xerrors.Errorf("Value in field t.Commit was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Commit))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Commit)); err != nil { + return err + } + + // t.Trigger (tangled.CiDefs_Pipeline_Trigger) (struct) + if len("trigger") > 1000000 { + return xerrors.Errorf("Value in field \"trigger\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("trigger"))); err != nil { + return err + } + if _, err := cw.WriteString(string("trigger")); err != nil { + return err + } + + if err := t.Trigger.MarshalCBOR(cw); err != nil { + return err + } + + // t.CreatedAt (string) (string) + if t.CreatedAt != nil { + + if len("createdAt") > 1000000 { + return xerrors.Errorf("Value in field \"createdAt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { + return err + } + if _, err := cw.WriteString(string("createdAt")); err != nil { + return err + } + + if t.CreatedAt == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.CreatedAt) > 1000000 { + return xerrors.Errorf("Value in field t.CreatedAt was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.CreatedAt))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.CreatedAt)); err != nil { + return err + } + } + } + + // t.Workflows ([]*tangled.CiDefs_Workflow) (slice) + if len("workflows") > 1000000 { + return xerrors.Errorf("Value in field \"workflows\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflows"))); err != nil { + return err + } + if _, err := cw.WriteString(string("workflows")); err != nil { + return err + } + + if len(t.Workflows) > 8192 { + return xerrors.Errorf("Slice value in field t.Workflows was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Workflows))); err != nil { + return err + } + for _, v := range t.Workflows { + if err := v.MarshalCBOR(cw); err != nil { + return err + } + + } + return nil +} + +func (t *CiDefs_Pipeline) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiDefs_Pipeline{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("CiDefs_Pipeline: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 9) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.Id (string) (string) + case "id": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Id = string(sval) + } + // t.Repo (string) (string) + case "repo": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Repo = (*string)(&sval) + } + } + // t.Commit (string) (string) + case "commit": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Commit = string(sval) + } + // t.Trigger (tangled.CiDefs_Pipeline_Trigger) (struct) + case "trigger": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Trigger = new(CiDefs_Pipeline_Trigger) + if err := t.Trigger.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Trigger pointer: %w", err) + } + } + + } + // t.CreatedAt (string) (string) + case "createdAt": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.CreatedAt = (*string)(&sval) + } + } + // t.Workflows ([]*tangled.CiDefs_Workflow) (slice) + case "workflows": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 8192 { + return fmt.Errorf("t.Workflows: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.Workflows = make([]*CiDefs_Workflow, extra) + } + + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Workflows[i] = new(CiDefs_Workflow) + if err := t.Workflows[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Workflows[i] pointer: %w", err) + } + } + + } + + } + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *CiDefs_Pipeline_Trigger) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{163}); err != nil { + return err + } + + // t.CiTrigger_Push (tangled.CiTrigger_Push) (struct) + if len("CiTrigger_Push") > 1000000 { + return xerrors.Errorf("Value in field \"CiTrigger_Push\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("CiTrigger_Push"))); err != nil { + return err + } + if _, err := cw.WriteString(string("CiTrigger_Push")); err != nil { + return err + } + + if err := t.CiTrigger_Push.MarshalCBOR(cw); err != nil { + return err + } + + // t.CiTrigger_Manual (tangled.CiTrigger_Manual) (struct) + if len("CiTrigger_Manual") > 1000000 { + return xerrors.Errorf("Value in field \"CiTrigger_Manual\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("CiTrigger_Manual"))); err != nil { + return err + } + if _, err := cw.WriteString(string("CiTrigger_Manual")); err != nil { + return err + } + + if err := t.CiTrigger_Manual.MarshalCBOR(cw); err != nil { + return err + } + + // t.CiTrigger_PullRequest (tangled.CiTrigger_PullRequest) (struct) + if len("CiTrigger_PullRequest") > 1000000 { + return xerrors.Errorf("Value in field \"CiTrigger_PullRequest\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("CiTrigger_PullRequest"))); err != nil { + return err + } + if _, err := cw.WriteString(string("CiTrigger_PullRequest")); err != nil { + return err + } + + if err := t.CiTrigger_PullRequest.MarshalCBOR(cw); err != nil { + return err + } + return nil +} + +func (t *CiDefs_Pipeline_Trigger) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiDefs_Pipeline_Trigger{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("CiDefs_Pipeline_Trigger: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 21) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.CiTrigger_Push (tangled.CiTrigger_Push) (struct) + case "CiTrigger_Push": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.CiTrigger_Push = new(CiTrigger_Push) + if err := t.CiTrigger_Push.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.CiTrigger_Push pointer: %w", err) + } + } + + } + // t.CiTrigger_Manual (tangled.CiTrigger_Manual) (struct) + case "CiTrigger_Manual": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.CiTrigger_Manual = new(CiTrigger_Manual) + if err := t.CiTrigger_Manual.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.CiTrigger_Manual pointer: %w", err) + } + } + + } + // t.CiTrigger_PullRequest (tangled.CiTrigger_PullRequest) (struct) + case "CiTrigger_PullRequest": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.CiTrigger_PullRequest = new(CiTrigger_PullRequest) + if err := t.CiTrigger_PullRequest.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.CiTrigger_PullRequest pointer: %w", err) + } + } + + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *CiDefs_Workflow) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + fieldCount := 5 + + if t.FinishedAt == nil { + fieldCount-- + } + + if t.StartedAt == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err + } + + // t.Id (string) (string) + if len("id") > 1000000 { + return xerrors.Errorf("Value in field \"id\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("id"))); err != nil { + return err + } + if _, err := cw.WriteString(string("id")); err != nil { + return err + } + + if len(t.Id) > 1000000 { + return xerrors.Errorf("Value in field t.Id was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Id))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Id)); err != nil { + return err + } + + // t.Name (string) (string) + if len("name") > 1000000 { + return xerrors.Errorf("Value in field \"name\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { + return err + } + if _, err := cw.WriteString(string("name")); err != nil { + return err + } + + if len(t.Name) > 1000000 { + return xerrors.Errorf("Value in field t.Name was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Name)); err != nil { + return err + } + + // t.Status (string) (string) + if len("status") > 1000000 { + return xerrors.Errorf("Value in field \"status\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { + return err + } + if _, err := cw.WriteString(string("status")); err != nil { + return err + } + + if len(t.Status) > 1000000 { + return xerrors.Errorf("Value in field t.Status was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Status)); err != nil { + return err + } + + // t.StartedAt (string) (string) + if t.StartedAt != nil { + + if len("startedAt") > 1000000 { + return xerrors.Errorf("Value in field \"startedAt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("startedAt"))); err != nil { + return err + } + if _, err := cw.WriteString(string("startedAt")); err != nil { + return err + } + + if t.StartedAt == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.StartedAt) > 1000000 { + return xerrors.Errorf("Value in field t.StartedAt was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.StartedAt))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.StartedAt)); err != nil { + return err + } + } + } + + // t.FinishedAt (string) (string) + if t.FinishedAt != nil { + + if len("finishedAt") > 1000000 { + return xerrors.Errorf("Value in field \"finishedAt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("finishedAt"))); err != nil { + return err + } + if _, err := cw.WriteString(string("finishedAt")); err != nil { + return err + } + + if t.FinishedAt == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.FinishedAt) > 1000000 { + return xerrors.Errorf("Value in field t.FinishedAt was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.FinishedAt))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.FinishedAt)); err != nil { + return err + } + } + } + return nil +} + +func (t *CiDefs_Workflow) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiDefs_Workflow{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("CiDefs_Workflow: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 10) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.Id (string) (string) + case "id": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Id = string(sval) + } + // t.Name (string) (string) + case "name": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Name = string(sval) + } + // t.Status (string) (string) + case "status": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Status = string(sval) + } + // t.StartedAt (string) (string) + case "startedAt": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.StartedAt = (*string)(&sval) + } + } + // t.FinishedAt (string) (string) + case "finishedAt": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.FinishedAt = (*string)(&sval) + } + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *CiPipelineSubscribeLogs_Control) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + fieldCount := 7 + + if t.Command == nil { + fieldCount-- + } + + if t.Kind == nil { + fieldCount-- + } + + if t.Status == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err + } + + // t.Kind (string) (string) + if t.Kind != nil { + + if len("kind") > 1000000 { + return xerrors.Errorf("Value in field \"kind\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("kind"))); err != nil { + return err + } + if _, err := cw.WriteString(string("kind")); err != nil { + return err + } + + if t.Kind == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Kind) > 1000000 { + return xerrors.Errorf("Value in field t.Kind was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Kind))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Kind)); err != nil { + return err + } + } + } + + // t.Step (int64) (int64) + if len("step") > 1000000 { + return xerrors.Errorf("Value in field \"step\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("step"))); err != nil { + return err + } + if _, err := cw.WriteString(string("step")); err != nil { + return err + } + + if t.Step >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Step)); err != nil { + return err + } + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Step-1)); err != nil { + return err + } + } + + // t.Time (string) (string) + if len("time") > 1000000 { + return xerrors.Errorf("Value in field \"time\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("time"))); err != nil { + return err + } + if _, err := cw.WriteString(string("time")); err != nil { + return err + } + + if len(t.Time) > 1000000 { + return xerrors.Errorf("Value in field t.Time was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Time))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Time)); err != nil { + return err + } + + // t.Status (string) (string) + if t.Status != nil { + + if len("status") > 1000000 { + return xerrors.Errorf("Value in field \"status\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { + return err + } + if _, err := cw.WriteString(string("status")); err != nil { + return err + } + + if t.Status == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Status) > 1000000 { + return xerrors.Errorf("Value in field t.Status was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Status))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Status)); err != nil { + return err + } + } + } + + // t.Command (string) (string) + if t.Command != nil { + + if len("command") > 1000000 { + return xerrors.Errorf("Value in field \"command\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("command"))); err != nil { + return err + } + if _, err := cw.WriteString(string("command")); err != nil { + return err + } + + if t.Command == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Command) > 1000000 { + return xerrors.Errorf("Value in field t.Command was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Command))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Command)); err != nil { + return err + } + } + } + + // t.Content (string) (string) + if len("content") > 1000000 { + return xerrors.Errorf("Value in field \"content\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("content"))); err != nil { + return err + } + if _, err := cw.WriteString(string("content")); err != nil { + return err + } + + if len(t.Content) > 1000000 { + return xerrors.Errorf("Value in field t.Content was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Content))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Content)); err != nil { + return err + } + + // t.Workflow (string) (string) + if len("workflow") > 1000000 { + return xerrors.Errorf("Value in field \"workflow\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflow"))); err != nil { + return err + } + if _, err := cw.WriteString(string("workflow")); err != nil { + return err + } + + if len(t.Workflow) > 1000000 { + return xerrors.Errorf("Value in field t.Workflow was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Workflow))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Workflow)); err != nil { + return err + } + return nil +} + +func (t *CiPipelineSubscribeLogs_Control) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiPipelineSubscribeLogs_Control{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("CiPipelineSubscribeLogs_Control: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 8) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.Kind (string) (string) + case "kind": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Kind = (*string)(&sval) + } + } + // t.Step (int64) (int64) + case "step": + { + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + var extraI int64 + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative overflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) + } + + t.Step = int64(extraI) + } + // t.Time (string) (string) + case "time": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Time = string(sval) + } + // t.Status (string) (string) + case "status": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Status = (*string)(&sval) + } + } + // t.Command (string) (string) + case "command": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Command = (*string)(&sval) + } + } + // t.Content (string) (string) + case "content": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Content = string(sval) + } + // t.Workflow (string) (string) + case "workflow": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Workflow = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *CiPipelineSubscribeLogs_Data) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{165}); err != nil { + return err + } + + // t.Step (int64) (int64) + if len("step") > 1000000 { + return xerrors.Errorf("Value in field \"step\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("step"))); err != nil { + return err + } + if _, err := cw.WriteString(string("step")); err != nil { + return err + } + + if t.Step >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Step)); err != nil { + return err + } + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Step-1)); err != nil { + return err + } + } + + // t.Time (string) (string) + if len("time") > 1000000 { + return xerrors.Errorf("Value in field \"time\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("time"))); err != nil { + return err + } + if _, err := cw.WriteString(string("time")); err != nil { + return err + } + + if len(t.Time) > 1000000 { + return xerrors.Errorf("Value in field t.Time was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Time))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Time)); err != nil { + return err + } + + // t.Stream (string) (string) + if len("stream") > 1000000 { + return xerrors.Errorf("Value in field \"stream\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("stream"))); err != nil { + return err + } + if _, err := cw.WriteString(string("stream")); err != nil { + return err + } + + if len(t.Stream) > 1000000 { + return xerrors.Errorf("Value in field t.Stream was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Stream))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Stream)); err != nil { + return err + } + + // t.Content (string) (string) + if len("content") > 1000000 { + return xerrors.Errorf("Value in field \"content\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("content"))); err != nil { + return err + } + if _, err := cw.WriteString(string("content")); err != nil { + return err + } + + if len(t.Content) > 1000000 { + return xerrors.Errorf("Value in field t.Content was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Content))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Content)); err != nil { + return err + } + + // t.Workflow (string) (string) + if len("workflow") > 1000000 { + return xerrors.Errorf("Value in field \"workflow\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("workflow"))); err != nil { + return err + } + if _, err := cw.WriteString(string("workflow")); err != nil { + return err + } + + if len(t.Workflow) > 1000000 { + return xerrors.Errorf("Value in field t.Workflow was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Workflow))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Workflow)); err != nil { + return err + } + return nil +} + +func (t *CiPipelineSubscribeLogs_Data) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiPipelineSubscribeLogs_Data{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("CiPipelineSubscribeLogs_Data: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 8) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.Step (int64) (int64) + case "step": + { + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + var extraI int64 + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative overflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) + } + + t.Step = int64(extraI) + } + // t.Time (string) (string) + case "time": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Time = string(sval) + } + // t.Stream (string) (string) + case "stream": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Stream = string(sval) + } + // t.Content (string) (string) + case "content": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Content = string(sval) + } + // t.Workflow (string) (string) + case "workflow": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Workflow = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *CiTrigger_Manual) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{161}); err != nil { + return err + } + + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.ci.trigger#manual"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sh.tangled.ci.trigger#manual")); err != nil { + return err + } + return nil +} + +func (t *CiTrigger_Manual) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiTrigger_Manual{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("CiTrigger_Manual: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 5) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *CiTrigger_PullRequest) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + fieldCount := 5 + + if t.SourceBranch == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err + } + + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.ci.trigger#pullRequest"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sh.tangled.ci.trigger#pullRequest")); err != nil { + return err + } + + // t.Action (string) (string) + if len("action") > 1000000 { + return xerrors.Errorf("Value in field \"action\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("action"))); err != nil { + return err + } + if _, err := cw.WriteString(string("action")); err != nil { + return err + } + + if len(t.Action) > 1000000 { + return xerrors.Errorf("Value in field t.Action was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Action))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Action)); err != nil { + return err + } + + // t.SourceSha (string) (string) + if len("sourceSha") > 1000000 { + return xerrors.Errorf("Value in field \"sourceSha\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceSha"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sourceSha")); err != nil { + return err + } + + if len(t.SourceSha) > 1000000 { + return xerrors.Errorf("Value in field t.SourceSha was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.SourceSha))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.SourceSha)); err != nil { + return err + } + + // t.SourceBranch (string) (string) + if t.SourceBranch != nil { + + if len("sourceBranch") > 1000000 { + return xerrors.Errorf("Value in field \"sourceBranch\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceBranch"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sourceBranch")); err != nil { + return err + } + + if t.SourceBranch == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.SourceBranch) > 1000000 { + return xerrors.Errorf("Value in field t.SourceBranch was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.SourceBranch))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.SourceBranch)); err != nil { + return err + } + } + } + + // t.TargetBranch (string) (string) + if len("targetBranch") > 1000000 { + return xerrors.Errorf("Value in field \"targetBranch\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetBranch"))); err != nil { + return err + } + if _, err := cw.WriteString(string("targetBranch")); err != nil { + return err + } + + if len(t.TargetBranch) > 1000000 { + return xerrors.Errorf("Value in field t.TargetBranch was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetBranch))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.TargetBranch)); err != nil { + return err + } + return nil +} + +func (t *CiTrigger_PullRequest) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiTrigger_PullRequest{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("CiTrigger_PullRequest: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 12) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + // t.Action (string) (string) + case "action": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Action = string(sval) + } + // t.SourceSha (string) (string) + case "sourceSha": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.SourceSha = string(sval) + } + // t.SourceBranch (string) (string) + case "sourceBranch": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.SourceBranch = (*string)(&sval) + } + } + // t.TargetBranch (string) (string) + case "targetBranch": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.TargetBranch = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *CiTrigger_Push) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{164}); err != nil { + return err + } + + // t.Ref (string) (string) + if len("ref") > 1000000 { + return xerrors.Errorf("Value in field \"ref\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ref"))); err != nil { + return err + } + if _, err := cw.WriteString(string("ref")); err != nil { + return err + } + + if len(t.Ref) > 1000000 { + return xerrors.Errorf("Value in field t.Ref was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Ref))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Ref)); err != nil { + return err + } + + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.ci.trigger#push"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sh.tangled.ci.trigger#push")); err != nil { + return err + } + + // t.NewSha (string) (string) + if len("newSha") > 1000000 { + return xerrors.Errorf("Value in field \"newSha\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("newSha"))); err != nil { + return err + } + if _, err := cw.WriteString(string("newSha")); err != nil { + return err + } + + if len(t.NewSha) > 1000000 { + return xerrors.Errorf("Value in field t.NewSha was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.NewSha))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.NewSha)); err != nil { + return err + } + + // t.OldSha (string) (string) + if len("oldSha") > 1000000 { + return xerrors.Errorf("Value in field \"oldSha\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("oldSha"))); err != nil { + return err + } + if _, err := cw.WriteString(string("oldSha")); err != nil { + return err + } + + if len(t.OldSha) > 1000000 { + return xerrors.Errorf("Value in field t.OldSha was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.OldSha))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.OldSha)); err != nil { + return err + } + return nil +} + +func (t *CiTrigger_Push) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiTrigger_Push{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("CiTrigger_Push: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 6) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.Ref (string) (string) + case "ref": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Ref = string(sval) + } + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + // t.NewSha (string) (string) + case "newSha": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.NewSha = string(sval) + } + // t.OldSha (string) (string) + case "oldSha": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.OldSha = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} func (t *FeedComment) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) diff --git a/api/tangled/cidefs.go b/api/tangled/cidefs.go new file mode 100644 index 00000000..d2360c1a --- /dev/null +++ b/api/tangled/cidefs.go @@ -0,0 +1,85 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.ci.defs + +import ( + "encoding/json" + "fmt" + + "github.com/bluesky-social/indigo/lex/util" +) + +const () + +// CiDefs_Pipeline is a "pipeline" in the sh.tangled.ci.defs schema. +type CiDefs_Pipeline struct { + // commit: Commit Id this pipeline is running on + Commit string `json:"commit" cborgen:"commit"` + CreatedAt *string `json:"createdAt,omitempty" cborgen:"createdAt,omitempty"` + // id: Spindle-local pipeline id + Id string `json:"id" cborgen:"id"` + // repo: Repository DID + Repo *string `json:"repo,omitempty" cborgen:"repo,omitempty"` + // trigger: Trigger event metadata + Trigger *CiDefs_Pipeline_Trigger `json:"trigger" cborgen:"trigger"` + // workflows: Triggered workflows + Workflows []*CiDefs_Workflow `json:"workflows" cborgen:"workflows"` +} + +// Trigger event metadata +type CiDefs_Pipeline_Trigger struct { + CiTrigger_Push *CiTrigger_Push + CiTrigger_PullRequest *CiTrigger_PullRequest + CiTrigger_Manual *CiTrigger_Manual +} + +func (t *CiDefs_Pipeline_Trigger) MarshalJSON() ([]byte, error) { + if t.CiTrigger_Push != nil { + t.CiTrigger_Push.LexiconTypeID = "sh.tangled.ci.trigger#push" + return json.Marshal(t.CiTrigger_Push) + } + if t.CiTrigger_PullRequest != nil { + t.CiTrigger_PullRequest.LexiconTypeID = "sh.tangled.ci.trigger#pullRequest" + return json.Marshal(t.CiTrigger_PullRequest) + } + if t.CiTrigger_Manual != nil { + t.CiTrigger_Manual.LexiconTypeID = "sh.tangled.ci.trigger#manual" + return json.Marshal(t.CiTrigger_Manual) + } + return nil, fmt.Errorf("cannot marshal empty enum") +} +func (t *CiDefs_Pipeline_Trigger) UnmarshalJSON(b []byte) error { + typ, err := util.TypeExtract(b) + if err != nil { + return err + } + + switch typ { + case "sh.tangled.ci.trigger#push": + t.CiTrigger_Push = new(CiTrigger_Push) + return json.Unmarshal(b, t.CiTrigger_Push) + case "sh.tangled.ci.trigger#pullRequest": + t.CiTrigger_PullRequest = new(CiTrigger_PullRequest) + return json.Unmarshal(b, t.CiTrigger_PullRequest) + case "sh.tangled.ci.trigger#manual": + t.CiTrigger_Manual = new(CiTrigger_Manual) + return json.Unmarshal(b, t.CiTrigger_Manual) + + default: + return nil + } +} + +// CiDefs_Workflow is a "workflow" in the sh.tangled.ci.defs schema. +type CiDefs_Workflow struct { + FinishedAt *string `json:"finishedAt,omitempty" cborgen:"finishedAt,omitempty"` + // id: Spindle-local workflow id. Unique per pipeline, usually same as name. + Id string `json:"id" cborgen:"id"` + // name: Name of the workflow + Name string `json:"name" cborgen:"name"` + StartedAt *string `json:"startedAt,omitempty" cborgen:"startedAt,omitempty"` + // status: Workflow status + Status string `json:"status" cborgen:"status"` +} diff --git a/api/tangled/cigetPipeline.go b/api/tangled/cigetPipeline.go new file mode 100644 index 00000000..37ec1d89 --- /dev/null +++ b/api/tangled/cigetPipeline.go @@ -0,0 +1,30 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.ci.getPipeline + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + CiGetPipelineNSID = "sh.tangled.ci.getPipeline" +) + +// CiGetPipeline calls the XRPC method "sh.tangled.ci.getPipeline". +// +// pipeline: Spindle-local pipeline id +func CiGetPipeline(ctx context.Context, c util.LexClient, pipeline string) (*CiDefs_Pipeline, error) { + var out CiDefs_Pipeline + + params := map[string]interface{}{} + params["pipeline"] = pipeline + if err := c.LexDo(ctx, util.Query, "", "sh.tangled.ci.getPipeline", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/tangled/ciqueryPipelines.go b/api/tangled/ciqueryPipelines.go new file mode 100644 index 00000000..8f6a336b --- /dev/null +++ b/api/tangled/ciqueryPipelines.go @@ -0,0 +1,50 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.ci.queryPipelines + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + CiQueryPipelinesNSID = "sh.tangled.ci.queryPipelines" +) + +// CiQueryPipelines_Output is the output of a sh.tangled.ci.queryPipelines call. +type CiQueryPipelines_Output struct { + Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"` + Pipelines []*CiDefs_Pipeline `json:"pipelines" cborgen:"pipelines"` + // total: Maximum number of pipelines + Total int64 `json:"total" cborgen:"total"` +} + +// CiQueryPipelines calls the XRPC method "sh.tangled.ci.queryPipelines". +// +// commits: Filter pipelines by commits. When provided, maximum one pipeline per commit id will be returned. +// cursor: Pagination cursor +// limit: Maximum number of pipelines to return +// repo: DID of the repository +func CiQueryPipelines(ctx context.Context, c util.LexClient, commits []string, cursor string, limit int64, repo string) (*CiQueryPipelines_Output, error) { + var out CiQueryPipelines_Output + + params := map[string]interface{}{} + if len(commits) != 0 { + params["commits"] = commits + } + if cursor != "" { + params["cursor"] = cursor + } + if limit != 0 { + params["limit"] = limit + } + params["repo"] = repo + if err := c.LexDo(ctx, util.Query, "", "sh.tangled.ci.queryPipelines", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/tangled/citrigger.go b/api/tangled/citrigger.go new file mode 100644 index 00000000..f75c2723 --- /dev/null +++ b/api/tangled/citrigger.go @@ -0,0 +1,37 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.ci.trigger + +const () + +// CiTrigger_Manual is a "manual" in the sh.tangled.ci.trigger schema. +// +// RECORDTYPE: CiTrigger_Manual +type CiTrigger_Manual struct { + LexiconTypeID string `json:"$type,const=sh.tangled.ci.trigger#manual" cborgen:"$type,const=sh.tangled.ci.trigger#manual"` +} + +// CiTrigger_PullRequest is a "pullRequest" in the sh.tangled.ci.trigger schema. +// +// TODO: reference PR record with strongRef instead of embedding raw values +// +// RECORDTYPE: CiTrigger_PullRequest +type CiTrigger_PullRequest struct { + LexiconTypeID string `json:"$type,const=sh.tangled.ci.trigger#pullRequest" cborgen:"$type,const=sh.tangled.ci.trigger#pullRequest"` + Action string `json:"action" cborgen:"action"` + SourceBranch *string `json:"sourceBranch,omitempty" cborgen:"sourceBranch,omitempty"` + SourceSha string `json:"sourceSha" cborgen:"sourceSha"` + TargetBranch string `json:"targetBranch" cborgen:"targetBranch"` +} + +// CiTrigger_Push is a "push" in the sh.tangled.ci.trigger schema. +// +// RECORDTYPE: CiTrigger_Push +type CiTrigger_Push struct { + LexiconTypeID string `json:"$type,const=sh.tangled.ci.trigger#push" cborgen:"$type,const=sh.tangled.ci.trigger#push"` + NewSha string `json:"newSha" cborgen:"newSha"` + OldSha string `json:"oldSha" cborgen:"oldSha"` + Ref string `json:"ref" cborgen:"ref"` +} diff --git a/api/tangled/pipelinestatus.go b/api/tangled/pipelinestatus.go index b13e43f6..89984f52 100644 --- a/api/tangled/pipelinestatus.go +++ b/api/tangled/pipelinestatus.go @@ -15,6 +15,8 @@ const ( func init() { util.RegisterType("sh.tangled.pipeline.status", &PipelineStatus{}) } // +// DEPRECATED: use sh.tangled.ci.defs#pipeline instead +// // RECORDTYPE: PipelineStatus type PipelineStatus struct { LexiconTypeID string `json:"$type,const=sh.tangled.pipeline.status" cborgen:"$type,const=sh.tangled.pipeline.status"` diff --git a/api/tangled/pipelinesubscribeLogs.go b/api/tangled/pipelinesubscribeLogs.go new file mode 100644 index 00000000..451d90e9 --- /dev/null +++ b/api/tangled/pipelinesubscribeLogs.go @@ -0,0 +1,36 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.ci.pipeline.subscribeLogs + +const ( + CiPipelineSubscribeLogsNSID = "sh.tangled.ci.pipeline.subscribeLogs" +) + +// CiPipelineSubscribeLogs_Control is a "control" in the sh.tangled.ci.pipeline.subscribeLogs schema. +type CiPipelineSubscribeLogs_Control struct { + // command: Step command + Command *string `json:"command,omitempty" cborgen:"command,omitempty"` + Content string `json:"content" cborgen:"content"` + // kind: Step kind + Kind *string `json:"kind,omitempty" cborgen:"kind,omitempty"` + // status: Step status + Status *string `json:"status,omitempty" cborgen:"status,omitempty"` + // step: Step ID + Step int64 `json:"step" cborgen:"step"` + Time string `json:"time" cborgen:"time"` + // workflow: workflow name + Workflow string `json:"workflow" cborgen:"workflow"` +} + +// CiPipelineSubscribeLogs_Data is a "data" in the sh.tangled.ci.pipeline.subscribeLogs schema. +type CiPipelineSubscribeLogs_Data struct { + Content string `json:"content" cborgen:"content"` + // step: Step ID + Step int64 `json:"step" cborgen:"step"` + Stream string `json:"stream" cborgen:"stream"` + Time string `json:"time" cborgen:"time"` + // workflow: workflow name + Workflow string `json:"workflow" cborgen:"workflow"` +} diff --git a/api/tangled/tangledpipeline.go b/api/tangled/tangledpipeline.go index b0ab4a1b..4cd70ab6 100644 --- a/api/tangled/tangledpipeline.go +++ b/api/tangled/tangledpipeline.go @@ -15,6 +15,8 @@ const ( func init() { util.RegisterType("sh.tangled.pipeline", &Pipeline{}) } // +// DEPRECATED: use sh.tangled.ci.defs#pipeline instead +// // RECORDTYPE: Pipeline type Pipeline struct { LexiconTypeID string `json:"$type,const=sh.tangled.pipeline" cborgen:"$type,const=sh.tangled.pipeline"` diff --git a/cmd/cborgen/cborgen.go b/cmd/cborgen/cborgen.go index 072f8600..3cbd17e2 100644 --- a/cmd/cborgen/cborgen.go +++ b/cmd/cborgen/cborgen.go @@ -15,6 +15,14 @@ func main() { "api/tangled/cbor_gen.go", "tangled", tangled.ActorProfile{}, + tangled.CiDefs_Pipeline{}, + tangled.CiDefs_Pipeline_Trigger{}, + tangled.CiDefs_Workflow{}, + tangled.CiPipelineSubscribeLogs_Control{}, + tangled.CiPipelineSubscribeLogs_Data{}, + tangled.CiTrigger_Manual{}, + tangled.CiTrigger_PullRequest{}, + tangled.CiTrigger_Push{}, tangled.FeedComment{}, tangled.FeedReaction{}, tangled.FeedStar{}, diff --git a/lexicons/ci/defs.json b/lexicons/ci/defs.json new file mode 100644 index 00000000..0c3c0b09 --- /dev/null +++ b/lexicons/ci/defs.json @@ -0,0 +1,84 @@ +{ + "lexicon": 1, + "id": "sh.tangled.ci.defs", + "defs": { + "pipeline": { + "type": "object", + "required": ["id", "trigger", "commit", "workflows"], + "properties": { + "id": { + "type": "string", + "description": "Spindle-local pipeline id" + }, + "repo": { + "type": "string", + "format": "did", + "description": "Repository DID" + }, + "trigger": { + "type": "union", + "refs": [ + "sh.tangled.ci.trigger#push", + "sh.tangled.ci.trigger#pullRequest", + "sh.tangled.ci.trigger#manual" + ], + "description": "Trigger event metadata" + }, + "commit": { + "type": "string", + "description": "Commit Id this pipeline is running on" + }, + "createdAt": { + "type": "string", + "format": "datetime" + }, + "workflows": { + "type": "array", + "description": "Triggered workflows", + "minLength": 1, + "maxLength": 50, + "items": { + "type": "ref", + "ref": "#workflow" + } + } + } + }, + "workflow": { + "type": "object", + "required": ["id", "name", "status"], + "properties": { + "id": { + "type": "string", + "description": "Spindle-local workflow id. Unique per pipeline, usually same as name." + }, + "name": { + "type": "string", + "description": "Name of the workflow", + "minGraphemes": 1, + "maxGraphemes": 40 + }, + "status": { + "type": "string", + "description": "Workflow status", + "enum": [ + "pending", + "running", + "failed", + "timeout", + "cancelled", + "success" + ] + }, + "startedAt": { + "type": "string", + "format": "datetime" + }, + "finishedAt": { + "type": "string", + "format": "datetime" + } + } + } + } +} diff --git a/lexicons/ci/getPipeline.json b/lexicons/ci/getPipeline.json new file mode 100644 index 00000000..9e66e14e --- /dev/null +++ b/lexicons/ci/getPipeline.json @@ -0,0 +1,37 @@ +{ + "lexicon": 1, + "id": "sh.tangled.ci.getPipeline", + "defs": { + "main": { + "type": "query", + "parameters": { + "type": "params", + "required": ["pipeline"], + "properties": { + "pipeline": { + "type": "string", + "format": "tid", + "description": "Spindle-local pipeline id" + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "ref", + "ref": "sh.tangled.ci.defs#pipeline" + } + }, + "errors": [ + { + "name": "PipelineNotFound", + "description": "Pipeline not found" + }, + { + "name": "InvalidRequest", + "description": "Invalid request parameters" + } + ] + } + } +} diff --git a/lexicons/ci/pipeline/cancelPipeline.json b/lexicons/ci/pipeline/cancelPipeline.json new file mode 100644 index 00000000..69e26999 --- /dev/null +++ b/lexicons/ci/pipeline/cancelPipeline.json @@ -0,0 +1,37 @@ +{ + "lexicon": 1, + "id": "sh.tangled.ci.pipeline.cancelPipeline", + "defs": { + "main": { + "type": "procedure", + "description": "Cancel running pipeline or specific workflows", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["repo", "pipeline"], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "git repository DID" + }, + "pipeline": { + "type": "string", + "format": "tid", + "description": "pipeline TID" + }, + "workflows": { + "type": "array", + "items": { + "type": "string", + "description": "workflow name" + }, + "description": "Workflow names to filter. When not provided, entire pipeline will be canceled." + } + } + } + } + } + } +} diff --git a/lexicons/ci/pipeline/subscribeLogs.json b/lexicons/ci/pipeline/subscribeLogs.json new file mode 100644 index 00000000..4d63e834 --- /dev/null +++ b/lexicons/ci/pipeline/subscribeLogs.json @@ -0,0 +1,77 @@ +{ + "lexicon": 1, + "id": "sh.tangled.ci.pipeline.subscribeLogs", + "defs": { + "main": { + "type": "subscription", + "description": "Pipeline logs stream", + "parameters": { + "type": "params", + "required": ["pipeline"], + "properties": { + "pipeline": { + "type": "string", + "format": "tid", + "description": "Pipeline ID" + }, + "workflows": { + "type": "array", + "items": { + "type": "string", + "description": "Workflow name" + }, + "description": "filter logs by specific workflows" + } + } + }, + "message": { + "schema": { + "type": "union", + "refs": ["#control", "#data"] + } + }, + "errors": [ + { + "name": "WorkflowNotFound", + "description": "Workflow not found" + }, + { + "name": "InvalidRequest", + "description": "Invalid request parameters" + } + ] + }, + "control": { + "type": "object", + "required": ["time", "workflow", "step", "content"], + "properties": { + "time": { "type": "string", "format": "datetime" }, + "workflow": { "type": "string", "description": "workflow name" }, + "step": { "type": "integer", "description": "Step ID" }, + "content": { "type": "string" }, + "command": { "type": "string", "description": "Step command" }, + "status": { + "type": "string", + "enum": ["start", "end"], + "description": "Step status" + }, + "kind": { + "type": "string", + "enum": ["system", "user"], + "description": "Step kind" + } + } + }, + "data": { + "type": "object", + "required": ["time", "workflow", "step", "content", "stream"], + "properties": { + "time": { "type": "string", "format": "datetime" }, + "workflow": { "type": "string", "description": "workflow name" }, + "step": { "type": "integer", "description": "Step ID" }, + "content": { "type": "string" }, + "stream": { "type": "string", "enum": [ "stdout", "stderr" ] } + } + } + } +} diff --git a/lexicons/ci/queryPipelines.json b/lexicons/ci/queryPipelines.json new file mode 100644 index 00000000..deb80b05 --- /dev/null +++ b/lexicons/ci/queryPipelines.json @@ -0,0 +1,64 @@ +{ + "lexicon": 1, + "id": "sh.tangled.ci.queryPipelines", + "defs": { + "main": { + "type": "query", + "description": "Query pipelines in git repository", + "parameters": { + "type": "params", + "required": ["repo"], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "DID of the repository" + }, + "commits": { + "type": "array", + "items": { + "type": "string", + "description": "commit id (SHA-1 or SHA-265)" + }, + "description": "Filter pipelines by commits. When provided, maximum one pipeline per commit id will be returned." + }, + "limit": { + "type": "integer", + "description": "Maximum number of pipelines to return", + "minimum": 1, + "maximum": 250, + "default": 50 + }, + "cursor": { + "type": "string", + "description": "Pagination cursor" + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["total", "pipelines"], + "properties": { + "cursor": { "type": "string" }, + "total": { + "type": "integer", + "description": "Maximum number of pipelines" + }, + "pipelines": { + "type": "array", + "items": { "type": "ref", "ref": "sh.tangled.ci.defs#pipeline" } + } + } + } + }, + "errors": [ + { + "name": "InvalidRequest", + "description": "Invalid request parameters" + } + ] + } + } +} diff --git a/lexicons/ci/trigger.json b/lexicons/ci/trigger.json new file mode 100644 index 00000000..f621b65b --- /dev/null +++ b/lexicons/ci/trigger.json @@ -0,0 +1,50 @@ +{ + "lexicon": 1, + "id": "sh.tangled.ci.trigger", + "defs": { + "push": { + "type": "object", + "required": ["ref", "newSha", "oldSha"], + "properties": { + "ref": { + "type": "string" + }, + "newSha": { + "type": "string", + "minLength": 40, + "maxLength": 40 + }, + "oldSha": { + "type": "string", + "minLength": 40, + "maxLength": 40 + } + } + }, + "pullRequest": { + "type": "object", + "required": ["targetBranch", "sourceSha", "action"], + "description": "TODO: reference PR record with strongRef instead of embedding raw values", + "properties": { + "sourceBranch": { + "type": "string" + }, + "targetBranch": { + "type": "string" + }, + "sourceSha": { + "type": "string", + "minLength": 40, + "maxLength": 40 + }, + "action": { + "type": "string" + } + } + }, + "manual": { + "type": "object", + "properties": {} + } + } +} diff --git a/lexicons/pipeline/cancelPipeline.json b/lexicons/pipeline/cancelPipeline.json index f1ecf48f..2feda77a 100644 --- a/lexicons/pipeline/cancelPipeline.json +++ b/lexicons/pipeline/cancelPipeline.json @@ -4,7 +4,7 @@ "defs": { "main": { "type": "procedure", - "description": "Cancel a running pipeline", + "description": "DEPRECATED: use sh.tangled.ci.pipeline.cancelPipeline instead - Cancel a running pipeline", "input": { "encoding": "application/json", "schema": { diff --git a/lexicons/pipeline/pipeline.json b/lexicons/pipeline/pipeline.json index 5d347f41..14f38a23 100644 --- a/lexicons/pipeline/pipeline.json +++ b/lexicons/pipeline/pipeline.json @@ -9,6 +9,7 @@ "key": "tid", "record": { "type": "object", + "description": "DEPRECATED: use sh.tangled.ci.defs#pipeline instead", "required": [ "triggerMetadata", "workflows" diff --git a/lexicons/pipeline/status.json b/lexicons/pipeline/status.json index 4f93318a..3106837f 100644 --- a/lexicons/pipeline/status.json +++ b/lexicons/pipeline/status.json @@ -9,6 +9,7 @@ "key": "tid", "record": { "type": "object", + "description": "DEPRECATED: use sh.tangled.ci.defs#pipeline instead", "required": ["pipeline", "workflow", "status", "createdAt"], "properties": { "pipeline": { -- 2.51.2