Skip to content

Use string for skip sync check#236

Merged
geoberle merged 3 commits into
mainfrom
use-string-not-bool
May 22, 2026
Merged

Use string for skip sync check#236
geoberle merged 3 commits into
mainfrom
use-string-not-bool

Conversation

@janboll
Copy link
Copy Markdown
Collaborator

@janboll janboll commented May 20, 2026

Adjusts “skip sync” controls to be string-based (instead of boolean), cause ev2 templating appears to break with booleans

Copilot AI review requested due to automatic review settings May 20, 2026 07:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts “skip sync” controls to be string-based (instead of boolean) so they can be passed through templating/parameterization layers more easily, updating both the grafanactl CLI and the pipelines type/schema surface.

Changes:

  • Changed SkipSync from bool to string in grafanactl sync options and updated runtime check accordingly.
  • Changed pipelines GrafanaDatasourcesStep.skipSync type from boolean to string (Go type + JSON schema) and added a guard test.
  • Regenerated graph SVG fixtures (Graphviz output differs due to version change).

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tools/grafanactl/cmd/sync/options.go Changes --skip-sync flag storage from bool to string.
tools/grafanactl/cmd/sync/cmd.go Updates skip logic to check string value.
pipelines/types/pipeline.schema.v1.json Updates skipSync schema type to string.
pipelines/types/common.go Updates GrafanaDatasourcesStep.SkipSync to string.
pipelines/types/common_test.go Adds reflection-based guard test against bool fields.
pipelines/graph/testdata/zz_fixture_TestForPipeline.svg Regenerated Graphviz fixture output.
pipelines/graph/testdata/zz_fixture_TestForEntrypoint.svg Regenerated Graphviz fixture output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/grafanactl/cmd/sync/options.go Outdated
Comment on lines 64 to 68
func (opts *RawSyncDashboardsOptions) Run(ctx context.Context) error {
logger := logr.FromContextOrDiscard(ctx)
if opts.SkipSync {
if strings.EqualFold(opts.SkipSync, "true") {
logger.Info("Skipping dashboard sync")
return nil
Comment thread pipelines/types/pipeline.schema.v1.json Outdated
Comment thread pipelines/types/common.go
@@ -738,7 +738,7 @@ type GrafanaDatasourcesStep struct {
GrafanaName string `json:"grafanaName"`

// SkipSync indicates whether to skip syncing datasources. It is intended for prow jobs to skip syncing datasources.
Comment on lines +316 to +323
func TestGrafanaDatasourcesStepNoBooleanFields(t *testing.T) {
rt := reflect.TypeOf(GrafanaDatasourcesStep{})
for i := 0; i < rt.NumField(); i++ {
field := rt.Field(i)
if field.Type.Kind() == reflect.Bool {
t.Errorf("field %q has type bool, use string instead", field.Name)
}
}
@janboll janboll force-pushed the use-string-not-bool branch from 42d726f to aa4e905 Compare May 20, 2026 08:41
Signed-off-by: Gerd Oberlechner <goberlec@redhat.com>
Copilot AI review requested due to automatic review settings May 22, 2026 08:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

pipelines/types/common.go:745

  • SkipSync is now a string, but the comment still describes it as a boolean and doesn’t document the accepted values ("true"/"false"). Also, YAML like skipSync: true will now fail unmarshalling into a string, which can break existing pipelines/templates; consider supporting both bool and string during unmarshalling (or at least documenting the required quoting).
	GrafanaName string `json:"grafanaName"`

	// SkipSync indicates whether to skip syncing datasources. It is intended for prow jobs to skip syncing datasources.
	SkipSync string `json:"skipSync,omitempty"`

	// IdentityFrom specifies the managed identity with which this deployment will run in Ev2.
	IdentityFrom Input `json:"identityFrom,omitempty"`
}

Comment on lines 71 to 74
flags := cmd.Flags()
flags.StringVar(&opts.ConfigFilePath, "config-file", "", "Path to config file with Grafana dashboard references (absolute or relative path, required)")
flags.BoolVar(&opts.SkipSync, "skip-sync", false, "Skip syncing dashboards")
flags.StringVar(&opts.SkipSync, "skip-sync", "false", "Skip syncing dashboards")

Comment on lines +66 to 68
if strings.EqualFold(opts.SkipSync, "true") {
logger.Info("Skipping dashboard sync")
return nil
Comment on lines +317 to +322
rt := reflect.TypeOf(GrafanaDatasourcesStep{})
for i := 0; i < rt.NumField(); i++ {
field := rt.Field(i)
if field.Type.Kind() == reflect.Bool {
t.Errorf("field %q has type bool, use string instead", field.Name)
}
@geoberle geoberle merged commit 76e79d0 into main May 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants