-
Notifications
You must be signed in to change notification settings - Fork 36
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
Publish to helm registry #91
Publish to helm registry #91
Conversation
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.
Despite all my quibbles, this looks great overall. Thanks for diving into it!
| Param name | Type | Required | Alias | Purpose | | ||
|------------------------|----------|----------|------------------------|---------| | ||
| registry_url | string | yes | | Registry url to where the chart be published| | ||
| registry_login_user_id | string | yes | | Login ID for the Helm registry | | ||
| registry_login_password| string | yes | | Login Password for the Helm registry | | ||
| registry_repo_name | string | yes | | Repository name in the Helm registry | | ||
| chart_version | string | yes | | Version of the chart | | ||
| chart | string | | | Local path of the chart | |
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.
Would you mind aligning the whitespace here? It doesn't matter for the rendered markdown, but it makes the file easier to read while editing :)
| Param name | Type | Required | Alias | Purpose | | |
|------------------------|----------|----------|------------------------|---------| | |
| registry_url | string | yes | | Registry url to where the chart be published| | |
| registry_login_user_id | string | yes | | Login ID for the Helm registry | | |
| registry_login_password| string | yes | | Login Password for the Helm registry | | |
| registry_repo_name | string | yes | | Repository name in the Helm registry | | |
| chart_version | string | yes | | Version of the chart | | |
| chart | string | | | Local path of the chart | | |
| Param name | Type | Required | Alias | Purpose | | |
| ------------------------ | ---------- | ---------- | ------------------------ | --------- | | |
| registry_url | string | yes | | Registry url to where the chart be published | | |
| registry_login_user_id | string | yes | | Login ID for the Helm registry | | |
| registry_login_password | string | yes | | Login Password for the Helm registry | | |
| registry_repo_name | string | yes | | Repository name in the Helm registry | | |
| chart_version | string | yes | | Version of the chart | | |
| chart | string | | | Local path of the chart | |
|
||
if reg.subCommand == "save" { | ||
args = append(args, "save") | ||
args = append(args, reg.chartPath) |
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.
Does this need to check for an empty chartPath? I haven't checked how helm save "" [ref]
behaves, but I wouldn't expect it to be the same as helm save [ref]
.
args = append(args, reg.chartPath) | |
if reg.chartPath != "" { | |
args = append(args, reg.chartPath) | |
} |
cmd := fmt.Sprintf("%s/%s:%s", reg.registryURL, reg.registryRepoName, reg.chartVersion) | ||
args = append(args, cmd) |
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.
These two lines are the same as their counterparts in reg.subCommand == "save"
, right? If so they should go after the if
clause, so they're less likely to accidentally diverge in the future.
RegistryURL string `envconfig:"registry_url"` | ||
RegistryLoginUserID string `envconfig:"registry_login_user_id"` | ||
RegistryLoginPassword string `envconfig:"registry_login_password"` | ||
RegistryRepoName string `envconfig:"registry_repo_name"` |
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.
Newly-added settings don't need entries in settingAliases
—the aliases are for backwards compatibility if a setting gets renamed.
@@ -136,3 +139,16 @@ var lint = func(cfg env.Config) []Step { | |||
var help = func(cfg env.Config) []Step { | |||
return []Step{run.NewHelp(cfg)} | |||
} | |||
|
|||
var publish = func(cfg env.Config) []Step { | |||
fmt.Println("inside publish") |
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.
There's some leftover debug logging here
fmt.Println("inside publish") |
func (reg *Chart) Execute() error { | ||
return reg.cmd.Run() |
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.
Minor: there's a bit of copy-paste left over here (and the same thing in Prepare)
func (reg *Chart) Execute() error { | |
return reg.cmd.Run() | |
func (chart *Chart) Execute() error { | |
return chart.cmd.Run() |
} | ||
|
||
// Prepare gets the Registry ready to execute. | ||
func (reg *Registry) Prepare() error { |
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.
Same as above—this should check for missing config, and a test for these cases would be nice if you have the time.
func (reg *Registry) Prepare() error { | |
func (reg *Registry) Prepare() error { | |
if reg.userID == "" { | |
return fmt.Errorf("registry_login_user_id is required") | |
} | |
if reg.password == "" { | |
return fmt.Errorf("registry_login_password is required") | |
} | |
if reg.registryURL == "" { | |
return fmt.Errorf("registry_url is required") | |
} |
fmt.Println("inside publish") | ||
var steps []Step | ||
|
||
os.Setenv("HELM_EXPERIMENTAL_OCI", "1") |
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.
Rather than a bare os.Setenv
, please set this in the environment for the cmd
in Chart
and Registry
:
environ := os.Environ()
environ = append(environ, "HELM_EXPERIMENTAL_OCI=1")
reg.cmd.Env(environ)
Changing the environment mid-execution doesn't always cause problems, but when problems do arise it's a headache trying to track them down.
RegistryURL: "registry_url", | ||
} | ||
|
||
u := NewRegistry("login", cfg) |
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.
Minor: some leftover copy-paste here (and in TestPrepareAndExecuteLogout
).
u := NewRegistry("login", cfg) | |
reg := NewRegistry("login", cfg) |
chart: ./ | ||
environment: | ||
REGISTRY_URL: | ||
from_secret: registry_url | ||
REGISTRY_LOGIN_USER_ID: | ||
from_secret: registry_login_user_id | ||
REGISTRY_LOGIN_PASSWORD: | ||
from_secret: registry_login_password | ||
REGISTRY_REPO_NAME: <helm_repository_name> | ||
CHART_VERSION: <version> |
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.
A couple of nitpicks here:
- Since
registry_repo_name
andchart_version
don't need to come from secrets, thesettings
block is a more appropriate spot for them. - The README examples should only contain the required params, to minimize the amount of scrolling people have to do.
chart: ./ | |
environment: | |
REGISTRY_URL: | |
from_secret: registry_url | |
REGISTRY_LOGIN_USER_ID: | |
from_secret: registry_login_user_id | |
REGISTRY_LOGIN_PASSWORD: | |
from_secret: registry_login_password | |
REGISTRY_REPO_NAME: <helm_repository_name> | |
CHART_VERSION: <version> | |
registry_repo_name: <helm_repository_name> | |
chart_version: <version> | |
environment: | |
REGISTRY_URL: | |
from_secret: registry_url | |
REGISTRY_LOGIN_USER_ID: | |
from_secret: registry_login_user_id | |
REGISTRY_LOGIN_PASSWORD: | |
from_secret: registry_login_password |
Hey thanks for the review, I will fix these soon. sorry for the delay |
This is pushing a couple years so I'm going to close this out - if issues get address we can reopen :) |
Support for publish to Helm Registry
Fixes #90
Its using method defined here : https://helm.sh/docs/topics/registries/
Basically following command:
Tested it with Azure Container Registry