Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ jobs:

- name: Build
run: make build

- name: Check gofmt
run: |
set -euo pipefail
go_files="$(git ls-files '*.go')"
if [ -z "$go_files" ]; then
exit 0
fi
unformatted="$(echo "$go_files" | xargs gofmt -l)"
if [ -n "$unformatted" ]; then
echo "The following files are not gofmt-formatted:"
echo "$unformatted"
exit 1
fi

- name: Run tests
env:
Expand Down Expand Up @@ -87,6 +101,21 @@ jobs:
run: make oapi-generate
- name: Build
run: make build

- name: Check gofmt
run: |
set -euo pipefail
go_files="$(git ls-files '*.go')"
if [ -z "$go_files" ]; then
exit 0
fi
unformatted="$(echo "$go_files" | xargs gofmt -l)"
if [ -n "$unformatted" ]; then
echo "The following files are not gofmt-formatted:"
echo "$unformatted"
exit 1
fi

- name: Run tests
env:
DEFAULT_HYPERVISOR: vz
Expand Down
2 changes: 0 additions & 2 deletions cmd/api/api/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,3 @@ func availableDeviceToOAPI(d devices.AvailableDevice) oapi.AvailableDevice {
CurrentDriver: d.CurrentDriver,
}
}


1 change: 0 additions & 1 deletion cmd/api/api/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ func (s *ApiService) GetHealth(ctx context.Context, request oapi.GetHealthReques
Status: oapi.Ok,
}, nil
}

