Skip to content

Commit 0b27c5d

Browse files
committed
fix gc build & add validation for dagger build
Signed-off-by: bupd <[email protected]>
1 parent aaa9653 commit 0b27c5d

File tree

8 files changed

+67
-65
lines changed

8 files changed

+67
-65
lines changed

ci/main.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,20 @@ func (m *HarborSatellite) Build(
2626
// +optional
2727
// +defaultPath="./"
2828
source *dagger.Directory,
29-
component string) *dagger.Directory {
30-
return m.build(source, component)
29+
component string,
30+
) (*dagger.Directory, error) {
31+
if component == "satellite" || component == "ground-control" {
32+
return m.build(source, component), nil
33+
}
34+
return nil, fmt.Errorf("error: please provide component as either satellite or ground-control")
3135
}
3236

3337
// Release function would release the build to the github with the tags provided. Directory should be "." for both the satellite and the ground control.
3438
func (m *HarborSatellite) Release(ctx context.Context, directory *dagger.Directory, token, name string,
3539
// +optional
3640
// +default="patch"
37-
release_type string) (string, error) {
38-
41+
release_type string,
42+
) (string, error) {
3943
container := dag.Container().
4044
From("alpine/git").
4145
WithEnvVariable("GITHUB_TOKEN", token).
@@ -66,7 +70,6 @@ func (m *HarborSatellite) Release(ctx context.Context, directory *dagger.Directo
6670
WithExec([]string{"git", "tag", release_tag}).
6771
WithExec([]string{"goreleaser", "release", "-f", pathToMain, "--clean"}).
6872
Stderr(ctx)
69-
7073
if err != nil {
7174
slog.Error("Failed to release: ", err, ".")
7275
slog.Error("Release Output:", release_output, ".")

ci/utils.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ func (m *HarborSatellite) Service(
5858
AsService()
5959
}
6060

61-
// Would build the project with the source provided. The name should be the name of the project.
62-
func (m *HarborSatellite) build(source *dagger.Directory, name string) *dagger.Directory {
63-
fmt.Printf("Building %s\n", name)
61+
// builds given component from source
62+
func (m *HarborSatellite) build(source *dagger.Directory, component string) *dagger.Directory {
63+
fmt.Printf("Building %s\n", component)
6464

6565
gooses := []string{"linux", "darwin"}
6666
goarches := []string{"amd64", "arm64"}
@@ -85,8 +85,13 @@ func (m *HarborSatellite) build(source *dagger.Directory, name string) *dagger.D
8585
WithMountedCache("/go/build-cache", dag.CacheVolume("go-build")).
8686
WithEnvVariable("GOCACHE", "/go/build-cache").
8787
WithEnvVariable("GOOS", goos).
88-
WithEnvVariable("GOARCH", goarch).
89-
WithExec([]string{"go", "build", "-o", outputBinary})
88+
WithEnvVariable("GOARCH", goarch)
89+
if component == "ground-control" {
90+
build = build.WithWorkdir("./ground-control/").
91+
WithExec([]string{"go", "build", "-o", outputBinary})
92+
} else {
93+
build = build.WithExec([]string{"go", "build", "-o", outputBinary})
94+
}
9095

9196
// add build to outputs
9297
outputs = outputs.WithDirectory(component, build.Directory(component))
@@ -101,15 +106,15 @@ func (m *HarborSatellite) build(source *dagger.Directory, name string) *dagger.D
101106
func (m *HarborSatellite) get_release_tag(ctx context.Context, git_container *dagger.Container, source *dagger.Directory, name string,
102107
// +optional
103108
// +default="patch"
104-
release_type string) (string, error) {
109+
release_type string,
110+
) (string, error) {
105111
/// This would get the last tag that was created. Empty string if no tag was created.
106112
getTagsOutput, err := git_container.
107113
WithExec([]string{
108114
"/bin/sh", "-c",
109115
fmt.Sprintf(`git tag --list "v*%s" | sort -V | tail -n 1`, name),
110116
}).
111117
Stdout(ctx)
112-
113118
if err != nil {
114119
slog.Error("Failed to get tags: ", err, ".")
115120
slog.Error("Get Tags Output:", getTagsOutput, ".")
@@ -151,7 +156,7 @@ func generateNewTag(latestTag, suffix, release_type string) (string, error) {
151156
slog.Error("Failed to convert patch version to integer: ", err.Error(), ".")
152157
return "", err
153158
}
154-
// Increment the version according to the release type
159+
// Increment the version accordin ground-control")g to the release type
155160
switch release_type {
156161
case "major":
157162
major++

dagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"name": "harbor-satellite",
33
"sdk": "go",
44
"source": "ci",
5-
"engineVersion": "v0.13.1"
5+
"engineVersion": "v0.13.3"
66
}

go.mod

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/google/go-containerregistry v0.19.2
1010
github.com/joho/godotenv v1.5.1
1111
github.com/prometheus/client_golang v1.19.1
12-
golang.org/x/sync v0.7.0
12+
golang.org/x/sync v0.8.0
1313
// use go get zotregistry.dev/zot@main to get package
1414
zotregistry.dev/zot v1.4.4-0.20240604183918-a4b6892a9c27
1515
)
@@ -20,7 +20,7 @@ require (
2020
github.com/stretchr/testify v1.9.0
2121
)
2222

23-
require golang.org/x/oauth2 v0.20.0 // indirect
23+
require golang.org/x/oauth2 v0.22.0 // indirect
2424

2525
require (
2626
cloud.google.com/go v0.112.1 // indirect
@@ -64,7 +64,7 @@ require (
6464
github.com/ThalesIgnite/crypto11 v1.2.5 // indirect
6565
github.com/VividCortex/ewma v1.2.0 // indirect
6666
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
67-
github.com/adrg/xdg v0.4.0 // indirect
67+
github.com/adrg/xdg v0.5.0 // indirect
6868
github.com/agext/levenshtein v1.2.3 // indirect
6969
github.com/agnivade/levenshtein v1.1.1 // indirect
7070
github.com/alecthomas/chroma v0.10.0 // indirect
@@ -118,7 +118,7 @@ require (
118118
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
119119
github.com/briandowns/spinner v1.23.0 // indirect
120120
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
121-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
121+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
122122
github.com/chai2010/gettext-go v1.0.2 // indirect
123123
github.com/chartmuseum/auth v0.5.0 // indirect
124124
github.com/cheggaaa/pb/v3 v3.1.5 // indirect
@@ -220,7 +220,7 @@ require (
220220
github.com/gorilla/websocket v1.5.0 // indirect
221221
github.com/gosuri/uitable v0.0.4 // indirect
222222
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
223-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
223+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
224224
github.com/hashicorp/errwrap v1.1.0 // indirect
225225
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
226226
github.com/hashicorp/go-getter v1.7.4 // indirect
@@ -405,21 +405,21 @@ require (
405405
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
406406
go.uber.org/multierr v1.11.0 // indirect
407407
go.uber.org/zap v1.27.0 // indirect
408-
golang.org/x/crypto v0.24.0 // indirect
408+
golang.org/x/crypto v0.27.0 // indirect
409409
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
410410
golang.org/x/mod v0.18.0 // indirect
411-
golang.org/x/net v0.26.0 // indirect
412-
golang.org/x/sys v0.21.0 // indirect
413-
golang.org/x/term v0.21.0 // indirect
414-
golang.org/x/text v0.16.0 // indirect
411+
golang.org/x/net v0.29.0 // indirect
412+
golang.org/x/sys v0.25.0 // indirect
413+
golang.org/x/term v0.24.0 // indirect
414+
golang.org/x/text v0.18.0 // indirect
415415
golang.org/x/time v0.5.0 // indirect
416416
golang.org/x/tools v0.22.0 // indirect
417417
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
418418
google.golang.org/api v0.172.0 // indirect
419419
google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 // indirect
420-
google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect
421-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 // indirect
422-
google.golang.org/grpc v1.64.0
420+
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
421+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
422+
google.golang.org/grpc v1.65.0
423423
google.golang.org/protobuf v1.34.2 // indirect
424424
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
425425
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect

0 commit comments

Comments
 (0)