-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17315 from pravisankar/fix-diag-imagepath
Automatic merge from submit-queue. Fix network diagnostic default image path - variable.DefaultImagePrefix is populated from {node,master}-config.yaml (imageConfig.format) and if this value is not specified in the config, openshift ansible defaults it to 'registry.access.redhat.com'. - Network diagnostics is run as a admin CLI command so there is no config for variable.DefaultImagePrefix and it defaults to 'registry.access.redhat.com' which may not be true for AWS or some other openshift environments. - This change will remove the registry path from the default image so that it defaults to registry configured on the openshift node. Example: Earlier image path: registry.access.redhat.com/openshift3/ose New image path: openshift3/ose On AWS node, this will resolve to registry.reg-aws.openshift.com:443/openshift3/ose
- Loading branch information
Showing
2 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
pkg/oc/admin/diagnostics/diagnostics/networkpod/util/util_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package util | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestTrimRegistryPath(t *testing.T) { | ||
testcases := map[string]struct { | ||
image string | ||
expectedImage string | ||
}{ | ||
"Empty image": { | ||
image: "", | ||
expectedImage: "", | ||
}, | ||
"Image with no slashes, no tags": { | ||
image: "origin", | ||
expectedImage: "origin", | ||
}, | ||
"Image with no slashes": { | ||
image: "origin:v1.2.3", | ||
expectedImage: "origin:v1.2.3", | ||
}, | ||
"Image with one slash, no tags": { | ||
image: "openshift/origin", | ||
expectedImage: "openshift/origin", | ||
}, | ||
"Image with one slash": { | ||
image: "openshift/origin:v1.2.3", | ||
expectedImage: "openshift/origin:v1.2.3", | ||
}, | ||
"Image with dns path, no port, no tags": { | ||
image: "registry.access.redhat.com/openshift3/ose", | ||
expectedImage: "openshift3/ose", | ||
}, | ||
"Image with dns path, no port": { | ||
image: "registry.access.redhat.com/openshift3/ose:v1.2.3", | ||
expectedImage: "openshift3/ose:v1.2.3", | ||
}, | ||
"Image with dns path": { | ||
image: "registry.reg-aws.openshift.com:443/openshift3/ose:v1.2.3", | ||
expectedImage: "openshift3/ose:v1.2.3", | ||
}, | ||
} | ||
|
||
for name, tc := range testcases { | ||
trimmedImage := trimRegistryPath(tc.image) | ||
if trimmedImage != tc.expectedImage { | ||
t.Fatalf("[%s] failed: expected %s but got %s", name, tc.expectedImage, trimmedImage) | ||
} | ||
} | ||
} |