Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look at the apbs in the catalog for a matching name when creating a secret #438

Merged
merged 6 commits into from Oct 19, 2017

Conversation

fabianvf
Copy link
Member

@fabianvf fabianvf commented Sep 15, 2017

Describe what this PR does and why we need it:
Running the ./scripts/create_broker_secret.py script will now check the catalog for a FQName that looks like the image passed in. This should make it work with non-dockerhub registries as well as locally pushed images.

Changes proposed in this pull request

  • Added dependency on requests library to use the script
  • Get a list of apbs from /v2/catalog
  • Match the provided org, image, and tag to the apbs in the broker
  • If multiple match, prompt the user to pick one

depends on ansibleplaybookbundle/ansible-playbook-bundle#143

@djwhatle
Copy link
Contributor

djwhatle commented Sep 18, 2017

This change allowed me to create broker secrets without needing to edit the configmap when I used "apb push" to get an APB into the catalog.

@shawn-hurley
Copy link
Contributor

visual ACK



def fqname(apb):
parts = apb.split('/')
Copy link
Contributor

Choose a reason for hiding this comment

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

Would doing parts = apb.split('/')[-1] work here?
It looks like this breaks the image apart like this: rthallisey/mediawiki123:latest -> mediawiki123:latest

Copy link
Member Author

Choose a reason for hiding this comment

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

no, given either rthallisey/mediawiki123:latest or docker.io/rthallisey/mediawiki123:latest it should produce rthallisey-mediawiki123-latest

Copy link
Contributor

Choose a reason for hiding this comment

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

You could do this:

if apb.count('/') >= 2:
    parts = apb.split("/", 1)[-1]
parts = parts.replace("/", "-").replace(":", "-")

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah that's way cleaner

if len(parts) == 3:
# Chop the service, we don't know what it will be translated to in the broker
parts = parts[1:]
if ':' in parts[-1]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this if statement ever be skipped? If it can, shouldn't latest be added to the end of parts?



def fqname(apb):
parts = apb.split('/')
Copy link
Contributor

Choose a reason for hiding this comment

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

You could do this:

if apb.count('/') >= 2:
    parts = apb.split("/", 1)[-1]
parts = parts.replace("/", "-").replace(":", "-")

Copy link
Member

@djzager djzager left a comment

Choose a reason for hiding this comment

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

Just one comment wrt import statements. Other than that it looks good.

import sys
import yaml
import subprocess

try:
import yaml
Copy link
Member

Choose a reason for hiding this comment

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

You have import yaml, so I don't believe you would ever reach print("No yaml parsing modules installed, try: pip install pyyaml") as it stands now.

Copy link
Member

Choose a reason for hiding this comment

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

It isn't immediately obvious why we are try/catching this. It would be helpful, to me at least, if you could explain why you are doing this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm just try-catching it because this isn't a python project and we can't really specifiy python dependencies, so I wanted a nice error message if they don't have the right dependencies installed. I messed up with the above import yaml though, oops.




def fqname(apb):
Copy link
Member

Choose a reason for hiding this comment

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

It looks like I need to make updates to this in my PR #433 since the FQName will be changing with those changes.

@fabianvf
Copy link
Member Author

fabianvf commented Oct 4, 2017

@rthallisey @djzager I think I addressed your comments.

Copy link
Member

@djzager djzager left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 5, 2017
@fabianvf
Copy link
Member Author

fabianvf commented Oct 5, 2017

This has been updated to deal with auth now

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 11, 2017
@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 11, 2017
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 11, 2017
@jwmatthews
Copy link
Member

I removed the needs-bugzilla from this because this isn't part of the shipping broker, it's a tool used to aid testing.

@shawn-hurley shawn-hurley merged commit a993cf7 into openshift:master Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants