Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cheina97 committed Oct 29, 2024
1 parent 7d0788e commit 64e9f00
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
1 change: 1 addition & 0 deletions cmd/liqoctl/cmd/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func newNetworkCommand(ctx context.Context, f *factory.Factory) *cobra.Command {

cmd.PersistentFlags().DurationVar(&options.Timeout, "timeout", 120*time.Second, "Timeout for completion")
cmd.PersistentFlags().BoolVar(&options.Wait, "wait", false, "Wait for completion")
cmd.PersistentFlags().BoolVar(&options.SkipValidation, "skip-validation", false, "Skip the validation")

options.LocalFactory.AddFlags(cmd.PersistentFlags(), cmd.RegisterFlagCompletionFunc)
options.RemoteFactory.AddFlags(cmd.PersistentFlags(), cmd.RegisterFlagCompletionFunc)
Expand Down
1 change: 1 addition & 0 deletions cmd/liqoctl/cmd/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func newPeerCommand(ctx context.Context, f *factory.Factory) *cobra.Command {
}

cmd.PersistentFlags().DurationVar(&options.Timeout, "timeout", 10*time.Minute, "Timeout for peering completion")
cmd.PersistentFlags().BoolVar(&options.SkipValidation, "skip-validation", false, "Skip the validation")

options.LocalFactory.AddFlags(cmd.PersistentFlags(), cmd.RegisterFlagCompletionFunc)
options.RemoteFactory.AddFlags(cmd.PersistentFlags(), cmd.RegisterFlagCompletionFunc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ spec:
- port: "{{"{{ .Spec.Endpoint.Port }}"}}"
protocol: UDP
targetPort: "{{"{{ .Spec.Endpoint.Port }}"}}"

{{- if .Values.networking.gatewayTemplates.server.service.allocateLoadBalancerNodePorts }}
allocateLoadBalancerNodePorts: {{ .Values.networking.gatewayTemplates.server.service.allocateLoadBalancerNodePorts }}
{{- end }}
Expand Down
21 changes: 12 additions & 9 deletions pkg/liqoctl/network/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ type Options struct {
LocalFactory *factory.Factory
RemoteFactory *factory.Factory

Timeout time.Duration
Wait bool
Timeout time.Duration
Wait bool
SkipValidation bool

ServerGatewayType string
ServerTemplateName string
Expand Down Expand Up @@ -165,14 +166,16 @@ func (o *Options) RunConnect(ctx context.Context) error {
return err
}

// Check if the Templates exists and is valid on cluster 1
if err := cluster1.CheckTemplateGwClient(ctx, o); err != nil {
return err
}
if !o.SkipValidation {
// Check if the Templates exists and is valid on cluster 1
if err := cluster1.CheckTemplateGwClient(ctx, o); err != nil {
return err
}

// Check if the Templates exists and is valid on cluster 2
if err := cluster2.CheckTemplateGwServer(ctx, o); err != nil {
return err
// Check if the Templates exists and is valid on cluster 2
if err := cluster2.CheckTemplateGwServer(ctx, o); err != nil {
return err
}
}

// Check if the Networking is initialized on cluster 1
Expand Down
12 changes: 7 additions & 5 deletions pkg/liqoctl/peer/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ import (

// Options encapsulates the arguments of the peer command.
type Options struct {
LocalFactory *factory.Factory
RemoteFactory *factory.Factory
Timeout time.Duration
LocalFactory *factory.Factory
RemoteFactory *factory.Factory
Timeout time.Duration
SkipValidation bool

// Networking options
NetworkingDisabled bool
Expand Down Expand Up @@ -103,8 +104,9 @@ func ensureNetworking(ctx context.Context, o *Options) error {
LocalFactory: o.LocalFactory,
RemoteFactory: o.RemoteFactory,

Timeout: o.Timeout,
Wait: true,
Timeout: o.Timeout,
Wait: true,
SkipValidation: o.SkipValidation,

ServerGatewayType: nwforge.DefaultGwServerType,
ServerTemplateName: nwforge.DefaultGwServerTemplateName,
Expand Down
6 changes: 3 additions & 3 deletions pkg/utils/maps/maps.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ func DeSerializeCache(s string) []string {
}

// GetNestedField returns the nested field of a map.
// Example: GetNestedField(map[string]interface{}{"a": map[string]interface{}{"b": "c"}}, "a.b") returns "c".
func GetNestedField(m map[string]interface{}, path string) (interface{}, error) {
// Example: GetNestedField(map[string]any{"a": map[string]any{"b": "c"}}, "a.b") returns "c".
func GetNestedField(m map[string]any, path string) (any, error) {
fields := strings.Split(path, ".")
current := m
for i, field := range fields {
Expand All @@ -211,7 +211,7 @@ func GetNestedField(m map[string]interface{}, path string) (interface{}, error)
if i == len(fields)-1 {
return next, nil
}
current, ok = next.(map[string]interface{})
current, ok = next.(map[string]any)
if !ok {
return nil, fmt.Errorf("unable to get %s", strings.Join(fields[:i+1], "."))
}
Expand Down

0 comments on commit 64e9f00

Please sign in to comment.