Skip to content

Commit

Permalink
follow-up after ab03773
Browse files Browse the repository at this point in the history
  • Loading branch information
f41gh7 committed Jul 25, 2022
1 parent 9a7ebe9 commit dbe2771
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controllers/factory/vmagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ func buildConfigReloaderContainer(cr *victoriametricsv1beta1.VMAgent, c *config.
configReloadArgs := buildConfigReloaderArgs(cr, c)
cntr := corev1.Container{
Name: "config-reloader",
Image: fmt.Sprintf("%s/%s", c.ContainerRegistry, c.VMAgentDefault.ConfigReloadImage),
Image: config.FormatContainerImage(c.ContainerRegistry, c.VMAgentDefault.ConfigReloadImage),
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
Env: []corev1.EnvVar{
{
Expand Down
2 changes: 1 addition & 1 deletion controllers/factory/vmauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ func buildVMAuthConfigReloaderContainer(cr *victoriametricsv1beta1.VMAuth, c *co

configReloader := corev1.Container{
Name: "config-reloader",
Image: fmt.Sprintf("%s/%s", c.ContainerRegistry, c.VMAuthDefault.ConfigReloadImage),
Image: config.FormatContainerImage(c.ContainerRegistry, c.VMAuthDefault.ConfigReloadImage),
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
Env: []corev1.EnvVar{
{
Expand Down
15 changes: 15 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,18 @@ type Namespaces struct {
// allow list for prometheus/alertmanager custom resources

}

// FormatContainerImage returns container image with registry prefix if needed.
func FormatContainerImage(globalRepo string, containerImage string) string {
if globalRepo == "docker.io" {
// no need to add global repo
return containerImage
}
if !strings.HasPrefix(containerImage, "quay.io") {
if !strings.HasSuffix(globalRepo, "/") {
globalRepo += "/"
}
return globalRepo + "/" + containerImage
}
return globalRepo + containerImage[len("quay.io"):]
}

0 comments on commit dbe2771

Please sign in to comment.