From c8097061db30a5ee3b900fe9912229fb5d131f24 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sat, 12 Aug 2023 14:43:21 +0000 Subject: [PATCH] Added script to generate compatibility table for different Logstash versions --- scripts/generate_compatibility_table.go | 53 +++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 scripts/generate_compatibility_table.go diff --git a/scripts/generate_compatibility_table.go b/scripts/generate_compatibility_table.go new file mode 100644 index 00000000..0645b61b --- /dev/null +++ b/scripts/generate_compatibility_table.go @@ -0,0 +1,53 @@ +package main + +import ( + "fmt" + "io/ioutil" + "net/http" + "os" + "strings" + + "github.com/docker/docker/client" +) + +func main() { + cli, err := client.NewClientWithOpts(client.FromEnv) + if err != nil { + panic(err) + } + + services, err := cli.ServiceList(context.Background(), types.ServiceListOptions{}) + if err != nil { + panic(err) + } + + var compatibilityTable strings.Builder + compatibilityTable.WriteString("| Logstash Version | Metric 1 | Metric 2 | Metric 3 |\n") + compatibilityTable.WriteString("|------------------|----------|----------|----------|\n") + + for _, service := range services { + if strings.HasPrefix(service.Spec.Name, "logstash") { + version := strings.TrimPrefix(service.Spec.Name, "logstash_") + compatibilityTable.WriteString("| " + version) + + resp, err := http.Get(fmt.Sprintf("http://%s:9600/_node/stats", service.Spec.Name)) + if err != nil { + panic(err) + } + defer resp.Body.Close() + + // Check the compatibility of the metrics and add the results to the compatibility table + // This is a simplified example and the actual implementation may vary + if resp.StatusCode == http.StatusOK { + compatibilityTable.WriteString(" | Yes | Yes | Yes |\n") + } else { + compatibilityTable.WriteString(" | No | No | No |\n") + } + } + } + + err = ioutil.WriteFile("COMPATIBILITY.md", []byte(compatibilityTable.String()), 0644) + if err != nil { + panic(err) + } +} \ No newline at end of file