[agent-wdd]-重构agent的bastion模式

This commit is contained in:
zeaslity
2025-02-10 11:15:35 +08:00
parent 5ca5689083
commit a0811d62e7
8 changed files with 138 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ import (
var log = logger.Log
// C:\Users\wddsh\go\bin\gox.exe -osarch="linux/amd64" -output "build/octopus-agent_{{.OS}}_{{.Arch}}"
// C:\Users\wdd\go\bin\gox.exe -osarch="linux/arm64" -output "build/octopus-agent_{{.OS}}_{{.Arch}}"
// C:\Users\wdd\go\bin\gox.exe -osarch="linux/amd64" -output "build/octopus-agent_{{.OS}}_{{.Arch}}"
// /root/go/bin/gox -osarch="linux/amd64" -output "build/octopus-agent_{{.OS}}_{{.Arch}}"

View File

@@ -405,6 +405,27 @@ func TestCmiiEnvDeploy_YunNanErJiXin(t *testing.T) {
}
func TestCmiiEnvDeploy_ShenZhenGuiZiXiangMu(t *testing.T) {
// 深圳规自项目
commonEnv := &z_dep.CommonEnvironmentConfig{
WebIP: "39.129.174.66",
WebPort: "8088",
HarborIPOrCustomImagePrefix: "192.168.186.11",
HarborPort: "8033",
Namespace: "ynydapp",
TagVersion: "6.1.0",
TenantEnv: "",
MinioPublicIP: "",
MinioInnerIP: "192.168.186.15",
NFSServerIP: "192.168.186.15",
ApplyFilePrefix: "",
}
CmiiEnvDeployOffline(commonEnv, true, real_project.Cmii611ImageList)
}
func TestCmiiNewAppDeploy(t *testing.T) {
deployNamespace := config.DevOperation

View File

@@ -22,7 +22,7 @@ func TestFetchDependencyRepos_Middle(t *testing.T) {
func TestFetchDependencyRepos_RKE(t *testing.T) {
errorPullImageList, errorGzipImageList, realCmiiImageName, allGzipFileNameList := C_DownloadCompressUploadDependency(true, true, true)
errorPullImageList, errorGzipImageList, realCmiiImageName, allGzipFileNameList := C_DownloadCompressUploadDependency(true, false, true)
utils.BeautifulPrintListWithTitle(errorPullImageList, "errorPullImageList")
utils.BeautifulPrintListWithTitle(errorGzipImageList, "errorGzipImageList")

View File

@@ -271,7 +271,7 @@ func TestUpdateCmiiDeploymentImageTag(t *testing.T) {
now := time.Now()
targetTime := time.Date(now.Year(), now.Month(), now.Day(), 17, 46, 00, 0, now.Location())
targetTime := time.Date(now.Year(), now.Month(), now.Day(), 17, 23, 00, 0, now.Location())
duration := time.Duration(0)
@@ -292,7 +292,9 @@ func TestUpdateCmiiDeploymentImageTag(t *testing.T) {
appNameTagMap := map[string]string{
//"cmii-app-release": "6.1.0-122001",
"cmii-uas-lifecycle": "6.2.0-master-1.1-012201",
//"cmii-uav-platform-oms": "6.2.0-012201",
//"cmii-uas-lifecycle": "6.2.0-012301",
"cmii-uav-advanced5g": "6.2.0-master-012301",
//"cmii-uav-platform-pilot2-to-cloud": "6.1.0-32030-123101",
//"cmii-uav-industrial-portfolio": "6.1.0-20241125-121702",
}

8
agent-wdd/Makefile Normal file
View File

@@ -0,0 +1,8 @@
.PHONY: build-linux
build-linux: ## Install dependencies
@C:\Users\wddsh\go\bin\gox.exe -osarch="linux/amd64" -output "build/agent-wdd_{{.OS}}_{{.Arch}}"

65
agent-wdd/cmd/root.go Normal file
View File

@@ -0,0 +1,65 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"os"
)
const WddConfigFilePath = "/usr/local/etc/wdd/"
var rootCmd = &cobra.Command{
Use: "wdd",
Short: "wdd应用程序是wdd封装的NB工具",
Long: `使用golang的强大特性加上wdd的高超技术\n打造一个方便、高效、适用于各种LINUX系统的瑞士军刀工具\n 尽情享用!`,
Run: func(cmd *cobra.Command, args []string) {
// Do Stuff Here
},
}
var cfgFile = ""
var userLicense = ""
var projectBase = ""
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
rootCmd.PersistentFlags().StringVarP(&projectBase, "projectbase", "b", "",
"base project directory eg. github.com/spf13/")
rootCmd.PersistentFlags().StringP("author", "a", "YOUR NAME", "Author name for copyright attribution")
rootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "Name of license for the project (can provide `licensetext` in config)")
rootCmd.PersistentFlags().Bool("viper", true, "Use Viper for configuration")
viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author"))
viper.BindPFlag("projectbase", rootCmd.PersistentFlags().Lookup("projectbase"))
viper.BindPFlag("useViper", rootCmd.PersistentFlags().Lookup("viper"))
viper.SetDefault("author", "Esdeath Wang(zeaslity@gamil.com)")
viper.SetDefault("license", "apache")
}
func initConfig() {
// Don't forget to read config either from cfgFile or from home directory!
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
} else {
// Search config in home directory with name ".cobra" (without extension).
viper.AddConfigPath(WddConfigFilePath)
viper.SetConfigName(".cobra")
}
if err := viper.ReadInConfig(); err != nil {
fmt.Println("Can't read config:", err)
os.Exit(1)
}
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

31
agent-wdd/go.mod Normal file
View File

@@ -0,0 +1,31 @@
module agent-wdd
go 1.23.5
require (
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
)
require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

7
agent-wdd/main.go Normal file
View File

@@ -0,0 +1,7 @@
package main
import "agent-wdd/cmd"
func main() {
cmd.Execute()
}