From 59e735194153c522a080981bcfb1f4be100127e5 Mon Sep 17 00:00:00 2001 From: cotishq Date: Tue, 11 Aug 2026 20:36:56 +0530 Subject: [PATCH 1/4] refactor: move shared internal packages under internal/shared Signed-off-by: cotishq --- cmd/groundcontrol/server/main.go | 2 +- cmd/satellite/audit_config_test.go | 2 +- cmd/satellite/main.go | 6 +++--- docs/decisions/0005-spiffe-identity-and-security.md | 12 ++++++------ docs/decisions/0007-security-plugins-parsec.md | 6 +++--- .../ground-control-internal-package-migration.md | 2 +- docs/decisions/security-parsec-integration-draft.md | 6 +++--- docs/guides/ground-control.md | 2 +- internal/groundcontrol/auth/password.go | 2 +- internal/groundcontrol/auth/policy.go | 2 +- internal/groundcontrol/auth/policy_test.go | 2 +- internal/groundcontrol/harbor/client.go | 2 +- internal/groundcontrol/harbor/robot.go | 2 +- internal/groundcontrol/harbor/robot_test.go | 2 +- internal/groundcontrol/harborhealth/check.go | 2 +- internal/groundcontrol/migrator/migrator.go | 2 +- internal/groundcontrol/server/audit_config_test.go | 4 ++-- internal/groundcontrol/server/auth_handlers.go | 2 +- internal/groundcontrol/server/bootstrap.go | 2 +- internal/groundcontrol/server/config_handlers.go | 4 ++-- internal/groundcontrol/server/group_handlers.go | 2 +- internal/groundcontrol/server/helpers.go | 4 ++-- internal/groundcontrol/server/helpers_test.go | 2 +- internal/groundcontrol/server/middleware.go | 4 ++-- internal/groundcontrol/server/middleware_test.go | 2 +- internal/groundcontrol/server/satellite_handlers.go | 4 ++-- .../groundcontrol/server/satellite_handlers_test.go | 2 +- internal/groundcontrol/server/server.go | 4 ++-- internal/groundcontrol/server/user_handlers.go | 2 +- internal/groundcontrol/spiffe/provider.go | 2 +- internal/groundcontrol/utils/helper.go | 2 +- internal/satellite/container_runtime/host.go | 2 +- internal/satellite/container_runtime/read_config.go | 4 ++-- internal/satellite/events/refresh_credentials.go | 4 ++-- internal/satellite/satellite.go | 2 +- internal/satellite/secure/config.go | 2 +- internal/satellite/secure/config_test.go | 2 +- internal/satellite/state/catalog.go | 2 +- internal/satellite/state/catalog_test.go | 2 +- internal/satellite/state/direct_delivery.go | 2 +- internal/satellite/state/helpers.go | 2 +- internal/satellite/state/registration_process.go | 2 +- internal/satellite/state/report.go | 2 +- internal/satellite/state/reporting_process.go | 6 +++--- internal/satellite/state/spiffe_registration.go | 4 ++-- internal/satellite/state/state_process.go | 4 ++-- internal/satellite/store/oci.go | 2 +- internal/satellite/store/registry.go | 2 +- internal/satellite/store/registry_test.go | 2 +- internal/{ => shared}/crypto/aes_provider.go | 0 internal/{ => shared}/crypto/aes_provider_test.go | 0 internal/{ => shared}/crypto/argon2.go | 0 internal/{ => shared}/crypto/argon2_test.go | 0 internal/{ => shared}/crypto/mock.go | 0 internal/{ => shared}/crypto/provider.go | 0 internal/{ => shared}/crypto/provider_stub.go | 0 internal/{ => shared}/crypto/provider_test.go | 0 internal/{ => shared}/env/env.go | 0 internal/{ => shared}/env/env_test.go | 0 internal/{ => shared}/env/ground-control.go | 0 internal/{ => shared}/env/harbor-satellite.go | 0 internal/{ => shared}/env/utils.go | 2 +- internal/{ => shared}/logger/audit.go | 0 internal/{ => shared}/logger/audit_test.go | 0 internal/{ => shared}/logger/logger.go | 2 +- internal/{ => shared}/logger/otel.go | 0 internal/{ => shared}/logger/otel_test.go | 0 internal/{ => shared}/logger/syslog.go | 0 internal/{ => shared}/logger/syslog_test.go | 0 internal/{ => shared}/spiffe/client.go | 0 internal/{ => shared}/spiffe/client_stub.go | 0 internal/{ => shared}/utils/folder.go | 0 internal/{ => shared}/utils/utils.go | 0 pkg/config/manager.go | 2 +- 74 files changed, 75 insertions(+), 75 deletions(-) rename internal/{ => shared}/crypto/aes_provider.go (100%) rename internal/{ => shared}/crypto/aes_provider_test.go (100%) rename internal/{ => shared}/crypto/argon2.go (100%) rename internal/{ => shared}/crypto/argon2_test.go (100%) rename internal/{ => shared}/crypto/mock.go (100%) rename internal/{ => shared}/crypto/provider.go (100%) rename internal/{ => shared}/crypto/provider_stub.go (100%) rename internal/{ => shared}/crypto/provider_test.go (100%) rename internal/{ => shared}/env/env.go (100%) rename internal/{ => shared}/env/env_test.go (100%) rename internal/{ => shared}/env/ground-control.go (100%) rename internal/{ => shared}/env/harbor-satellite.go (100%) rename internal/{ => shared}/env/utils.go (99%) rename internal/{ => shared}/logger/audit.go (100%) rename internal/{ => shared}/logger/audit_test.go (100%) rename internal/{ => shared}/logger/logger.go (97%) rename internal/{ => shared}/logger/otel.go (100%) rename internal/{ => shared}/logger/otel_test.go (100%) rename internal/{ => shared}/logger/syslog.go (100%) rename internal/{ => shared}/logger/syslog_test.go (100%) rename internal/{ => shared}/spiffe/client.go (100%) rename internal/{ => shared}/spiffe/client_stub.go (100%) rename internal/{ => shared}/utils/folder.go (100%) rename internal/{ => shared}/utils/utils.go (100%) diff --git a/cmd/groundcontrol/server/main.go b/cmd/groundcontrol/server/main.go index 0c84a5cd2..1119493d3 100644 --- a/cmd/groundcontrol/server/main.go +++ b/cmd/groundcontrol/server/main.go @@ -11,10 +11,10 @@ import ( "syscall" "time" - "github.com/container-registry/harbor-satellite/internal/env" "github.com/container-registry/harbor-satellite/internal/groundcontrol/harborhealth" "github.com/container-registry/harbor-satellite/internal/groundcontrol/migrator" "github.com/container-registry/harbor-satellite/internal/groundcontrol/server" + "github.com/container-registry/harbor-satellite/internal/shared/env" "github.com/joho/godotenv" ) diff --git a/cmd/satellite/audit_config_test.go b/cmd/satellite/audit_config_test.go index 7296decf9..967110159 100644 --- a/cmd/satellite/audit_config_test.go +++ b/cmd/satellite/audit_config_test.go @@ -3,7 +3,7 @@ package main import ( "testing" - "github.com/container-registry/harbor-satellite/internal/logger" + "github.com/container-registry/harbor-satellite/internal/shared/logger" "github.com/container-registry/harbor-satellite/pkg/config" "github.com/stretchr/testify/require" ) diff --git a/cmd/satellite/main.go b/cmd/satellite/main.go index 7196b2d24..0a73e680c 100755 --- a/cmd/satellite/main.go +++ b/cmd/satellite/main.go @@ -8,14 +8,14 @@ import ( "os" "time" - "github.com/container-registry/harbor-satellite/internal/env" - "github.com/container-registry/harbor-satellite/internal/logger" "github.com/container-registry/harbor-satellite/internal/satellite" runtime "github.com/container-registry/harbor-satellite/internal/satellite/container_runtime" "github.com/container-registry/harbor-satellite/internal/satellite/events" "github.com/container-registry/harbor-satellite/internal/satellite/hotreload" "github.com/container-registry/harbor-satellite/internal/satellite/watcher" - "github.com/container-registry/harbor-satellite/internal/utils" + "github.com/container-registry/harbor-satellite/internal/shared/env" + "github.com/container-registry/harbor-satellite/internal/shared/logger" + "github.com/container-registry/harbor-satellite/internal/shared/utils" "github.com/container-registry/harbor-satellite/pkg/config" "github.com/joho/godotenv" diff --git a/docs/decisions/0005-spiffe-identity-and-security.md b/docs/decisions/0005-spiffe-identity-and-security.md index 2e0f9675b..d202ef45b 100644 --- a/docs/decisions/0005-spiffe-identity-and-security.md +++ b/docs/decisions/0005-spiffe-identity-and-security.md @@ -207,7 +207,7 @@ sequenceDiagram ### 5. Satellite SPIFFE Client -File: `internal/spiffe/client.go` +File: `internal/shared/spiffe/client.go` - Connects to SPIRE agent via Workload API socket (embedded or external) - Obtains X.509 SVID, creates mTLS HTTP client @@ -234,7 +234,7 @@ sequenceDiagram ### 6. Embedded SPIRE Agent in Satellite (Phase 1 - TO IMPLEMENT) - Mirror the pattern from GC's `embedded_server.go` -- Create `internal/spiffe/embedded_agent.go`: subprocess manager for `spire-agent run` +- Create `internal/shared/spiffe/embedded_agent.go`: subprocess manager for `spire-agent run` - Start/stop with readiness polling, graceful shutdown - Config generation: trust domain, attestation method - SPIRE server address must be explicitly configured (no assumption that GC runs the server) @@ -307,7 +307,7 @@ spiffe:///satellite/region// ### 11. Device Identity and Config Encryption - `internal/identity/device_linux.go`: SHA-256 fingerprint from machine-id + MAC + disk serial -- `internal/crypto/aes_provider.go`: AES-256-GCM, Argon2id key derivation (OWASP 2024) +- `internal/shared/crypto/aes_provider.go`: AES-256-GCM, Argon2id key derivation (OWASP 2024) - `internal/secure/config.go`: encrypted config-at-rest, version 1 envelope - Device-bound: config cannot migrate between machines - Encryption must work in ALL builds (currently broken in nospiffe build tag; must be decoupled) @@ -441,10 +441,10 @@ sequenceDiagram - `internal/satellite/satellite.go:35-55` - ZTR path selection - `internal/state/spiffe_registration.go` - SPIFFE ZTR process - `internal/state/registration_process.go` - Token ZTR process -- `internal/spiffe/client.go` - Workload API client +- `internal/shared/spiffe/client.go` - Workload API client - `internal/identity/device_linux.go` - Device fingerprinting -- `internal/crypto/aes_provider.go` - AES encryption -- `internal/crypto/provider_stub.go` - nospiffe stub (no-op) +- `internal/shared/crypto/aes_provider.go` - AES encryption +- `internal/shared/crypto/provider_stub.go` - nospiffe stub (no-op) - `internal/identity/device_stub.go` - nospiffe stub (errors) - `internal/secure/config.go` - Config encryption wrapper - `pkg/config/manager.go` - EncryptConfig flag, write logic diff --git a/docs/decisions/0007-security-plugins-parsec.md b/docs/decisions/0007-security-plugins-parsec.md index 988b5e32e..acf9fdeca 100644 --- a/docs/decisions/0007-security-plugins-parsec.md +++ b/docs/decisions/0007-security-plugins-parsec.md @@ -111,7 +111,7 @@ internal/parsec/ ### `KeyProvider` implements `crypto.Provider` -`KeyProvider` implements the existing `internal/crypto.Provider` interface so it can be swapped +`KeyProvider` implements the existing `internal/shared/crypto.Provider` interface so it can be swapped into `pkg/config/manager.go` without changes to any downstream consumer. The key design challenge is that `crypto.Provider.Sign(data []byte, key crypto.PrivateKey)` @@ -193,7 +193,7 @@ In Phase 2, `Signer` is used as the private key for SPIRE's `tpm_devid` node att This makes the SPIRE agent's attestation to the SPIRE server hardware-rooted: Ground Control's trust in the satellite is cryptographically bound to the physical device. -The existing `workloadapi.X509Source` SVID delivery flow in `internal/spiffe/client.go` is +The existing `workloadapi.X509Source` SVID delivery flow in `internal/shared/spiffe/client.go` is unaffected — PARSEC operates below the SVID layer. ``` @@ -210,7 +210,7 @@ PARSEC (hardware key) → SPIRE tpm_devid (node attestation) → SVID issuance Target coverage (not all of these exist yet; see Phase-1 Limitations below): -- Unit tests for `KeyProvider` using a mock PARSEC client (same pattern as `internal/crypto/mock.go`) +- Unit tests for `KeyProvider` using a mock PARSEC client (same pattern as `internal/shared/crypto/mock.go`) - `parsec` build tag compiles cleanly alongside `nospiffe` and default builds - Default build (no `parsec` tag) continues to pass all existing tests unchanged - E2E test (`test-parsec` task in `taskfiles/e2e.yml`) using a real PARSEC daemon in CI, diff --git a/docs/decisions/ground-control-internal-package-migration.md b/docs/decisions/ground-control-internal-package-migration.md index 1a13edebd..a8df5b810 100644 --- a/docs/decisions/ground-control-internal-package-migration.md +++ b/docs/decisions/ground-control-internal-package-migration.md @@ -45,7 +45,7 @@ harbor-satellite/ - Move executable entrypoints into `cmd//main.go`. - Keep `cmd` packages thin. They should only parse configuration, initialize dependencies, and call internal application code. - Prefer `internal/satellite` and `internal/groundcontrol` for binary-specific application logic. -- Avoid a generic `internal/shared` package. Shared code should live in packages named after the behavior or domain they own, such as `internal/logger`, `internal/spiffe`, `internal/auth`, or `internal/database`. +- Avoid a generic catch-all package under `internal/shared`. Shared code should live in packages named after the behavior or domain they own, such as `internal/shared/logger`, `internal/shared/spiffe`, `internal/auth`, or `internal/database`. - Keep code in `pkg` only when it is intentionally public and stable for external consumers. Code used only by repository binaries should live under `internal`. ## Migration Plan diff --git a/docs/decisions/security-parsec-integration-draft.md b/docs/decisions/security-parsec-integration-draft.md index 20b472a3d..f8ab90e1e 100644 --- a/docs/decisions/security-parsec-integration-draft.md +++ b/docs/decisions/security-parsec-integration-draft.md @@ -51,7 +51,7 @@ PARSEC and SPIRE are **complementary, not competing**: | Workload identity | SPIRE | Issues X.509 SVIDs after attestation succeeds | | mTLS & ZTR | Existing SPIFFE client | Unchanged — receives SVID and uses it for mTLS with Ground Control | -PARSEC plugs into SPIRE at the **node attestation layer**. The existing `internal/spiffe/client.go` +PARSEC plugs into SPIRE at the **node attestation layer**. The existing `internal/shared/spiffe/client.go` SVID delivery flow is unaffected. This maps directly onto ADR-0005's explicit roadmap: - **Phase 2** (planned): TPM-based node attestation via SPIRE `tpm_devid` plugin — PARSEC enables this @@ -139,7 +139,7 @@ internal/parsec/ provider_stub.go # no-op stubs, same shape as spiffe/client_stub.go [!parsec] ``` -All files under `internal/parsec/` follow the same build tag pattern as `internal/spiffe/`: +All files under `internal/parsec/` follow the same build tag pattern as `internal/shared/spiffe/`: `//go:build parsec` for real implementations, `//go:build !parsec` for stubs. Default builds compile to zero PARSEC dependency. @@ -253,7 +253,7 @@ core PARSEC integration and should be designed independently. ### Tests needed -- Unit tests for `KeyProvider` using a mock PARSEC client (same pattern as `internal/crypto/mock.go`) +- Unit tests for `KeyProvider` using a mock PARSEC client (same pattern as `internal/shared/crypto/mock.go`) - E2E test similar to `TestSpiffeJoinTokenE2E` that exercises the full flow with a real PARSEC daemon in CI (the `parsec-client-go` repo has a Docker-based test harness that can be reused) diff --git a/docs/guides/ground-control.md b/docs/guides/ground-control.md index 75bca3750..dc5d91255 100644 --- a/docs/guides/ground-control.md +++ b/docs/guides/ground-control.md @@ -68,7 +68,7 @@ Key groups include: - `internal/groundcontrol/harbor` - Harbor API client helpers - `internal/groundcontrol/spiffe` - SPIFFE/SPIRE provider and server client integration - `internal/groundcontrol/auth` - password policy and hashing helpers -- `internal/crypto` - shared crypto helpers used by Ground Control +- `internal/shared/crypto` - shared crypto helpers used by Ground Control ## Related Docs diff --git a/internal/groundcontrol/auth/password.go b/internal/groundcontrol/auth/password.go index 3df0adeec..e6c103f3c 100644 --- a/internal/groundcontrol/auth/password.go +++ b/internal/groundcontrol/auth/password.go @@ -5,7 +5,7 @@ import ( "encoding/base64" "fmt" - "github.com/container-registry/harbor-satellite/internal/crypto" + "github.com/container-registry/harbor-satellite/internal/shared/crypto" ) // HashPassword creates an Argon2id hash of the password. diff --git a/internal/groundcontrol/auth/policy.go b/internal/groundcontrol/auth/policy.go index 537b6099c..914d601f1 100644 --- a/internal/groundcontrol/auth/policy.go +++ b/internal/groundcontrol/auth/policy.go @@ -5,7 +5,7 @@ import ( "strings" "unicode" - "github.com/container-registry/harbor-satellite/internal/env" + "github.com/container-registry/harbor-satellite/internal/shared/env" ) type PasswordPolicy struct { diff --git a/internal/groundcontrol/auth/policy_test.go b/internal/groundcontrol/auth/policy_test.go index 27f11ff8d..64a90e6f4 100644 --- a/internal/groundcontrol/auth/policy_test.go +++ b/internal/groundcontrol/auth/policy_test.go @@ -3,7 +3,7 @@ package auth import ( "testing" - "github.com/container-registry/harbor-satellite/internal/env" + "github.com/container-registry/harbor-satellite/internal/shared/env" "github.com/stretchr/testify/require" ) diff --git a/internal/groundcontrol/harbor/client.go b/internal/groundcontrol/harbor/client.go index 94aa2666d..febd8d135 100644 --- a/internal/groundcontrol/harbor/client.go +++ b/internal/groundcontrol/harbor/client.go @@ -3,7 +3,7 @@ package harbor import ( "sync" - "github.com/container-registry/harbor-satellite/internal/env" + "github.com/container-registry/harbor-satellite/internal/shared/env" "github.com/goharbor/go-client/pkg/harbor" v2client "github.com/goharbor/go-client/pkg/sdk/v2.0/client" ) diff --git a/internal/groundcontrol/harbor/robot.go b/internal/groundcontrol/harbor/robot.go index 39f5161f2..f6875696d 100644 --- a/internal/groundcontrol/harbor/robot.go +++ b/internal/groundcontrol/harbor/robot.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/container-registry/harbor-satellite/internal/env" + "github.com/container-registry/harbor-satellite/internal/shared/env" "github.com/goharbor/go-client/pkg/sdk/v2.0/client/robot" "github.com/goharbor/go-client/pkg/sdk/v2.0/models" ) diff --git a/internal/groundcontrol/harbor/robot_test.go b/internal/groundcontrol/harbor/robot_test.go index 3fd48bb91..53c976c6d 100644 --- a/internal/groundcontrol/harbor/robot_test.go +++ b/internal/groundcontrol/harbor/robot_test.go @@ -3,7 +3,7 @@ package harbor import ( "testing" - "github.com/container-registry/harbor-satellite/internal/env" + "github.com/container-registry/harbor-satellite/internal/shared/env" "github.com/stretchr/testify/require" ) diff --git a/internal/groundcontrol/harborhealth/check.go b/internal/groundcontrol/harborhealth/check.go index d70d5bf50..aa62acea1 100644 --- a/internal/groundcontrol/harborhealth/check.go +++ b/internal/groundcontrol/harborhealth/check.go @@ -8,7 +8,7 @@ import ( "net/url" "time" - "github.com/container-registry/harbor-satellite/internal/env" + "github.com/container-registry/harbor-satellite/internal/shared/env" ) type config struct { diff --git a/internal/groundcontrol/migrator/migrator.go b/internal/groundcontrol/migrator/migrator.go index 66a1d4b04..676d54f28 100644 --- a/internal/groundcontrol/migrator/migrator.go +++ b/internal/groundcontrol/migrator/migrator.go @@ -7,7 +7,7 @@ import ( "os" "time" - "github.com/container-registry/harbor-satellite/internal/env" + "github.com/container-registry/harbor-satellite/internal/shared/env" _ "github.com/lib/pq" "github.com/pressly/goose/v3" ) diff --git a/internal/groundcontrol/server/audit_config_test.go b/internal/groundcontrol/server/audit_config_test.go index d988382b3..13247f81e 100644 --- a/internal/groundcontrol/server/audit_config_test.go +++ b/internal/groundcontrol/server/audit_config_test.go @@ -3,8 +3,8 @@ package server import ( "testing" - "github.com/container-registry/harbor-satellite/internal/env" - auditlog "github.com/container-registry/harbor-satellite/internal/groundcontrol/logger" + "github.com/container-registry/harbor-satellite/internal/shared/env" + auditlog "github.com/container-registry/harbor-satellite/internal/shared/logger" "github.com/stretchr/testify/require" ) diff --git a/internal/groundcontrol/server/auth_handlers.go b/internal/groundcontrol/server/auth_handlers.go index 022b4c6d0..8c8739bbb 100644 --- a/internal/groundcontrol/server/auth_handlers.go +++ b/internal/groundcontrol/server/auth_handlers.go @@ -10,8 +10,8 @@ import ( "github.com/container-registry/harbor-satellite/internal/groundcontrol/auth" "github.com/container-registry/harbor-satellite/internal/groundcontrol/database" - auditlog "github.com/container-registry/harbor-satellite/internal/groundcontrol/logger" "github.com/container-registry/harbor-satellite/internal/groundcontrol/spiffe" + auditlog "github.com/container-registry/harbor-satellite/internal/shared/logger" ) const maxFailedAttempts = 5 diff --git a/internal/groundcontrol/server/bootstrap.go b/internal/groundcontrol/server/bootstrap.go index c0a359629..2dc34b2a0 100644 --- a/internal/groundcontrol/server/bootstrap.go +++ b/internal/groundcontrol/server/bootstrap.go @@ -5,9 +5,9 @@ import ( "fmt" "log" - "github.com/container-registry/harbor-satellite/internal/env" "github.com/container-registry/harbor-satellite/internal/groundcontrol/auth" "github.com/container-registry/harbor-satellite/internal/groundcontrol/database" + "github.com/container-registry/harbor-satellite/internal/shared/env" ) const systemAdminUsername = "admin" diff --git a/internal/groundcontrol/server/config_handlers.go b/internal/groundcontrol/server/config_handlers.go index 67dfddd4c..86aebcb87 100644 --- a/internal/groundcontrol/server/config_handlers.go +++ b/internal/groundcontrol/server/config_handlers.go @@ -10,10 +10,10 @@ import ( "reflect" "strings" - "github.com/container-registry/harbor-satellite/internal/env" "github.com/container-registry/harbor-satellite/internal/groundcontrol/database" - auditlog "github.com/container-registry/harbor-satellite/internal/groundcontrol/logger" "github.com/container-registry/harbor-satellite/internal/groundcontrol/utils" + "github.com/container-registry/harbor-satellite/internal/shared/env" + auditlog "github.com/container-registry/harbor-satellite/internal/shared/logger" jsonpatch "github.com/evanphx/json-patch" "github.com/lib/pq" ) diff --git a/internal/groundcontrol/server/group_handlers.go b/internal/groundcontrol/server/group_handlers.go index 5b6ef6924..49a994449 100644 --- a/internal/groundcontrol/server/group_handlers.go +++ b/internal/groundcontrol/server/group_handlers.go @@ -5,10 +5,10 @@ import ( "log" "net/http" - "github.com/container-registry/harbor-satellite/internal/env" "github.com/container-registry/harbor-satellite/internal/groundcontrol/database" "github.com/container-registry/harbor-satellite/internal/groundcontrol/harbor" "github.com/container-registry/harbor-satellite/internal/groundcontrol/utils" + "github.com/container-registry/harbor-satellite/internal/shared/env" ) func (s *Server) SyncGroup(w http.ResponseWriter, r *http.Request) { diff --git a/internal/groundcontrol/server/helpers.go b/internal/groundcontrol/server/helpers.go index 6ea5b6e5e..57b9261c4 100644 --- a/internal/groundcontrol/server/helpers.go +++ b/internal/groundcontrol/server/helpers.go @@ -13,11 +13,11 @@ import ( "strings" "time" - "github.com/container-registry/harbor-satellite/internal/crypto" - "github.com/container-registry/harbor-satellite/internal/env" "github.com/container-registry/harbor-satellite/internal/groundcontrol/database" "github.com/container-registry/harbor-satellite/internal/groundcontrol/harbor" "github.com/container-registry/harbor-satellite/internal/groundcontrol/utils" + "github.com/container-registry/harbor-satellite/internal/shared/crypto" + "github.com/container-registry/harbor-satellite/internal/shared/env" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/crane" ) diff --git a/internal/groundcontrol/server/helpers_test.go b/internal/groundcontrol/server/helpers_test.go index 97cb4405a..59f5e9453 100644 --- a/internal/groundcontrol/server/helpers_test.go +++ b/internal/groundcontrol/server/helpers_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/container-registry/harbor-satellite/internal/crypto" + "github.com/container-registry/harbor-satellite/internal/shared/crypto" "github.com/stretchr/testify/require" ) diff --git a/internal/groundcontrol/server/middleware.go b/internal/groundcontrol/server/middleware.go index 207399a06..f84e227e6 100644 --- a/internal/groundcontrol/server/middleware.go +++ b/internal/groundcontrol/server/middleware.go @@ -10,10 +10,10 @@ import ( "strings" "time" - "github.com/container-registry/harbor-satellite/internal/crypto" "github.com/container-registry/harbor-satellite/internal/groundcontrol/auth" - auditlog "github.com/container-registry/harbor-satellite/internal/groundcontrol/logger" "github.com/container-registry/harbor-satellite/internal/groundcontrol/spiffe" + "github.com/container-registry/harbor-satellite/internal/shared/crypto" + auditlog "github.com/container-registry/harbor-satellite/internal/shared/logger" "github.com/google/uuid" ) diff --git a/internal/groundcontrol/server/middleware_test.go b/internal/groundcontrol/server/middleware_test.go index dc1aa62eb..cbeafbb3d 100644 --- a/internal/groundcontrol/server/middleware_test.go +++ b/internal/groundcontrol/server/middleware_test.go @@ -9,8 +9,8 @@ import ( "time" "github.com/DATA-DOG/go-sqlmock" - "github.com/container-registry/harbor-satellite/internal/crypto" "github.com/container-registry/harbor-satellite/internal/groundcontrol/spiffe" + "github.com/container-registry/harbor-satellite/internal/shared/crypto" "github.com/stretchr/testify/require" ) diff --git a/internal/groundcontrol/server/satellite_handlers.go b/internal/groundcontrol/server/satellite_handlers.go index a0271ceea..97689d385 100644 --- a/internal/groundcontrol/server/satellite_handlers.go +++ b/internal/groundcontrol/server/satellite_handlers.go @@ -9,12 +9,12 @@ import ( "strings" "time" - "github.com/container-registry/harbor-satellite/internal/env" "github.com/container-registry/harbor-satellite/internal/groundcontrol/database" "github.com/container-registry/harbor-satellite/internal/groundcontrol/harbor" - auditlog "github.com/container-registry/harbor-satellite/internal/groundcontrol/logger" "github.com/container-registry/harbor-satellite/internal/groundcontrol/spiffe" "github.com/container-registry/harbor-satellite/internal/groundcontrol/utils" + "github.com/container-registry/harbor-satellite/internal/shared/env" + auditlog "github.com/container-registry/harbor-satellite/internal/shared/logger" ) type SatelliteSyncResponse struct { diff --git a/internal/groundcontrol/server/satellite_handlers_test.go b/internal/groundcontrol/server/satellite_handlers_test.go index 899974d1c..623c173ab 100644 --- a/internal/groundcontrol/server/satellite_handlers_test.go +++ b/internal/groundcontrol/server/satellite_handlers_test.go @@ -7,8 +7,8 @@ import ( "os" "testing" - "github.com/container-registry/harbor-satellite/internal/env" "github.com/container-registry/harbor-satellite/internal/groundcontrol/database" + "github.com/container-registry/harbor-satellite/internal/shared/env" "github.com/stretchr/testify/require" ) diff --git a/internal/groundcontrol/server/server.go b/internal/groundcontrol/server/server.go index 0d4022e04..2208ab99e 100644 --- a/internal/groundcontrol/server/server.go +++ b/internal/groundcontrol/server/server.go @@ -13,12 +13,12 @@ import ( _ "github.com/lib/pq" - "github.com/container-registry/harbor-satellite/internal/env" "github.com/container-registry/harbor-satellite/internal/groundcontrol/auth" "github.com/container-registry/harbor-satellite/internal/groundcontrol/database" - auditlog "github.com/container-registry/harbor-satellite/internal/groundcontrol/logger" "github.com/container-registry/harbor-satellite/internal/groundcontrol/middleware" "github.com/container-registry/harbor-satellite/internal/groundcontrol/spiffe" + "github.com/container-registry/harbor-satellite/internal/shared/env" + auditlog "github.com/container-registry/harbor-satellite/internal/shared/logger" ) type Server struct { diff --git a/internal/groundcontrol/server/user_handlers.go b/internal/groundcontrol/server/user_handlers.go index 4949d5693..7fc5b6a80 100644 --- a/internal/groundcontrol/server/user_handlers.go +++ b/internal/groundcontrol/server/user_handlers.go @@ -11,7 +11,7 @@ import ( "github.com/container-registry/harbor-satellite/internal/groundcontrol/auth" "github.com/container-registry/harbor-satellite/internal/groundcontrol/database" - auditlog "github.com/container-registry/harbor-satellite/internal/groundcontrol/logger" + auditlog "github.com/container-registry/harbor-satellite/internal/shared/logger" ) // actorFromContext returns the authenticated user's username, or "unknown". diff --git a/internal/groundcontrol/spiffe/provider.go b/internal/groundcontrol/spiffe/provider.go index 8b865ec68..905c61d02 100644 --- a/internal/groundcontrol/spiffe/provider.go +++ b/internal/groundcontrol/spiffe/provider.go @@ -8,7 +8,7 @@ import ( "fmt" "sync" - "github.com/container-registry/harbor-satellite/internal/env" + "github.com/container-registry/harbor-satellite/internal/shared/env" "github.com/spiffe/go-spiffe/v2/bundle/x509bundle" "github.com/spiffe/go-spiffe/v2/spiffeid" "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" diff --git a/internal/groundcontrol/utils/helper.go b/internal/groundcontrol/utils/helper.go index a81581f42..68c733abe 100644 --- a/internal/groundcontrol/utils/helper.go +++ b/internal/groundcontrol/utils/helper.go @@ -11,8 +11,8 @@ import ( "strings" "time" - "github.com/container-registry/harbor-satellite/internal/env" "github.com/container-registry/harbor-satellite/internal/groundcontrol/harbor" + "github.com/container-registry/harbor-satellite/internal/shared/env" "github.com/goharbor/go-client/pkg/sdk/v2.0/client/robot" "github.com/goharbor/go-client/pkg/sdk/v2.0/models" "github.com/google/go-containerregistry/pkg/authn" diff --git a/internal/satellite/container_runtime/host.go b/internal/satellite/container_runtime/host.go index 0562a7305..6a2ad5e78 100644 --- a/internal/satellite/container_runtime/host.go +++ b/internal/satellite/container_runtime/host.go @@ -6,7 +6,7 @@ package runtime // "path/filepath" // "strings" -// "github.com/container-registry/harbor-satellite/internal/utils" +// "github.com/container-registry/harbor-satellite/internal/shared/utils" // "github.com/pelletier/go-toml/v2" // "github.com/rs/zerolog" // ) diff --git a/internal/satellite/container_runtime/read_config.go b/internal/satellite/container_runtime/read_config.go index 3d45e184a..5a2f98bc8 100644 --- a/internal/satellite/container_runtime/read_config.go +++ b/internal/satellite/container_runtime/read_config.go @@ -3,8 +3,8 @@ package runtime // import ( // "fmt" -// "github.com/container-registry/harbor-satellite/internal/logger" -// "github.com/container-registry/harbor-satellite/internal/utils" +// "github.com/container-registry/harbor-satellite/internal/shared/logger" +// "github.com/container-registry/harbor-satellite/internal/shared/utils" // "github.com/spf13/cobra" // ) diff --git a/internal/satellite/events/refresh_credentials.go b/internal/satellite/events/refresh_credentials.go index b2abb3c1e..edda46e65 100644 --- a/internal/satellite/events/refresh_credentials.go +++ b/internal/satellite/events/refresh_credentials.go @@ -9,9 +9,9 @@ import ( "strings" "sync" - "github.com/container-registry/harbor-satellite/internal/logger" "github.com/container-registry/harbor-satellite/internal/satellite/scheduler" - "github.com/container-registry/harbor-satellite/internal/spiffe" + "github.com/container-registry/harbor-satellite/internal/shared/logger" + "github.com/container-registry/harbor-satellite/internal/shared/spiffe" "github.com/container-registry/harbor-satellite/pkg/config" "github.com/rs/zerolog" ) diff --git a/internal/satellite/satellite.go b/internal/satellite/satellite.go index 5f5b5ca7b..91e9df6b1 100644 --- a/internal/satellite/satellite.go +++ b/internal/satellite/satellite.go @@ -4,11 +4,11 @@ import ( "context" "errors" - "github.com/container-registry/harbor-satellite/internal/logger" runtime "github.com/container-registry/harbor-satellite/internal/satellite/container_runtime" "github.com/container-registry/harbor-satellite/internal/satellite/events" "github.com/container-registry/harbor-satellite/internal/satellite/scheduler" "github.com/container-registry/harbor-satellite/internal/satellite/state" + "github.com/container-registry/harbor-satellite/internal/shared/logger" "github.com/container-registry/harbor-satellite/pkg/config" ) diff --git a/internal/satellite/secure/config.go b/internal/satellite/secure/config.go index f8b02ca6d..d663bacae 100644 --- a/internal/satellite/secure/config.go +++ b/internal/satellite/secure/config.go @@ -6,8 +6,8 @@ import ( "os" "path/filepath" - "github.com/container-registry/harbor-satellite/internal/crypto" "github.com/container-registry/harbor-satellite/internal/satellite/identity" + "github.com/container-registry/harbor-satellite/internal/shared/crypto" ) var ( diff --git a/internal/satellite/secure/config_test.go b/internal/satellite/secure/config_test.go index de0ca52d2..25b322095 100644 --- a/internal/satellite/secure/config_test.go +++ b/internal/satellite/secure/config_test.go @@ -5,8 +5,8 @@ import ( "path/filepath" "testing" - "github.com/container-registry/harbor-satellite/internal/crypto" "github.com/container-registry/harbor-satellite/internal/satellite/identity" + "github.com/container-registry/harbor-satellite/internal/shared/crypto" "github.com/stretchr/testify/require" ) diff --git a/internal/satellite/state/catalog.go b/internal/satellite/state/catalog.go index b5d3dc23c..86e7bdc15 100644 --- a/internal/satellite/state/catalog.go +++ b/internal/satellite/state/catalog.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-containerregistry/pkg/crane" v1 "github.com/google/go-containerregistry/pkg/v1" - "github.com/container-registry/harbor-satellite/internal/logger" + "github.com/container-registry/harbor-satellite/internal/shared/logger" ) type CachedImage struct { diff --git a/internal/satellite/state/catalog_test.go b/internal/satellite/state/catalog_test.go index 24add0a53..eb8a347c7 100644 --- a/internal/satellite/state/catalog_test.go +++ b/internal/satellite/state/catalog_test.go @@ -10,7 +10,7 @@ import ( "strings" "testing" - "github.com/container-registry/harbor-satellite/internal/logger" + "github.com/container-registry/harbor-satellite/internal/shared/logger" "github.com/google/go-containerregistry/pkg/crane" "github.com/rs/zerolog" "github.com/stretchr/testify/require" diff --git a/internal/satellite/state/direct_delivery.go b/internal/satellite/state/direct_delivery.go index d05a843df..163a488b0 100644 --- a/internal/satellite/state/direct_delivery.go +++ b/internal/satellite/state/direct_delivery.go @@ -9,7 +9,7 @@ import ( "strings" "sync" - "github.com/container-registry/harbor-satellite/internal/logger" + "github.com/container-registry/harbor-satellite/internal/shared/logger" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" diff --git a/internal/satellite/state/helpers.go b/internal/satellite/state/helpers.go index 5bc0e6819..26c5c11a6 100644 --- a/internal/satellite/state/helpers.go +++ b/internal/satellite/state/helpers.go @@ -3,7 +3,7 @@ package state import ( "fmt" - "github.com/container-registry/harbor-satellite/internal/utils" + "github.com/container-registry/harbor-satellite/internal/shared/utils" "github.com/container-registry/harbor-satellite/pkg/config" "github.com/rs/zerolog" ) diff --git a/internal/satellite/state/registration_process.go b/internal/satellite/state/registration_process.go index 43656f0ee..032c613dc 100644 --- a/internal/satellite/state/registration_process.go +++ b/internal/satellite/state/registration_process.go @@ -11,8 +11,8 @@ import ( "sync" "time" - "github.com/container-registry/harbor-satellite/internal/logger" satTLS "github.com/container-registry/harbor-satellite/internal/satellite/tls" + "github.com/container-registry/harbor-satellite/internal/shared/logger" "github.com/container-registry/harbor-satellite/pkg/config" "github.com/rs/zerolog" ) diff --git a/internal/satellite/state/report.go b/internal/satellite/state/report.go index a850eeb18..e24340426 100644 --- a/internal/satellite/state/report.go +++ b/internal/satellite/state/report.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/container-registry/harbor-satellite/internal/logger" + "github.com/container-registry/harbor-satellite/internal/shared/logger" "github.com/container-registry/harbor-satellite/pkg/config" "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/disk" diff --git a/internal/satellite/state/reporting_process.go b/internal/satellite/state/reporting_process.go index c5e7cb04a..b1a44eed3 100644 --- a/internal/satellite/state/reporting_process.go +++ b/internal/satellite/state/reporting_process.go @@ -11,11 +11,11 @@ import ( "sync" "time" - "github.com/container-registry/harbor-satellite/internal/logger" runtime "github.com/container-registry/harbor-satellite/internal/satellite/container_runtime" "github.com/container-registry/harbor-satellite/internal/satellite/events" - "github.com/container-registry/harbor-satellite/internal/spiffe" - "github.com/container-registry/harbor-satellite/internal/utils" + "github.com/container-registry/harbor-satellite/internal/shared/logger" + "github.com/container-registry/harbor-satellite/internal/shared/spiffe" + "github.com/container-registry/harbor-satellite/internal/shared/utils" "github.com/container-registry/harbor-satellite/pkg/config" ) diff --git a/internal/satellite/state/spiffe_registration.go b/internal/satellite/state/spiffe_registration.go index 54523cca2..e1432fd55 100644 --- a/internal/satellite/state/spiffe_registration.go +++ b/internal/satellite/state/spiffe_registration.go @@ -8,8 +8,8 @@ import ( "net/http" "sync" - "github.com/container-registry/harbor-satellite/internal/logger" - "github.com/container-registry/harbor-satellite/internal/spiffe" + "github.com/container-registry/harbor-satellite/internal/shared/logger" + "github.com/container-registry/harbor-satellite/internal/shared/spiffe" "github.com/container-registry/harbor-satellite/pkg/config" "github.com/rs/zerolog" ) diff --git a/internal/satellite/state/state_process.go b/internal/satellite/state/state_process.go index 8f43a281c..a968c3210 100644 --- a/internal/satellite/state/state_process.go +++ b/internal/satellite/state/state_process.go @@ -6,9 +6,9 @@ import ( "strings" "sync" - "github.com/container-registry/harbor-satellite/internal/logger" "github.com/container-registry/harbor-satellite/internal/satellite/store" - "github.com/container-registry/harbor-satellite/internal/utils" + "github.com/container-registry/harbor-satellite/internal/shared/logger" + "github.com/container-registry/harbor-satellite/internal/shared/utils" "github.com/container-registry/harbor-satellite/pkg/config" "github.com/rs/zerolog" ) diff --git a/internal/satellite/store/oci.go b/internal/satellite/store/oci.go index 355f81e03..3d418dc73 100644 --- a/internal/satellite/store/oci.go +++ b/internal/satellite/store/oci.go @@ -10,8 +10,8 @@ import ( "strings" "sync" - "github.com/container-registry/harbor-satellite/internal/logger" satTLS "github.com/container-registry/harbor-satellite/internal/satellite/tls" + "github.com/container-registry/harbor-satellite/internal/shared/logger" "github.com/container-registry/harbor-satellite/pkg/config" oras "oras.land/oras-go/v2" "oras.land/oras-go/v2/content/oci" diff --git a/internal/satellite/store/registry.go b/internal/satellite/store/registry.go index 8613c66e4..ff1b4939b 100644 --- a/internal/satellite/store/registry.go +++ b/internal/satellite/store/registry.go @@ -6,8 +6,8 @@ import ( "fmt" "net/http" - "github.com/container-registry/harbor-satellite/internal/logger" satTLS "github.com/container-registry/harbor-satellite/internal/satellite/tls" + "github.com/container-registry/harbor-satellite/internal/shared/logger" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/crane" "github.com/google/go-containerregistry/pkg/name" diff --git a/internal/satellite/store/registry_test.go b/internal/satellite/store/registry_test.go index 4837e41a3..50849a626 100644 --- a/internal/satellite/store/registry_test.go +++ b/internal/satellite/store/registry_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/container-registry/harbor-satellite/internal/logger" + "github.com/container-registry/harbor-satellite/internal/shared/logger" "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/registry" v1 "github.com/google/go-containerregistry/pkg/v1" diff --git a/internal/crypto/aes_provider.go b/internal/shared/crypto/aes_provider.go similarity index 100% rename from internal/crypto/aes_provider.go rename to internal/shared/crypto/aes_provider.go diff --git a/internal/crypto/aes_provider_test.go b/internal/shared/crypto/aes_provider_test.go similarity index 100% rename from internal/crypto/aes_provider_test.go rename to internal/shared/crypto/aes_provider_test.go diff --git a/internal/crypto/argon2.go b/internal/shared/crypto/argon2.go similarity index 100% rename from internal/crypto/argon2.go rename to internal/shared/crypto/argon2.go diff --git a/internal/crypto/argon2_test.go b/internal/shared/crypto/argon2_test.go similarity index 100% rename from internal/crypto/argon2_test.go rename to internal/shared/crypto/argon2_test.go diff --git a/internal/crypto/mock.go b/internal/shared/crypto/mock.go similarity index 100% rename from internal/crypto/mock.go rename to internal/shared/crypto/mock.go diff --git a/internal/crypto/provider.go b/internal/shared/crypto/provider.go similarity index 100% rename from internal/crypto/provider.go rename to internal/shared/crypto/provider.go diff --git a/internal/crypto/provider_stub.go b/internal/shared/crypto/provider_stub.go similarity index 100% rename from internal/crypto/provider_stub.go rename to internal/shared/crypto/provider_stub.go diff --git a/internal/crypto/provider_test.go b/internal/shared/crypto/provider_test.go similarity index 100% rename from internal/crypto/provider_test.go rename to internal/shared/crypto/provider_test.go diff --git a/internal/env/env.go b/internal/shared/env/env.go similarity index 100% rename from internal/env/env.go rename to internal/shared/env/env.go diff --git a/internal/env/env_test.go b/internal/shared/env/env_test.go similarity index 100% rename from internal/env/env_test.go rename to internal/shared/env/env_test.go diff --git a/internal/env/ground-control.go b/internal/shared/env/ground-control.go similarity index 100% rename from internal/env/ground-control.go rename to internal/shared/env/ground-control.go diff --git a/internal/env/harbor-satellite.go b/internal/shared/env/harbor-satellite.go similarity index 100% rename from internal/env/harbor-satellite.go rename to internal/shared/env/harbor-satellite.go diff --git a/internal/env/utils.go b/internal/shared/env/utils.go similarity index 99% rename from internal/env/utils.go rename to internal/shared/env/utils.go index 6a5841790..1d6ee19c6 100644 --- a/internal/env/utils.go +++ b/internal/shared/env/utils.go @@ -4,7 +4,7 @@ import ( "fmt" "net" - auditlog "github.com/container-registry/harbor-satellite/internal/groundcontrol/logger" + auditlog "github.com/container-registry/harbor-satellite/internal/shared/logger" ) func (d Database) URL() string { diff --git a/internal/logger/audit.go b/internal/shared/logger/audit.go similarity index 100% rename from internal/logger/audit.go rename to internal/shared/logger/audit.go diff --git a/internal/logger/audit_test.go b/internal/shared/logger/audit_test.go similarity index 100% rename from internal/logger/audit_test.go rename to internal/shared/logger/audit_test.go diff --git a/internal/logger/logger.go b/internal/shared/logger/logger.go similarity index 97% rename from internal/logger/logger.go rename to internal/shared/logger/logger.go index 8e5142d40..0da25d03a 100644 --- a/internal/logger/logger.go +++ b/internal/shared/logger/logger.go @@ -6,7 +6,7 @@ import ( "os" "strings" - "github.com/container-registry/harbor-satellite/internal/utils" + "github.com/container-registry/harbor-satellite/internal/shared/utils" "github.com/rs/zerolog" ) diff --git a/internal/logger/otel.go b/internal/shared/logger/otel.go similarity index 100% rename from internal/logger/otel.go rename to internal/shared/logger/otel.go diff --git a/internal/logger/otel_test.go b/internal/shared/logger/otel_test.go similarity index 100% rename from internal/logger/otel_test.go rename to internal/shared/logger/otel_test.go diff --git a/internal/logger/syslog.go b/internal/shared/logger/syslog.go similarity index 100% rename from internal/logger/syslog.go rename to internal/shared/logger/syslog.go diff --git a/internal/logger/syslog_test.go b/internal/shared/logger/syslog_test.go similarity index 100% rename from internal/logger/syslog_test.go rename to internal/shared/logger/syslog_test.go diff --git a/internal/spiffe/client.go b/internal/shared/spiffe/client.go similarity index 100% rename from internal/spiffe/client.go rename to internal/shared/spiffe/client.go diff --git a/internal/spiffe/client_stub.go b/internal/shared/spiffe/client_stub.go similarity index 100% rename from internal/spiffe/client_stub.go rename to internal/shared/spiffe/client_stub.go diff --git a/internal/utils/folder.go b/internal/shared/utils/folder.go similarity index 100% rename from internal/utils/folder.go rename to internal/shared/utils/folder.go diff --git a/internal/utils/utils.go b/internal/shared/utils/utils.go similarity index 100% rename from internal/utils/utils.go rename to internal/shared/utils/utils.go diff --git a/pkg/config/manager.go b/pkg/config/manager.go index 48c7a4b0e..7f1790129 100644 --- a/pkg/config/manager.go +++ b/pkg/config/manager.go @@ -10,9 +10,9 @@ import ( "strings" "sync" - "github.com/container-registry/harbor-satellite/internal/crypto" "github.com/container-registry/harbor-satellite/internal/satellite/identity" "github.com/container-registry/harbor-satellite/internal/satellite/secure" + "github.com/container-registry/harbor-satellite/internal/shared/crypto" ) type ConfigChangeType string From 30fce793ccc9727432f494f2b8e07926af82ba24 Mon Sep 17 00:00:00 2001 From: cotishq Date: Tue, 11 Aug 2026 20:57:57 +0530 Subject: [PATCH 2/4] docs: align internal shared package migration ADR Signed-off-by: cotishq --- ...ground-control-internal-package-migration.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/decisions/ground-control-internal-package-migration.md b/docs/decisions/ground-control-internal-package-migration.md index a8df5b810..2370dff23 100644 --- a/docs/decisions/ground-control-internal-package-migration.md +++ b/docs/decisions/ground-control-internal-package-migration.md @@ -25,15 +25,12 @@ harbor-satellite/ ├── internal/ │ ├── satellite/ │ ├── groundcontrol/ -│ ├── auth/ -│ ├── database/ -│ ├── harborhealth/ -│ ├── middleware/ -│ ├── models/ -│ ├── server/ -│ ├── spiffe/ -│ ├── logger/ -│ ├── crypto/ +│ ├── shared/ +│ │ ├── crypto/ +│ │ ├── env/ +│ │ ├── logger/ +│ │ ├── spiffe/ +│ │ └── utils/ │ └── ... ├── pkg/ └── go.mod @@ -59,7 +56,7 @@ harbor-satellite/ ### Phase 2: Refactor Satellite Internal Packages - [x] Move satellite-specific packages from `internal/*` into `internal/satellite/*`. -- [x] Keep cross-cutting packages used by both binaries at the root of `internal`. +- [x] Keep cross-cutting packages used by both binaries under `internal/shared/*`. - [x] Update satellite imports to use `github.com/container-registry/harbor-satellite/internal/satellite/...`. - [x] Run satellite package tests from the root module. From 196bb0a48f0c4bdf58ae5cb33a29e88b1f031010 Mon Sep 17 00:00:00 2001 From: cotishq Date: Thu, 13 Aug 2026 23:18:52 +0530 Subject: [PATCH 3/4] docs: align ADR guidelines and add reference Signed-off-by: cotishq --- CONTRIBUTING.md | 8 ++++---- .../ground-control-internal-package-migration.md | 5 +++-- docs/guides/ground-control.md | 9 +++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5238303bd..c70e735c2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,8 +32,8 @@ This repository uses a single Go module at the root, with two binaries: | Path | Purpose | |---|---| -| `cmd/harbor-satellite/` | Satellite edge daemon - CLI, config, registry, state replication | -| `cmd/ground-control/` | Ground Control cloud service - satellite management, Harbor integration, PostgreSQL | +| `cmd/satellite/` | Satellite edge daemon - CLI, config, registry, state replication | +| `cmd/groundcontrol/` | Ground Control cloud service (server and CLI) - satellite management, Harbor integration, PostgreSQL | Run all Go commands from the repository root. @@ -48,10 +48,10 @@ task _build:satellite task _build:ground-control # Run the satellite directly -go run cmd/harbor-satellite/main.go --token "" --ground-control-url "http://127.0.0.1:8080" +go run cmd/satellite/main.go --token "" --ground-control-url "http://127.0.0.1:8080" # Run Ground Control directly (requires a configured .env file) -go run cmd/ground-control/main.go +go run cmd/groundcontrol/server/main.go ``` For Ground Control local setup, copy `.env.example` to `.env` and fill in the required values. diff --git a/docs/decisions/ground-control-internal-package-migration.md b/docs/decisions/ground-control-internal-package-migration.md index 2370dff23..6d8dd46cf 100644 --- a/docs/decisions/ground-control-internal-package-migration.md +++ b/docs/decisions/ground-control-internal-package-migration.md @@ -35,14 +35,15 @@ harbor-satellite/ ├── pkg/ └── go.mod ``` +> **Note:** This layout has been superseded by issue #593. ## Design Guidelines - Keep exactly one Go module at the repository root. - Move executable entrypoints into `cmd//main.go`. - Keep `cmd` packages thin. They should only parse configuration, initialize dependencies, and call internal application code. -- Prefer `internal/satellite` and `internal/groundcontrol` for binary-specific application logic. -- Avoid a generic catch-all package under `internal/shared`. Shared code should live in packages named after the behavior or domain they own, such as `internal/shared/logger`, `internal/shared/spiffe`, `internal/auth`, or `internal/database`. +- Prefer `internal/satellite` and `internal/groundcontrol` for binary-specific application logic (such as `internal/groundcontrol/auth` or `internal/groundcontrol/database`). +- Avoid a generic catch-all package under `internal/shared`. Shared code should live in packages named after the behavior or domain they own, such as `internal/shared/logger`, `internal/shared/spiffe`, `internal/shared/crypto`, or `internal/shared/env`. - Keep code in `pkg` only when it is intentionally public and stable for external consumers. Code used only by repository binaries should live under `internal`. ## Migration Plan diff --git a/docs/guides/ground-control.md b/docs/guides/ground-control.md index dc5d91255..b4607bf0d 100644 --- a/docs/guides/ground-control.md +++ b/docs/guides/ground-control.md @@ -2,11 +2,11 @@ Ground Control is the cloud-side management service for Harbor Satellite. It manages satellites, groups, configs, registration, desired state, status reporting, and Harbor integration. -Ground Control is part of the single Go module at the repository root. Its code lives under `internal/groundcontrol/` with the entrypoint in `cmd/ground-control/main.go`. Run all Go commands from the repository root. +Ground Control is part of the single Go module at the repository root. Its code lives under `internal/groundcontrol/` with the entrypoint in `cmd/groundcontrol/server/main.go`. Run all Go commands from the repository root. ## What It Starts -`cmd/ground-control/main.go` performs the Ground Control startup sequence: +`cmd/groundcontrol/server/main.go` performs the Ground Control startup sequence: - Checks Harbor health - Runs PostgreSQL migrations @@ -22,7 +22,7 @@ Populate the required environment variables first. For local development, use `. Run Ground Control locally from the repository root: ```bash -go run cmd/ground-control/main.go +go run cmd/groundcontrol/server/main.go ``` Run Ground Control tests: @@ -59,7 +59,8 @@ Key groups include: ## Directory Guide -- `cmd/ground-control/main.go` - service entrypoint +- `cmd/groundcontrol/server/main.go` - service entrypoint +- `cmd/groundcontrol/cli/root.go` - CLI entrypoint - `internal/groundcontrol/server` - routes, handlers, auth middleware, bootstrap, cleanup, and status APIs - `internal/groundcontrol/database` - sqlc-generated database access code - `internal/groundcontrol/sql/schema` - PostgreSQL migrations From 5198af1d663e46ae797ab37ee150c982aaae2507 Mon Sep 17 00:00:00 2001 From: cotishq Date: Sun, 16 Aug 2026 15:51:04 +0530 Subject: [PATCH 4/4] docs: update spiffe state source paths Signed-off-by: cotishq --- docs/decisions/0005-spiffe-identity-and-security.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/decisions/0005-spiffe-identity-and-security.md b/docs/decisions/0005-spiffe-identity-and-security.md index d202ef45b..fe25f73ba 100644 --- a/docs/decisions/0005-spiffe-identity-and-security.md +++ b/docs/decisions/0005-spiffe-identity-and-security.md @@ -439,8 +439,8 @@ sequenceDiagram ## Source Files - `internal/satellite/satellite.go:35-55` - ZTR path selection -- `internal/state/spiffe_registration.go` - SPIFFE ZTR process -- `internal/state/registration_process.go` - Token ZTR process +- `internal/satellite/state/spiffe_registration.go` - SPIFFE ZTR process +- `internal/satellite/state/registration_process.go` - Token ZTR process - `internal/shared/spiffe/client.go` - Workload API client - `internal/identity/device_linux.go` - Device fingerprinting - `internal/shared/crypto/aes_provider.go` - AES encryption