From 46fdf62a800715476fc06d1e214a151be7d0ff49 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Wed, 26 Aug 2026 17:15:36 +0900 Subject: [PATCH] api,cmd,flake: generate org.tangled bindings Signed-off-by: dawn --- api/org_tangled/cbor_gen.go | 1268 ++++++++++++++++++ api/org_tangled/cigetPipeline.go | 30 + api/org_tangled/cigetWorkflowDefinition.go | 34 + api/org_tangled/cilistWorkflowDefinitions.go | 36 + api/org_tangled/cipipeline.go | 100 ++ api/org_tangled/ciqueryPipelines.go | 54 + api/org_tangled/cisubscribePipelineLogs.go | 36 + api/org_tangled/ciworkflow.go | 91 ++ api/org_tangled/eventpullRequest.go | 23 + api/org_tangled/eventpush.go | 23 + api/org_tangled/secretaddSecret.go | 31 + api/org_tangled/secretlistSecrets.go | 40 + api/org_tangled/secretremoveSecret.go | 30 + api/org_tangled/triggermanual.go | 33 + cmd/cborgen/cborgen.go | 6 + cmd/lexpostgen/main.go | 42 + flake.nix | 1 + 17 files changed, 1878 insertions(+) create mode 100644 api/org_tangled/cigetPipeline.go create mode 100644 api/org_tangled/cigetWorkflowDefinition.go create mode 100644 api/org_tangled/cilistWorkflowDefinitions.go create mode 100644 api/org_tangled/cipipeline.go create mode 100644 api/org_tangled/ciqueryPipelines.go create mode 100644 api/org_tangled/cisubscribePipelineLogs.go create mode 100644 api/org_tangled/ciworkflow.go create mode 100644 api/org_tangled/eventpullRequest.go create mode 100644 api/org_tangled/eventpush.go create mode 100644 api/org_tangled/secretaddSecret.go create mode 100644 api/org_tangled/secretlistSecrets.go create mode 100644 api/org_tangled/secretremoveSecret.go create mode 100644 api/org_tangled/triggermanual.go create mode 100644 cmd/lexpostgen/main.go diff --git a/api/org_tangled/cbor_gen.go b/api/org_tangled/cbor_gen.go index 6ada35ddd..3579d802c 100644 --- a/api/org_tangled/cbor_gen.go +++ b/api/org_tangled/cbor_gen.go @@ -18,6 +18,1274 @@ var _ = cid.Undef var _ = math.E var _ = sort.Sort +func (t *CiSubscribePipelineLogs_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 *CiSubscribePipelineLogs_Control) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiSubscribePipelineLogs_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("CiSubscribePipelineLogs_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 *CiSubscribePipelineLogs_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 *CiSubscribePipelineLogs_Data) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiSubscribePipelineLogs_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("CiSubscribePipelineLogs_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 *CiTriggerManual) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + fieldCount := 5 + + if t.Inputs == nil { + fieldCount-- + } + + if t.Ref == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err + } + + // t.Ref (string) (string) + if t.Ref != nil { + + 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 t.Ref == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + 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.Repo (string) (string) + if len("repo") > 1000000 { + return xerrors.Errorf("Value in field \"repo\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { + return err + } + if _, err := cw.WriteString(string("repo")); err != nil { + return err + } + + if len(t.Repo) > 1000000 { + return xerrors.Errorf("Value in field t.Repo was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Repo)); err != nil { + return err + } + + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("org.tangled.ci.trigger.manual"))); err != nil { + return err + } + if _, err := cw.WriteString(string("org.tangled.ci.trigger.manual")); 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.Inputs ([]*org_tangled.CiTriggerManual_Pair) (slice) + if t.Inputs != nil { + + if len("inputs") > 1000000 { + return xerrors.Errorf("Value in field \"inputs\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("inputs"))); err != nil { + return err + } + if _, err := cw.WriteString(string("inputs")); err != nil { + return err + } + + if len(t.Inputs) > 8192 { + return xerrors.Errorf("Slice value in field t.Inputs was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Inputs))); err != nil { + return err + } + for _, v := range t.Inputs { + if err := v.MarshalCBOR(cw); err != nil { + return err + } + + } + } + return nil +} + +func (t *CiTriggerManual) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiTriggerManual{} + + 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("CiTriggerManual: 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": + + { + 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.Ref = (*string)(&sval) + } + } + // t.Repo (string) (string) + case "repo": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Repo = string(sval) + } + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + // t.Commit (string) (string) + case "commit": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Commit = string(sval) + } + // t.Inputs ([]*org_tangled.CiTriggerManual_Pair) (slice) + case "inputs": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 8192 { + return fmt.Errorf("t.Inputs: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.Inputs = make([]*CiTriggerManual_Pair, extra) + } + + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Inputs[i] = new(CiTriggerManual_Pair) + if err := t.Inputs[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Inputs[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 *CiTriggerManual_Pair) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{162}); err != nil { + return err + } + + // t.Key (string) (string) + if len("key") > 1000000 { + return xerrors.Errorf("Value in field \"key\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil { + return err + } + if _, err := cw.WriteString(string("key")); err != nil { + return err + } + + if len(t.Key) > 1000000 { + return xerrors.Errorf("Value in field t.Key was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Key)); err != nil { + return err + } + + // t.Value (string) (string) + if len("value") > 1000000 { + return xerrors.Errorf("Value in field \"value\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil { + return err + } + if _, err := cw.WriteString(string("value")); err != nil { + return err + } + + if len(t.Value) > 1000000 { + return xerrors.Errorf("Value in field t.Value was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Value)); err != nil { + return err + } + return nil +} + +func (t *CiTriggerManual_Pair) UnmarshalCBOR(r io.Reader) (err error) { + *t = CiTriggerManual_Pair{} + + 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("CiTriggerManual_Pair: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 5) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.Key (string) (string) + case "key": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Key = string(sval) + } + // t.Value (string) (string) + case "value": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Value = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *EventPullRequest) 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("org.tangled.event.pullRequest"))); err != nil { + return err + } + if _, err := cw.WriteString(string("org.tangled.event.pullRequest")); err != nil { + return err + } + return nil +} + +func (t *EventPullRequest) UnmarshalCBOR(r io.Reader) (err error) { + *t = EventPullRequest{} + + 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("EventPullRequest: 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 *EventPush) 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("org.tangled.event.push"))); err != nil { + return err + } + if _, err := cw.WriteString(string("org.tangled.event.push")); err != nil { + return err + } + return nil +} + +func (t *EventPush) UnmarshalCBOR(r io.Reader) (err error) { + *t = EventPush{} + + 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("EventPush: 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 *FeedSubscription) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) diff --git a/api/org_tangled/cigetPipeline.go b/api/org_tangled/cigetPipeline.go new file mode 100644 index 000000000..10ccac20c --- /dev/null +++ b/api/org_tangled/cigetPipeline.go @@ -0,0 +1,30 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.ci.getPipeline + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + CiGetPipelineNSID = "org.tangled.ci.getPipeline" +) + +// CiGetPipeline calls the XRPC method "org.tangled.ci.getPipeline". +// +// pipeline: Spindle-local pipeline id +func CiGetPipeline(ctx context.Context, c util.LexClient, pipeline string) (*CiPipeline, error) { + var out CiPipeline + + params := map[string]interface{}{} + params["pipeline"] = pipeline + if err := c.LexDo(ctx, util.Query, "", "org.tangled.ci.getPipeline", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/org_tangled/cigetWorkflowDefinition.go b/api/org_tangled/cigetWorkflowDefinition.go new file mode 100644 index 000000000..023a7fd0b --- /dev/null +++ b/api/org_tangled/cigetWorkflowDefinition.go @@ -0,0 +1,34 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.ci.getWorkflowDefinition + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + CiGetWorkflowDefinitionNSID = "org.tangled.ci.getWorkflowDefinition" +) + +// CiGetWorkflowDefinition_Output is the output of a org.tangled.ci.getWorkflowDefinition call. +type CiGetWorkflowDefinition_Output struct { + Workflow *CiWorkflow `json:"workflow" cborgen:"workflow"` +} + +// CiGetWorkflowDefinition calls the XRPC method "org.tangled.ci.getWorkflowDefinition". +func CiGetWorkflowDefinition(ctx context.Context, c util.LexClient, repo string, workflow string) (*CiGetWorkflowDefinition_Output, error) { + var out CiGetWorkflowDefinition_Output + + params := map[string]interface{}{} + params["repo"] = repo + params["workflow"] = workflow + if err := c.LexDo(ctx, util.Query, "", "org.tangled.ci.getWorkflowDefinition", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/org_tangled/cilistWorkflowDefinitions.go b/api/org_tangled/cilistWorkflowDefinitions.go new file mode 100644 index 000000000..051d5bdcb --- /dev/null +++ b/api/org_tangled/cilistWorkflowDefinitions.go @@ -0,0 +1,36 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.ci.listWorkflowDefinitions + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + CiListWorkflowDefinitionsNSID = "org.tangled.ci.listWorkflowDefinitions" +) + +// CiListWorkflowDefinitions_Output is the output of a org.tangled.ci.listWorkflowDefinitions call. +type CiListWorkflowDefinitions_Output struct { + Workflows []*CiWorkflow `json:"workflows" cborgen:"workflows"` +} + +// CiListWorkflowDefinitions calls the XRPC method "org.tangled.ci.listWorkflowDefinitions". +func CiListWorkflowDefinitions(ctx context.Context, c util.LexClient, ref string, repo string) (*CiListWorkflowDefinitions_Output, error) { + var out CiListWorkflowDefinitions_Output + + params := map[string]interface{}{} + if ref != "" { + params["ref"] = ref + } + params["repo"] = repo + if err := c.LexDo(ctx, util.Query, "", "org.tangled.ci.listWorkflowDefinitions", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/org_tangled/cipipeline.go b/api/org_tangled/cipipeline.go new file mode 100644 index 000000000..cb6624b80 --- /dev/null +++ b/api/org_tangled/cipipeline.go @@ -0,0 +1,100 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.ci.pipeline + +import ( + "encoding/json" + "fmt" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + CiPipelineNSID = "org.tangled.ci.pipeline" +) + +// CiPipeline is a "main" in the org.tangled.ci.pipeline schema. +// +// A CI pipeline. Record-like, but owned by the spindle rather than a PDS. +type CiPipeline 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" cborgen:"repo"` + // sourceRepo: Repository DID that the commit was checked out from, if different from repo (e.g. a fork for a fork-based pull request) + SourceRepo *string `json:"sourceRepo,omitempty" cborgen:"sourceRepo,omitempty"` + // trigger: Trigger event that triggered this pipeline. + Trigger *CiPipeline_Trigger `json:"trigger" cborgen:"trigger"` + // workflows: Triggered workflows + Workflows []*CiPipeline_Workflow `json:"workflows" cborgen:"workflows"` +} + +// Trigger event that triggered this pipeline. +type CiPipeline_Trigger struct { + EventPush *EventPush + EventPullRequest *EventPullRequest + CiTriggerManual *CiTriggerManual + Unknown json.RawMessage +} + +func (t *CiPipeline_Trigger) MarshalJSON() ([]byte, error) { + if t.EventPush != nil { + t.EventPush.LexiconTypeID = "org.tangled.event.push" + return json.Marshal(t.EventPush) + } + if t.EventPullRequest != nil { + t.EventPullRequest.LexiconTypeID = "org.tangled.event.pullRequest" + return json.Marshal(t.EventPullRequest) + } + if t.CiTriggerManual != nil { + t.CiTriggerManual.LexiconTypeID = "org.tangled.ci.trigger.manual" + return json.Marshal(t.CiTriggerManual) + } + if t.Unknown != nil { + return t.Unknown, nil + } + return nil, fmt.Errorf("cannot marshal empty enum") +} +func (t *CiPipeline_Trigger) UnmarshalJSON(b []byte) error { + typ, err := util.TypeExtract(b) + if err != nil { + return err + } + + *t = CiPipeline_Trigger{} + switch typ { + case "org.tangled.event.push": + t.EventPush = new(EventPush) + return json.Unmarshal(b, t.EventPush) + case "org.tangled.event.pullRequest": + t.EventPullRequest = new(EventPullRequest) + return json.Unmarshal(b, t.EventPullRequest) + case "org.tangled.ci.trigger.manual": + t.CiTriggerManual = new(CiTriggerManual) + return json.Unmarshal(b, t.CiTriggerManual) + + default: + t.Unknown = append(t.Unknown[:0], b...) + return nil + } +} + +// CiPipeline_Workflow is a "workflow" in the org.tangled.ci.pipeline schema. +type CiPipeline_Workflow struct { + // definition: Workflow definition where this workflow run is originated from. + Definition *CiWorkflow `json:"definition" cborgen:"definition"` + Error *string `json:"error,omitempty" cborgen:"error,omitempty"` + FinishedAt *string `json:"finishedAt,omitempty" cborgen:"finishedAt,omitempty"` + // id: Pipeline-local workflow id, usually same as name. + Id string `json:"id" cborgen:"id"` + // name: Human-readable name of the workflow + Name *string `json:"name,omitempty" cborgen:"name,omitempty"` + StartedAt *string `json:"startedAt,omitempty" cborgen:"startedAt,omitempty"` + // status: Workflow status + Status string `json:"status" cborgen:"status"` +} diff --git a/api/org_tangled/ciqueryPipelines.go b/api/org_tangled/ciqueryPipelines.go new file mode 100644 index 000000000..7685129fc --- /dev/null +++ b/api/org_tangled/ciqueryPipelines.go @@ -0,0 +1,54 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.ci.queryPipelines + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + CiQueryPipelinesNSID = "org.tangled.ci.queryPipelines" +) + +// CiQueryPipelines_Output is the output of a org.tangled.ci.queryPipelines call. +type CiQueryPipelines_Output struct { + Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"` + Pipelines []*CiPipeline `json:"pipelines" cborgen:"pipelines"` + // total: Number of matching pipelines + Total int64 `json:"total" cborgen:"total"` +} + +// CiQueryPipelines calls the XRPC method "org.tangled.ci.queryPipelines". +// +// commits: Filter pipelines by commit ids. +// cursor: Pagination cursor +// limit: Maximum number of pipelines to return +// repo: DID of the repository +// triggers: Filter pipelines by trigger kind. When provided, pipelines matching any listed kind are returned; when omitted, every kind is returned. +func CiQueryPipelines(ctx context.Context, c util.LexClient, commits []string, cursor string, limit int64, repo string, triggers []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 len(triggers) != 0 { + params["triggers"] = triggers + } + if err := c.LexDo(ctx, util.Query, "", "org.tangled.ci.queryPipelines", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/org_tangled/cisubscribePipelineLogs.go b/api/org_tangled/cisubscribePipelineLogs.go new file mode 100644 index 000000000..9366ab347 --- /dev/null +++ b/api/org_tangled/cisubscribePipelineLogs.go @@ -0,0 +1,36 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.ci.subscribePipelineLogs + +const ( + CiSubscribePipelineLogsNSID = "org.tangled.ci.subscribePipelineLogs" +) + +// CiSubscribePipelineLogs_Control is a "control" in the org.tangled.ci.subscribePipelineLogs schema. +type CiSubscribePipelineLogs_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"` +} + +// CiSubscribePipelineLogs_Data is a "data" in the org.tangled.ci.subscribePipelineLogs schema. +type CiSubscribePipelineLogs_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/org_tangled/ciworkflow.go b/api/org_tangled/ciworkflow.go new file mode 100644 index 000000000..2fad72e37 --- /dev/null +++ b/api/org_tangled/ciworkflow.go @@ -0,0 +1,91 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.ci.workflow + +import ( + "encoding/json" + "fmt" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + CiWorkflowNSID = "org.tangled.ci.workflow" +) + +// CiWorkflow is a "main" in the org.tangled.ci.workflow schema. +// +// A workflow definition +type CiWorkflow struct { + // hash: Fingerprint of the workflow definition as resolved by the spindle. + Hash *string `json:"hash,omitempty" cborgen:"hash,omitempty"` + Id string `json:"id" cborgen:"id"` + // name: Human-readable name of the workflow + Name *string `json:"name,omitempty" cborgen:"name,omitempty"` + Source *CiWorkflow_Source `json:"source" cborgen:"source"` + // triggers: Event types that triggers this workflow. + Triggers []string `json:"triggers" cborgen:"triggers"` +} + +// CiWorkflow_ExternalSource is a "externalSource" in the org.tangled.ci.workflow schema. +// +// RECORDTYPE: CiWorkflow_ExternalSource +type CiWorkflow_ExternalSource struct { + LexiconTypeID string `json:"$type,const=org.tangled.ci.workflow#externalSource" cborgen:"$type,const=org.tangled.ci.workflow#externalSource"` + Link string `json:"link" cborgen:"link"` + // name: human-readable name of external source + Name *string `json:"name,omitempty" cborgen:"name,omitempty"` +} + +// CiWorkflow_FileSource is a "fileSource" in the org.tangled.ci.workflow schema. +// +// RECORDTYPE: CiWorkflow_FileSource +type CiWorkflow_FileSource struct { + LexiconTypeID string `json:"$type,const=org.tangled.ci.workflow#fileSource" cborgen:"$type,const=org.tangled.ci.workflow#fileSource"` + Commit string `json:"commit" cborgen:"commit"` + Lines *CiWorkflow_FileSource_Lines `json:"lines,omitempty" cborgen:"lines,omitempty"` + Path string `json:"path" cborgen:"path"` + Repo string `json:"repo" cborgen:"repo"` +} + +type CiWorkflow_FileSource_Lines struct { + End int64 `json:"end" cborgen:"end"` + Start int64 `json:"start" cborgen:"start"` +} + +type CiWorkflow_Source struct { + CiWorkflow_FileSource *CiWorkflow_FileSource + CiWorkflow_ExternalSource *CiWorkflow_ExternalSource +} + +func (t *CiWorkflow_Source) MarshalJSON() ([]byte, error) { + if t.CiWorkflow_FileSource != nil { + t.CiWorkflow_FileSource.LexiconTypeID = "org.tangled.ci.workflow#fileSource" + return json.Marshal(t.CiWorkflow_FileSource) + } + if t.CiWorkflow_ExternalSource != nil { + t.CiWorkflow_ExternalSource.LexiconTypeID = "org.tangled.ci.workflow#externalSource" + return json.Marshal(t.CiWorkflow_ExternalSource) + } + return nil, fmt.Errorf("cannot marshal empty enum") +} +func (t *CiWorkflow_Source) UnmarshalJSON(b []byte) error { + typ, err := util.TypeExtract(b) + if err != nil { + return err + } + + switch typ { + case "org.tangled.ci.workflow#fileSource": + t.CiWorkflow_FileSource = new(CiWorkflow_FileSource) + return json.Unmarshal(b, t.CiWorkflow_FileSource) + case "org.tangled.ci.workflow#externalSource": + t.CiWorkflow_ExternalSource = new(CiWorkflow_ExternalSource) + return json.Unmarshal(b, t.CiWorkflow_ExternalSource) + + default: + return nil + } +} diff --git a/api/org_tangled/eventpullRequest.go b/api/org_tangled/eventpullRequest.go new file mode 100644 index 000000000..c33917ede --- /dev/null +++ b/api/org_tangled/eventpullRequest.go @@ -0,0 +1,23 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.event.pullRequest + +import ( + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + EventPullRequestNSID = "org.tangled.event.pullRequest" +) + +func init() { + util.RegisterType("org.tangled.event.pullRequest#main", &EventPullRequest{}) +} // EventPullRequest is a "main" in the org.tangled.event.pullRequest schema. +// When pull request is created or resubmitted. +// +// RECORDTYPE: EventPullRequest +type EventPullRequest struct { + LexiconTypeID string `json:"$type,const=org.tangled.event.pullRequest" cborgen:"$type,const=org.tangled.event.pullRequest"` +} diff --git a/api/org_tangled/eventpush.go b/api/org_tangled/eventpush.go new file mode 100644 index 000000000..bac20f86a --- /dev/null +++ b/api/org_tangled/eventpush.go @@ -0,0 +1,23 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.event.push + +import ( + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + EventPushNSID = "org.tangled.event.push" +) + +func init() { + util.RegisterType("org.tangled.event.push#main", &EventPush{}) +} // EventPush is a "main" in the org.tangled.event.push schema. +// When a repository ref is updated. +// +// RECORDTYPE: EventPush +type EventPush struct { + LexiconTypeID string `json:"$type,const=org.tangled.event.push" cborgen:"$type,const=org.tangled.event.push"` +} diff --git a/api/org_tangled/secretaddSecret.go b/api/org_tangled/secretaddSecret.go new file mode 100644 index 000000000..df7e4bc85 --- /dev/null +++ b/api/org_tangled/secretaddSecret.go @@ -0,0 +1,31 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.secret.addSecret + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + SecretAddSecretNSID = "org.tangled.secret.addSecret" +) + +// SecretAddSecret_Input is the input argument to a org.tangled.secret.addSecret call. +type SecretAddSecret_Input struct { + Key string `json:"key" cborgen:"key"` + Repo string `json:"repo" cborgen:"repo"` + Value string `json:"value" cborgen:"value"` +} + +// SecretAddSecret calls the XRPC method "org.tangled.secret.addSecret". +func SecretAddSecret(ctx context.Context, c util.LexClient, input *SecretAddSecret_Input) error { + if err := c.LexDo(ctx, util.Procedure, "application/json", "org.tangled.secret.addSecret", nil, input, nil); err != nil { + return err + } + + return nil +} diff --git a/api/org_tangled/secretlistSecrets.go b/api/org_tangled/secretlistSecrets.go new file mode 100644 index 000000000..a224ed2c5 --- /dev/null +++ b/api/org_tangled/secretlistSecrets.go @@ -0,0 +1,40 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.secret.listSecrets + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + SecretListSecretsNSID = "org.tangled.secret.listSecrets" +) + +// SecretListSecrets_Output is the output of a org.tangled.secret.listSecrets call. +type SecretListSecrets_Output struct { + Secrets []*SecretListSecrets_Secret `json:"secrets" cborgen:"secrets"` +} + +// SecretListSecrets_Secret is a "secret" in the org.tangled.secret.listSecrets schema. +type SecretListSecrets_Secret struct { + CreatedAt string `json:"createdAt" cborgen:"createdAt"` + CreatedBy string `json:"createdBy" cborgen:"createdBy"` + Key string `json:"key" cborgen:"key"` +} + +// SecretListSecrets calls the XRPC method "org.tangled.secret.listSecrets". +func SecretListSecrets(ctx context.Context, c util.LexClient, repo string) (*SecretListSecrets_Output, error) { + var out SecretListSecrets_Output + + params := map[string]interface{}{} + params["repo"] = repo + if err := c.LexDo(ctx, util.Query, "", "org.tangled.secret.listSecrets", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/org_tangled/secretremoveSecret.go b/api/org_tangled/secretremoveSecret.go new file mode 100644 index 000000000..273ba2a4e --- /dev/null +++ b/api/org_tangled/secretremoveSecret.go @@ -0,0 +1,30 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.secret.removeSecret + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + SecretRemoveSecretNSID = "org.tangled.secret.removeSecret" +) + +// SecretRemoveSecret_Input is the input argument to a org.tangled.secret.removeSecret call. +type SecretRemoveSecret_Input struct { + Key string `json:"key" cborgen:"key"` + Repo string `json:"repo" cborgen:"repo"` +} + +// SecretRemoveSecret calls the XRPC method "org.tangled.secret.removeSecret". +func SecretRemoveSecret(ctx context.Context, c util.LexClient, input *SecretRemoveSecret_Input) error { + if err := c.LexDo(ctx, util.Procedure, "application/json", "org.tangled.secret.removeSecret", nil, input, nil); err != nil { + return err + } + + return nil +} diff --git a/api/org_tangled/triggermanual.go b/api/org_tangled/triggermanual.go new file mode 100644 index 000000000..6c13ae7e1 --- /dev/null +++ b/api/org_tangled/triggermanual.go @@ -0,0 +1,33 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.ci.trigger.manual + +import ( + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + CiTriggerManualNSID = "org.tangled.ci.trigger.manual" +) + +func init() { + util.RegisterType("org.tangled.ci.trigger.manual#main", &CiTriggerManual{}) +} // CiTriggerManual is a "main" in the org.tangled.ci.trigger.manual schema. +// RECORDTYPE: CiTriggerManual +type CiTriggerManual struct { + LexiconTypeID string `json:"$type,const=org.tangled.ci.trigger.manual" cborgen:"$type,const=org.tangled.ci.trigger.manual"` + // commit: Commit id the pipeline will run on. + Commit string `json:"commit" cborgen:"commit"` + Inputs []*CiTriggerManual_Pair `json:"inputs,omitempty" cborgen:"inputs,omitempty"` + // ref: Optional ref the commit was resolved from. + Ref *string `json:"ref,omitempty" cborgen:"ref,omitempty"` + Repo string `json:"repo" cborgen:"repo"` +} + +// CiTriggerManual_Pair is a "pair" in the org.tangled.ci.trigger.manual schema. +type CiTriggerManual_Pair struct { + Key string `json:"key" cborgen:"key"` + Value string `json:"value" cborgen:"value"` +} diff --git a/cmd/cborgen/cborgen.go b/cmd/cborgen/cborgen.go index fdaaec81a..962706742 100644 --- a/cmd/cborgen/cborgen.go +++ b/cmd/cborgen/cborgen.go @@ -85,6 +85,12 @@ func main() { if err := genCfg.WriteMapEncodersToFile( "api/org_tangled/cbor_gen.go", "org_tangled", + org_tangled.CiSubscribePipelineLogs_Control{}, + org_tangled.CiSubscribePipelineLogs_Data{}, + org_tangled.CiTriggerManual{}, + org_tangled.CiTriggerManual_Pair{}, + org_tangled.EventPullRequest{}, + org_tangled.EventPush{}, org_tangled.FeedSubscription{}, org_tangled.FeedSubscription_Record{}, org_tangled.FeedSubscription_Repo{}, diff --git a/cmd/lexpostgen/main.go b/cmd/lexpostgen/main.go new file mode 100644 index 000000000..1d60d3776 --- /dev/null +++ b/cmd/lexpostgen/main.go @@ -0,0 +1,42 @@ +package main + +import ( + "bytes" + "fmt" + "os" +) + +const pipelinePath = "api/org_tangled/cipipeline.go" + +func replaceOnce(source, old, new []byte) []byte { + if bytes.Count(source, old) != 1 { + panic(fmt.Sprintf("expected one generated match, got %d", bytes.Count(source, old))) + } + return bytes.Replace(source, old, new, 1) +} + +func main() { + source, err := os.ReadFile(pipelinePath) + if err != nil { + panic(err) + } + source = replaceOnce(source, + []byte("type CiPipeline_Trigger struct {\n\tEventPush *EventPush\n\tEventPullRequest *EventPullRequest\n\tCiTriggerManual *CiTriggerManual\n}"), + []byte("type CiPipeline_Trigger struct {\n\tEventPush *EventPush\n\tEventPullRequest *EventPullRequest\n\tCiTriggerManual *CiTriggerManual\n\tUnknown json.RawMessage\n}"), + ) + source = replaceOnce(source, + []byte("\tif t.CiTriggerManual != nil {\n\t\tt.CiTriggerManual.LexiconTypeID = \"org.tangled.ci.trigger.manual\"\n\t\treturn json.Marshal(t.CiTriggerManual)\n\t}\n\treturn nil, fmt.Errorf(\"cannot marshal empty enum\")"), + []byte("\tif t.CiTriggerManual != nil {\n\t\tt.CiTriggerManual.LexiconTypeID = \"org.tangled.ci.trigger.manual\"\n\t\treturn json.Marshal(t.CiTriggerManual)\n\t}\n\tif t.Unknown != nil {\n\t\treturn t.Unknown, nil\n\t}\n\treturn nil, fmt.Errorf(\"cannot marshal empty enum\")"), + ) + source = replaceOnce(source, + []byte("\ttyp, err := util.TypeExtract(b)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tswitch typ {"), + []byte("\ttyp, err := util.TypeExtract(b)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*t = CiPipeline_Trigger{}\n\tswitch typ {"), + ) + source = replaceOnce(source, + []byte("\tdefault:\n\t\treturn nil\n\t}\n}"), + []byte("\tdefault:\n\t\tt.Unknown = append(t.Unknown[:0], b...)\n\t\treturn nil\n\t}\n}"), + ) + if err := os.WriteFile(pipelinePath, source, 0o644); err != nil { + panic(err) + } +} diff --git a/flake.nix b/flake.nix index b37cbf77d..2af10e343 100644 --- a/flake.nix +++ b/flake.nix @@ -677,6 +677,7 @@ for f in api/tangled/*_ext.go.bak api/org_tangled/*_ext.go.bak; do [ -e "''$f" ] || continue; mv "''$f" "''${f%.bak}"; done lexgen --build-file lexicon-build-config.json lexicons + go run ./cmd/lexpostgen/ rm -f api/tangled/*.bak api/org_tangled/*.bak ''; }) -- 2.51.2