@@ -42,32 +42,22 @@ const (
42
42
var (
43
43
ImagePrefixes = []string {DockerHub , GHCR }
44
44
Architectures = []string {"386" , "amd64" , "arm" , "arm64" , "ppc64le" , "s390x" }
45
+ ArmVersions = []string {"7" }
45
46
DefaultConfigDists = map [string ]bool {CoreDistro : true , ContribDistro : true }
46
47
MSIWindowsDists = map [string ]bool {CoreDistro : true , ContribDistro : true , OTLPDistro : true }
47
48
K8sDockerSkipArchs = map [string ]bool {"arm" : true , "386" : true }
48
49
K8sGoos = []string {"linux" }
49
50
K8sArchs = []string {"amd64" , "arm64" , "ppc64le" , "s390x" }
50
51
)
51
52
52
- func GenerateContribBuildOnly (dist string , buildOrRest bool ) config.Project {
53
- return config.Project {
54
- ProjectName : "opentelemetry-collector-releases" ,
55
- Builds : Builds (dist , buildOrRest ),
56
- Version : 2 ,
57
- Monorepo : config.Monorepo {
58
- TagPrefix : "v" ,
59
- },
60
- }
61
- }
62
-
63
- func Generate (dist string , buildOrRest bool ) config.Project {
53
+ func Generate (dist string ) config.Project {
64
54
return config.Project {
65
55
ProjectName : "opentelemetry-collector-releases" ,
66
56
Checksum : config.Checksum {
67
57
NameTemplate : fmt .Sprintf ("{{ .ProjectName }}_%v_checksums.txt" , dist ),
68
58
},
69
59
Env : []string {"COSIGN_YES=true" },
70
- Builds : Builds (dist , buildOrRest ),
60
+ Builds : Builds (dist ),
71
61
Archives : Archives (dist ),
72
62
MSI : WinPackages (dist ),
73
63
NFPMs : Packages (dist ),
@@ -83,41 +73,37 @@ func Generate(dist string, buildOrRest bool) config.Project {
83
73
}
84
74
}
85
75
86
- func Builds (dist string , buildOrRest bool ) []config.Build {
76
+ func Builds (dist string ) []config.Build {
87
77
return []config.Build {
88
- Build (dist , buildOrRest ),
78
+ Build (dist ),
89
79
}
90
80
}
91
81
92
82
// Build configures a goreleaser build.
93
83
// https://goreleaser.com/customization/build/
94
- func Build (dist string , buildOrRest bool ) config.Build {
95
- goos := []string {"darwin" , "linux" , "windows" }
96
- archs := Architectures
97
-
98
- if dist == ContribDistro && ! buildOrRest {
99
- // only return build config for contrib build file
100
- return config.Build {
101
- ID : dist ,
102
- Builder : "prebuilt" ,
103
- PreBuilt : config.PreBuiltOptions {
104
- Path : "artifacts/otelcol-contrib_{{ .Target }}" +
105
- "/otelcol-contrib{{- if eq .Os \" windows\" }}.exe{{ end }}" ,
106
- },
107
- Goos : goos ,
108
- Goarch : archs ,
109
- Goarm : ArmVersions (dist ),
110
- Dir : "_build" ,
111
- Binary : dist ,
112
- Ignore : IgnoreBuildCombinations (dist ),
113
- }
114
- }
115
-
84
+ func Build (dist string ) config.Build {
85
+ var goos []string
86
+ var archs []string
87
+ var ignore []config.IgnoredBuild
88
+ var armVersions []string
116
89
if dist == K8sDistro {
117
90
goos = K8sGoos
118
91
archs = K8sArchs
92
+ ignore = make ([]config.IgnoredBuild , 0 )
93
+ armVersions = make ([]string , 0 )
94
+ } else {
95
+ goos = []string {"darwin" , "linux" , "windows" }
96
+ archs = Architectures
97
+ ignore = []config.IgnoredBuild {
98
+ {Goos : "darwin" , Goarch : "386" },
99
+ {Goos : "darwin" , Goarch : "arm" },
100
+ {Goos : "darwin" , Goarch : "s390x" },
101
+ {Goos : "windows" , Goarch : "arm" },
102
+ {Goos : "windows" , Goarch : "arm64" },
103
+ {Goos : "windows" , Goarch : "s390x" },
104
+ }
105
+ armVersions = ArmVersions
119
106
}
120
-
121
107
return config.Build {
122
108
ID : dist ,
123
109
Dir : "_build" ,
@@ -129,33 +115,12 @@ func Build(dist string, buildOrRest bool) config.Build {
129
115
},
130
116
Goos : goos ,
131
117
Goarch : archs ,
132
- Goarm : ArmVersions ( dist ) ,
133
- Ignore : IgnoreBuildCombinations ( dist ) ,
118
+ Goarm : armVersions ,
119
+ Ignore : ignore ,
134
120
}
135
121
}
136
122
137
- func IgnoreBuildCombinations (dist string ) []config.IgnoredBuild {
138
- if dist == K8sDistro {
139
- return nil
140
- }
141
- return []config.IgnoredBuild {
142
- {Goos : "darwin" , Goarch : "386" },
143
- {Goos : "darwin" , Goarch : "arm" },
144
- {Goos : "darwin" , Goarch : "s390x" },
145
- {Goos : "windows" , Goarch : "arm" },
146
- {Goos : "windows" , Goarch : "arm64" },
147
- {Goos : "windows" , Goarch : "s390x" },
148
- }
149
- }
150
-
151
- func ArmVersions (dist string ) []string {
152
- if dist == K8sDistro {
153
- return nil
154
- }
155
- return []string {"7" }
156
- }
157
-
158
- func Archives (dist string ) []config.Archive {
123
+ func Archives (dist string ) (r []config.Archive ) {
159
124
return []config.Archive {
160
125
Archive (dist ),
161
126
}
@@ -173,7 +138,7 @@ func Archive(dist string) config.Archive {
173
138
174
139
func WinPackages (dist string ) []config.MSI {
175
140
if _ , ok := MSIWindowsDists [dist ]; ! ok {
176
- return nil
141
+ return []config. MSI {}
177
142
}
178
143
return []config.MSI {
179
144
WinPackage (dist ),
@@ -195,9 +160,9 @@ func WinPackage(dist string) config.MSI {
195
160
}
196
161
}
197
162
198
- func Packages (dist string ) []config.NFPM {
163
+ func Packages (dist string ) ( r []config.NFPM ) {
199
164
if dist == K8sDistro {
200
- return nil
165
+ return []config. NFPM {}
201
166
}
202
167
return []config.NFPM {
203
168
Package (dist ),
@@ -226,17 +191,21 @@ func Package(dist string) config.NFPM {
226
191
})
227
192
}
228
193
return config.NFPM {
229
- ID : dist ,
230
- Builds : []string {dist },
231
- Formats : []string {"deb" , "rpm" },
194
+ ID : dist ,
195
+ Builds : []string {dist },
196
+ Formats : []string {"deb" , "rpm" },
197
+
232
198
License : "Apache 2.0" ,
233
199
Description : fmt .Sprintf ("OpenTelemetry Collector - %s" , dist ),
234
200
Maintainer :
"The OpenTelemetry Collector maintainers <[email protected] >" ,
235
201
Overrides : map [string ]config.NFPMOverridables {
236
202
"rpm" : {
237
- Dependencies : []string {"/bin/sh" },
203
+ Dependencies : []string {
204
+ "/bin/sh" ,
205
+ },
238
206
},
239
207
},
208
+
240
209
NFPMOverridables : config.NFPMOverridables {
241
210
PackageName : dist ,
242
211
Scripts : config.NFPMScripts {
@@ -250,14 +219,16 @@ func Package(dist string) config.NFPM {
250
219
}
251
220
252
221
func DockerImages (dist string ) []config.Docker {
253
- var r []config.Docker
222
+ r := make ( []config.Docker , 0 )
254
223
for _ , arch := range Architectures {
255
- if dist == K8sDistro && K8sDockerSkipArchs [arch ] {
256
- continue
224
+ if dist == K8sDistro {
225
+ if _ , ok := K8sDockerSkipArchs [arch ]; ok {
226
+ continue
227
+ }
257
228
}
258
229
switch arch {
259
230
case ArmArch :
260
- for _ , vers := range ArmVersions ( dist ) {
231
+ for _ , vers := range ArmVersions {
261
232
r = append (r , DockerImage (dist , arch , vers ))
262
233
}
263
234
default :
@@ -331,7 +302,7 @@ func DockerManifest(prefix, version, dist string) config.DockerManifest {
331
302
}
332
303
switch arch {
333
304
case ArmArch :
334
- for _ , armVers := range ArmVersions ( dist ) {
305
+ for _ , armVers := range ArmVersions {
335
306
dockerArchTag := strings .ReplaceAll (archName (arch , armVers ), "/" , "" )
336
307
imageTemplates = append (
337
308
imageTemplates ,
0 commit comments