Skip to content

Commit

Permalink
update error message to tlsCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnemorrison committed Dec 10, 2024
1 parent febe755 commit cc50135
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/skupper/connector/nonkube/connector_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (cmd *CmdConnectorCreate) ValidateInput(args []string) []error {
if cmd.Flags.TlsCredentials != "" {
ok, err := resourceStringValidator.Evaluate(cmd.Flags.TlsCredentials)
if !ok {
validationErrors = append(validationErrors, fmt.Errorf("tlsCredentials is not valid: %s", err))
validationErrors = append(validationErrors, fmt.Errorf("tlsCredentials value is not valid: %s", err))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestNonKubeCmdConnectorCreate_ValidateInput(t *testing.T) {
name: "TlsCredentials is not valid",
args: []string{"my-connector-tls", "8080"},
flags: &common.CommandConnectorCreateFlags{TlsCredentials: "not-valid$", Host: "1.2.3.4"},
expectedErrors: []string{"tlsCredentials is not valid: value does not match this regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])*(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])*)*$"},
expectedErrors: []string{"tlsCredentials value is not valid: value does not match this regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])*(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])*)*$"},
},
{
name: "host is not valid",
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/skupper/connector/nonkube/connector_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (cmd *CmdConnectorUpdate) ValidateInput(args []string) []error {
if cmd.Flags.TlsCredentials != "" {
ok, err := resourceStringValidator.Evaluate(cmd.Flags.TlsCredentials)
if !ok {
validationErrors = append(validationErrors, fmt.Errorf("tlsCredentials is not valid: %s", err))
validationErrors = append(validationErrors, fmt.Errorf("tlsCredentials value is not valid: %s", err))
} else {
cmd.newSettings.tlsCredentials = cmd.Flags.TlsCredentials
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestCmdConnectorUpdate_ValidateInput(t *testing.T) {
name: "tlsCredentials is not valid",
args: []string{"my-connector"},
flags: &common.CommandConnectorUpdateFlags{TlsCredentials: "not-valid$", Host: "1.2.3.4"},
expectedErrors: []string{"tlsCredentials is not valid: value does not match this regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])*(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])*)*$"},
expectedErrors: []string{"tlsCredentials value is not valid: value does not match this regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])*(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])*)*$"},
},
{
name: "host is not valid",
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/skupper/listener/nonkube/listener_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (cmd *CmdListenerCreate) ValidateInput(args []string) []error {
if cmd.Flags.TlsCredentials != "" {
ok, err := resourceStringValidator.Evaluate(cmd.Flags.TlsCredentials)
if !ok {
validationErrors = append(validationErrors, fmt.Errorf("tlsCredentials is not valid: %s", err))
validationErrors = append(validationErrors, fmt.Errorf("tlsCredentials value is not valid: %s", err))
}
}

Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/skupper/listener/nonkube/listener_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestNonKubeCmdListenerCreate_ValidateInput(t *testing.T) {
name: "TlsCredentials key is not valid",
args: []string{"my-listener-tls", "8080"},
flags: &common.CommandListenerCreateFlags{TlsCredentials: "not-valid$", Host: "1.2.3.4"},
expectedErrors: []string{"tlsCredentials is not valid: value does not match this regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])*(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])*)*$"},
expectedErrors: []string{"tlsCredentials value is not valid: value does not match this regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])*(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])*)*$"},
},
{
name: "host is not valid",
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestNonKubeCmdListenerCreate_InputToOptions(t *testing.T) {
testTable := []test{
{
name: "test1",
flags: common.CommandListenerCreateFlags{"backend", "", "secret", "tcp", 0, "json"},
flags: common.CommandListenerCreateFlags{"backend", "", "secret", "tcp", 0, "json", "none"},
expectedTlsCredentials: "secret",
expectedHost: "0.0.0.0",
expectedRoutingKey: "backend",
Expand All @@ -175,7 +175,7 @@ func TestNonKubeCmdListenerCreate_InputToOptions(t *testing.T) {
{
name: "test2",
namespace: "test",
flags: common.CommandListenerCreateFlags{"backend", "1.2.3.4", "secret", "tcp", 0, "json"},
flags: common.CommandListenerCreateFlags{"backend", "1.2.3.4", "secret", "tcp", 0, "json", "configured"},
expectedTlsCredentials: "secret",
expectedHost: "1.2.3.4",
expectedRoutingKey: "backend",
Expand All @@ -186,7 +186,7 @@ func TestNonKubeCmdListenerCreate_InputToOptions(t *testing.T) {
{
name: "test3",
namespace: "default",
flags: common.CommandListenerCreateFlags{"", "", "secret", "tcp", 0, "yaml"},
flags: common.CommandListenerCreateFlags{"", "", "secret", "tcp", 0, "yaml", "ready"},
expectedTlsCredentials: "secret",
expectedHost: "0.0.0.0",
expectedRoutingKey: "my-listener",
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/skupper/listener/nonkube/listener_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (cmd *CmdListenerUpdate) ValidateInput(args []string) []error {
if cmd.Flags.TlsCredentials != "" {
ok, err := resourceStringValidator.Evaluate(cmd.Flags.TlsCredentials)
if !ok {
validationErrors = append(validationErrors, fmt.Errorf("tlsCredentials is not valid: %s", err))
validationErrors = append(validationErrors, fmt.Errorf("tlsCredentials value is not valid: %s", err))
} else {
cmd.newSettings.tlsCredentials = cmd.Flags.TlsCredentials
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestCmdListenerUpdate_ValidateInput(t *testing.T) {
name: "TlsCredentials key is not valid",
args: []string{"my-listener"},
flags: &common.CommandListenerUpdateFlags{TlsCredentials: "not-valid$", Host: "1.2.3.4"},
expectedErrors: []string{"tlsCredentials is not valid: value does not match this regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])*(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])*)*$"},
expectedErrors: []string{"tlsCredentials value is not valid: value does not match this regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])*(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])*)*$"},
},
{
name: "port is not valid",
Expand Down

0 comments on commit cc50135

Please sign in to comment.