diff --git a/VERSION b/VERSION index 90ab6e9..8ce995b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.0.2 \ No newline at end of file +v0.0.3 \ No newline at end of file diff --git a/charts/smartdocter/Chart.yaml b/charts/smartdocter/Chart.yaml index 6657d8b..0d8133f 100644 --- a/charts/smartdocter/Chart.yaml +++ b/charts/smartdocter/Chart.yaml @@ -4,11 +4,11 @@ home: "https://spidernet-io.github.io/smartdocter" # application or library type: application # no need to modify this version , CI will auto update it with /VERSION -version: v0.0.1 +version: v0.0.3 # This field is informational, and has no impact on chart version calculations . # Leaving it unquoted can lead to parsing issues in some cases # no need to modify this version , CI will auto update it with /VERSION -appVersion: "v0.0.1" +appVersion: "v0.0.3" kubeVersion: ">= 1.16.0-0" description: smart docter for kubernetes sources: diff --git a/smartdocter-agent-cmd/serve-hostname/main.go b/smartdocter-agent-cmd/serve-hostname/main.go index c98112b..da42dc1 100644 --- a/smartdocter-agent-cmd/serve-hostname/main.go +++ b/smartdocter-agent-cmd/serve-hostname/main.go @@ -23,6 +23,7 @@ package main import ( "fmt" + "github.com/spf13/cobra" "log" "net" "net/http" @@ -30,8 +31,6 @@ import ( "os/signal" "syscall" "time" - - "github.com/spf13/cobra" ) // CmdServeHostname is used by agnhost Cobra. @@ -56,7 +55,7 @@ func init() { CmdServeHostname.Flags().BoolVar(&doUDP, "udp", false, "Serve raw over UDP.") CmdServeHostname.Flags().BoolVar(&doHTTP, "http", true, "Serve HTTP.") CmdServeHostname.Flags().BoolVar(&doClose, "close", false, "Close connection per each HTTP request.") - CmdServeHostname.Flags().IntVar(&port, "port", 9376, "Port number.") + CmdServeHostname.Flags().IntVar(&port, "port", 80, "Port number.") } func rootmain(cmd *cobra.Command, args []string) { @@ -124,8 +123,24 @@ func rootmain(cmd *cobra.Command, args []string) { // Add this header to force to close the connection after serving the request. w.Header().Add("Connection", "close") } - res := "server: " + hostname + ", client: " + r.RemoteAddr - fmt.Fprintf(w, "%s", res) + message := "{ \n" + message += fmt.Sprintf(" \"server\": \"%s\"\n", hostname) + message += fmt.Sprintf(" \"clientIp\": \"%s\"\n", r.RemoteAddr) + message += "}" + fmt.Fprintf(w, "%s", message) + + message = "\n" + message += "{ \n" + message += fmt.Sprintf(" \"request method\": \"%s\"\n", r.Method) + message += fmt.Sprintf(" \"request url\": \"%s\"\n", r.RequestURI) + message += " \"request header\": {\n" + for k, v := range r.Header { + message += fmt.Sprintf(" \"%s\": \"%s\"\n", k, v) + } + message += " }\n" + message += "}" + fmt.Fprintf(w, "%s", message) + }) go func() { // Run in a closure so http.ListenAndServe doesn't block