-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathsource_generated.go
More file actions
194 lines (159 loc) · 3.7 KB
/
source_generated.go
File metadata and controls
194 lines (159 loc) · 3.7 KB
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
183
184
185
186
187
188
189
190
191
192
193
194
// Code generated by cmd/gen-source-variants. DO NOT EDIT.
package dalec
import (
"context"
"fmt"
"github.com/goccy/go-yaml/ast"
)
// validateSourceVariants ensures exactly one source variant is set
func (s *Source) validateSourceVariants() error {
count := 0
if s.Build != nil {
count++
}
if s.Context != nil {
count++
}
if s.DockerImage != nil {
count++
}
if s.Git != nil {
count++
}
if s.HTTP != nil {
count++
}
if s.Inline != nil {
count++
}
if s.LLB != nil {
count++
}
switch count {
case 0:
return fmt.Errorf("no non-nil source variant")
case 1:
return nil
default:
return fmt.Errorf("more than one source variant defined")
}
}
// toInterface returns the underlying source interface implementation
func (s *Source) toInterface() source {
switch {
case s.Build != nil:
return s.Build
case s.Context != nil:
return s.Context
case s.DockerImage != nil:
return s.DockerImage
case s.Git != nil:
return s.Git
case s.HTTP != nil:
return s.HTTP
case s.Inline != nil:
return s.Inline
case s.LLB != nil:
return s.LLB
default:
panic(errNoSourceVariant)
}
}
func (s *SourceBuild) sourceMap() *sourceMap {
return s._sourceMap
}
func (s *SourceBuild) UnmarshalYAML(ctx context.Context, node ast.Node) error {
type internal SourceBuild
var i internal
dec := getDecoder(ctx)
if err := dec.DecodeFromNodeContext(ctx, node, &i); err != nil {
return err
}
*s = SourceBuild(i)
s._sourceMap = newSourceMap(ctx, node)
return nil
}
func (s *SourceContext) sourceMap() *sourceMap {
return s._sourceMap
}
func (s *SourceContext) UnmarshalYAML(ctx context.Context, node ast.Node) error {
type internal SourceContext
var i internal
dec := getDecoder(ctx)
if err := dec.DecodeFromNodeContext(ctx, node, &i); err != nil {
return err
}
*s = SourceContext(i)
s._sourceMap = newSourceMap(ctx, node)
return nil
}
func (s *SourceDockerImage) sourceMap() *sourceMap {
return s._sourceMap
}
func (s *SourceDockerImage) UnmarshalYAML(ctx context.Context, node ast.Node) error {
type internal SourceDockerImage
var i internal
dec := getDecoder(ctx)
if err := dec.DecodeFromNodeContext(ctx, node, &i); err != nil {
return err
}
*s = SourceDockerImage(i)
s._sourceMap = newSourceMap(ctx, node)
return nil
}
func (s *SourceGit) sourceMap() *sourceMap {
return s._sourceMap
}
func (s *SourceGit) UnmarshalYAML(ctx context.Context, node ast.Node) error {
type internal SourceGit
var i internal
dec := getDecoder(ctx)
if err := dec.DecodeFromNodeContext(ctx, node, &i); err != nil {
return err
}
*s = SourceGit(i)
s._sourceMap = newSourceMap(ctx, node)
return nil
}
func (s *SourceHTTP) sourceMap() *sourceMap {
return s._sourceMap
}
func (s *SourceHTTP) UnmarshalYAML(ctx context.Context, node ast.Node) error {
type internal SourceHTTP
var i internal
dec := getDecoder(ctx)
if err := dec.DecodeFromNodeContext(ctx, node, &i); err != nil {
return err
}
*s = SourceHTTP(i)
s._sourceMap = newSourceMap(ctx, node)
return nil
}
func (s *SourceInline) sourceMap() *sourceMap {
return s._sourceMap
}
func (s *SourceInline) UnmarshalYAML(ctx context.Context, node ast.Node) error {
type internal SourceInline
var i internal
dec := getDecoder(ctx)
if err := dec.DecodeFromNodeContext(ctx, node, &i); err != nil {
return err
}
*s = SourceInline(i)
s._sourceMap = newSourceMap(ctx, node)
return nil
}
func (s *SourceLLB) sourceMap() *sourceMap {
return s._sourceMap
}
func (s *SourceLLB) UnmarshalYAML(ctx context.Context, node ast.Node) error {
type internal SourceLLB
var i internal
dec := getDecoder(ctx)
if err := dec.DecodeFromNodeContext(ctx, node, &i); err != nil {
return err
}
*s = SourceLLB(i)
s._sourceMap = newSourceMap(ctx, node)
return nil
}