1 change: 0 additions & 1 deletion cmd/api/api/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ func SwaggerUIHandler(w http.ResponseWriter, r *http.Request) {
</html>`
w.Write([]byte(html))
}

47 changes: 23 additions & 24 deletions cmd/api/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ type NetworkConfig struct {

// CaddyConfig holds Caddy reverse-proxy / ingress settings.
type CaddyConfig struct {
ListenAddress string `koanf:"listen_address"`
AdminAddress string `koanf:"admin_address"`
AdminPort int `koanf:"admin_port"`
InternalDNSPort int `koanf:"internal_dns_port"`
StopOnShutdown bool `koanf:"stop_on_shutdown"`
ListenAddress string `koanf:"listen_address"`
AdminAddress string `koanf:"admin_address"`
AdminPort int `koanf:"admin_port"`
InternalDNSPort int `koanf:"internal_dns_port"`
StopOnShutdown bool `koanf:"stop_on_shutdown"`
}

// ACMEConfig holds ACME / TLS certificate settings.
Expand Down Expand Up @@ -128,12 +128,12 @@ type RegistryConfig struct {

// LimitsConfig holds per-instance and aggregate resource limits.
type LimitsConfig struct {
MaxVcpusPerInstance int `koanf:"max_vcpus_per_instance"`
MaxMemoryPerInstance string `koanf:"max_memory_per_instance"`
MaxTotalVolumeStorage string `koanf:"max_total_volume_storage"`
MaxConcurrentBuilds int `koanf:"max_concurrent_builds"`
MaxOverlaySize string `koanf:"max_overlay_size"`
MaxImageStorage float64 `koanf:"max_image_storage"`
MaxVcpusPerInstance int `koanf:"max_vcpus_per_instance"`
MaxMemoryPerInstance string `koanf:"max_memory_per_instance"`
MaxTotalVolumeStorage string `koanf:"max_total_volume_storage"`
MaxConcurrentBuilds int `koanf:"max_concurrent_builds"`
MaxOverlaySize string `koanf:"max_overlay_size"`
MaxImageStorage float64 `koanf:"max_image_storage"`
}

// OversubscriptionConfig holds oversubscription ratios (1.0 = no oversubscription).
Expand Down Expand Up @@ -170,19 +170,19 @@ type Config struct {
Env string `koanf:"env"`
Version string `koanf:"version"`

Network NetworkConfig `koanf:"network"`
Caddy CaddyConfig `koanf:"caddy"`
ACME ACMEConfig `koanf:"acme"`
API APIConfig `koanf:"api"`
Otel OtelConfig `koanf:"otel"`
Logging LoggingConfig `koanf:"logging"`
Build BuildConfig `koanf:"build"`
Registry RegistryConfig `koanf:"registry"`
Limits LimitsConfig `koanf:"limits"`
Network NetworkConfig `koanf:"network"`
Caddy CaddyConfig `koanf:"caddy"`
ACME ACMEConfig `koanf:"acme"`
API APIConfig `koanf:"api"`
Otel OtelConfig `koanf:"otel"`
Logging LoggingConfig `koanf:"logging"`
Build BuildConfig `koanf:"build"`
Registry RegistryConfig `koanf:"registry"`
Limits LimitsConfig `koanf:"limits"`
Oversubscription OversubscriptionConfig `koanf:"oversubscription"`
Capacity CapacityConfig `koanf:"capacity"`
Hypervisor HypervisorConfig `koanf:"hypervisor"`
GPU GPUConfig `koanf:"gpu"`
Capacity CapacityConfig `koanf:"capacity"`
Hypervisor HypervisorConfig `koanf:"hypervisor"`
GPU GPUConfig `koanf:"gpu"`
}

// GetDefaultConfigPaths returns the default config file paths to search.
Expand All @@ -201,7 +201,6 @@ func GetDefaultConfigPaths() []string {
}
}


// defaultConfig returns a Config struct with all default values set.
func defaultConfig() *Config {
return &Config{
Expand Down
1 change: 0 additions & 1 deletion cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,3 @@ func run() error {
slog.Info("all goroutines finished")
return err
}

13 changes: 6 additions & 7 deletions lib/builds/builder_agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type BuildConfig struct {
Secrets []SecretRef `json:"secrets,omitempty"`
TimeoutSeconds int `json:"timeout_seconds"`
NetworkMode string `json:"network_mode"`
IsAdminBuild bool `json:"is_admin_build,omitempty"`
GlobalCacheKey string `json:"global_cache_key,omitempty"`
IsAdminBuild bool `json:"is_admin_build,omitempty"`
GlobalCacheKey string `json:"global_cache_key,omitempty"`
}

// SecretRef references a secret to inject during build
Expand Down Expand Up @@ -599,8 +599,8 @@ func setupRegistryAuth(config *BuildConfig) error {
dockerConfig := map[string]interface{}{
"auths": map[string]interface{}{
registryHost: map[string]string{
"auth": authValue, // Basic auth: base64(jwt:)
"identitytoken": token, // JWT directly for OAuth2-style auth
"auth": authValue, // Basic auth: base64(jwt:)
"identitytoken": token, // JWT directly for OAuth2-style auth
},
},
"credsStore": "",
Expand Down Expand Up @@ -888,8 +888,8 @@ func runBuild(ctx context.Context, config *BuildConfig, logWriter io.Writer) (st
env := make([]string, 0, len(os.Environ())+3)
for _, e := range os.Environ() {
if !strings.HasPrefix(e, "DOCKER_CONFIG=") &&
!strings.HasPrefix(e, "BUILDKITD_FLAGS=") &&
!strings.HasPrefix(e, "HOME=") {
!strings.HasPrefix(e, "BUILDKITD_FLAGS=") &&
!strings.HasPrefix(e, "HOME=") {
env = append(env, e)
}
}
Expand Down Expand Up @@ -999,4 +999,3 @@ func getBuildkitVersion() string {
out, _ := cmd.Output()
return strings.TrimSpace(string(out))
}

2 changes: 0 additions & 2 deletions lib/builds/file_secret_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,3 @@ func (p *FileSecretProvider) GetSecrets(ctx context.Context, secretIDs []string)

// Ensure FileSecretProvider implements SecretProvider
var _ SecretProvider = (*FileSecretProvider)(nil)


2 changes: 0 additions & 2 deletions lib/builds/file_secret_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,3 @@ func TestNoOpSecretProvider(t *testing.T) {
require.NoError(t, err)
assert.Empty(t, secrets)
}


1 change: 0 additions & 1 deletion lib/builds/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,3 @@ func (m *Metrics) RegisterQueueCallbacks(queue *BuildQueue, meter metric.Meter)
)
return err
}

1 change: 0 additions & 1 deletion lib/builds/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,3 @@ func (q *BuildQueue) QueueLength() int {
defer q.mu.Unlock()
return len(q.active) + len(q.pending)
}

1 change: 0 additions & 1 deletion lib/builds/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,3 @@ func TestBuildQueue_Counts(t *testing.T) {

close(done)
}

4 changes: 2 additions & 2 deletions lib/builds/registry_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ func TestRegistryTokenClaims_RepoAccess(t *testing.T) {
})

t.Run("IsPullAllowedForRepo", func(t *testing.T) {
assert.True(t, claims.IsPullAllowedForRepo("builds/abc123")) // push implies pull
assert.True(t, claims.IsPullAllowedForRepo("builds/abc123")) // push implies pull
assert.True(t, claims.IsPullAllowedForRepo("cache/global/node"))
assert.True(t, claims.IsPullAllowedForRepo("cache/tenant-x")) // push implies pull
assert.True(t, claims.IsPullAllowedForRepo("cache/tenant-x")) // push implies pull
assert.False(t, claims.IsPullAllowedForRepo("builds/other"))
})

Expand Down
2 changes: 0 additions & 2 deletions lib/devices/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ var (
// ErrIOMMUGroupConflict is returned when not all devices in IOMMU group can be passed through
ErrIOMMUGroupConflict = errors.New("IOMMU group contains other devices that must also be passed through")
)


2 changes: 1 addition & 1 deletion lib/devices/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"sync"
"time"

"github.com/nrednav/cuid2"
"github.com/kernel/hypeman/lib/logger"
"github.com/kernel/hypeman/lib/paths"
"github.com/nrednav/cuid2"
)

// InstanceLivenessChecker provides a way to check if an instance is running.
Expand Down
2 changes: 0 additions & 2 deletions lib/devices/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,3 @@ func TestErrors(t *testing.T) {
assert.Contains(t, ErrInvalidName.Error(), "pattern")
})
}


Loading