This is an automated email from the ASF dual-hosted git repository.
zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new 5c134de5 [navi] add navi discovery command (#760)
5c134de5 is described below
commit 5c134de5a60a5167deb004575c49e499755bd2c0
Author: Jian Zhong <[email protected]>
AuthorDate: Thu Jul 31 00:40:01 2025 +0800
[navi] add navi discovery command (#760)
---
navigator/cmd/navigator-agent/app/cmd.go | 19 +++++-
navigator/cmd/navigator-agent/app/wait.go | 17 +++++
navigator/cmd/navigator-agent/main.go | 17 +++++
.../cmd/navigator-agent/options/agent_proxy.go | 17 +++++
navigator/cmd/navigator-discovery/app/cmd.go | 75 +++++++++++++++++++++-
navigator/cmd/navigator-discovery/main.go | 17 +++++
navigator/pkg/bootstrap/options.go | 21 ++++++
navigator/pkg/bootstrap/server.go | 29 +++++++++
{navigator/pkg => pkg}/cmd/cmd.go | 0
pkg/model/proxy.go | 17 +++++
pkg/navi-agent/agent.go | 17 +++++
11 files changed, 244 insertions(+), 2 deletions(-)
diff --git a/navigator/cmd/navigator-agent/app/cmd.go
b/navigator/cmd/navigator-agent/app/cmd.go
index bb133333..21f85e01 100644
--- a/navigator/cmd/navigator-agent/app/cmd.go
+++ b/navigator/cmd/navigator-agent/app/cmd.go
@@ -1,9 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package app
import (
"fmt"
"github.com/apache/dubbo-kubernetes/navigator/cmd/navigator-agent/options"
- "github.com/apache/dubbo-kubernetes/navigator/pkg/cmd"
+ "github.com/apache/dubbo-kubernetes/pkg/cmd"
"github.com/apache/dubbo-kubernetes/pkg/model"
"github.com/spf13/cobra"
)
diff --git a/navigator/cmd/navigator-agent/app/wait.go
b/navigator/cmd/navigator-agent/app/wait.go
index 367208fe..c43b1157 100644
--- a/navigator/cmd/navigator-agent/app/wait.go
+++ b/navigator/cmd/navigator-agent/app/wait.go
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package app
import (
diff --git a/navigator/cmd/navigator-agent/main.go
b/navigator/cmd/navigator-agent/main.go
index f72b5ea8..12c71bb1 100644
--- a/navigator/cmd/navigator-agent/main.go
+++ b/navigator/cmd/navigator-agent/main.go
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package main
import (
diff --git a/navigator/cmd/navigator-agent/options/agent_proxy.go
b/navigator/cmd/navigator-agent/options/agent_proxy.go
index a52abd7c..aeba967e 100644
--- a/navigator/cmd/navigator-agent/options/agent_proxy.go
+++ b/navigator/cmd/navigator-agent/options/agent_proxy.go
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package options
import naviagent "github.com/apache/dubbo-kubernetes/pkg/navi-agent"
diff --git a/navigator/cmd/navigator-discovery/app/cmd.go
b/navigator/cmd/navigator-discovery/app/cmd.go
index f6d5e4aa..697b0e00 100644
--- a/navigator/cmd/navigator-discovery/app/cmd.go
+++ b/navigator/cmd/navigator-discovery/app/cmd.go
@@ -1,11 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package app
-import "github.com/spf13/cobra"
+import (
+ "fmt"
+ "github.com/apache/dubbo-kubernetes/navigator/pkg/bootstrap"
+ "github.com/apache/dubbo-kubernetes/pkg/cmd"
+ "github.com/spf13/cobra"
+)
+
+var (
+ serverArgs *bootstrap.NaviArgs
+)
func NewRootCommand() *cobra.Command {
rootCmd := &cobra.Command{
Use: "navi-discovery",
+ Short: "Dubbo Navigator.",
+ Long: "Dubbo Navigator provides mesh-wide traffic
management, security and policy capabilities in the Dubbo Service Mesh.",
SilenceUsage: true,
+ FParseErrWhitelist: cobra.FParseErrWhitelist{
+ // Allow unknown flags for backward-compatibility.
+ UnknownFlags: true,
+ },
+ PreRunE: func(c *cobra.Command, args []string) error {
+ cmd.AddFlags(c)
+ return nil
+ },
}
+ discoveryCmd := newDiscoveryCommand()
+ addFlags(discoveryCmd)
+ rootCmd.AddCommand(discoveryCmd)
return rootCmd
}
+
+func newDiscoveryCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "discovery",
+ Short: "Start Dubbo proxy discovery service.",
+ Args: cobra.ExactArgs(0),
+ FParseErrWhitelist: cobra.FParseErrWhitelist{
+ // Allow unknown flags for backward-compatibility.
+ UnknownFlags: true,
+ },
+ PreRunE: func(c *cobra.Command, args []string) error {
+ return nil
+ },
+ RunE: func(c *cobra.Command, args []string) error {
+ // Create the stop channel for all the servers.
+ stop := make(chan struct{})
+
+ // Create the server for the discovery service.
+ discoveryServer, err := bootstrap.NewServer(serverArgs)
+ if err != nil {
+ return fmt.Errorf("failed to create discovery
service: %v", err)
+ }
+
+ // Start the server
+ if err := discoveryServer.Start(stop); err != nil {
+ return fmt.Errorf("failed to start discovery
service: %v", err)
+ }
+ return nil
+ },
+ }
+}
+
+func addFlags(c *cobra.Command) {
+}
diff --git a/navigator/cmd/navigator-discovery/main.go
b/navigator/cmd/navigator-discovery/main.go
index 90b59883..88088642 100644
--- a/navigator/cmd/navigator-discovery/main.go
+++ b/navigator/cmd/navigator-discovery/main.go
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package main
import (
diff --git a/navigator/pkg/bootstrap/options.go
b/navigator/pkg/bootstrap/options.go
new file mode 100644
index 00000000..bfb76817
--- /dev/null
+++ b/navigator/pkg/bootstrap/options.go
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package bootstrap
+
+type NaviArgs struct {
+}
diff --git a/navigator/pkg/bootstrap/server.go
b/navigator/pkg/bootstrap/server.go
new file mode 100644
index 00000000..c4d55457
--- /dev/null
+++ b/navigator/pkg/bootstrap/server.go
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package bootstrap
+
+type Server struct {
+}
+
+func NewServer(args *NaviArgs, initFuncs ...func(*Server)) (*Server, error) {
+ return nil, nil
+}
+
+func (s *Server) Start(stop <-chan struct{}) error {
+ return nil
+}
diff --git a/navigator/pkg/cmd/cmd.go b/pkg/cmd/cmd.go
similarity index 100%
rename from navigator/pkg/cmd/cmd.go
rename to pkg/cmd/cmd.go
diff --git a/pkg/model/proxy.go b/pkg/model/proxy.go
index 2aab6b74..fd275798 100644
--- a/pkg/model/proxy.go
+++ b/pkg/model/proxy.go
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package model
// NodeType decides the responsibility of the proxy serves in the mesh
diff --git a/pkg/navi-agent/agent.go b/pkg/navi-agent/agent.go
index 8c65019a..aee9c873 100644
--- a/pkg/navi-agent/agent.go
+++ b/pkg/navi-agent/agent.go
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package naviagent
import "github.com/apache/dubbo-kubernetes/pkg/model"