refactor(pkg): update manifest package and dependencies for clean architecture
- Update go.mod dependencies for mockery and testing - Refactor manifest annotations and types packages - Update test utilities for new architecture
- commit
- 0453d8d356730b7136c77ae7a206df2b428c0264
- author
- brice · · 2026-01-12 17:05 UTC
- committer
- brice · · 2026-01-12 19:09 UTC
- parent
- 51f38f9
- signature
- unsigned
8 files · +154 -152
M go.mod +26 -23
| @@ -1,18 +1,24 @@ | |||
| 1 | 1 | module gordon | |
| 2 | 2 | ||
| 3 | - | go 1.24.3 | |
| 3 | + | go 1.25.5 | |
| 4 | 4 | ||
| 5 | 5 | require ( | |
| 6 | + | github.com/bnema/zerowrap v1.3.0 | |
| 6 | 7 | github.com/docker/docker v28.3.3+incompatible | |
| 7 | 8 | github.com/docker/go-connections v0.5.0 | |
| 8 | 9 | github.com/google/uuid v1.6.0 | |
| 9 | 10 | github.com/rs/zerolog v1.34.0 | |
| 10 | - | github.com/spf13/cobra v1.9.1 | |
| 11 | - | github.com/spf13/viper v1.20.1 | |
| 12 | - | github.com/stretchr/testify v1.10.0 | |
| 11 | + | github.com/spf13/cobra v1.10.2 | |
| 12 | + | github.com/spf13/viper v1.21.0 | |
| 13 | + | github.com/stretchr/testify v1.11.1 | |
| 13 | 14 | gopkg.in/natefinch/lumberjack.v2 v2.2.1 | |
| 14 | 15 | ) | |
| 15 | 16 | ||
| 17 | + | require ( | |
| 18 | + | github.com/cespare/xxhash/v2 v2.3.0 // indirect | |
| 19 | + | go.yaml.in/yaml/v3 v3.0.4 // indirect | |
| 20 | + | ) | |
| 21 | + | ||
| 16 | 22 | require ( | |
| 17 | 23 | github.com/davecgh/go-spew v1.1.1 // indirect | |
| 18 | 24 | github.com/pmezard/go-difflib v1.0.0 // indirect | |
| @@ -29,39 +35,36 @@ require ( | |||
| 29 | 35 | github.com/distribution/reference v0.6.0 // indirect | |
| 30 | 36 | github.com/docker/go-units v0.5.0 // indirect | |
| 31 | 37 | github.com/felixge/httpsnoop v1.0.4 // indirect | |
| 32 | - | github.com/fsnotify/fsnotify v1.8.0 // direct | |
| 33 | - | github.com/go-logr/logr v1.4.2 // indirect | |
| 38 | + | github.com/fsnotify/fsnotify v1.9.0 // direct | |
| 39 | + | github.com/go-logr/logr v1.4.3 // indirect | |
| 34 | 40 | github.com/go-logr/stdr v1.2.2 // indirect | |
| 35 | - | github.com/go-viper/mapstructure/v2 v2.4.0 // indirect | |
| 41 | + | github.com/go-viper/mapstructure/v2 v2.5.0 // indirect | |
| 36 | 42 | github.com/gogo/protobuf v1.3.2 // indirect | |
| 37 | 43 | github.com/inconshreveable/mousetrap v1.1.0 // indirect | |
| 38 | - | github.com/mattn/go-colorable v0.1.13 // indirect | |
| 39 | - | github.com/mattn/go-isatty v0.0.19 // indirect | |
| 44 | + | github.com/mattn/go-colorable v0.1.14 // indirect | |
| 45 | + | github.com/mattn/go-isatty v0.0.20 // indirect | |
| 40 | 46 | github.com/moby/docker-image-spec v1.3.1 // indirect | |
| 41 | 47 | github.com/moby/sys/atomicwriter v0.1.0 // indirect | |
| 42 | 48 | github.com/moby/term v0.5.2 // indirect | |
| 43 | 49 | github.com/morikuni/aec v1.0.0 // indirect | |
| 44 | 50 | github.com/opencontainers/go-digest v1.0.0 // indirect | |
| 45 | 51 | github.com/opencontainers/image-spec v1.1.1 // indirect | |
| 46 | - | github.com/pelletier/go-toml/v2 v2.2.3 // indirect | |
| 52 | + | github.com/pelletier/go-toml/v2 v2.2.4 // indirect | |
| 47 | 53 | github.com/pkg/errors v0.9.1 // indirect | |
| 48 | - | github.com/sagikazarmark/locafero v0.7.0 // indirect | |
| 49 | - | github.com/sourcegraph/conc v0.3.0 // indirect | |
| 50 | - | github.com/spf13/afero v1.14.0 | |
| 51 | - | github.com/spf13/cast v1.7.1 // indirect | |
| 52 | - | github.com/spf13/pflag v1.0.6 // indirect | |
| 54 | + | github.com/sagikazarmark/locafero v0.12.0 // indirect | |
| 55 | + | github.com/spf13/afero v1.15.0 | |
| 56 | + | github.com/spf13/cast v1.10.0 // indirect | |
| 57 | + | github.com/spf13/pflag v1.0.10 // indirect | |
| 53 | 58 | github.com/subosito/gotenv v1.6.0 // indirect | |
| 54 | - | go.opentelemetry.io/auto/sdk v1.1.0 // indirect | |
| 59 | + | go.opentelemetry.io/auto/sdk v1.2.1 // indirect | |
| 55 | 60 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect | |
| 56 | - | go.opentelemetry.io/otel v1.36.0 // indirect | |
| 61 | + | go.opentelemetry.io/otel v1.39.0 // indirect | |
| 57 | 62 | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.36.0 // indirect | |
| 58 | - | go.opentelemetry.io/otel/metric v1.36.0 // indirect | |
| 63 | + | go.opentelemetry.io/otel/metric v1.39.0 // indirect | |
| 59 | 64 | go.opentelemetry.io/otel/sdk v1.36.0 // indirect | |
| 60 | - | go.opentelemetry.io/otel/trace v1.36.0 // indirect | |
| 61 | - | go.uber.org/atomic v1.9.0 // indirect | |
| 62 | - | go.uber.org/multierr v1.9.0 // indirect | |
| 63 | - | golang.org/x/sys v0.33.0 // indirect | |
| 64 | - | golang.org/x/text v0.26.0 // indirect | |
| 65 | + | go.opentelemetry.io/otel/trace v1.39.0 // indirect | |
| 66 | + | golang.org/x/sys v0.40.0 // indirect | |
| 67 | + | golang.org/x/text v0.33.0 // indirect | |
| 65 | 68 | gopkg.in/yaml.v3 v3.0.1 // indirect | |
| 66 | 69 | gotest.tools/v3 v3.5.2 // indirect | |
| 67 | 70 | ) | |
| @@ -1,18 +1,24 @@ | |||||
| 1 | module gordon | 1 | module gordon | ||
| 2 | 2 | ||||
| 3 | - | go 1.24.3 | 3 | + | go 1.25.5 |
| 4 | 4 | ||||
| 5 | require ( | 5 | require ( | ||
| 6 | + | github.com/bnema/zerowrap v1.3.0 | |||
| 6 | github.com/docker/docker v28.3.3+incompatible | 7 | github.com/docker/docker v28.3.3+incompatible | ||
| 7 | github.com/docker/go-connections v0.5.0 | 8 | github.com/docker/go-connections v0.5.0 | ||
| 8 | github.com/google/uuid v1.6.0 | 9 | github.com/google/uuid v1.6.0 | ||
| 9 | github.com/rs/zerolog v1.34.0 | 10 | github.com/rs/zerolog v1.34.0 | ||
| 10 | - | github.com/spf13/cobra v1.9.1 | 11 | + | github.com/spf13/cobra v1.10.2 |
| 11 | - | github.com/spf13/viper v1.20.1 | 12 | + | github.com/spf13/viper v1.21.0 |
| 12 | - | github.com/stretchr/testify v1.10.0 | 13 | + | github.com/stretchr/testify v1.11.1 |
| 13 | gopkg.in/natefinch/lumberjack.v2 v2.2.1 | 14 | gopkg.in/natefinch/lumberjack.v2 v2.2.1 | ||
| 14 | ) | 15 | ) | ||
| 15 | 16 | ||||
| 17 | + | require ( | |||
| 18 | + | github.com/cespare/xxhash/v2 v2.3.0 // indirect | |||
| 19 | + | go.yaml.in/yaml/v3 v3.0.4 // indirect | |||
| 20 | + | ) | |||
| 21 | + | ||||
| 16 | require ( | 22 | require ( | ||
| 17 | github.com/davecgh/go-spew v1.1.1 // indirect | 23 | github.com/davecgh/go-spew v1.1.1 // indirect | ||
| 18 | github.com/pmezard/go-difflib v1.0.0 // indirect | 24 | github.com/pmezard/go-difflib v1.0.0 // indirect | ||
| @@ -29,39 +35,36 @@ require ( | |||||
| 29 | github.com/distribution/reference v0.6.0 // indirect | 35 | github.com/distribution/reference v0.6.0 // indirect | ||
| 30 | github.com/docker/go-units v0.5.0 // indirect | 36 | github.com/docker/go-units v0.5.0 // indirect | ||
| 31 | github.com/felixge/httpsnoop v1.0.4 // indirect | 37 | github.com/felixge/httpsnoop v1.0.4 // indirect | ||
| 32 | - | github.com/fsnotify/fsnotify v1.8.0 // direct | 38 | + | github.com/fsnotify/fsnotify v1.9.0 // direct |
| 33 | - | github.com/go-logr/logr v1.4.2 // indirect | 39 | + | github.com/go-logr/logr v1.4.3 // indirect |
| 34 | github.com/go-logr/stdr v1.2.2 // indirect | 40 | github.com/go-logr/stdr v1.2.2 // indirect | ||
| 35 | - | github.com/go-viper/mapstructure/v2 v2.4.0 // indirect | 41 | + | github.com/go-viper/mapstructure/v2 v2.5.0 // indirect |
| 36 | github.com/gogo/protobuf v1.3.2 // indirect | 42 | github.com/gogo/protobuf v1.3.2 // indirect | ||
| 37 | github.com/inconshreveable/mousetrap v1.1.0 // indirect | 43 | github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
| 38 | - | github.com/mattn/go-colorable v0.1.13 // indirect | 44 | + | github.com/mattn/go-colorable v0.1.14 // indirect |
| 39 | - | github.com/mattn/go-isatty v0.0.19 // indirect | 45 | + | github.com/mattn/go-isatty v0.0.20 // indirect |
| 40 | github.com/moby/docker-image-spec v1.3.1 // indirect | 46 | github.com/moby/docker-image-spec v1.3.1 // indirect | ||
| 41 | github.com/moby/sys/atomicwriter v0.1.0 // indirect | 47 | github.com/moby/sys/atomicwriter v0.1.0 // indirect | ||
| 42 | github.com/moby/term v0.5.2 // indirect | 48 | github.com/moby/term v0.5.2 // indirect | ||
| 43 | github.com/morikuni/aec v1.0.0 // indirect | 49 | github.com/morikuni/aec v1.0.0 // indirect | ||
| 44 | github.com/opencontainers/go-digest v1.0.0 // indirect | 50 | github.com/opencontainers/go-digest v1.0.0 // indirect | ||
| 45 | github.com/opencontainers/image-spec v1.1.1 // indirect | 51 | github.com/opencontainers/image-spec v1.1.1 // indirect | ||
| 46 | - | github.com/pelletier/go-toml/v2 v2.2.3 // indirect | 52 | + | github.com/pelletier/go-toml/v2 v2.2.4 // indirect |
| 47 | github.com/pkg/errors v0.9.1 // indirect | 53 | github.com/pkg/errors v0.9.1 // indirect | ||
| 48 | - | github.com/sagikazarmark/locafero v0.7.0 // indirect | 54 | + | github.com/sagikazarmark/locafero v0.12.0 // indirect |
| 49 | - | github.com/sourcegraph/conc v0.3.0 // indirect | 55 | + | github.com/spf13/afero v1.15.0 |
| 50 | - | github.com/spf13/afero v1.14.0 | 56 | + | github.com/spf13/cast v1.10.0 // indirect |
| 51 | - | github.com/spf13/cast v1.7.1 // indirect | 57 | + | github.com/spf13/pflag v1.0.10 // indirect |
| 52 | - | github.com/spf13/pflag v1.0.6 // indirect | |||
| 53 | github.com/subosito/gotenv v1.6.0 // indirect | 58 | github.com/subosito/gotenv v1.6.0 // indirect | ||
| 54 | - | go.opentelemetry.io/auto/sdk v1.1.0 // indirect | 59 | + | go.opentelemetry.io/auto/sdk v1.2.1 // indirect |
| 55 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect | 60 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect | ||
| 56 | - | go.opentelemetry.io/otel v1.36.0 // indirect | 61 | + | go.opentelemetry.io/otel v1.39.0 // indirect |
| 57 | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.36.0 // indirect | 62 | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.36.0 // indirect | ||
| 58 | - | go.opentelemetry.io/otel/metric v1.36.0 // indirect | 63 | + | go.opentelemetry.io/otel/metric v1.39.0 // indirect |
| 59 | go.opentelemetry.io/otel/sdk v1.36.0 // indirect | 64 | go.opentelemetry.io/otel/sdk v1.36.0 // indirect | ||
| 60 | - | go.opentelemetry.io/otel/trace v1.36.0 // indirect | 65 | + | go.opentelemetry.io/otel/trace v1.39.0 // indirect |
| 61 | - | go.uber.org/atomic v1.9.0 // indirect | 66 | + | golang.org/x/sys v0.40.0 // indirect |
| 62 | - | go.uber.org/multierr v1.9.0 // indirect | 67 | + | golang.org/x/text v0.33.0 // indirect |
| 63 | - | golang.org/x/sys v0.33.0 // indirect | |||
| 64 | - | golang.org/x/text v0.26.0 // indirect | |||
| 65 | gopkg.in/yaml.v3 v3.0.1 // indirect | 68 | gopkg.in/yaml.v3 v3.0.1 // indirect | ||
| 66 | gotest.tools/v3 v3.5.2 // indirect | 69 | gotest.tools/v3 v3.5.2 // indirect | ||
| 67 | ) | 70 | ) | ||
M go.sum +47 -47 generated file: collapsed
M internal/testutils/helpers.go +1 -1
| @@ -80,4 +80,4 @@ port = 8080` | |||
| 80 | 80 | default: | |
| 81 | 81 | return content | |
| 82 | 82 | } | |
| 83 | - | }⏎̸ | |
| 83 | + | } | |
| @@ -80,4 +80,4 @@ port = 8080` | |||||
| 80 | default: | 80 | default: | ||
| 81 | return content | 81 | return content | ||
| 82 | } | 82 | } | ||
| 83 | - | }⏎̸ | 83 | + | } |
M pkg/manifest/annotations.go +6 -7
| @@ -14,7 +14,7 @@ func ParseManifestAnnotations(manifestData []byte, contentType string) (map[stri | |||
| 14 | 14 | // Docker v2.2 manifests don't support annotations at manifest level | |
| 15 | 15 | return map[string]string{}, nil | |
| 16 | 16 | case "application/vnd.oci.image.index.v1+json", | |
| 17 | - | "application/vnd.docker.distribution.manifest.list.v2+json": | |
| 17 | + | "application/vnd.docker.distribution.manifest.list.v2+json": | |
| 18 | 18 | return parseManifestListAnnotations(manifestData) | |
| 19 | 19 | default: | |
| 20 | 20 | return map[string]string{}, fmt.Errorf("unsupported manifest media type: %s", contentType) | |
| @@ -27,11 +27,11 @@ func parseOCIManifestAnnotations(manifestData []byte) (map[string]string, error) | |||
| 27 | 27 | if err := json.Unmarshal(manifestData, &manifest); err != nil { | |
| 28 | 28 | return nil, fmt.Errorf("failed to parse OCI manifest: %w", err) | |
| 29 | 29 | } | |
| 30 | - | ||
| 30 | + | ||
| 31 | 31 | if manifest.Annotations == nil { | |
| 32 | 32 | return map[string]string{}, nil | |
| 33 | 33 | } | |
| 34 | - | ||
| 34 | + | ||
| 35 | 35 | return manifest.Annotations, nil | |
| 36 | 36 | } | |
| 37 | 37 | ||
| @@ -41,11 +41,11 @@ func parseManifestListAnnotations(manifestData []byte) (map[string]string, error | |||
| 41 | 41 | if err := json.Unmarshal(manifestData, &manifestList); err != nil { | |
| 42 | 42 | return nil, fmt.Errorf("failed to parse manifest list: %w", err) | |
| 43 | 43 | } | |
| 44 | - | ||
| 44 | + | ||
| 45 | 45 | if manifestList.Annotations == nil { | |
| 46 | 46 | return map[string]string{}, nil | |
| 47 | 47 | } | |
| 48 | - | ||
| 48 | + | ||
| 49 | 49 | return manifestList.Annotations, nil | |
| 50 | 50 | } | |
| 51 | 51 | ||
| @@ -62,7 +62,6 @@ func GetDeploymentVersion(annotations map[string]string) string { | |||
| 62 | 62 | if version, exists := annotations["version"]; exists && version != "" { | |
| 63 | 63 | return version | |
| 64 | 64 | } | |
| 65 | - | ||
| 65 | + | ||
| 66 | 66 | return "" | |
| 67 | 67 | } | |
| 68 | - | ||
| @@ -14,7 +14,7 @@ func ParseManifestAnnotations(manifestData []byte, contentType string) (map[stri | |||||
| 14 | // Docker v2.2 manifests don't support annotations at manifest level | 14 | // Docker v2.2 manifests don't support annotations at manifest level | ||
| 15 | return map[string]string{}, nil | 15 | return map[string]string{}, nil | ||
| 16 | case "application/vnd.oci.image.index.v1+json", | 16 | case "application/vnd.oci.image.index.v1+json", | ||
| 17 | - | "application/vnd.docker.distribution.manifest.list.v2+json": | 17 | + | "application/vnd.docker.distribution.manifest.list.v2+json": |
| 18 | return parseManifestListAnnotations(manifestData) | 18 | return parseManifestListAnnotations(manifestData) | ||
| 19 | default: | 19 | default: | ||
| 20 | return map[string]string{}, fmt.Errorf("unsupported manifest media type: %s", contentType) | 20 | return map[string]string{}, fmt.Errorf("unsupported manifest media type: %s", contentType) | ||
| @@ -27,11 +27,11 @@ func parseOCIManifestAnnotations(manifestData []byte) (map[string]string, error) | |||||
| 27 | if err := json.Unmarshal(manifestData, &manifest); err != nil { | 27 | if err := json.Unmarshal(manifestData, &manifest); err != nil { | ||
| 28 | return nil, fmt.Errorf("failed to parse OCI manifest: %w", err) | 28 | return nil, fmt.Errorf("failed to parse OCI manifest: %w", err) | ||
| 29 | } | 29 | } | ||
| 30 | - | 30 | + | ||
| 31 | if manifest.Annotations == nil { | 31 | if manifest.Annotations == nil { | ||
| 32 | return map[string]string{}, nil | 32 | return map[string]string{}, nil | ||
| 33 | } | 33 | } | ||
| 34 | - | 34 | + | ||
| 35 | return manifest.Annotations, nil | 35 | return manifest.Annotations, nil | ||
| 36 | } | 36 | } | ||
| 37 | 37 | ||||
| @@ -41,11 +41,11 @@ func parseManifestListAnnotations(manifestData []byte) (map[string]string, error | |||||
| 41 | if err := json.Unmarshal(manifestData, &manifestList); err != nil { | 41 | if err := json.Unmarshal(manifestData, &manifestList); err != nil { | ||
| 42 | return nil, fmt.Errorf("failed to parse manifest list: %w", err) | 42 | return nil, fmt.Errorf("failed to parse manifest list: %w", err) | ||
| 43 | } | 43 | } | ||
| 44 | - | 44 | + | ||
| 45 | if manifestList.Annotations == nil { | 45 | if manifestList.Annotations == nil { | ||
| 46 | return map[string]string{}, nil | 46 | return map[string]string{}, nil | ||
| 47 | } | 47 | } | ||
| 48 | - | 48 | + | ||
| 49 | return manifestList.Annotations, nil | 49 | return manifestList.Annotations, nil | ||
| 50 | } | 50 | } | ||
| 51 | 51 | ||||
| @@ -62,7 +62,6 @@ func GetDeploymentVersion(annotations map[string]string) string { | |||||
| 62 | if version, exists := annotations["version"]; exists && version != "" { | 62 | if version, exists := annotations["version"]; exists && version != "" { | ||
| 63 | return version | 63 | return version | ||
| 64 | } | 64 | } | ||
| 65 | - | 65 | + | ||
| 66 | return "" | 66 | return "" | ||
| 67 | } | 67 | } | ||
| 68 | - | ||||
M pkg/manifest/annotations_test.go +27 -27
| @@ -10,12 +10,12 @@ import ( | |||
| 10 | 10 | ||
| 11 | 11 | func TestParseManifestAnnotations(t *testing.T) { | |
| 12 | 12 | tests := []struct { | |
| 13 | - | name string | |
| 14 | - | manifestData []byte | |
| 15 | - | contentType string | |
| 13 | + | name string | |
| 14 | + | manifestData []byte | |
| 15 | + | contentType string | |
| 16 | 16 | expectedAnnotations map[string]string | |
| 17 | - | expectedError bool | |
| 18 | - | errorContains string | |
| 17 | + | expectedError bool | |
| 18 | + | errorContains string | |
| 19 | 19 | }{ | |
| 20 | 20 | { | |
| 21 | 21 | name: "OCI manifest with annotations", | |
| @@ -53,7 +53,7 @@ func TestParseManifestAnnotations(t *testing.T) { | |||
| 53 | 53 | }, | |
| 54 | 54 | "layers": [] | |
| 55 | 55 | }`), | |
| 56 | - | contentType: "application/vnd.oci.image.manifest.v1+json", | |
| 56 | + | contentType: "application/vnd.oci.image.manifest.v1+json", | |
| 57 | 57 | expectedAnnotations: map[string]string{}, | |
| 58 | 58 | }, | |
| 59 | 59 | { | |
| @@ -69,7 +69,7 @@ func TestParseManifestAnnotations(t *testing.T) { | |||
| 69 | 69 | "layers": [], | |
| 70 | 70 | "annotations": {} | |
| 71 | 71 | }`), | |
| 72 | - | contentType: "application/vnd.oci.image.manifest.v1+json", | |
| 72 | + | contentType: "application/vnd.oci.image.manifest.v1+json", | |
| 73 | 73 | expectedAnnotations: map[string]string{}, | |
| 74 | 74 | }, | |
| 75 | 75 | { | |
| @@ -84,7 +84,7 @@ func TestParseManifestAnnotations(t *testing.T) { | |||
| 84 | 84 | }, | |
| 85 | 85 | "layers": [] | |
| 86 | 86 | }`), | |
| 87 | - | contentType: "application/vnd.docker.distribution.manifest.v2+json", | |
| 87 | + | contentType: "application/vnd.docker.distribution.manifest.v2+json", | |
| 88 | 88 | expectedAnnotations: map[string]string{}, | |
| 89 | 89 | }, | |
| 90 | 90 | { | |
| @@ -126,7 +126,7 @@ func TestParseManifestAnnotations(t *testing.T) { | |||
| 126 | 126 | "mediaType": "application/vnd.oci.image.index.v1+json", | |
| 127 | 127 | "manifests": [] | |
| 128 | 128 | }`), | |
| 129 | - | contentType: "application/vnd.oci.image.index.v1+json", | |
| 129 | + | contentType: "application/vnd.oci.image.index.v1+json", | |
| 130 | 130 | expectedAnnotations: map[string]string{}, | |
| 131 | 131 | }, | |
| 132 | 132 | { | |
| @@ -208,11 +208,11 @@ func TestParseManifestAnnotations(t *testing.T) { | |||
| 208 | 208 | ||
| 209 | 209 | func TestParseOCIManifestAnnotations(t *testing.T) { | |
| 210 | 210 | tests := []struct { | |
| 211 | - | name string | |
| 212 | - | manifestData []byte | |
| 211 | + | name string | |
| 212 | + | manifestData []byte | |
| 213 | 213 | expectedAnnotations map[string]string | |
| 214 | - | expectedError bool | |
| 215 | - | errorContains string | |
| 214 | + | expectedError bool | |
| 215 | + | errorContains string | |
| 216 | 216 | }{ | |
| 217 | 217 | { | |
| 218 | 218 | name: "valid OCI manifest with annotations", | |
| @@ -259,8 +259,8 @@ func TestParseOCIManifestAnnotations(t *testing.T) { | |||
| 259 | 259 | errorContains: "failed to parse OCI manifest", | |
| 260 | 260 | }, | |
| 261 | 261 | { | |
| 262 | - | name: "empty manifest data", | |
| 263 | - | manifestData: []byte(`{}`), | |
| 262 | + | name: "empty manifest data", | |
| 263 | + | manifestData: []byte(`{}`), | |
| 264 | 264 | expectedAnnotations: map[string]string{}, | |
| 265 | 265 | }, | |
| 266 | 266 | } | |
| @@ -284,11 +284,11 @@ func TestParseOCIManifestAnnotations(t *testing.T) { | |||
| 284 | 284 | ||
| 285 | 285 | func TestParseManifestListAnnotations(t *testing.T) { | |
| 286 | 286 | tests := []struct { | |
| 287 | - | name string | |
| 288 | - | manifestData []byte | |
| 287 | + | name string | |
| 288 | + | manifestData []byte | |
| 289 | 289 | expectedAnnotations map[string]string | |
| 290 | - | expectedError bool | |
| 291 | - | errorContains string | |
| 290 | + | expectedError bool | |
| 291 | + | errorContains string | |
| 292 | 292 | }{ | |
| 293 | 293 | { | |
| 294 | 294 | name: "valid manifest list with annotations", | |
| @@ -325,8 +325,8 @@ func TestParseManifestListAnnotations(t *testing.T) { | |||
| 325 | 325 | errorContains: "failed to parse manifest list", | |
| 326 | 326 | }, | |
| 327 | 327 | { | |
| 328 | - | name: "empty manifest list", | |
| 329 | - | manifestData: []byte(`{}`), | |
| 328 | + | name: "empty manifest list", | |
| 329 | + | manifestData: []byte(`{}`), | |
| 330 | 330 | expectedAnnotations: map[string]string{}, | |
| 331 | 331 | }, | |
| 332 | 332 | } | |
| @@ -406,9 +406,9 @@ func TestIsVersionedDeployment(t *testing.T) { | |||
| 406 | 406 | { | |
| 407 | 407 | name: "multiple version-like annotations", | |
| 408 | 408 | annotations: map[string]string{ | |
| 409 | - | "app-version": "1.0.0", | |
| 410 | - | "image-version": "2.0.0", | |
| 411 | - | "semver": "3.0.0", | |
| 409 | + | "app-version": "1.0.0", | |
| 410 | + | "image-version": "2.0.0", | |
| 411 | + | "semver": "3.0.0", | |
| 412 | 412 | }, | |
| 413 | 413 | expected: false, // Only exact "version" key should match | |
| 414 | 414 | }, | |
| @@ -638,8 +638,8 @@ func TestAnnotations_Integration(t *testing.T) { | |||
| 638 | 638 | }, | |
| 639 | 639 | Layers: []OCIDescriptor{}, | |
| 640 | 640 | Annotations: map[string]string{ | |
| 641 | - | "version": "1.0.0", | |
| 642 | - | "description": "Round trip test", | |
| 641 | + | "version": "1.0.0", | |
| 642 | + | "description": "Round trip test", | |
| 643 | 643 | }, | |
| 644 | 644 | } | |
| 645 | 645 | ||
| @@ -658,4 +658,4 @@ func TestAnnotations_Integration(t *testing.T) { | |||
| 658 | 658 | assert.True(t, IsVersionedDeployment(annotations)) | |
| 659 | 659 | assert.Equal(t, "1.0.0", GetDeploymentVersion(annotations)) | |
| 660 | 660 | }) | |
| 661 | - | }⏎̸ | |
| 661 | + | } | |
| @@ -10,12 +10,12 @@ import ( | |||||
| 10 | 10 | ||||
| 11 | func TestParseManifestAnnotations(t *testing.T) { | 11 | func TestParseManifestAnnotations(t *testing.T) { | ||
| 12 | tests := []struct { | 12 | tests := []struct { | ||
| 13 | - | name string | 13 | + | name string |
| 14 | - | manifestData []byte | 14 | + | manifestData []byte |
| 15 | - | contentType string | 15 | + | contentType string |
| 16 | expectedAnnotations map[string]string | 16 | expectedAnnotations map[string]string | ||
| 17 | - | expectedError bool | 17 | + | expectedError bool |
| 18 | - | errorContains string | 18 | + | errorContains string |
| 19 | }{ | 19 | }{ | ||
| 20 | { | 20 | { | ||
| 21 | name: "OCI manifest with annotations", | 21 | name: "OCI manifest with annotations", | ||
| @@ -53,7 +53,7 @@ func TestParseManifestAnnotations(t *testing.T) { | |||||
| 53 | }, | 53 | }, | ||
| 54 | "layers": [] | 54 | "layers": [] | ||
| 55 | }`), | 55 | }`), | ||
| 56 | - | contentType: "application/vnd.oci.image.manifest.v1+json", | 56 | + | contentType: "application/vnd.oci.image.manifest.v1+json", |
| 57 | expectedAnnotations: map[string]string{}, | 57 | expectedAnnotations: map[string]string{}, | ||
| 58 | }, | 58 | }, | ||
| 59 | { | 59 | { | ||
| @@ -69,7 +69,7 @@ func TestParseManifestAnnotations(t *testing.T) { | |||||
| 69 | "layers": [], | 69 | "layers": [], | ||
| 70 | "annotations": {} | 70 | "annotations": {} | ||
| 71 | }`), | 71 | }`), | ||
| 72 | - | contentType: "application/vnd.oci.image.manifest.v1+json", | 72 | + | contentType: "application/vnd.oci.image.manifest.v1+json", |
| 73 | expectedAnnotations: map[string]string{}, | 73 | expectedAnnotations: map[string]string{}, | ||
| 74 | }, | 74 | }, | ||
| 75 | { | 75 | { | ||
| @@ -84,7 +84,7 @@ func TestParseManifestAnnotations(t *testing.T) { | |||||
| 84 | }, | 84 | }, | ||
| 85 | "layers": [] | 85 | "layers": [] | ||
| 86 | }`), | 86 | }`), | ||
| 87 | - | contentType: "application/vnd.docker.distribution.manifest.v2+json", | 87 | + | contentType: "application/vnd.docker.distribution.manifest.v2+json", |
| 88 | expectedAnnotations: map[string]string{}, | 88 | expectedAnnotations: map[string]string{}, | ||
| 89 | }, | 89 | }, | ||
| 90 | { | 90 | { | ||
| @@ -126,7 +126,7 @@ func TestParseManifestAnnotations(t *testing.T) { | |||||
| 126 | "mediaType": "application/vnd.oci.image.index.v1+json", | 126 | "mediaType": "application/vnd.oci.image.index.v1+json", | ||
| 127 | "manifests": [] | 127 | "manifests": [] | ||
| 128 | }`), | 128 | }`), | ||
| 129 | - | contentType: "application/vnd.oci.image.index.v1+json", | 129 | + | contentType: "application/vnd.oci.image.index.v1+json", |
| 130 | expectedAnnotations: map[string]string{}, | 130 | expectedAnnotations: map[string]string{}, | ||
| 131 | }, | 131 | }, | ||
| 132 | { | 132 | { | ||
| @@ -208,11 +208,11 @@ func TestParseManifestAnnotations(t *testing.T) { | |||||
| 208 | 208 | ||||
| 209 | func TestParseOCIManifestAnnotations(t *testing.T) { | 209 | func TestParseOCIManifestAnnotations(t *testing.T) { | ||
| 210 | tests := []struct { | 210 | tests := []struct { | ||
| 211 | - | name string | 211 | + | name string |
| 212 | - | manifestData []byte | 212 | + | manifestData []byte |
| 213 | expectedAnnotations map[string]string | 213 | expectedAnnotations map[string]string | ||
| 214 | - | expectedError bool | 214 | + | expectedError bool |
| 215 | - | errorContains string | 215 | + | errorContains string |
| 216 | }{ | 216 | }{ | ||
| 217 | { | 217 | { | ||
| 218 | name: "valid OCI manifest with annotations", | 218 | name: "valid OCI manifest with annotations", | ||
| @@ -259,8 +259,8 @@ func TestParseOCIManifestAnnotations(t *testing.T) { | |||||
| 259 | errorContains: "failed to parse OCI manifest", | 259 | errorContains: "failed to parse OCI manifest", | ||
| 260 | }, | 260 | }, | ||
| 261 | { | 261 | { | ||
| 262 | - | name: "empty manifest data", | 262 | + | name: "empty manifest data", |
| 263 | - | manifestData: []byte(`{}`), | 263 | + | manifestData: []byte(`{}`), |
| 264 | expectedAnnotations: map[string]string{}, | 264 | expectedAnnotations: map[string]string{}, | ||
| 265 | }, | 265 | }, | ||
| 266 | } | 266 | } | ||
| @@ -284,11 +284,11 @@ func TestParseOCIManifestAnnotations(t *testing.T) { | |||||
| 284 | 284 | ||||
| 285 | func TestParseManifestListAnnotations(t *testing.T) { | 285 | func TestParseManifestListAnnotations(t *testing.T) { | ||
| 286 | tests := []struct { | 286 | tests := []struct { | ||
| 287 | - | name string | 287 | + | name string |
| 288 | - | manifestData []byte | 288 | + | manifestData []byte |
| 289 | expectedAnnotations map[string]string | 289 | expectedAnnotations map[string]string | ||
| 290 | - | expectedError bool | 290 | + | expectedError bool |
| 291 | - | errorContains string | 291 | + | errorContains string |
| 292 | }{ | 292 | }{ | ||
| 293 | { | 293 | { | ||
| 294 | name: "valid manifest list with annotations", | 294 | name: "valid manifest list with annotations", | ||
| @@ -325,8 +325,8 @@ func TestParseManifestListAnnotations(t *testing.T) { | |||||
| 325 | errorContains: "failed to parse manifest list", | 325 | errorContains: "failed to parse manifest list", | ||
| 326 | }, | 326 | }, | ||
| 327 | { | 327 | { | ||
| 328 | - | name: "empty manifest list", | 328 | + | name: "empty manifest list", |
| 329 | - | manifestData: []byte(`{}`), | 329 | + | manifestData: []byte(`{}`), |
| 330 | expectedAnnotations: map[string]string{}, | 330 | expectedAnnotations: map[string]string{}, | ||
| 331 | }, | 331 | }, | ||
| 332 | } | 332 | } | ||
| @@ -406,9 +406,9 @@ func TestIsVersionedDeployment(t *testing.T) { | |||||
| 406 | { | 406 | { | ||
| 407 | name: "multiple version-like annotations", | 407 | name: "multiple version-like annotations", | ||
| 408 | annotations: map[string]string{ | 408 | annotations: map[string]string{ | ||
| 409 | - | "app-version": "1.0.0", | 409 | + | "app-version": "1.0.0", |
| 410 | - | "image-version": "2.0.0", | 410 | + | "image-version": "2.0.0", |
| 411 | - | "semver": "3.0.0", | 411 | + | "semver": "3.0.0", |
| 412 | }, | 412 | }, | ||
| 413 | expected: false, // Only exact "version" key should match | 413 | expected: false, // Only exact "version" key should match | ||
| 414 | }, | 414 | }, | ||
| @@ -638,8 +638,8 @@ func TestAnnotations_Integration(t *testing.T) { | |||||
| 638 | }, | 638 | }, | ||
| 639 | Layers: []OCIDescriptor{}, | 639 | Layers: []OCIDescriptor{}, | ||
| 640 | Annotations: map[string]string{ | 640 | Annotations: map[string]string{ | ||
| 641 | - | "version": "1.0.0", | 641 | + | "version": "1.0.0", |
| 642 | - | "description": "Round trip test", | 642 | + | "description": "Round trip test", |
| 643 | }, | 643 | }, | ||
| 644 | } | 644 | } | ||
| 645 | 645 | ||||
| @@ -658,4 +658,4 @@ func TestAnnotations_Integration(t *testing.T) { | |||||
| 658 | assert.True(t, IsVersionedDeployment(annotations)) | 658 | assert.True(t, IsVersionedDeployment(annotations)) | ||
| 659 | assert.Equal(t, "1.0.0", GetDeploymentVersion(annotations)) | 659 | assert.Equal(t, "1.0.0", GetDeploymentVersion(annotations)) | ||
| 660 | }) | 660 | }) | ||
| 661 | - | }⏎̸ | 661 | + | } |
M pkg/manifest/types.go +19 -19
| @@ -2,19 +2,19 @@ package manifest | |||
| 2 | 2 | ||
| 3 | 3 | // OCIManifest represents an OCI image manifest structure | |
| 4 | 4 | type OCIManifest struct { | |
| 5 | - | SchemaVersion int `json:"schemaVersion"` | |
| 6 | - | MediaType string `json:"mediaType"` | |
| 7 | - | Config OCIDescriptor `json:"config"` | |
| 8 | - | Layers []OCIDescriptor `json:"layers"` | |
| 9 | - | Annotations map[string]string `json:"annotations,omitempty"` | |
| 5 | + | SchemaVersion int `json:"schemaVersion"` | |
| 6 | + | MediaType string `json:"mediaType"` | |
| 7 | + | Config OCIDescriptor `json:"config"` | |
| 8 | + | Layers []OCIDescriptor `json:"layers"` | |
| 9 | + | Annotations map[string]string `json:"annotations,omitempty"` | |
| 10 | 10 | } | |
| 11 | 11 | ||
| 12 | - | // DockerManifest represents a Docker v2.2 manifest structure | |
| 12 | + | // DockerManifest represents a Docker v2.2 manifest structure | |
| 13 | 13 | type DockerManifest struct { | |
| 14 | - | SchemaVersion int `json:"schemaVersion"` | |
| 15 | - | MediaType string `json:"mediaType"` | |
| 16 | - | Config OCIDescriptor `json:"config"` | |
| 17 | - | Layers []OCIDescriptor `json:"layers"` | |
| 14 | + | SchemaVersion int `json:"schemaVersion"` | |
| 15 | + | MediaType string `json:"mediaType"` | |
| 16 | + | Config OCIDescriptor `json:"config"` | |
| 17 | + | Layers []OCIDescriptor `json:"layers"` | |
| 18 | 18 | } | |
| 19 | 19 | ||
| 20 | 20 | // OCIDescriptor represents a content descriptor | |
| @@ -27,10 +27,10 @@ type OCIDescriptor struct { | |||
| 27 | 27 | ||
| 28 | 28 | // ManifestList represents a multi-platform manifest list | |
| 29 | 29 | type ManifestList struct { | |
| 30 | - | SchemaVersion int `json:"schemaVersion"` | |
| 31 | - | MediaType string `json:"mediaType"` | |
| 32 | - | Manifests []ManifestDescriptor `json:"manifests"` | |
| 33 | - | Annotations map[string]string `json:"annotations,omitempty"` | |
| 30 | + | SchemaVersion int `json:"schemaVersion"` | |
| 31 | + | MediaType string `json:"mediaType"` | |
| 32 | + | Manifests []ManifestDescriptor `json:"manifests"` | |
| 33 | + | Annotations map[string]string `json:"annotations,omitempty"` | |
| 34 | 34 | } | |
| 35 | 35 | ||
| 36 | 36 | // ManifestDescriptor represents a manifest in a manifest list | |
| @@ -44,9 +44,9 @@ type ManifestDescriptor struct { | |||
| 44 | 44 | ||
| 45 | 45 | // Platform represents the platform information | |
| 46 | 46 | type Platform struct { | |
| 47 | - | Architecture string `json:"architecture"` | |
| 48 | - | OS string `json:"os"` | |
| 49 | - | OSVersion string `json:"os.version,omitempty"` | |
| 47 | + | Architecture string `json:"architecture"` | |
| 48 | + | OS string `json:"os"` | |
| 49 | + | OSVersion string `json:"os.version,omitempty"` | |
| 50 | 50 | OSFeatures []string `json:"os.features,omitempty"` | |
| 51 | - | Variant string `json:"variant,omitempty"` | |
| 52 | - | }⏎̸ | |
| 51 | + | Variant string `json:"variant,omitempty"` | |
| 52 | + | } | |
| @@ -2,19 +2,19 @@ package manifest | |||||
| 2 | 2 | ||||
| 3 | // OCIManifest represents an OCI image manifest structure | 3 | // OCIManifest represents an OCI image manifest structure | ||
| 4 | type OCIManifest struct { | 4 | type OCIManifest struct { | ||
| 5 | - | SchemaVersion int `json:"schemaVersion"` | 5 | + | SchemaVersion int `json:"schemaVersion"` |
| 6 | - | MediaType string `json:"mediaType"` | 6 | + | MediaType string `json:"mediaType"` |
| 7 | - | Config OCIDescriptor `json:"config"` | 7 | + | Config OCIDescriptor `json:"config"` |
| 8 | - | Layers []OCIDescriptor `json:"layers"` | 8 | + | Layers []OCIDescriptor `json:"layers"` |
| 9 | - | Annotations map[string]string `json:"annotations,omitempty"` | 9 | + | Annotations map[string]string `json:"annotations,omitempty"` |
| 10 | } | 10 | } | ||
| 11 | 11 | ||||
| 12 | - | // DockerManifest represents a Docker v2.2 manifest structure | 12 | + | // DockerManifest represents a Docker v2.2 manifest structure |
| 13 | type DockerManifest struct { | 13 | type DockerManifest struct { | ||
| 14 | - | SchemaVersion int `json:"schemaVersion"` | 14 | + | SchemaVersion int `json:"schemaVersion"` |
| 15 | - | MediaType string `json:"mediaType"` | 15 | + | MediaType string `json:"mediaType"` |
| 16 | - | Config OCIDescriptor `json:"config"` | 16 | + | Config OCIDescriptor `json:"config"` |
| 17 | - | Layers []OCIDescriptor `json:"layers"` | 17 | + | Layers []OCIDescriptor `json:"layers"` |
| 18 | } | 18 | } | ||
| 19 | 19 | ||||
| 20 | // OCIDescriptor represents a content descriptor | 20 | // OCIDescriptor represents a content descriptor | ||
| @@ -27,10 +27,10 @@ type OCIDescriptor struct { | |||||
| 27 | 27 | ||||
| 28 | // ManifestList represents a multi-platform manifest list | 28 | // ManifestList represents a multi-platform manifest list | ||
| 29 | type ManifestList struct { | 29 | type ManifestList struct { | ||
| 30 | - | SchemaVersion int `json:"schemaVersion"` | 30 | + | SchemaVersion int `json:"schemaVersion"` |
| 31 | - | MediaType string `json:"mediaType"` | 31 | + | MediaType string `json:"mediaType"` |
| 32 | - | Manifests []ManifestDescriptor `json:"manifests"` | 32 | + | Manifests []ManifestDescriptor `json:"manifests"` |
| 33 | - | Annotations map[string]string `json:"annotations,omitempty"` | 33 | + | Annotations map[string]string `json:"annotations,omitempty"` |
| 34 | } | 34 | } | ||
| 35 | 35 | ||||
| 36 | // ManifestDescriptor represents a manifest in a manifest list | 36 | // ManifestDescriptor represents a manifest in a manifest list | ||
| @@ -44,9 +44,9 @@ type ManifestDescriptor struct { | |||||
| 44 | 44 | ||||
| 45 | // Platform represents the platform information | 45 | // Platform represents the platform information | ||
| 46 | type Platform struct { | 46 | type Platform struct { | ||
| 47 | - | Architecture string `json:"architecture"` | 47 | + | Architecture string `json:"architecture"` |
| 48 | - | OS string `json:"os"` | 48 | + | OS string `json:"os"` |
| 49 | - | OSVersion string `json:"os.version,omitempty"` | 49 | + | OSVersion string `json:"os.version,omitempty"` |
| 50 | OSFeatures []string `json:"os.features,omitempty"` | 50 | OSFeatures []string `json:"os.features,omitempty"` | ||
| 51 | - | Variant string `json:"variant,omitempty"` | 51 | + | Variant string `json:"variant,omitempty"` |
| 52 | - | }⏎̸ | 52 | + | } |
M pkg/manifest/types_test.go +8 -8
| @@ -458,8 +458,8 @@ func TestManifestDescriptor_JSON(t *testing.T) { | |||
| 458 | 458 | Variant: "power9", | |
| 459 | 459 | }, | |
| 460 | 460 | Annotations: map[string]string{ | |
| 461 | - | "build.date": "2023-01-01T00:00:00Z", | |
| 462 | - | "maintainer": "gordon-team", | |
| 461 | + | "build.date": "2023-01-01T00:00:00Z", | |
| 462 | + | "maintainer": "gordon-team", | |
| 463 | 463 | "io.buildah.version": "1.23.0", | |
| 464 | 464 | }, | |
| 465 | 465 | }, | |
| @@ -493,13 +493,13 @@ func TestManifestTypes_EdgeCases(t *testing.T) { | |||
| 493 | 493 | Digest: "sha256:config", | |
| 494 | 494 | Size: 100, | |
| 495 | 495 | }, | |
| 496 | - | Layers: []OCIDescriptor{}, | |
| 496 | + | Layers: []OCIDescriptor{}, | |
| 497 | 497 | Annotations: map[string]string{}, // Empty map should be omitted | |
| 498 | 498 | } | |
| 499 | 499 | ||
| 500 | 500 | jsonData, err := json.Marshal(manifest) | |
| 501 | 501 | require.NoError(t, err) | |
| 502 | - | ||
| 502 | + | ||
| 503 | 503 | // Should not contain "annotations" field | |
| 504 | 504 | assert.NotContains(t, string(jsonData), "annotations") | |
| 505 | 505 | }) | |
| @@ -519,7 +519,7 @@ func TestManifestTypes_EdgeCases(t *testing.T) { | |||
| 519 | 519 | ||
| 520 | 520 | jsonData, err := json.Marshal(manifest) | |
| 521 | 521 | require.NoError(t, err) | |
| 522 | - | ||
| 522 | + | ||
| 523 | 523 | // Should not contain "annotations" field | |
| 524 | 524 | assert.NotContains(t, string(jsonData), "annotations") | |
| 525 | 525 | }) | |
| @@ -534,7 +534,7 @@ func TestManifestTypes_EdgeCases(t *testing.T) { | |||
| 534 | 534 | ||
| 535 | 535 | jsonData, err := json.Marshal(descriptor) | |
| 536 | 536 | require.NoError(t, err) | |
| 537 | - | ||
| 537 | + | ||
| 538 | 538 | // Should not contain "platform" field | |
| 539 | 539 | assert.NotContains(t, string(jsonData), "platform") | |
| 540 | 540 | }) | |
| @@ -549,9 +549,9 @@ func TestManifestTypes_EdgeCases(t *testing.T) { | |||
| 549 | 549 | ||
| 550 | 550 | jsonData, err := json.Marshal(platform) | |
| 551 | 551 | require.NoError(t, err) | |
| 552 | - | ||
| 552 | + | ||
| 553 | 553 | // Empty strings should be preserved | |
| 554 | 554 | assert.Contains(t, string(jsonData), `"architecture":""`) | |
| 555 | 555 | assert.Contains(t, string(jsonData), `"os":""`) | |
| 556 | 556 | }) | |
| 557 | - | }⏎̸ | |
| 557 | + | } | |
| @@ -458,8 +458,8 @@ func TestManifestDescriptor_JSON(t *testing.T) { | |||||
| 458 | Variant: "power9", | 458 | Variant: "power9", | ||
| 459 | }, | 459 | }, | ||
| 460 | Annotations: map[string]string{ | 460 | Annotations: map[string]string{ | ||
| 461 | - | "build.date": "2023-01-01T00:00:00Z", | 461 | + | "build.date": "2023-01-01T00:00:00Z", |
| 462 | - | "maintainer": "gordon-team", | 462 | + | "maintainer": "gordon-team", |
| 463 | "io.buildah.version": "1.23.0", | 463 | "io.buildah.version": "1.23.0", | ||
| 464 | }, | 464 | }, | ||
| 465 | }, | 465 | }, | ||
| @@ -493,13 +493,13 @@ func TestManifestTypes_EdgeCases(t *testing.T) { | |||||
| 493 | Digest: "sha256:config", | 493 | Digest: "sha256:config", | ||
| 494 | Size: 100, | 494 | Size: 100, | ||
| 495 | }, | 495 | }, | ||
| 496 | - | Layers: []OCIDescriptor{}, | 496 | + | Layers: []OCIDescriptor{}, |
| 497 | Annotations: map[string]string{}, // Empty map should be omitted | 497 | Annotations: map[string]string{}, // Empty map should be omitted | ||
| 498 | } | 498 | } | ||
| 499 | 499 | ||||
| 500 | jsonData, err := json.Marshal(manifest) | 500 | jsonData, err := json.Marshal(manifest) | ||
| 501 | require.NoError(t, err) | 501 | require.NoError(t, err) | ||
| 502 | - | 502 | + | ||
| 503 | // Should not contain "annotations" field | 503 | // Should not contain "annotations" field | ||
| 504 | assert.NotContains(t, string(jsonData), "annotations") | 504 | assert.NotContains(t, string(jsonData), "annotations") | ||
| 505 | }) | 505 | }) | ||
| @@ -519,7 +519,7 @@ func TestManifestTypes_EdgeCases(t *testing.T) { | |||||
| 519 | 519 | ||||
| 520 | jsonData, err := json.Marshal(manifest) | 520 | jsonData, err := json.Marshal(manifest) | ||
| 521 | require.NoError(t, err) | 521 | require.NoError(t, err) | ||
| 522 | - | 522 | + | ||
| 523 | // Should not contain "annotations" field | 523 | // Should not contain "annotations" field | ||
| 524 | assert.NotContains(t, string(jsonData), "annotations") | 524 | assert.NotContains(t, string(jsonData), "annotations") | ||
| 525 | }) | 525 | }) | ||
| @@ -534,7 +534,7 @@ func TestManifestTypes_EdgeCases(t *testing.T) { | |||||
| 534 | 534 | ||||
| 535 | jsonData, err := json.Marshal(descriptor) | 535 | jsonData, err := json.Marshal(descriptor) | ||
| 536 | require.NoError(t, err) | 536 | require.NoError(t, err) | ||
| 537 | - | 537 | + | ||
| 538 | // Should not contain "platform" field | 538 | // Should not contain "platform" field | ||
| 539 | assert.NotContains(t, string(jsonData), "platform") | 539 | assert.NotContains(t, string(jsonData), "platform") | ||
| 540 | }) | 540 | }) | ||
| @@ -549,9 +549,9 @@ func TestManifestTypes_EdgeCases(t *testing.T) { | |||||
| 549 | 549 | ||||
| 550 | jsonData, err := json.Marshal(platform) | 550 | jsonData, err := json.Marshal(platform) | ||
| 551 | require.NoError(t, err) | 551 | require.NoError(t, err) | ||
| 552 | - | 552 | + | ||
| 553 | // Empty strings should be preserved | 553 | // Empty strings should be preserved | ||
| 554 | assert.Contains(t, string(jsonData), `"architecture":""`) | 554 | assert.Contains(t, string(jsonData), `"architecture":""`) | ||
| 555 | assert.Contains(t, string(jsonData), `"os":""`) | 555 | assert.Contains(t, string(jsonData), `"os":""`) | ||
| 556 | }) | 556 | }) | ||
| 557 | - | }⏎̸ | 557 | + | } |
M pkg/runtime/interface.go +20 -20
| @@ -7,21 +7,21 @@ import ( | |||
| 7 | 7 | ||
| 8 | 8 | // Container represents a running container | |
| 9 | 9 | type Container struct { | |
| 10 | - | ID string | |
| 11 | - | Image string | |
| 12 | - | Name string | |
| 13 | - | Status string | |
| 14 | - | Ports []int | |
| 15 | - | Labels map[string]string | |
| 10 | + | ID string | |
| 11 | + | Image string | |
| 12 | + | Name string | |
| 13 | + | Status string | |
| 14 | + | Ports []int | |
| 15 | + | Labels map[string]string | |
| 16 | 16 | } | |
| 17 | 17 | ||
| 18 | 18 | // NetworkInfo represents a network | |
| 19 | 19 | type NetworkInfo struct { | |
| 20 | - | ID string | |
| 21 | - | Name string | |
| 22 | - | Driver string | |
| 23 | - | Containers []string | |
| 24 | - | Labels map[string]string | |
| 20 | + | ID string | |
| 21 | + | Name string | |
| 22 | + | Driver string | |
| 23 | + | Containers []string | |
| 24 | + | Labels map[string]string | |
| 25 | 25 | } | |
| 26 | 26 | ||
| 27 | 27 | // ContainerConfig holds configuration for creating a container | |
| @@ -48,40 +48,40 @@ type Runtime interface { | |||
| 48 | 48 | StopContainer(ctx context.Context, containerID string) error | |
| 49 | 49 | RestartContainer(ctx context.Context, containerID string) error | |
| 50 | 50 | RemoveContainer(ctx context.Context, containerID string, force bool) error | |
| 51 | - | ||
| 51 | + | ||
| 52 | 52 | // Container inspection | |
| 53 | 53 | ListContainers(ctx context.Context, all bool) ([]*Container, error) | |
| 54 | 54 | InspectContainer(ctx context.Context, containerID string) (*Container, error) | |
| 55 | 55 | GetContainerLogs(ctx context.Context, containerID string, follow bool) (io.ReadCloser, error) | |
| 56 | - | ||
| 56 | + | ||
| 57 | 57 | // Image operations | |
| 58 | 58 | PullImage(ctx context.Context, image string) error | |
| 59 | 59 | PullImageWithAuth(ctx context.Context, image, username, password string) error | |
| 60 | 60 | RemoveImage(ctx context.Context, image string, force bool) error | |
| 61 | 61 | ListImages(ctx context.Context) ([]string, error) | |
| 62 | - | ||
| 62 | + | ||
| 63 | 63 | // Runtime information | |
| 64 | 64 | Ping(ctx context.Context) error | |
| 65 | 65 | Version(ctx context.Context) (string, error) | |
| 66 | - | ||
| 66 | + | ||
| 67 | 67 | // Health and status | |
| 68 | 68 | IsContainerRunning(ctx context.Context, containerID string) (bool, error) | |
| 69 | 69 | GetContainerPort(ctx context.Context, containerID string, internalPort int) (int, error) | |
| 70 | - | ||
| 70 | + | ||
| 71 | 71 | // Image and port inspection | |
| 72 | 72 | GetImageExposedPorts(ctx context.Context, imageRef string) ([]int, error) | |
| 73 | 73 | GetContainerExposedPorts(ctx context.Context, containerID string) ([]int, error) | |
| 74 | 74 | GetContainerNetworkInfo(ctx context.Context, containerID string) (string, int, error) | |
| 75 | - | ||
| 75 | + | ||
| 76 | 76 | // Volume management | |
| 77 | 77 | InspectImageVolumes(ctx context.Context, imageRef string) ([]string, error) | |
| 78 | 78 | VolumeExists(ctx context.Context, volumeName string) (bool, error) | |
| 79 | 79 | CreateVolume(ctx context.Context, volumeName string) error | |
| 80 | 80 | RemoveVolume(ctx context.Context, volumeName string, force bool) error | |
| 81 | - | ||
| 81 | + | ||
| 82 | 82 | // Environment inspection | |
| 83 | 83 | InspectImageEnv(ctx context.Context, imageRef string) ([]string, error) | |
| 84 | - | ||
| 84 | + | ||
| 85 | 85 | // Network management | |
| 86 | 86 | CreateNetwork(ctx context.Context, name string, options map[string]string) error | |
| 87 | 87 | RemoveNetwork(ctx context.Context, name string) error | |
| @@ -89,4 +89,4 @@ type Runtime interface { | |||
| 89 | 89 | NetworkExists(ctx context.Context, name string) (bool, error) | |
| 90 | 90 | ConnectContainerToNetwork(ctx context.Context, containerName, networkName string) error | |
| 91 | 91 | DisconnectContainerFromNetwork(ctx context.Context, containerName, networkName string) error | |
| 92 | - | }⏎̸ | |
| 92 | + | } | |
| @@ -7,21 +7,21 @@ import ( | |||||
| 7 | 7 | ||||
| 8 | // Container represents a running container | 8 | // Container represents a running container | ||
| 9 | type Container struct { | 9 | type Container struct { | ||
| 10 | - | ID string | 10 | + | ID string |
| 11 | - | Image string | 11 | + | Image string |
| 12 | - | Name string | 12 | + | Name string |
| 13 | - | Status string | 13 | + | Status string |
| 14 | - | Ports []int | 14 | + | Ports []int |
| 15 | - | Labels map[string]string | 15 | + | Labels map[string]string |
| 16 | } | 16 | } | ||
| 17 | 17 | ||||
| 18 | // NetworkInfo represents a network | 18 | // NetworkInfo represents a network | ||
| 19 | type NetworkInfo struct { | 19 | type NetworkInfo struct { | ||
| 20 | - | ID string | 20 | + | ID string |
| 21 | - | Name string | 21 | + | Name string |
| 22 | - | Driver string | 22 | + | Driver string |
| 23 | - | Containers []string | 23 | + | Containers []string |
| 24 | - | Labels map[string]string | 24 | + | Labels map[string]string |
| 25 | } | 25 | } | ||
| 26 | 26 | ||||
| 27 | // ContainerConfig holds configuration for creating a container | 27 | // ContainerConfig holds configuration for creating a container | ||
| @@ -48,40 +48,40 @@ type Runtime interface { | |||||
| 48 | StopContainer(ctx context.Context, containerID string) error | 48 | StopContainer(ctx context.Context, containerID string) error | ||
| 49 | RestartContainer(ctx context.Context, containerID string) error | 49 | RestartContainer(ctx context.Context, containerID string) error | ||
| 50 | RemoveContainer(ctx context.Context, containerID string, force bool) error | 50 | RemoveContainer(ctx context.Context, containerID string, force bool) error | ||
| 51 | - | 51 | + | ||
| 52 | // Container inspection | 52 | // Container inspection | ||
| 53 | ListContainers(ctx context.Context, all bool) ([]*Container, error) | 53 | ListContainers(ctx context.Context, all bool) ([]*Container, error) | ||
| 54 | InspectContainer(ctx context.Context, containerID string) (*Container, error) | 54 | InspectContainer(ctx context.Context, containerID string) (*Container, error) | ||
| 55 | GetContainerLogs(ctx context.Context, containerID string, follow bool) (io.ReadCloser, error) | 55 | GetContainerLogs(ctx context.Context, containerID string, follow bool) (io.ReadCloser, error) | ||
| 56 | - | 56 | + | ||
| 57 | // Image operations | 57 | // Image operations | ||
| 58 | PullImage(ctx context.Context, image string) error | 58 | PullImage(ctx context.Context, image string) error | ||
| 59 | PullImageWithAuth(ctx context.Context, image, username, password string) error | 59 | PullImageWithAuth(ctx context.Context, image, username, password string) error | ||
| 60 | RemoveImage(ctx context.Context, image string, force bool) error | 60 | RemoveImage(ctx context.Context, image string, force bool) error | ||
| 61 | ListImages(ctx context.Context) ([]string, error) | 61 | ListImages(ctx context.Context) ([]string, error) | ||
| 62 | - | 62 | + | ||
| 63 | // Runtime information | 63 | // Runtime information | ||
| 64 | Ping(ctx context.Context) error | 64 | Ping(ctx context.Context) error | ||
| 65 | Version(ctx context.Context) (string, error) | 65 | Version(ctx context.Context) (string, error) | ||
| 66 | - | 66 | + | ||
| 67 | // Health and status | 67 | // Health and status | ||
| 68 | IsContainerRunning(ctx context.Context, containerID string) (bool, error) | 68 | IsContainerRunning(ctx context.Context, containerID string) (bool, error) | ||
| 69 | GetContainerPort(ctx context.Context, containerID string, internalPort int) (int, error) | 69 | GetContainerPort(ctx context.Context, containerID string, internalPort int) (int, error) | ||
| 70 | - | 70 | + | ||
| 71 | // Image and port inspection | 71 | // Image and port inspection | ||
| 72 | GetImageExposedPorts(ctx context.Context, imageRef string) ([]int, error) | 72 | GetImageExposedPorts(ctx context.Context, imageRef string) ([]int, error) | ||
| 73 | GetContainerExposedPorts(ctx context.Context, containerID string) ([]int, error) | 73 | GetContainerExposedPorts(ctx context.Context, containerID string) ([]int, error) | ||
| 74 | GetContainerNetworkInfo(ctx context.Context, containerID string) (string, int, error) | 74 | GetContainerNetworkInfo(ctx context.Context, containerID string) (string, int, error) | ||
| 75 | - | 75 | + | ||
| 76 | // Volume management | 76 | // Volume management | ||
| 77 | InspectImageVolumes(ctx context.Context, imageRef string) ([]string, error) | 77 | InspectImageVolumes(ctx context.Context, imageRef string) ([]string, error) | ||
| 78 | VolumeExists(ctx context.Context, volumeName string) (bool, error) | 78 | VolumeExists(ctx context.Context, volumeName string) (bool, error) | ||
| 79 | CreateVolume(ctx context.Context, volumeName string) error | 79 | CreateVolume(ctx context.Context, volumeName string) error | ||
| 80 | RemoveVolume(ctx context.Context, volumeName string, force bool) error | 80 | RemoveVolume(ctx context.Context, volumeName string, force bool) error | ||
| 81 | - | 81 | + | ||
| 82 | // Environment inspection | 82 | // Environment inspection | ||
| 83 | InspectImageEnv(ctx context.Context, imageRef string) ([]string, error) | 83 | InspectImageEnv(ctx context.Context, imageRef string) ([]string, error) | ||
| 84 | - | 84 | + | ||
| 85 | // Network management | 85 | // Network management | ||
| 86 | CreateNetwork(ctx context.Context, name string, options map[string]string) error | 86 | CreateNetwork(ctx context.Context, name string, options map[string]string) error | ||
| 87 | RemoveNetwork(ctx context.Context, name string) error | 87 | RemoveNetwork(ctx context.Context, name string) error | ||
| @@ -89,4 +89,4 @@ type Runtime interface { | |||||
| 89 | NetworkExists(ctx context.Context, name string) (bool, error) | 89 | NetworkExists(ctx context.Context, name string) (bool, error) | ||
| 90 | ConnectContainerToNetwork(ctx context.Context, containerName, networkName string) error | 90 | ConnectContainerToNetwork(ctx context.Context, containerName, networkName string) error | ||
| 91 | DisconnectContainerFromNetwork(ctx context.Context, containerName, networkName string) error | 91 | DisconnectContainerFromNetwork(ctx context.Context, containerName, networkName string) error | ||
| 92 | - | }⏎̸ | 92 | + | } |