-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added script to generate compatibility table for different Logstash v…
…ersions
- Loading branch information
1 parent
d232491
commit c809706
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |