~james/core

core/api/org_tangled/cidefs.go -rw-r--r-- 6.4 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 16 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.

package org_tangled

// schema: org.tangled.ci.defs

import (
	"encoding/json"
	"fmt"

	"github.com/bluesky-social/indigo/lex/util"
)

const ()

// CiDefs_ExternalSource is a "externalSource" in the org.tangled.ci.defs schema.
//
// RECORDTYPE: CiDefs_ExternalSource
type CiDefs_ExternalSource struct {
	LexiconTypeID string `json:"$type,const=org.tangled.ci.defs#externalSource" cborgen:"$type,const=org.tangled.ci.defs#externalSource"`
	Link          string `json:"link" cborgen:"link"`
	// name: human-readable name of external source
	Name *string `json:"name,omitempty" cborgen:"name,omitempty"`
}

// CiDefs_FileSource is a "fileSource" in the org.tangled.ci.defs schema.
//
// RECORDTYPE: CiDefs_FileSource
type CiDefs_FileSource struct {
	LexiconTypeID string            `json:"$type,const=org.tangled.ci.defs#fileSource" cborgen:"$type,const=org.tangled.ci.defs#fileSource"`
	Commit        string            `json:"commit" cborgen:"commit"`
	Lines         *CiDefs_LineRange `json:"lines,omitempty" cborgen:"lines,omitempty"`
	Path          string            `json:"path" cborgen:"path"`
	Repo          string            `json:"repo" cborgen:"repo"`
}

// CiDefs_LineRange is a "lineRange" in the org.tangled.ci.defs schema.
type CiDefs_LineRange struct {
	End   int64 `json:"end" cborgen:"end"`
	Start int64 `json:"start" cborgen:"start"`
}

// CiDefs_Pipeline is a "pipeline" in the org.tangled.ci.defs schema.
//
// A CI pipeline. Record-like, but owned by the spindle rather than a PDS.
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" 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 *CiDefs_Pipeline_Trigger `json:"trigger" cborgen:"trigger"`
	// workflows: Triggered workflows
	Workflows []*CiDefs_WorkflowRun `json:"workflows" cborgen:"workflows"`
}

// Trigger event that triggered this pipeline.
type CiDefs_Pipeline_Trigger struct {
	EventPush         *EventPush
	EventPullRequest  *EventPullRequest
	CiTriggerManual   *CiTriggerManual
	CiTriggerSchedule *CiTriggerSchedule
	Unknown           json.RawMessage
}

func (t *CiDefs_Pipeline_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.CiTriggerSchedule != nil {
		t.CiTriggerSchedule.LexiconTypeID = "org.tangled.ci.trigger.schedule"
		return json.Marshal(t.CiTriggerSchedule)
	}
	if t.Unknown != nil {
		return t.Unknown, nil
	}
	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
	}

	*t = CiDefs_Pipeline_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)
	case "org.tangled.ci.trigger.schedule":
		t.CiTriggerSchedule = new(CiTriggerSchedule)
		return json.Unmarshal(b, t.CiTriggerSchedule)

	default:
		t.Unknown = append(t.Unknown[:0], b...)
		return nil
	}
}

// CiDefs_Workflow is a "workflow" in the org.tangled.ci.defs schema.
//
// A workflow definition
type CiDefs_Workflow 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 *CiDefs_Workflow_Source `json:"source" cborgen:"source"`
	// triggers: Event types that triggers this workflow.
	Triggers []string `json:"triggers" cborgen:"triggers"`
}

// CiDefs_WorkflowRun is a "workflowRun" in the org.tangled.ci.defs schema.
type CiDefs_WorkflowRun struct {
	// definition: Workflow definition where this workflow run is originated from.
	Definition *CiDefs_Workflow `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"`
}

type CiDefs_Workflow_Source struct {
	CiDefs_FileSource     *CiDefs_FileSource
	CiDefs_ExternalSource *CiDefs_ExternalSource
}

func (t *CiDefs_Workflow_Source) MarshalJSON() ([]byte, error) {
	if t.CiDefs_FileSource != nil {
		t.CiDefs_FileSource.LexiconTypeID = "org.tangled.ci.defs#fileSource"
		return json.Marshal(t.CiDefs_FileSource)
	}
	if t.CiDefs_ExternalSource != nil {
		t.CiDefs_ExternalSource.LexiconTypeID = "org.tangled.ci.defs#externalSource"
		return json.Marshal(t.CiDefs_ExternalSource)
	}
	return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *CiDefs_Workflow_Source) UnmarshalJSON(b []byte) error {
	typ, err := util.TypeExtract(b)
	if err != nil {
		return err
	}

	switch typ {
	case "org.tangled.ci.defs#fileSource":
		t.CiDefs_FileSource = new(CiDefs_FileSource)
		return json.Unmarshal(b, t.CiDefs_FileSource)
	case "org.tangled.ci.defs#externalSource":
		t.CiDefs_ExternalSource = new(CiDefs_ExternalSource)
		return json.Unmarshal(b, t.CiDefs_ExternalSource)

	default:
		return nil
	}
}