Skip to content

Commit

Permalink
Merge pull request #2489 from gdbranco/fix/ocm-10846
Browse files Browse the repository at this point in the history
OCM-10846 | fix: adjust error message for ingress identifier
  • Loading branch information
openshift-merge-bot[bot] authored Sep 23, 2024
2 parents 19b7ec7 + 7faae06 commit d34ff6c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
4 changes: 3 additions & 1 deletion cmd/describe/ingress/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ Wildcard Policy: WildcardsAllowed
Expect(err).ToNot(BeNil())
Expect(
err.Error(),
).To(Equal("ingress identifier 'A1b2' isn't valid: it must contain only letters or digits"))
).To(Equal(
"Ingress identifier 'A1b2' isn't valid: it must contain between three and five lowercase letters or digits",
))
})

It("Cluster not ready", func() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/describe/ingress/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (i *DescribeIngressOptions) Bind(args DescribeIngressUserOptions) error {
ingressKey := args.ingress
if !ingressKeyRE.MatchString(ingressKey) {
return fmt.Errorf(
"ingress identifier '%s' isn't valid: it must contain only letters or digits",
"Ingress identifier '%s' isn't valid: it must contain between three and five lowercase letters or digits",
ingressKey,
)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dlt/ingress/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func run(_ *cobra.Command, argv []string) {
ingressID := argv[0]
if !ingressKeyRE.MatchString(ingressID) {
r.Reporter.Errorf(
"Ingress identifier '%s' isn't valid: it must contain only four letters or digits",
"Ingress identifier '%s' isn't valid: it must contain between three and five lowercase letters or digits",
ingressID,
)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion cmd/edit/ingress/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func run(cmd *cobra.Command, argv []string) {
ingressKey := argv[0]
if !ingressKeyRE.MatchString(ingressKey) {
r.Reporter.Errorf(
"Ingress identifier '%s' isn't valid: it must contain only letters or digits",
"Ingress identifier '%s' isn't valid: it must contain between three and five lowercase letters or digits",
ingressKey,
)
os.Exit(1)
Expand Down
19 changes: 14 additions & 5 deletions tests/e2e/test_rosacli_ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ var _ = Describe("Edit default ingress",
By("Get cluster ingress with invalid/non-existing cluster id")
out, err := rosaClient.Ingress.DescribeIngress(clusterID, "xxx")
Expect(err).To(HaveOccurred())
Expect(out.String()).Should(ContainSubstring("ERR: Failed to get ingress 'xxx' for cluster '%s'", clusterID))
Expect(
out.String(),
).Should(ContainSubstring("ERR: Failed to get ingress 'xxx' for cluster '%s'", clusterID))
})

It("change load balancer type - [id:64767]",
Expand Down Expand Up @@ -278,7 +280,9 @@ var _ = Describe("Edit default ingress",
defaultIngressRouteSelectorList := strings.Split(ingressConfig.DefaultIngressRouteSelector, ",")
defaultIngressRouteSelector_1 := defaultIngressRouteSelectorList[1] + ", " + defaultIngressRouteSelectorList[0]
defaultIngressRouteSelector_2 := defaultIngressRouteSelectorList[0] + ", " + defaultIngressRouteSelectorList[1]
Expect(ingress.RouteSelectors).To(Or(Equal(defaultIngressRouteSelector_1), Equal(defaultIngressRouteSelector_2)))
Expect(
ingress.RouteSelectors,
).To(Or(Equal(defaultIngressRouteSelector_1), Equal(defaultIngressRouteSelector_2)))
Expect(ingress.NamespaceOwnershipPolicy).To(Equal(ingressConfig.DefaultIngressNamespaceOwnershipPolicy))
Expect(ingress.WildcardPolicy).To(Equal(ingressConfig.DefaultIngressWildcardPolicy))
})
Expand Down Expand Up @@ -379,7 +383,9 @@ var _ = Describe("Edit default ingress",
)
if profile.ClusterConfig.PrivateLink && !isHosted {
Expect(err).To(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("Can't update listening mode on an AWS Private Link cluster"))
Expect(
output.String(),
).Should(ContainSubstring("Can't update listening mode on an AWS Private Link cluster"))

By("Edit label-match only")
output, err = rosaClient.Ingress.EditIngress(clusterID,
Expand Down Expand Up @@ -496,7 +502,7 @@ var _ = Describe("Edit ingress",
)
Expect(err).To(HaveOccurred())
Expect(output.String()).Should(
ContainSubstring("Ingress identifier 'notexisting' isn't valid"))
ContainSubstring("Ingress identifier 'notexisting' isn't valid"))

By("Edit ingress with invalid LB-type")
output, err = ingressService.EditIngress(clusterID, "apps",
Expand Down Expand Up @@ -569,7 +575,10 @@ var _ = Describe("Delete ingress validations",
output, err = ingressService.DeleteIngress(clusterID, invalidIngress)
Expect(err).To(HaveOccurred())
Expect(output.String()).Should(
ContainSubstring("identifier '%s' isn't valid: it must contain only four letters or digits", invalidIngress))
ContainSubstring(
"identifier '%s' isn't valid: it must contain between three and five lowercase letters or digits",
invalidIngress,
))

})
})

0 comments on commit d34ff6c

Please sign in to comment.