-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Quickstart #60
base: main
Are you sure you want to change the base?
Add Quickstart #60
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[build] | ||
bin = "main" | ||
dir = "." | ||
cmd = "go build -o main ." | ||
exclude_dir = ["assets", "tmp", "vendor", "testdata"] | ||
exclude_regex = ["_test.go"] | ||
exclude_unchanged = false | ||
follow_symlink = false | ||
run_after_build = "chmod +x main" | ||
include_ext = ["go"] | ||
|
||
[log] | ||
level = "debug" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
## Quickstart: Local Setup of Harbor Satellite from Source | ||
|
||
To set up Harbor Satellite locally, follow these steps: | ||
|
||
### 1. Prerequisites | ||
Ensure you have: | ||
- A Harbor registry instance (or similar OCI-compliant registry). | ||
- Credentials with permission to create robot accounts in the registry. | ||
- The latest version of Dagger installed. | ||
|
||
### 2. Set Up the Registry | ||
In this guide, we'll use a Harbor registry instance. | ||
|
||
- **Registry Login**: Obtain the username and password for your registry, ensuring it has appropriate permissions. | ||
|
||
### 3. Configure Ground Control | ||
Navigate to the `ground-control` directory and set up the following environment variables: | ||
|
||
```bash | ||
HARBOR_USERNAME=admin | ||
HARBOR_PASSWORD=Harbor12345 | ||
HARBOR_URL=https://demo.goharbor.io | ||
|
||
PORT=8080 | ||
APP_ENV=local | ||
|
||
DB_HOST=pgservice | ||
DB_PORT=5432 | ||
DB_DATABASE=groundcontrol | ||
DB_USERNAME=postgres # Customize based on your DB config | ||
DB_PASSWORD=password # Customize based on your DB config | ||
``` | ||
|
||
### 4. Run Ground Control | ||
To start the Ground Control service, execute the following Dagger command: | ||
|
||
```bash | ||
dagger call run-ground-control up | ||
``` | ||
|
||
You can also build ground-control binary using the below command | ||
|
||
```bash | ||
dagger call build-dev --platform "linux/amd64" --component "ground-control" export --path=./gc-dev | ||
``` | ||
|
||
To Run ground-control binary use | ||
|
||
```bash | ||
./gc-dev | ||
``` | ||
|
||
> **Note:** Ensure you have set up Dagger with the latest version before running this command. Ground Control will run on port 8080. | ||
|
||
### 5. Configure Satellite | ||
Return to the root project directory: | ||
|
||
```bash | ||
cd .. | ||
``` | ||
|
||
Then navigate to the `satellite` directory and verify that `config.toml` is set up correctly: | ||
|
||
```toml | ||
# Whether to use the built-in Zot registry or not | ||
bring_own_registry = false | ||
|
||
# IP address and port of the registry | ||
own_registry_adr = "127.0.0.1" | ||
own_registry_port = "8585" | ||
|
||
# URL of remote registry or local file path | ||
url_or_file = "https://demo.goharbor.io/v2/myproject/album-server" | ||
|
||
|
||
|
||
# Default path for Zot registry config.json | ||
zotConfigPath = "./registry/config.json" | ||
|
||
# Set logging level | ||
log_level = "info" | ||
``` | ||
|
||
### 6. Register the Satellite with Ground Control | ||
Using `curl` or Postman, make a `POST` request to register the Satellite with Ground Control: | ||
|
||
```bash | ||
curl -X POST http://localhost:8080/satellites/register -H "Content-Type: application/json" -d '{ "name": "<satellite_name_here>" }' | ||
``` | ||
|
||
The response will include a token string. Set this token in the Satellite `.env` file: | ||
|
||
```console | ||
TOKEN=<string_from_ground_control> | ||
``` | ||
|
||
### 7. Build the Satellite | ||
Run the following Dagger command to build the Satellite: | ||
|
||
```bash | ||
dagger call build-dev --platform "linux/amd64" --component satellite export --path=./satellite-dev | ||
``` | ||
|
||
To Run Satellite: | ||
```bash | ||
./satellite-dev | ||
``` | ||
|
||
The Satellite service will start on port 9090. Ensure that the `ground_control_url` is correctly set in the Satellite configuration before launching. | ||
|
||
|
||
### 8. Finalize and Run | ||
After setting the token, you can now run the Satellite. This setup will launch the Satellite in a container with the following exposed ports: | ||
- **9090** for the Satellite service. | ||
- **8585** for the Zot registry (if configured). | ||
|
||
With this setup, your Harbor Satellite should be up and running! | ||
Comment on lines
+84
to
+117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add security considerations and verification steps for registration process. The registration and execution instructions need enhancement:
Apply this diff: curl -X POST http://localhost:8080/satellites/register -H "Content-Type: application/json" -d '{ "name": "<satellite_name_here>" }'
+
+# Verify registration status
+curl -X GET http://localhost:8080/satellites/status
+
+# Store token securely (do not commit to version control)
+echo "TOKEN=<string_from_ground_control>" > .env
+chmod 600 .env Add a security note: > **Security Note:** The registration token grants access to Ground Control. Store it securely and never commit it to version control. Rotate tokens periodically following security best practices. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ Harbor Satellite will synchronize with the central Harbor registry, when Interne | |
|
||
Harbor Satellite will also include a toolset enabling the monitoring and management of local decentralized registries. | ||
|
||
## QuickStart | ||
Please refer to the latest setup instructions in QUICKSTART.md file for detailed steps on setting up Harbor Satellite locally. | ||
|
||
## Non-Goals | ||
|
||
T.B.D. | ||
|
@@ -51,29 +54,29 @@ Harbor Satellite, at its most basic, will run in a single container and will be | |
|
||
Harbor Satellite may be implemented following 1 or several of 3 different architectures depending on its use cases : | ||
|
||
1. **Replicating from a remote registry to a local registry.** | ||
1. **Replicating from a remote registry to a local registry.** | ||
In this basic use case, the stateless satellite component will handle pulling images from a remote registry and then pushing them to the local OCI compliant registry. This local registry will then be accessible to other local edge devices who can pull required images directly from it. | ||
_(A direct access from edge device to the remote registry is still possible when network conditions permit it)._ | ||
The satellite component may also handle updating container runtime configurations and fetching image lists from Ground Control, a part of Harbor. | ||
The stateful local regsitry will also need to handle storing and managing data on local volumes. | ||
A typical use case would work as follows : | ||
_(A direct access from edge device to the remote registry is still possible when network conditions permit it)._ | ||
The satellite component may also handle updating container runtime configurations and fetching image lists from Ground Control, a part of Harbor. | ||
The stateful local regsitry will also need to handle storing and managing data on local volumes. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in "registry" spelling. There are instances where "registry" is misspelled as "regsitry". Apply these corrections: -regsitry
+registry Also applies to: 68-68 |
||
A typical use case would work as follows : | ||
_In an edge computing environment where IoT devices are deployed to a location with limited or no internet connnectivity, these devices need to run containerised images but cannot pull from a central Harbor registry. A local Harbor Satellite instance can be deployed and take up this role while Internet connectivity is unreliable and distribute all required images. Once a reliable connection is re-established, the Harbor Satellite instance will be able to pull required images from its central Harbor registry and thus store up to date images locally._ | ||
|
||
![Use Case #1](docs/images/satellite_use_case_1.svg) | ||
<p align="center"><em>Use case #1</em></p> | ||
|
||
2. **Replicating from a remote regsitry to a local Spegel Registry** | ||
The stateless satellite component send pull instructions to Spegel instances running with each node of a Kubernetes cluster. The node will then directly pull images from a remote registry and share it with other local nodes, removing the need for each of them to individually pull an image from a remote registry. | ||
The network interfaces (boundaries) represented in this use case should and will be the same as those represented in use case #1 | ||
A typical use case would work as follows : | ||
2. **Replicating from a remote regsitry to a local Spegel Registry** | ||
The stateless satellite component send pull instructions to Spegel instances running with each node of a Kubernetes cluster. The node will then directly pull images from a remote registry and share it with other local nodes, removing the need for each of them to individually pull an image from a remote registry. | ||
The network interfaces (boundaries) represented in this use case should and will be the same as those represented in use case #1 | ||
A typical use case would work as follows : | ||
_In a larger scale edge computing environment with a significant amount of IoT devices needing to run containerised applications, a single local registry in might not be able to handle the increased amount of demands from edge devices. The solution is to deploy several registries to several nodes who are able to automatically replicate images across each other thanks to Spegel instances running together with each node. The Satellite component will use the same interface to instruct each node when, where and how to pull new images that need to be replicated across the cluster._ | ||
|
||
![Use Case #2](docs/images/satellite_use_case_2.svg) | ||
<p align="center"><em>Use case #2</em></p> | ||
|
||
3. **Proxying from a remote regsitry over the local registry** | ||
The stateless satellite component will be in charge of configuring the local OCI compliant registry, which will be running in proxy mode only. This local registry will then handle pulling necessary images from the remote registry and serving them up for use by local edge devices. | ||
A typical use case would work as follows : | ||
3. **Proxying from a remote regsitry over the local registry** | ||
The stateless satellite component will be in charge of configuring the local OCI compliant registry, which will be running in proxy mode only. This local registry will then handle pulling necessary images from the remote registry and serving them up for use by local edge devices. | ||
A typical use case would work as follows : | ||
_When, for a number of possible different reasons, the remote registry side of the diagram would not be able to produce a list of images to push down to the Harbor Satellite, the Satellite would then act as a proxy and forward all requests from edge devices to the remote registry. This ensures the availability of necessary images without the need for a pre-compiled list of images_ | ||
|
||
![Use Case #3](docs/images/satellite_use_case_3.svg) | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,8 +3,10 @@ package main | |||||||||||||||||||||||||
import ( | ||||||||||||||||||||||||||
"context" | ||||||||||||||||||||||||||
"fmt" | ||||||||||||||||||||||||||
"log" | ||||||||||||||||||||||||||
"log/slog" | ||||||||||||||||||||||||||
"os" | ||||||||||||||||||||||||||
"strings" | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
"container-registry.com/harbor-satellite/ci/internal/dagger" | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
|
@@ -20,6 +22,107 @@ const ( | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
type HarborSatellite struct{} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// start the dev server for ground-control. | ||||||||||||||||||||||||||
func (m *HarborSatellite) RunGroundControl( | ||||||||||||||||||||||||||
ctx context.Context, | ||||||||||||||||||||||||||
// +optional | ||||||||||||||||||||||||||
// +defaultPath="." | ||||||||||||||||||||||||||
source *dagger.Directory, | ||||||||||||||||||||||||||
) (*dagger.Service, error) { | ||||||||||||||||||||||||||
golang := dag.Container(). | ||||||||||||||||||||||||||
From("golang:latest"). | ||||||||||||||||||||||||||
WithMountedCache("/go/pkg/mod", dag.CacheVolume("go-mod")). | ||||||||||||||||||||||||||
WithEnvVariable("GOMODCACHE", "/go/pkg/mod"). | ||||||||||||||||||||||||||
WithMountedCache("/go/build-cache", dag.CacheVolume("go-build")). | ||||||||||||||||||||||||||
WithEnvVariable("GOCACHE", "/go/build-cache"). | ||||||||||||||||||||||||||
WithMountedDirectory(PROJ_MOUNT, source). | ||||||||||||||||||||||||||
WithWorkdir(PROJ_MOUNT). | ||||||||||||||||||||||||||
WithExec([]string{"go", "install", "github.com/air-verse/air@latest"}) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Comment on lines
+32
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin container and tool versions for reproducibility Several improvements needed for container setup:
Apply this diff: golang := dag.Container().
- From("golang:latest").
+ From(DEFAULT_GO). // Using the constant defined above
WithMountedCache("/go/pkg/mod", dag.CacheVolume("go-mod")).
WithEnvVariable("GOMODCACHE", "/go/pkg/mod").
WithMountedCache("/go/build-cache", dag.CacheVolume("go-build")).
WithEnvVariable("GOCACHE", "/go/build-cache").
WithMountedDirectory(PROJ_MOUNT, source).
WithWorkdir(PROJ_MOUNT).
- WithExec([]string{"go", "install", "github.com/air-verse/air@latest"})
+ WithExec([]string{"go", "install", "github.com/air-verse/[email protected]"}).
+ WithExec([]string{"which", "air"}) // Verify installation
🧰 Tools🪛 golangci-lint32-32: undefined: dag (typecheck) 34-34: undefined: dag (typecheck) |
||||||||||||||||||||||||||
db, err := m.Db(ctx) | ||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||
return nil, err | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
golang = golang. | ||||||||||||||||||||||||||
WithWorkdir(PROJ_MOUNT+"/ground-control/sql/schema"). | ||||||||||||||||||||||||||
WithExec([]string{"ls", "-la"}). | ||||||||||||||||||||||||||
WithServiceBinding("pgservice", db). | ||||||||||||||||||||||||||
WithExec([]string{"go", "install", "github.com/pressly/goose/v3/cmd/goose@latest"}). | ||||||||||||||||||||||||||
WithExec([]string{"goose", "postgres", "postgres://postgres:password@pgservice:5432/groundcontrol", "up"}). | ||||||||||||||||||||||||||
WithWorkdir(PROJ_MOUNT + "/ground-control"). | ||||||||||||||||||||||||||
WithExec([]string{"ls", "-la"}). | ||||||||||||||||||||||||||
WithExec([]string{"go", "mod", "download"}). | ||||||||||||||||||||||||||
WithExec([]string{"air", "-c", ".air.toml"}). | ||||||||||||||||||||||||||
WithExposedPort(8080) | ||||||||||||||||||||||||||
Comment on lines
+47
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clean up development setup and improve error handling Several improvements needed:
Apply this diff: golang = golang.
WithWorkdir(PROJ_MOUNT+"/ground-control/sql/schema").
- WithExec([]string{"ls", "-la"}).
WithServiceBinding("pgservice", db).
- WithExec([]string{"go", "install", "github.com/pressly/goose/v3/cmd/goose@latest"}).
+ WithExec([]string{"go", "install", "github.com/pressly/goose/v3/cmd/[email protected]"}).
+ WithExec([]string{"test", "-f", "migrations"}). // Verify migrations exist
WithExec([]string{"goose", "postgres", "postgres://postgres:password@pgservice:5432/groundcontrol", "up"}).
WithWorkdir(PROJ_MOUNT + "/ground-control").
- WithExec([]string{"ls", "-la"}).
+ WithExec([]string{"test", "-f", ".air.toml"}). // Verify config exists
WithExec([]string{"go", "mod", "download"}).
WithExec([]string{"air", "-c", ".air.toml"}).
WithExposedPort(8080)
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
return golang.AsService(), nil | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// quickly build binaries for components for given platform. | ||||||||||||||||||||||||||
func (m *HarborSatellite) BuildDev( | ||||||||||||||||||||||||||
ctx context.Context, | ||||||||||||||||||||||||||
// +optional | ||||||||||||||||||||||||||
// +defaultPath="." | ||||||||||||||||||||||||||
source *dagger.Directory, | ||||||||||||||||||||||||||
platform string, | ||||||||||||||||||||||||||
component string, | ||||||||||||||||||||||||||
) (*dagger.File, error) { | ||||||||||||||||||||||||||
fmt.Println("🛠️ Building Harbor-Cli with Dagger...") | ||||||||||||||||||||||||||
// Define the path for the binary output | ||||||||||||||||||||||||||
os, arch, err := parsePlatform(platform) | ||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||
log.Fatalf("Error parsing platform: %v", err) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
Comment on lines
+71
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve error handling and messaging The error handling could be improved:
Apply this diff: - fmt.Println("🛠️ Building Harbor-Cli with Dagger...")
+ fmt.Printf("🛠️ Building %s with Dagger...\n", component)
// Define the path for the binary output
os, arch, err := parsePlatform(platform)
if err != nil {
- log.Fatalf("Error parsing platform: %v", err)
+ return nil, fmt.Errorf("error parsing platform: %w", err)
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if component == "satellite" || component == "ground-control" { | ||||||||||||||||||||||||||
var binaryFile *dagger.File | ||||||||||||||||||||||||||
golang := dag.Container(). | ||||||||||||||||||||||||||
From("golang:latest"). | ||||||||||||||||||||||||||
WithMountedCache("/go/pkg/mod", dag.CacheVolume("go-mod")). | ||||||||||||||||||||||||||
WithEnvVariable("GOMODCACHE", "/go/pkg/mod"). | ||||||||||||||||||||||||||
WithMountedCache("/go/build-cache", dag.CacheVolume("go-build")). | ||||||||||||||||||||||||||
WithEnvVariable("GOCACHE", "/go/build-cache"). | ||||||||||||||||||||||||||
WithMountedDirectory(PROJ_MOUNT, source). | ||||||||||||||||||||||||||
WithWorkdir(PROJ_MOUNT). | ||||||||||||||||||||||||||
WithEnvVariable("GOOS", os). | ||||||||||||||||||||||||||
WithEnvVariable("GOARCH", arch) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if component == "ground-control" { | ||||||||||||||||||||||||||
golang = golang. | ||||||||||||||||||||||||||
WithWorkdir(PROJ_MOUNT + "/ground-control"). | ||||||||||||||||||||||||||
WithExec([]string{"ls", "-la"}). | ||||||||||||||||||||||||||
WithExec([]string{"go", "mod", "download"}). | ||||||||||||||||||||||||||
WithExec([]string{"go", "build", "."}) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
binaryFile = golang.File(PROJ_MOUNT + "/ground-control/ground-control") | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
golang = golang. | ||||||||||||||||||||||||||
WithExec([]string{"ls", "-la"}). | ||||||||||||||||||||||||||
WithExec([]string{"go", "mod", "download"}). | ||||||||||||||||||||||||||
WithExec([]string{"go", "build", "."}) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
binaryFile = golang.File(PROJ_MOUNT + "/harbor-satellite") | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
Comment on lines
+78
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Refactor container setup and remove debug commands The code has several issues:
Extract common container setup to a helper method and clean up the code: +func setupGolangContainer(source *dagger.Directory, os, arch string) *dagger.Container {
+ return dag.Container().
+ From(DEFAULT_GO).
+ WithMountedCache("/go/pkg/mod", dag.CacheVolume("go-mod")).
+ WithEnvVariable("GOMODCACHE", "/go/pkg/mod").
+ WithMountedCache("/go/build-cache", dag.CacheVolume("go-build")).
+ WithEnvVariable("GOCACHE", "/go/build-cache").
+ WithMountedDirectory(PROJ_MOUNT, source).
+ WithWorkdir(PROJ_MOUNT).
+ WithEnvVariable("GOOS", os).
+ WithEnvVariable("GOARCH", arch)
+}
if component == "satellite" || component == "ground-control" {
var binaryFile *dagger.File
- golang := dag.Container().
- From("golang:latest").
- WithMountedCache("/go/pkg/mod", dag.CacheVolume("go-mod")).
- WithEnvVariable("GOMODCACHE", "/go/pkg/mod").
- WithMountedCache("/go/build-cache", dag.CacheVolume("go-build")).
- WithEnvVariable("GOCACHE", "/go/build-cache").
- WithMountedDirectory(PROJ_MOUNT, source).
- WithWorkdir(PROJ_MOUNT).
- WithEnvVariable("GOOS", os).
- WithEnvVariable("GOARCH", arch)
+ golang := setupGolangContainer(source, os, arch)
if component == "ground-control" {
golang = golang.
WithWorkdir(PROJ_MOUNT + "/ground-control").
- WithExec([]string{"ls", "-la"}).
WithExec([]string{"go", "mod", "download"}).
WithExec([]string{"go", "build", "."})
binaryFile = golang.File(PROJ_MOUNT + "/ground-control/ground-control")
} else {
golang = golang.
- WithExec([]string{"ls", "-la"}).
WithExec([]string{"go", "mod", "download"}).
WithExec([]string{"go", "build", "."})
binaryFile = golang.File(PROJ_MOUNT + "/harbor-satellite")
}
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
return binaryFile, nil | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
return nil, fmt.Errorf("error: please provide component as either satellite or ground-control") | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// starts postgres DB container for ground-control. | ||||||||||||||||||||||||||
func (m *HarborSatellite) Db(ctx context.Context) (*dagger.Service, error) { | ||||||||||||||||||||||||||
return dag.Container(). | ||||||||||||||||||||||||||
From("postgres:17"). | ||||||||||||||||||||||||||
WithEnvVariable("POSTGRES_USER", "postgres"). | ||||||||||||||||||||||||||
WithEnvVariable("POSTGRES_PASSWORD", "password"). | ||||||||||||||||||||||||||
WithEnvVariable("POSTGRES_HOST_AUTH_METHOD", "trust"). | ||||||||||||||||||||||||||
WithEnvVariable("POSTGRES_DB", "groundcontrol"). | ||||||||||||||||||||||||||
WithExposedPort(5432). | ||||||||||||||||||||||||||
AsService().Start(ctx) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
Comment on lines
+114
to
+124
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve database container configuration and security. Several improvements needed:
func (m *HarborSatellite) Db(ctx context.Context) (*dagger.Service, error) {
+ const POSTGRES_VERSION = "17.2" // Pin specific version
+
return dag.Container().
- From("postgres:17").
+ From("postgres:" + POSTGRES_VERSION).
WithEnvVariable("POSTGRES_USER", "postgres").
WithEnvVariable("POSTGRES_PASSWORD", "password").
WithEnvVariable("POSTGRES_HOST_AUTH_METHOD", "trust").
WithEnvVariable("POSTGRES_DB", "groundcontrol").
WithExposedPort(5432).
+ WithHealthCheck(
+ dag.Container().
+ WithExec([]string{"pg_isready", "-U", "postgres"}),
+ ).
AsService().Start(ctx)
} Consider extracting credentials to environment variables or a configuration file for better security and flexibility.
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// Build function would start the build process for the name provided. Source should be the path to the main.go file. | ||||||||||||||||||||||||||
func (m *HarborSatellite) Build( | ||||||||||||||||||||||||||
ctx context.Context, | ||||||||||||||||||||||||||
|
@@ -78,3 +181,12 @@ func (m *HarborSatellite) Release(ctx context.Context, directory *dagger.Directo | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
return release_output, nil | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// Parse the platform string into os and arch | ||||||||||||||||||||||||||
func parsePlatform(platform string) (string, string, error) { | ||||||||||||||||||||||||||
parts := strings.Split(platform, "/") | ||||||||||||||||||||||||||
if len(parts) != 2 { | ||||||||||||||||||||||||||
return "", "", fmt.Errorf("invalid platform format: %s. Should be os/arch. E.g. darwin/amd64", platform) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
return parts[0], parts[1], nil | ||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "harbor-satellite", | ||
"engineVersion": "v0.14.0", | ||
"sdk": "go", | ||
"source": "ci", | ||
"engineVersion": "v0.13.3" | ||
"source": "ci" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance configuration documentation with explanations and validation steps.
The configuration section needs:
Apply this diff:
Add validation steps: