Skip to content

Commit

Permalink
default binging host
Browse files Browse the repository at this point in the history
stderr for warning
  • Loading branch information
lynnemorrison committed Dec 12, 2024
1 parent 2c20d0f commit f496955
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
4 changes: 0 additions & 4 deletions internal/cmd/skupper/site/nonkube/site_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ func (cmd *CmdSiteCreate) ValidateInput(args []string) []error {
}
}

if cmd.Flags != nil && cmd.Flags.BindHost == "" && cmd.Flags.EnableLinkAccess {
validationErrors = append(validationErrors, fmt.Errorf("bindhost should not be empty"))
}

if cmd.Flags != nil && cmd.Flags.BindHost != "" {
ip := net.ParseIP(cmd.Flags.BindHost)
ok, _ := hostStringValidator.Evaluate(cmd.Flags.BindHost)
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/skupper/site/nonkube/site_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ func TestNonKubeCmdSiteCreate_ValidateInput(t *testing.T) {
},
},
{
name: "bindHost was not specified",
name: "bindHost was not specified ok",
args: []string{"my-site"},
flags: &common.CommandSiteCreateFlags{EnableLinkAccess: true},
expectedErrors: []string{"bindhost should not be empty"},
expectedErrors: []string{},
},
{
name: "bindHost was not valid",
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/skupper/site/nonkube/site_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/skupperproject/skupper/pkg/apis/skupper/v2alpha1"
"github.com/skupperproject/skupper/pkg/nonkube/api"
"github.com/spf13/cobra"
"gotest.tools/assert"
"gotest.tools/v3/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/skupper/site/nonkube/site_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/skupperproject/skupper/internal/nonkube/client/fs"
"github.com/skupperproject/skupper/pkg/apis/skupper/v2alpha1"
"github.com/skupperproject/skupper/pkg/nonkube/api"
"gotest.tools/assert"
"gotest.tools/v3/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/skupper/site/nonkube/site_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ func (cmd *CmdSiteUpdate) Run() error {
Namespace: cmd.namespace,
},
Spec: v2alpha1.SiteSpec{
Settings: cmd.options,
LinkAccess: "default",
Settings: cmd.options,
},
}

Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/skupper/site/nonkube/site_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/skupperproject/skupper/pkg/apis/skupper/v2alpha1"
"github.com/skupperproject/skupper/pkg/nonkube/api"
"github.com/spf13/cobra"
"gotest.tools/assert"
"gotest.tools/v3/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down Expand Up @@ -285,6 +285,7 @@ func TestCmdSiteUpdate_Run(t *testing.T) {
errorMessage string
siteName string
flags common.CommandSiteUpdateFlags
linkAccessEnabled bool
}

testTable := []test{
Expand All @@ -297,6 +298,7 @@ func TestCmdSiteUpdate_Run(t *testing.T) {
EnableLinkAccess: true,
SubjectAlternativeNames: []string{"2.2.2.2", "test"},
},
linkAccessEnabled: true,
},
{
name: "runs ok",
Expand All @@ -313,6 +315,7 @@ func TestCmdSiteUpdate_Run(t *testing.T) {
SubjectAlternativeNames: []string{"2.2.2.2", "test", "5.6.7.8"},
Output: "json",
},
linkAccessEnabled: true,
},
{
name: "run ok output yaml",
Expand All @@ -333,6 +336,7 @@ func TestCmdSiteUpdate_Run(t *testing.T) {
command.routerAccessHandler = fs.NewRouterAccessHandler(command.namespace)
command.newSettings.bindHost = test.flags.BindHost
command.newSettings.subjectAlternativeNames = test.flags.SubjectAlternativeNames
command.linkAccessEnabled = test.linkAccessEnabled
defer command.siteHandler.Delete("my-site")
defer command.routerAccessHandler.Delete("my-site")
t.Run(test.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/skupper/site/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ There can be only one site definition per namespace.`,
cmd.Flags().StringVarP(&cmdFlags.Output, common.FlagNameOutput, "o", "", common.FlagDescOutput)
cmd.Flags().StringVar(&cmdFlags.ServiceAccount, common.FlagNameServiceAccount, "", common.FlagDescServiceAccount)
cmd.Flags().DurationVar(&cmdFlags.Timeout, common.FlagNameTimeout, 30*time.Second, common.FlagDescTimeout)
cmd.Flags().StringVar(&cmdFlags.BindHost, common.FlagNameBindHost, "", common.FlagDescBindHost)
cmd.Flags().StringVar(&cmdFlags.BindHost, common.FlagNameBindHost, "0.0.0.0", common.FlagDescBindHost)
cmd.Flags().StringSliceVar(&cmdFlags.SubjectAlternativeNames, common.FlagNameSubjectAlternativeNames, []string{}, common.FlagDescSubjectAlternativeNames)
cmd.Flags().StringVar(&cmdFlags.Wait, common.FlagNameWait, "ready", common.FlagDescWait)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/skupper/site/site_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestCmdSiteFactory(t *testing.T) {
common.FlagNameServiceAccount: "",
common.FlagNameOutput: "",
common.FlagNameTimeout: "30s",
common.FlagNameBindHost: "",
common.FlagNameBindHost: "0.0.0.0",
common.FlagNameSubjectAlternativeNames: "[]",
common.FlagNameWait: "ready",
},
Expand Down
6 changes: 3 additions & 3 deletions internal/nonkube/client/fs/site_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package fs

import (
"errors"
"fmt"
"io/fs"
"os"

"github.com/skupperproject/skupper/internal/cmd/skupper/common"
"github.com/skupperproject/skupper/pkg/apis/skupper/v2alpha1"
Expand Down Expand Up @@ -48,7 +48,7 @@ func (s *SiteHandler) Get(name string, opts GetOptions) (*v2alpha1.Site, error)
err, file := s.ReadFile(s.pathProvider.GetRuntimeNamespace(), fileName, common.Sites)
if err != nil {
if opts.LogWarning {
fmt.Println("Site not initialized yet")
os.Stderr.WriteString("Site not initialized yet\n")
}
err, file = s.ReadFile(s.pathProvider.GetNamespace(), fileName, common.Sites)
if err != nil {
Expand Down Expand Up @@ -93,7 +93,7 @@ func (s *SiteHandler) List() ([]*v2alpha1.Site, error) {
path := s.pathProvider.GetRuntimeNamespace()
err, files := s.ReadDir(path, common.Sites)
if err != nil {
fmt.Println("Site not initialized yet")
os.Stderr.WriteString("Site not initialized yet\n")
path = s.pathProvider.GetNamespace()
err, files = s.ReadDir(path, common.Sites)
if err != nil {
Expand Down

0 comments on commit f496955

Please sign in to comment.