distribution icon indicating copy to clipboard operation
distribution copied to clipboard

Replace WithName with CreateNamed

Open dmcgowan opened this issue 8 years ago • 5 comments

Based on feedback from #2142

WithName is a poorly named function and already has a similar role to ParseNamed without enforcement for normalization and no support for tags or digest values. For places that require creating a raw named value it is cleaner to explicitly pass in the domain and path needed to create a fully parsed and normalized value. The registry does not use domain and will explicitly pass in the empty string while clients such as the Docker Engine will likely have no use for CreateNamed.

dmcgowan avatar Jan 19 '17 03:01 dmcgowan

Codecov Report

Merging #2159 into master will not impact coverage by -6.56%.

@@            Coverage Diff            @@
##           master   #2159      +/-   ##
=========================================
- Coverage   57.85%   51.3%   -6.56%     
=========================================
  Files         125     125              
  Lines       11446   11448       +2     
=========================================
- Hits         6622    5873     -749     
- Misses       3989    4829     +840     
+ Partials      835     746      -89
Impacted Files Coverage Δ
reference/regexp.go 90% <ø> (ø) :white_check_mark:
registry/handlers/blobupload.go 45.17% <ø> (ø) :white_check_mark:
registry/handlers/app.go 48.2% <100%> (ø) :white_check_mark:
registry/storage/garbagecollect.go 64.91% <100%> (ø) :white_check_mark:
reference/reference.go 84.43% <81.81%> (+3.82%) :white_check_mark:
registry/storage/driver/gcs/gcs.go 0.4% <ø> (-68.94%) :x:
registry/storage/driver/oss/oss.go 0.56% <ø> (-57.23%) :x:
registry/storage/driver/s3-goamz/s3.go 0.5% <ø> (-18.79%) :x:
registry/storage/driver/s3-aws/s3.go 4.58% <ø> (-18.49%) :x:
registry/storage/driver/storagedriver.go 33.33% <ø> (-11.12%) :x:
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update fb0bebc...ce6bd26. Read the comment docs.

codecov-io avatar Jan 19 '17 04:01 codecov-io

Updated, also renamed "nameComponentRegexp" to "pathComponentRegexp" to match the grammar

dmcgowan avatar Jan 19 '17 19:01 dmcgowan

LGTM

aaronlehmann avatar Jan 19 '17 19:01 aaronlehmann

@dmcgowan could you rebase?

dmp42 avatar Aug 08 '18 00:08 dmp42

@dmcgowan would you mind rebasing?

milosgajdos avatar May 05 '21 18:05 milosgajdos

Accidentally closed this from the milestone. Reopening. GH UX really needs work.

milosgajdos avatar Aug 10 '23 07:08 milosgajdos

The reference code has now moved to https://github.com/distribution/reference/

@milosgajdos @thaJeztah is this something that you think is worth reopening against that repo?

Jamstah avatar Sep 18 '23 10:09 Jamstah

Good question...maybe? I think we could do it but it'd have to be done in the new repo yeah.

milosgajdos avatar Sep 18 '23 10:09 milosgajdos

If we still want it, then it should be there yes

Honestly, many of the Utilities in reference are named quite awkward (and it's not always clear what's meant by each of them). Of course naming is hard, and perhaps better GoDoc can "fix" some of them.

thaJeztah avatar Sep 18 '23 13:09 thaJeztah

I feel like neither @milosgajdos or @thaJeztah feel strongly that it should be renamed (or that it shouldn't).

So I'd say we close this, and any changes like this could be discussed as part of https://github.com/opencontainers/tob/pull/114

Jamstah avatar Sep 18 '23 14:09 Jamstah

@dmcgowan what are your thoughts?

Jamstah avatar Sep 18 '23 14:09 Jamstah

@Jamstah I'm fine closing this, clearly it is not a change which has been needed. I wouldn't classify this as a change to the reference grammar, just a way to validate the parts separately.

I believe the background to this is making it easier to support the mirror case when the namespace is provided. In such a case, the path remains the same but the domain is passed to the registry via a ns query parameters. Validating the domain and path separately then joining them would be the cleanest/safest approach. This would be useful for mirrors handling multiple upstreams or domains. It could be a separate function rather than a replacement as @thaJeztah suggested.

dmcgowan avatar Sep 18 '23 14:09 dmcgowan

Thanks. I agree the code is a little spaghetti and a proper review would be worthwhile. I'm less sure however how to drive that.

Jamstah avatar Sep 18 '23 14:09 Jamstah