Commit Graph

1451 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] 19ab7a41b0 Address code review nitpicks: improve POSIX compliance and maintainability
Co-authored-by: rchincha <45800463+rchincha@users.noreply.github.com>
2026-01-23 03:23:58 +00:00
copilot-swe-agent[bot] f4975db165 Address code review feedback: Add timeout check and clarify docs
Co-authored-by: rchincha <45800463+rchincha@users.noreply.github.com>
2026-01-23 03:22:50 +00:00
copilot-swe-agent[bot] 5fb417f9ae Add interactive flag and improve script usability
Co-authored-by: rchincha <45800463+rchincha@users.noreply.github.com>
2026-01-23 03:21:11 +00:00
copilot-swe-agent[bot] 3357d33502 Fix zot OIDC configuration to use proper format
Co-authored-by: rchincha <45800463+rchincha@users.noreply.github.com>
2026-01-23 03:20:01 +00:00
copilot-swe-agent[bot] e6255a042b Add kind-oidc.sh test and README
Co-authored-by: rchincha <45800463+rchincha@users.noreply.github.com>
2026-01-23 03:18:40 +00:00
copilot-swe-agent[bot] a0dfe9fe3a Initial plan 2026-01-23 03:13:25 +00:00
Ramkumar Chinchani dd1987fd11 chore: fix dependabot alerts (#3726)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2026-01-22 14:54:11 +02:00
Andrei Aaron 088914bb05 fix: graphql playground documentation was hardcoded to an unrelated example (#3721)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-01-21 09:28:49 +02:00
Andrei Aaron 14e537a5eb chore: remove direct usage of the github.com/aws/aws-sdk-go package (aws sdk v1) (#3701)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-01-15 21:43:34 +02:00
Ramkumar Chinchani 0cac8a7ee8 chore: fix dependabot alerts (#3707)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2026-01-15 20:42:39 +02:00
Andrei Aaron d33c1e3b22 fix: now attempt to bind to the zot server socket to check if the server is running (#3703)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-01-15 20:02:15 +02:00
Andrei Aaron 7c9064574d fix: remove usage of deprecated function aws.EndpointResolverWithOptionsFunc (#3700)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-01-15 09:29:01 -08:00
Asgeir Storesund Nilsen 708adf63d4 fix: CVE-2025-30204 - golang-jwt DoS vulnerability via excessive memory allocation (#3687)
* fix: CVE-2025-30204 - golang-jwt DoS vulnerability via excessive memory
allocation

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>

* fix: linting

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>

* chore: update project-zot/mockoidc to remove golang-jwt v3

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>

* test: Add more tests for bearer tokens

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>

* fix: Rewrite tests to remove MakeAuthTestServerLegacy

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>

---------

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>
2026-01-14 11:34:58 +02:00
Andrei Aaron e2ba7c8e20 fix: pre-existing dynamodb versions table should be populated with version if it doesn't contain it already (#3699)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-01-13 13:11:40 +02:00
Ramkumar Chinchani bc9f270e96 ci: fix nightly due to outdated kind (#3676)
ci: update kind version

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2026-01-12 10:14:23 -08:00
Ricardo Noriega ac5fbd9110 Fix typos in documentation (#3678)
docs: Fix typos in documentation

Signed-off-by: Ricardo Noriega De Soto <rnoriega@redhat.com>
2026-01-12 11:00:30 +02:00
Ramkumar Chinchani 800a545fbe chore: fix dependabot alerts (#3677)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-12-29 09:59:57 +02:00
Andrei Aaron 95b8d65c8a test: fix some coverage issues, refactored some of the pagination logic to accomplish this (#3674)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-23 19:06:13 +02:00
Andrei Aaron 4ad3fad3bc fix: do not reject requests having an Authorization header if basic auth is disabled (#3673)
See https://github.com/project-zot/zot/issues/3662

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
v2.1.13
2025-12-23 11:30:22 +02:00
Ramkumar Chinchani 331a927fa4 chore: fix dependabot alerts (#3660)
* chore: fix dependabot alerts

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: linter error

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
v2.1.12
2025-12-19 12:12:10 -08:00
Andrei Aaron f39c5e058e fix: make sure the function and caller information are added to log messages emitted by 3rd party libraries using slog directly. (#3659) 2025-12-19 07:32:13 +02:00
Andrei Aaron 79439bbf63 feat: add configurable mTLS identity extraction with fallback chain (#3640)
Add support for configurable identity attributes in mTLS authentication,
allowing identity extraction from CommonName, Subject DN, Email SAN,
URI SAN, or DNSName SAN with fallback chain support. Includes regex
pattern matching for URI SANs (e.g., SPIFFE workload IDs).

- Add MTLSConfig with identity attributes, URISANPattern, and index fields
- Implement extractMTLSIdentity with fallback chain logic
- Move the mtls tests in the api package to pkg/api/mtls_test.go

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-18 09:10:47 -08:00
Gianluca Boiano f2064c9af0 fix: prevent nil pointer dereference in RemoveImageFromRepoMeta (#3658)
* fix: prevent nil pointer dereference in RemoveImageFromRepoMeta

This commit fixes a critical bug where RemoveImageFromRepoMeta crashes with
a nil pointer dereference during retention policy execution and GC operations.

Root Cause:
The function was accessing blob metadata without checking if it exists first.
During GC/retention operations, the metadata database might have stale
references to blobs that no longer exist, causing runtime panics.

Changes:
- Added nil check for descriptorBlobInfo before accessing LastUpdated field
- Added nil check for blobInfo before dereferencing Size, Vendors, Platforms, and SubBlobs
- Made the function consistent with recalculateAggregateFields which already had these checks

Impact:
- Fixes crashes during retention policy execution
- Fixes crashes during GC manifest removal
- Fixes image deletion failures via API
- Eliminates need for dryRun: true workaround in retention config

The fix gracefully handles missing blob metadata by skipping those entries
instead of crashing.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* test: add comprehensive tests for RemoveImageFromRepoMeta nil checks

Add test coverage for the nil pointer dereference fixes in RemoveImageFromRepoMeta.
These tests ensure the function handles missing blob metadata gracefully during
GC and retention operations.

Test cases:
- Handle nil blob info for descriptor digest (line 280 check)
- Handle nil blob info in queue traversal (line 297 check)
- Verify correct behavior with valid blob info
- Handle empty tags edge case
- Skip tags with empty digest

Coverage: RemoveImageFromRepoMeta now has 100% test coverage

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* test: fix RemoveImageFromRepoMeta tests to match actual usage

Address review feedback:
- Delete tag from repoMeta.Tags before calling RemoveImageFromRepoMeta
- Fix blob count expectations after tag removal
- Add assertion to verify tag was removed from metadata
- Update comments to clarify expected behavior

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* test: add tag removal assertion to second test case

Add missing assertion to verify tag1 was removed from resultMeta.Tags
in the 'should handle nil blob info in queue traversal' test.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* refactor: improve nil blob handling documentation and test coverage

Address Copilot review feedback:
- Expand comment at line 278 to explain implications of skipping tags
  with missing blob info, clarifying that metadata inconsistency is
  acceptable in GC/cleanup scenarios
- Revise 'should handle nil blob info for descriptor digest' test to
  cover more realistic scenario: remove tag1 while tag2 has missing
  blob info, demonstrating graceful handling of data inconsistencies
  in remaining tags during removal operations

All tests pass with 49 total assertions.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* fix: prevent nil pointer in GetCandidates when statistics missing

Add defensive check in pkg/retention/candidate.go to handle cases where
a tag exists in repoMeta.Tags but has no corresponding entry in
repoMeta.Statistics. This prevents incorrect retention decisions based
on zero-value timestamps.

Changes:
- Check statistics existence before creating candidates
- Skip tags with missing statistics (retained by GetRetainedTagsFromMetaDB)
- Improve performance from O(n*m) to O(n) by using direct map lookup
- Add comprehensive test coverage for missing statistics scenarios

This addresses the concern raised in PR #3658 about metadata
inconsistencies due to non-transactional writes to blob store and metaDB.

Related: #3658
Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* test: achieve 100% coverage for RemoveImageFromRepoMeta nil checks

Enhance test coverage for RemoveImageFromRepoMeta to address codecov failures
by adding comprehensive test cases that exercise all code paths including nil
pointer checks and continue statements.

Changes:
- Enhanced 'nil blob info for descriptor digest' test to verify processing
  continues with other valid tags after skipping nil entries
- Enhanced 'nil blob info in queue traversal' test to handle mixed valid/nil
  sub-blobs and verify correct processing continuation
- Added 'multiple nil blobs in deeply nested structure' test to cover complex
  scenarios with multiple missing blobs at various nesting levels
- Enhanced 'skip tags with empty digest' test to verify processing continues
  with valid tags after skipping empty digest entries
- Added 'combined edge cases' test to verify all edge cases work together:
  empty digest, nil descriptor blob, and nil queue blob

Coverage Results:
- RemoveImageFromRepoMeta: 100.0% line coverage (was 87.50%)
- All 7 test scenarios pass with 75 total assertions
- All nil check code paths fully exercised
- All continue statement behaviors validated

Fixes codecov/patch failure on PR #3658 where 2 lines were missing coverage.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

---------

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>
2025-12-17 11:44:51 +02:00
Ramkumar Chinchani 3a349dccec chore: fix dependabot alerts (#3657)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-12-15 23:34:32 -08:00
Andrei Aaron ed40bfd689 fix: more logging for sync extension (#3656)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-16 00:03:24 +02:00
Andrei Aaron e069229744 docs: fix deadlink and typo (#3641)
Fix the issue initially reported in https://github.com/project-zot/zot/pull/2380

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-14 13:58:08 +02:00
Andrei Aaron cf8b0bdbf9 refactor: enhance TLS cert generation and refactor HTTP client architecture (#3638)
- Refactored HTTP client from global cache to struct-based approach (global state was shared between tests, including what certificates to use)
- Enhanced pkg/test/tls to support ECDSA and ED25519 key types
- Replaced static certificate files with dynamic generation in golang tests
- Fixed test cleanup issues and improved resource management

This eliminates dependency on external cert generation scripts and
improves test maintainability.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-13 09:47:32 +02:00
Andrei Aaron 1447bb24b4 fix: accept log levels supported by older zot versions, validate configured log level (#3639)
In zot config accept the same log levels as in https://github.com/rs/zerolog/blob/5391dd7c34c86c2a3b731cd3c3f1b252706e7925/globals.go#L37
This is to maintain backward compatibility with other zot version configurations.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-13 00:33:54 +02:00
Andrei Aaron 08fae9104d feat: support mTLS-only authn/authz with AccessControl and allow combining mTLS with other auth mechanisms (#3624)
* feat: support mTLS-only authn/authz with AccessControl and allow combining mTLS with other auth mechanisms

Signed-off-by: Ivan Arkhipov <me@endevir.ru>

* refactor: improve authentication logic and TLS certificate generation

- Fix mTLS authentication to use only leaf certificate instead of iterating
  through all certificates in the chain
- Reject Authorization headers when corresponding auth method is disabled,
  regardless of mTLS status (security improvement)
- Simplify authentication switch statement ordering and logic
- Move ErrUserDataNotFound error handling into sessionAuthn method
- Refactor TLS certificate generation to use Options pattern with
  CertificateOptions struct for better extensibility
- Consolidate duplicate certificate generation code into helper functions
  (generateCertificate, parseCA, initializeTemplate, applyOptions)
- Rename certificate generation functions for clarity:
  - GenerateCertWithCN -> GenerateClientCert
  - GenerateSelfSignedCertWithCN -> GenerateClientSelfSignedCert
- Add support for SAN settings including email addresses in certificates
- Update tests to reflect new authentication behavior and certificate API

This commit improves both the security posture (rejecting disabled auth
methods) and code maintainability (consolidated certificate generation).

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>

* fix: guard against multiple Authorization headers

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>

---------

Signed-off-by: Ivan Arkhipov <me@endevir.ru>
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Co-authored-by: Ivan Arkhipov <me@endevir.ru>
2025-12-11 20:08:32 +02:00
Ramkumar Chinchani e7b73b6c2d chore: fix dependabot alerts (#3636)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-12-09 10:49:45 +02:00
Andrei Aaron 4628080fa1 fix: remove misleading error messages on successful syncs (#3619)
See: https://github.com/project-zot/zot/issues/3560#issuecomment-3594856118
What happens is:
- syncRef skips the image ("skipping image because it's already synced")
- syncReferrers doesn't sync anything
- CommitAll is still called even though nothing was synced
- The temp directory exists but is empty (no index.json, no blobs)
- CommitAll fails because index.json is missing

Let's ensure we properly check for errors, and skip the log messages if some of the cases.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-09 08:11:28 +02:00
Andrei Aaron ba8ab49502 ci: save unified coverage as build artifact (#3626)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-06 21:58:37 +02:00
Andrei Aaron 667ecfa40e ci: split needsprivileges tests from devmode tests (#3625)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-06 20:36:32 +02:00
Andrei Aaron 9dfa7c3ae6 refactor(test): new apis for creating temporary files (#3605)
Replace MakeTempFile usage with MakeTempFilePath and MakeTempFileWithContent
helpers that automatically handle file lifecycle. This prevents resource
leaks by ensuring temporary files are properly closed.

Shoudld also make the tests easier to read.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-05 09:54:38 +02:00
Ramkumar Chinchani 92aee8ebce chore: Fix deps (#3620)
* chore: fix dependabot alerts

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* chore: update zui

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-12-04 11:43:24 +02:00
Andrei Aaron edaef52d50 fix(trivy): cleanup Trivy temporary directory (#3618)
This Trivy commit changed the way the cleanup is done for Trivy operations:
https://github.com/aquasecurity/trivy/commit/8f5b56005a4e8752976524750089dc9ea2c91e40

We need to start calling the APIs to create and cleanup the temp dir to ensure we don't leave around content in the /tmp folder

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-03 10:11:32 +02:00
Andrei Aaron 8226b25509 feat(config): validate storage root directories for path conflicts (#3602)
Add validation to reject configuration files where stores and substores
of the same storage type (local or S3) have root directories that are
nested within each other or identical. Stores of different types (local
vs S3) are allowed to share the same root directory since they use
different storage backends.

The validation:
- Checks all stores (default + substores) for path conflicts
- Only compares stores of the same storage type
- Reports clear error messages indicating which stores conflict and why

Add comprehensive tests covering:
- Same storage types with identical/nested paths (rejected)
- Different storage types with same/nested paths (allowed)
- Various combinations of default store and substores

Fixes issues where nested or identical root directories could cause
data corruption or routing conflicts.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-29 23:55:27 +02:00
Andrei Aaron e510ab6426 Fix error handling: return nil explicitly on successful completion (#3603)
fix: error handling: return nil explicitly on successful completion

Several functions in pkg/meta/redis/redis.go were returning 'err' at the
end of successful execution paths, which could lead to incorrect error
handling when 'err' was overwritten in loops or conditionals.

Changed the following functions to return nil explicitly when all
operations succeed:
- SearchRepos: return nil instead of err after successful loop
- SearchTags: return nil instead of err after successful loop
- GetRepoMeta: return nil instead of err after successful operations
- GetImageMeta: return nil instead of err after successful operations
- GetReferrersInfo: return nil instead of err after successful loop

This ensures that when functions complete successfully, they explicitly
return nil rather than relying on the last value of err, which may have
been overwritten during execution. This fixes TestRedisUnreachable which
was failing because SearchRepos was incorrectly returning nil error when
Redis was unreachable.

See failure in: https://github.com/project-zot/zot/actions/runs/19729927463/job/56528529923?pr=3599

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-28 11:49:17 +02:00
Andrei Aaron cc34a6f4ef fix(meta): handle cases when substores are nested (#3598)
fix(meta): handle cases where repositories when substores are nested

Note this is a case of bad configuration: having multiple stores
in the same tree structure. Guard against it in parse.go.

Fix getAllRepos to prevent duplicate repositories in metaDB when substore
directories are nested under the default store root directory.

The fix processes substores first, then the default store, using a
map-based deduplication approach to skip repositories that have already
been added. This ensures that when both the default store and substores
contain repositories with the same name (e.g., when a substore is nested
within the default store), only one instance is added to the repository
list.

Add test TestNoDuplicateReposWithSubstoresAndNestedRepoNames to verify
the deduplication logic works correctly with nested substores.

Also update the other tests to avoid these issues in the future
this is not a vali configuration.

This is not the intended use case for substores, and it may have caused:
https://github.com/project-zot/zot/actions/runs/19665302669/job/56320640980

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-27 20:11:52 +02:00
Andrei Aaron 69c3a0b99b feat: explicitly log if each authentication method is enabled (#3599)
feat: explicitly log if each autentication methods is enabled

When the server starts or when the config is reloaded.
See the discussion in: https://github.com/project-zot/zot/pull/3577#issuecomment-3568505810

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-27 11:30:14 +02:00
Andrei Aaron e068b8dc9f chore: Enable Go jsonv2 experiment and update the trivy dependency (v0.67.2) (#3572)
It requires the encoding/json/jsontext
package which is only available when the goexperiment.jsonv2 build
tag is enabled. This was causing build constraint errors during
tests and builds.

Changes:
- Add GOEXPERIMENT=jsonv2 to Makefile export and all go build/test
  commands that use env (since env creates a fresh environment)
- Add GOEXPERIMENT=jsonv2 to GitHub workflows that use direct go
  commands (workflows using make inherit it from Makefile)

Fix other dependabot alerts.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-27 09:58:37 +02:00
Ramkumar Chinchani 6452bec403 chore: fix dependabot alerts (#3595)
* chore: fix dependabot alerts

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* ci: bump up golang to 1.25.x

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: linter errors

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: stacker and docker build files to use golang 1.25

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-11-26 11:21:36 +02:00
Andrei Aaron 09de471774 fix(storage): enforce standard OCI blob path structure in GetNextDigestWithBlobPaths (#3594)
Require blob files to follow standard OCI image layout:
rootDir/repo/blobs/algorithm/digest

- Validate grandparent directory is ImageBlobsDir
- Validate parent directory is valid digest algorithm
- Update tests to use standard OCI structure
- Add blobPath() helper to reduce duplication and fix linting

This should reduce the number of uneeded digest computations
if other non-oci specific files are present in the layout.

Fix also a race condition when picking ports in monitoring tests.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-25 11:50:48 +02:00
Ramkumar Chinchani 05e9b8cdf8 chore: sync golang 1.25 (#3596)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-11-25 09:29:01 +02:00
Andrei Aaron a296968c1a fix: multiple fixes based on recent test failures (#3582)
* fix(monitoring): fix race condition in TestPopulateStorageMetrics

Write images to filesystem before starting controller to prevent GC
from reading index.json while it's being written.

See failure:
https://github.com/project-zot/zot/actions/runs/19633819097/job/56219606041

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>

* fix(sync): fix TestSignatures assertion on referrers order

Search through all referrers to find the expected OCI ref digest instead
of assuming it's at index.Manifests[1], as the order is not guaranteed.

See https://github.com/project-zot/zot/actions/runs/19630382617/job/56208492397?pr=3579

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>

* fix(redis): fix error handling in GetMultipleRepoMeta

The function was returning err at the end, which could be nil even when
HGetAll should have failed, because err gets reassigned in the loop.
Changed to return nil on success path, ensuring HGetAll errors are
properly propagated. Fixes TestRedisUnreachable failure.

See https://github.com/project-zot/zot/actions/runs/19634990856/job/56223414955?pr=3582

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>

* refactor(sync): simplify sync test structure and restore file permissions

Remove unnecessary nested Convey blocks and integrate error tests into
parent blocks. Add defer statements to restore file permissions after
chmod operations to prevent side effects on subsequent tests.

Fix potential root cause of https://github.com/project-zot/zot/actions/runs/19636284485/job/56227682319?pr=3579

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>

---------

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-24 19:23:52 +02:00
mottetm 6f0e05e676 fix: sync should be disabled when enable is false (#3579)
Signed-off-by: Matthieu Mottet <m.mottet@outlook.com>
2025-11-24 16:51:56 +02:00
Andrei Aaron 7bc6637380 ci: use minio==7.2.18 (#3581)
Looks like they broke the public API in a minor version: https://github.com/minio/minio-py/releases/tag/7.2.19
It was probably not intetional, until they figure it out, let's use the older working version.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-24 14:10:35 +02:00
Andrei Aaron 3b931a3a7a fix: handle zero time values in LastUpdated sorting functions (#3580)
When GetRepoLastUpdated fails (e.g., redis: nil), it returns time.Time{}
which gets converted to &time.Time{} (not nil). The existing nil checks
in sorting functions didn't account for zero time values, which should
also be treated as "oldest" (sorted last in descending order).

This commit:
- Adds zero time checks in addition to existing nil checks
- Treats both nil and zero time values as "oldest"
- Adds comprehensive tests for zero time edge cases

Affects ImgSortByUpdateTime, RepoSortByUpdateTime, and GetExpandedRepoInfo
sort functions.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-24 11:02:33 +02:00
Andrei Aaron e072aa09e2 refactor: optimize code with modern Go patterns and pre-allocation (#3576)
This commit modernizes code across multiple packages by:
- Using Go 1.18+ features (slices.IndexFunc, strings.Cut)
- Pre-allocating slices and maps with known capacity
- Consolidating defensive checks and improving code clarity
- Fixing test data and build tag issues

CLI client improvements:
- Pre-allocate slices in search functions and service methods
- Replace strings.Split with strings.Cut for username:password parsing
- Use range-based iteration instead of manual index loops

Search extension optimizations:
- Cache sort functions in pagination modules
- Pre-allocate page buffers and maps
- Consolidate defensive checks in filterBaseImages/filterDerivedImages
- Fix image bas and derived logic allowing out of sequence layers for base images
- Fix image pagination reporting images groupped by repos when sorted by update time
- Remove duplicate resolver_test.go file

Monitoring extension:
- Replace manual loops with slices.IndexFunc
- Pre-allocate bucketsFloat2String map

Sync extension:
- Pre-allocate slice in parseRegistryURLs

Test utilities:
- Fix build tags in oci_layout.go

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-24 09:42:45 +02:00
Andrei Aaron da426850e7 chore: update golangci-lint and fix all issues (#3575)
* chore: Update golangci-lint

Signed-off-by: Lars Francke <git@lars-francke.de>

* chore: fix all golangci-lint issues

- Remove deprecated `// +build` tags
- Fix godoclint, modernize, wsl_v5, govet, lll, gci, noctx issues
- Update linter configuration
- Modernize code to use Go 1.22+ features (for range N, slices.Contains, etc.)
- Update make check lint the privileged tests

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>

---------

Signed-off-by: Lars Francke <git@lars-francke.de>
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Co-authored-by: Lars Francke <git@lars-francke.de>
2025-11-22 23:36:48 +02:00