Skip to content

Commit 7f23adc

Browse files
committed
chore: bump Go to 1.26.3 and centralize CLI build in integration tests
- Bump go to 1.26.3 and update GoBaseImage accordingly - Use go 1.25.0 for integration go test as lowest version for compatibility - Move CLI build out of individual tests into shared buildOpenFeatureCLI - Fix golangci-lint issues - Fix test/README.md and update new-generator.md Signed-off-by: Roman Dmytrenko <rdmytrenko@gmail.com>
1 parent d29afd8 commit 7f23adc

14 files changed

Lines changed: 89 additions & 100 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/open-feature/cli
22

3-
go 1.25.0
3+
go 1.26.3
44

55
require (
66
dagger.io/dagger v0.20.6

internal/generators/csharp/csharp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func toCSharpDict(value any) string {
6969
for _, key := range keys {
7070
val := assertedMap[key]
7171

72-
builder.WriteString(fmt.Sprintf(".Set(%q, %s)", key, formatNestedValue(val)))
72+
fmt.Fprintf(&builder, ".Set(%q, %s)", key, formatNestedValue(val))
7373
}
7474
builder.WriteString(".Build())")
7575

internal/generators/golang/golang.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func toMapLiteral(value any) string {
9090
}
9191
val := assertedMap[key]
9292

93-
builder.WriteString(fmt.Sprintf(`%q: %s`, key, formatNestedValue(val)))
93+
fmt.Fprintf(&builder, `%q: %s`, key, formatNestedValue(val))
9494
}
9595

9696
builder.WriteString("}")

internal/generators/java/java.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func toMapLiteral(value any) string {
7373
}
7474
val := assertedMap[key]
7575

76-
builder.WriteString(fmt.Sprintf("%q, %s", key, formatNestedValue(val)))
76+
fmt.Fprintf(&builder, "%q, %s", key, formatNestedValue(val))
7777
}
7878
builder.WriteString(")")
7979

internal/generators/python/python.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func toPythonDict(value any) string {
9898
}
9999
val := assertedMap[key]
100100

101-
builder.WriteString(fmt.Sprintf(`%q: %s`, key, formatNestedValue(val)))
101+
fmt.Fprintf(&builder, `%q: %s`, key, formatNestedValue(val))
102102
}
103103

104104
builder.WriteString("}")

internal/manifest/compare.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ func getKnownFlagProperties() map[string]bool {
6868

6969
// Extract fields from BaseFlag struct
7070
t := reflect.TypeFor[BaseFlag]()
71-
for i := range t.NumField() {
72-
field := t.Field(i)
71+
for field := range t.Fields() {
7372
jsonTag := field.Tag.Get("json")
7473
if jsonTag != "" {
7574
// Extract field name from json tag (e.g., "flagType,omitempty" -> "flagType")

internal/manifest/validate.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,10 @@ func FormatValidationError(issues []ValidationError) string {
199199
if flagType == "" {
200200
flagType = "missing"
201201
}
202-
sb.WriteString(fmt.Sprintf(
203-
"- flagType: %s\n flagPath: %s\n errors:\n ~ %s\n \tSuggestions:\n \t- flagType: boolean\n \t- defaultValue: true\n\n",
202+
fmt.Fprintf(&sb, "- flagType: %s\n flagPath: %s\n errors:\n ~ %s\n \tSuggestions:\n \t- flagType: boolean\n \t- defaultValue: true\n\n",
204203
flagType,
205204
path,
206-
strings.Join(entry.messages, "\n ~ "),
207-
))
205+
strings.Join(entry.messages, "\n ~ "))
208206
}
209207
return sb.String()
210208
}

test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ make test-integration
2525

2626
```bash
2727
# For C# tests
28-
make test-csharp-dagger
28+
make test-integration-csharp
2929
```
3030

3131
## Adding a New Integration Test

test/integration/cmd/angular/run.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,18 @@ import (
1111
)
1212

1313
type Test struct {
14-
ProjectDir string
14+
projectDir string
1515
TestDir string
1616
}
1717

1818
func New(projectDir, testDir string) *Test {
1919
return &Test{
20-
ProjectDir: projectDir,
20+
projectDir: projectDir,
2121
TestDir: testDir,
2222
}
2323
}
2424

25-
func (t *Test) Run(ctx context.Context, client *dagger.Client) (*dagger.Container, error) {
26-
// Mount the project source
27-
source := client.Host().Directory(t.ProjectDir)
28-
25+
func (t *Test) Run(ctx context.Context, client *dagger.Client, cli *dagger.Container) (*dagger.Container, error) {
2926
// Mount the test files
3027
testFiles := client.Host().Directory(t.TestDir, dagger.HostDirectoryOpts{
3128
Include: []string{
@@ -37,14 +34,7 @@ func (t *Test) Run(ctx context.Context, client *dagger.Client) (*dagger.Containe
3734
},
3835
})
3936

40-
// Build the CLI in a Go container
41-
cli := client.Container().
42-
From(integration.GoBaseImage).
43-
WithDirectory("/src", source).
44-
WithWorkdir("/src").
45-
WithExec([]string{"go", "build", "-o", "cli", "./cmd/openfeature"})
46-
47-
// Generate the Angular code
37+
// Generate the Angular code using the pre-built CLI
4838
generated := cli.WithExec([]string{
4939
"./cli", "generate", "angular",
5040
"--manifest=/src/sample/sample_manifest.json",
@@ -76,6 +66,10 @@ func (t *Test) Name() string {
7666
return "angular"
7767
}
7868

69+
func (t *Test) ProjectDir() string {
70+
return t.projectDir
71+
}
72+
7973
func main() {
8074
ctx := context.Background()
8175

test/integration/cmd/csharp/run.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,28 @@ import (
1212

1313
// Test implements the integration test for the C# generator
1414
type Test struct {
15-
// ProjectDir is the absolute path to the root of the project
16-
ProjectDir string
15+
// projectDir is the absolute path to the root of the project
16+
projectDir string
1717
// TestDir is the absolute path to the test directory
1818
TestDir string
1919
}
2020

2121
// New creates a new Test
2222
func New(projectDir, testDir string) *Test {
2323
return &Test{
24-
ProjectDir: projectDir,
24+
projectDir: projectDir,
2525
TestDir: testDir,
2626
}
2727
}
2828

2929
// Run executes the C# integration test using Dagger
30-
func (t *Test) Run(ctx context.Context, client *dagger.Client) (*dagger.Container, error) {
31-
// Source code container
32-
source := client.Host().Directory(t.ProjectDir)
30+
func (t *Test) Run(ctx context.Context, client *dagger.Client, cli *dagger.Container) (*dagger.Container, error) {
31+
// Test source files
3332
testFiles := client.Host().Directory(t.TestDir, dagger.HostDirectoryOpts{
3433
Include: []string{"CompileTest.csproj", "Program.cs"},
3534
})
3635

37-
// Build the CLI
38-
cli := client.Container().
39-
From(integration.GoBaseImage).
40-
WithDirectory("/src", source).
41-
WithWorkdir("/src").
42-
WithExec([]string{"go", "build", "-o", "cli", "./cmd/openfeature"})
43-
44-
// Generate C# client
36+
// Generate C# client using the pre-built CLI
4537
generated := cli.WithExec([]string{
4638
"./cli", "generate", "csharp",
4739
"--manifest=/src/sample/sample_manifest.json",
@@ -70,6 +62,11 @@ func (t *Test) Name() string {
7062
return "csharp"
7163
}
7264

65+
// ProjectDir returns the absolute path to the project root
66+
func (t *Test) ProjectDir() string {
67+
return t.projectDir
68+
}
69+
7370
func main() {
7471
ctx := context.Background()
7572

0 commit comments

Comments
 (0)