Skip to content

Conversation

@vrothberg
Copy link
Contributor

This is a follow-up change for containers/image#428.

It is a common pitfall to add a trailing slash when specifying a
registry (e.g., "docker.io/library/" version "docker.io/library").
Remove trailing slash to normalize the representation of registries.

Signed-off-by: Valentin Rothberg vrothberg@suse.com

@rh-atomic-bot
Copy link

Can one of the admins verify this patch?
I understand the following commands:

  • bot, add author to whitelist
  • bot, test pull request
  • bot, test pull request once

@vrothberg
Copy link
Contributor Author

Ping @baude. Haven't touched python for a while 😃

f.write(data)


def trim_suffix(s, suffix):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use rstrip.

 python
Python 2.7.14 (default, Feb 27 2018, 20:43:24) 
[GCC 7.3.1 20180130 (Red Hat 7.3.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> s="This is a test///"
>>> s.rstrip("/")
'This is a test'

Copy link
Contributor Author

@vrothberg vrothberg Mar 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rstrip would remove any number of trailing slashes, but we remove at most one (see https://github.com/vrothberg/image/blob/1c2d9a32e63ab66cb512803622a9e0c414e89381/pkg/sysregistries/system_registries_test.go#L42). Should we adjust that in containers/image as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no reason why you would ever have a url of a registry that ends with a slash, so removing only one versus all seems like the wrong solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this PR to use str.rstrip(). Shall I update containers/image to strip all as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhatdan
Copy link
Member

rhatdan commented Mar 19, 2018

LGTM

@rhatdan
Copy link
Member

rhatdan commented Mar 19, 2018

@baude PTAL

@baude
Copy link
Member

baude commented Mar 19, 2018

could you add a test or two ?

This is a follow-up change for containers/image#428.

It is a common pitfall to add a trailing slash when specifying a
registry (e.g., "docker.io/library/" version "docker.io/library").
Remove trailing slashes to normalize the representation of registries.

To facilitate testing, don't overwrite the BINARY and MIGRATOR variable
when being set in test.bats.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>
@vrothberg
Copy link
Contributor Author

@baude I just extended the bats tests. I did not manage to get the tests running with the Makefile, so I made the BINARY and MIGRATOR variables configurable for the bats test.

Tests are passing on my machine. If I find some time, I can look into enabling Travis.

@vrothberg
Copy link
Contributor Author

ping @baude

@baude
Copy link
Member

baude commented Apr 2, 2018

LGTM!

@baude
Copy link
Member

baude commented Apr 2, 2018

@rh-atomic-bot r+

@rh-atomic-bot
Copy link

📌 Commit 2e9862b has been approved by baude

@rh-atomic-bot
Copy link

⌛ Testing commit 2e9862b with merge da9a9c8...

@rh-atomic-bot
Copy link

☀️ Test successful - status-papr
Approved by: baude
Pushing da9a9c8 to master...

@vrothberg vrothberg deleted the trim-slash branch April 5, 2018 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants