Skip to content

Commit

Permalink
output missing services from diff
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Feb 20, 2024
1 parent a977f86 commit 8578505
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tools/teamcity-diff-check/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,28 @@ import (
"io"
"os"
"os/exec"
"reflect"
"regexp"
)

var serviceFile = flag.String("service_file", "services_ga.kt", "kotlin service file to be parsed")
var provider = flag.String("provider", "google", "Specify which provider to run diff_check on")

func serviceDifference(gS, tS []string) []string {
g := make(map[string]struct{}, len(gS))
for _, s := range gS {
g[s] = struct{}{}
}

var diff []string
for _, s := range tS {
if _, found := g[s]; !found {
diff = append(diff, s)
}
}

return diff
}

func main() {
flag.Parse()

Expand Down Expand Up @@ -98,8 +113,9 @@ func main() {
teamcityServices = append(teamcityServices, string(service))
}

if !reflect.DeepEqual(googleServices, teamcityServices) {
if diff := serviceDifference(googleServices, teamcityServices); len(diff) != 0 {
fmt.Fprintf(os.Stderr, "error: diff in %s\n", *serviceFile)
fmt.Fprintf(os.Stderr, "Missing Services: %s\n", diff)
os.Exit(1)
}

Expand Down

0 comments on commit 8578505

Please sign in to comment.