Skip to content

Commit

Permalink
Set docker.io as default host for image url
Browse files Browse the repository at this point in the history
  • Loading branch information
waodim committed Jul 1, 2024
1 parent 619e50a commit ea80b58
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/controllers/dynakube/istio/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const defaultRepositoryHost = "docker.io/"

type Reconciler interface {
ReconcileAPIUrl(ctx context.Context, dynakube *dynatracev1beta2.DynaKube) error
ReconcileCodeModulesInjectionEndpoints(ctx context.Context, dynakube *dynatracev1beta2.DynaKube) error
Expand Down Expand Up @@ -74,6 +76,11 @@ func parseCodeModulesImageURL(rawUrl string) (string, error) {
return "", errors.New("can't parse the codeModules image URL")
}

tmpURL := strings.Split(rawUrl, "/")
if !strings.Contains(tmpURL[0], ".") {
rawUrl = defaultRepositoryHost + rawUrl
}

if parsedURL.Scheme == "" {
parsedURL.Scheme = "https"

Expand Down
5 changes: 5 additions & 0 deletions pkg/controllers/dynakube/istio/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,11 @@ func TestParseCodeModulesImageURL(t *testing.T) {
output: "https://some.url.com/test:some-tag",
parsedCorreclty: true,
},
{
input: "some/url/test:some-tag",
output: "https://docker.io/some/url/test:some-tag",
parsedCorreclty: true,
},
{
input: ":example.com/test:some-tag",
output: "",
Expand Down

0 comments on commit ea80b58

Please sign in to comment.