-
Notifications
You must be signed in to change notification settings - Fork 64
added option to authenticate with registry #88
Changes from 2 commits
d07f85e
b6bc2c7
9912054
907b24d
3226c66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,15 @@ def parse_file(args, input_file, output_file): | |
with open(input_file) as file: | ||
input_data = file.read() | ||
|
||
output_data = input_data.replace("{{IMAGE_PATH}}", args.image_path).replace("{{IMAGE_TAG}}", args.image_tag) | ||
data = input_data.replace("{{IMAGE_PATH}}", args.image_path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any particular reason for splitting this? I think we'd probably prefer to keep this as a single line given the templating is also a single line to change. Helps to keep the concepts in sync There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just thought that putting it in a single line leads to a line which is too long, which I consider bad style. I'm happy to change it to one line if you want. |
||
data = data.replace("{{IMAGE_TAG}}", args.image_tag) | ||
|
||
# this argument is optional | ||
# ~ means null in yaml | ||
output_data = data.replace("{{IMAGE_SECRET}}", args.image_secret if (args.image_secret != None) else "~") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll probably try this out a bit on our rigs, to make sure it behaves as i'm expecting, but can you give a summary of any testing/checking you've done here on if there isn't a secret provided? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't done proper testing of the no secret case, because I don't have a public repo. I did try running it on my private repo, and it seemed to parse fine and then give an authentication failed error. Today I created a public docker hub repo. I'll try on that when I get a chance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it does work with no authentication. I just tried. |
||
|
||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to clean up the unnecessary blank lines here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep I'll fix that. |
||
|
||
with open(output_file, "w") as file: | ||
file.write(output_data) | ||
|
@@ -27,6 +35,7 @@ def parse_files_in_dir(args, src, dest): | |
|
||
parse_file(args, os.path.join(src, template_file_name), os.path.join(dest, template_name+".yaml")) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
|
@@ -35,6 +44,9 @@ if __name__ == '__main__': | |
parser.add_argument( | ||
'--image_tag', required=True, | ||
help='The image tag to use') | ||
parser.add_argument( | ||
'--image_secret', required=False, | ||
help='(Optional) The kubernetes secret for authenticating with the container registry') | ||
args = parser.parse_args() | ||
|
||
# Create kubernetes manifests | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,4 +60,6 @@ spec: | |
volumes: | ||
- name: bonologs | ||
emptyDir: {} | ||
imagePullSecrets: | ||
- name: {{IMAGE_SECRET}} | ||
restartPolicy: Always |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,6 @@ spec: | |
readinessProbe: | ||
tcpSocket: | ||
port: 80 | ||
imagePullSecrets: | ||
- name: {{IMAGE_SECRET}} | ||
restartPolicy: Always |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,4 +55,6 @@ spec: | |
readinessProbe: | ||
tcpSocket: | ||
port: 4001 | ||
imagePullSecrets: | ||
- name: {{IMAGE_SECRET}} | ||
restartPolicy: Always |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,6 @@ spec: | |
readinessProbe: | ||
tcpSocket: | ||
port: 7888 | ||
imagePullSecrets: | ||
- name: {{IMAGE_SECRET}} | ||
restartPolicy: Always |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,6 @@ spec: | |
volumes: | ||
- name: ralflogs | ||
emptyDir: {} | ||
imagePullSecrets: | ||
- name: {{IMAGE_SECRET}} | ||
restartPolicy: Always |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,6 @@ spec: | |
volumes: | ||
- name: sproutlogs | ||
emptyDir: {} | ||
imagePullSecrets: | ||
- name: {{IMAGE_SECRET}} | ||
restartPolicy: Always |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this has probably come in from a different set of changes. Would be good to revert this change here to keep the PR clean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah woops. Yes that's my mistake for not keeping my repos clean and separated. I'll fix that.