From 3b1a1a007313274c872d186ff6a33c7b2c8c3fc2 Mon Sep 17 00:00:00 2001 From: cs-308-2023 Date: Tue, 14 Jan 2025 09:48:45 +0530 Subject: [PATCH 1/4] Beautified --feature-flags Signed-off-by: cs-308-2023 --- features/main.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 features/main.go diff --git a/features/main.go b/features/main.go new file mode 100644 index 00000000000..5b885cf9bdc --- /dev/null +++ b/features/main.go @@ -0,0 +1,58 @@ +package features + +import ( + "fmt" + "io" + "os" + "strings" +) + +func beautify(data string) string { + outputString := string(data) + startIndex := strings.Index(outputString, "--feature-gates") + if startIndex == -1 { + fmt.Println("The string '--feature-gates' was not found.") + os.Exit(1) + } + relativeLineBreak := strings.Index(outputString[startIndex:], "\n") + var featureLine string + if relativeLineBreak == -1 { + featureLine = outputString[startIndex:] + } else { + featureLine = outputString[startIndex : startIndex+relativeLineBreak] + } + openParen := strings.Index(featureLine, "(") + closeParen := strings.Index(featureLine, ")") + if openParen == -1 || closeParen == -1 || closeParen <= openParen { + fmt.Println("Could not find parentheses surrounding the feature gates data.") + os.Exit(1) + } + inside := featureLine[openParen+1 : closeParen] + splitData := strings.Split(inside, ",") + combined_split := "A list of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.\n" + for _, item := range splitData { + cleanItem := strings.TrimSpace(item) + combined_split = combined_split + "\t" + cleanItem + "\n" + } + return combined_split +} +func main() { + data, err := io.ReadAll(os.Stdin) + if err != nil { + panic(err) + } + outputString := string(data) + startIndex := strings.Index(outputString, "--feature-gates") + if startIndex == -1 { + fmt.Print(outputString) + return + } + relativeLineBreak := strings.Index(outputString[startIndex:], "\n") + if relativeLineBreak == -1 { + relativeLineBreak = len(outputString) - startIndex + } + lineBreakIndex := startIndex + relativeLineBreak + extracted := outputString[startIndex:lineBreakIndex] + // newString := outputString[:startIndex] + beautify(extracted) + outputString[lineBreakIndex:] + fmt.Println(beautify(extracted)) +} \ No newline at end of file From 15c72170859895285368d0cbfc474a7973337ba3 Mon Sep 17 00:00:00 2001 From: cs-308-2023 Date: Tue, 14 Jan 2025 09:56:28 +0530 Subject: [PATCH 2/4] New make command 'features' Signed-off-by: cs-308-2023 --- Makefile | 4 ++++ {features => cmd/features}/main.go | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) rename {features => cmd/features}/main.go (94%) diff --git a/Makefile b/Makefile index e903f95e3a9..ba20bfc310c 100644 --- a/Makefile +++ b/Makefile @@ -218,6 +218,10 @@ generate-mocks: $(MOCKERY) certs: cd pkg/config/tlscfg/testdata && ./gen-certs.sh +.PHONY: features +features: + go run ./cmd/jaeger help | go run ./cmd/features + .PHONY: certs-dryrun certs-dryrun: cd pkg/config/tlscfg/testdata && ./gen-certs.sh -d diff --git a/features/main.go b/cmd/features/main.go similarity index 94% rename from features/main.go rename to cmd/features/main.go index 5b885cf9bdc..6b7a27cdfdb 100644 --- a/features/main.go +++ b/cmd/features/main.go @@ -1,4 +1,7 @@ -package features +// Copyright (c) 2025 The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 + +package main import ( "fmt" @@ -36,6 +39,7 @@ func beautify(data string) string { } return combined_split } + func main() { data, err := io.ReadAll(os.Stdin) if err != nil { @@ -55,4 +59,4 @@ func main() { extracted := outputString[startIndex:lineBreakIndex] // newString := outputString[:startIndex] + beautify(extracted) + outputString[lineBreakIndex:] fmt.Println(beautify(extracted)) -} \ No newline at end of file +} From 0cdf922badd882a7fab1b76ffd80c0b139d6d859 Mon Sep 17 00:00:00 2001 From: cs-308-2023 Date: Wed, 15 Jan 2025 15:39:12 +0530 Subject: [PATCH 3/4] Added feature command Signed-off-by: cs-308-2023 --- Makefile | 2 +- cmd/features/main.go | 62 ---------------------------------- cmd/jaeger/features/main.go | 53 +++++++++++++++++++++++++++++ cmd/jaeger/internal/command.go | 5 +++ 4 files changed, 59 insertions(+), 63 deletions(-) delete mode 100644 cmd/features/main.go create mode 100644 cmd/jaeger/features/main.go diff --git a/Makefile b/Makefile index ba20bfc310c..043ebf5e4c0 100644 --- a/Makefile +++ b/Makefile @@ -220,7 +220,7 @@ certs: .PHONY: features features: - go run ./cmd/jaeger help | go run ./cmd/features + go run ./cmd/jaeger/features .PHONY: certs-dryrun certs-dryrun: diff --git a/cmd/features/main.go b/cmd/features/main.go deleted file mode 100644 index 6b7a27cdfdb..00000000000 --- a/cmd/features/main.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2025 The Jaeger Authors. -// SPDX-License-Identifier: Apache-2.0 - -package main - -import ( - "fmt" - "io" - "os" - "strings" -) - -func beautify(data string) string { - outputString := string(data) - startIndex := strings.Index(outputString, "--feature-gates") - if startIndex == -1 { - fmt.Println("The string '--feature-gates' was not found.") - os.Exit(1) - } - relativeLineBreak := strings.Index(outputString[startIndex:], "\n") - var featureLine string - if relativeLineBreak == -1 { - featureLine = outputString[startIndex:] - } else { - featureLine = outputString[startIndex : startIndex+relativeLineBreak] - } - openParen := strings.Index(featureLine, "(") - closeParen := strings.Index(featureLine, ")") - if openParen == -1 || closeParen == -1 || closeParen <= openParen { - fmt.Println("Could not find parentheses surrounding the feature gates data.") - os.Exit(1) - } - inside := featureLine[openParen+1 : closeParen] - splitData := strings.Split(inside, ",") - combined_split := "A list of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.\n" - for _, item := range splitData { - cleanItem := strings.TrimSpace(item) - combined_split = combined_split + "\t" + cleanItem + "\n" - } - return combined_split -} - -func main() { - data, err := io.ReadAll(os.Stdin) - if err != nil { - panic(err) - } - outputString := string(data) - startIndex := strings.Index(outputString, "--feature-gates") - if startIndex == -1 { - fmt.Print(outputString) - return - } - relativeLineBreak := strings.Index(outputString[startIndex:], "\n") - if relativeLineBreak == -1 { - relativeLineBreak = len(outputString) - startIndex - } - lineBreakIndex := startIndex + relativeLineBreak - extracted := outputString[startIndex:lineBreakIndex] - // newString := outputString[:startIndex] + beautify(extracted) + outputString[lineBreakIndex:] - fmt.Println(beautify(extracted)) -} diff --git a/cmd/jaeger/features/main.go b/cmd/jaeger/features/main.go new file mode 100644 index 00000000000..13b5afcd0d2 --- /dev/null +++ b/cmd/jaeger/features/main.go @@ -0,0 +1,53 @@ +// Copyright (c) 2023 The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 + +package main + +import ( + "fmt" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/confmap" + "go.opentelemetry.io/collector/confmap/provider/envprovider" + "go.opentelemetry.io/collector/confmap/provider/fileprovider" + "go.opentelemetry.io/collector/confmap/provider/httpprovider" + "go.opentelemetry.io/collector/confmap/provider/httpsprovider" + "go.opentelemetry.io/collector/confmap/provider/yamlprovider" + "go.opentelemetry.io/collector/otelcol" + + "github.com/jaegertracing/jaeger/cmd/jaeger/internal" + "github.com/jaegertracing/jaeger/pkg/version" +) + + + + + + +func main(){ + info := component.BuildInfo{ + Command: "jaeger", + Description: internal.GetDescription(), + Version: version.Get().GitVersion, + } + + settings := otelcol.CollectorSettings{ + BuildInfo: info, + Factories: internal.Components, + ConfigProviderSettings: otelcol.ConfigProviderSettings{ + ResolverSettings: confmap.ResolverSettings{ + ProviderFactories: []confmap.ProviderFactory{ + envprovider.NewFactory(), + fileprovider.NewFactory(), + httpprovider.NewFactory(), + httpsprovider.NewFactory(), + yamlprovider.NewFactory(), + }, + }, + }, + } + + fmt.Println("\n"+internal.GetDescription()) + fmt.Println("List of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.\n") + otelcol.FeatureCommand(settings) +} \ No newline at end of file diff --git a/cmd/jaeger/internal/command.go b/cmd/jaeger/internal/command.go index 6ac217dadd6..44c354fc10e 100644 --- a/cmd/jaeger/internal/command.go +++ b/cmd/jaeger/internal/command.go @@ -26,6 +26,11 @@ var yamlAllInOne embed.FS const description = "Jaeger backend v2" +func GetDescription() string { + return description +} + + func Command() *cobra.Command { info := component.BuildInfo{ Command: "jaeger", From 0821aa6bdb082016d59949ff65d0c822419f128d Mon Sep 17 00:00:00 2001 From: cs-308-2023 Date: Wed, 15 Jan 2025 15:47:03 +0530 Subject: [PATCH 4/4] Lint solved Signed-off-by: cs-308-2023 --- cmd/jaeger/features/main.go | 15 +++++---------- cmd/jaeger/internal/command.go | 1 - 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/cmd/jaeger/features/main.go b/cmd/jaeger/features/main.go index 13b5afcd0d2..24a69e4c950 100644 --- a/cmd/jaeger/features/main.go +++ b/cmd/jaeger/features/main.go @@ -19,12 +19,7 @@ import ( "github.com/jaegertracing/jaeger/pkg/version" ) - - - - - -func main(){ +func main() { info := component.BuildInfo{ Command: "jaeger", Description: internal.GetDescription(), @@ -47,7 +42,7 @@ func main(){ }, } - fmt.Println("\n"+internal.GetDescription()) - fmt.Println("List of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.\n") - otelcol.FeatureCommand(settings) -} \ No newline at end of file + fmt.Println("\n" + internal.GetDescription()) + fmt.Println("List of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.\n ") + otelcol.FeatureCommand(settings) +} diff --git a/cmd/jaeger/internal/command.go b/cmd/jaeger/internal/command.go index 44c354fc10e..e98459e2222 100644 --- a/cmd/jaeger/internal/command.go +++ b/cmd/jaeger/internal/command.go @@ -30,7 +30,6 @@ func GetDescription() string { return description } - func Command() *cobra.Command { info := component.BuildInfo{ Command: "jaeger",