Skip to content

Commit

Permalink
rpk: check_compatibility --verbose-compat
Browse files Browse the repository at this point in the history
Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
  • Loading branch information
oleiman authored and pgellert committed Aug 19, 2024
1 parent 992a8e7 commit 2825e14
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/go/rpk/pkg/cli/registry/schema/check_compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (
)

type compatCheckResponse struct {
Compatible bool `json:"compatible" yaml:"compatible"`
Compatible bool `json:"compatible" yaml:"compatible"`
Messages []string `json:"messages,omitempty" yaml:"messages,omitempty"`
}

func newCheckCompatibilityCommand(fs afero.Fs, p *config.Params) *cobra.Command {
Expand Down Expand Up @@ -66,16 +67,19 @@ func newCheckCompatibilityCommand(fs afero.Fs, p *config.Params) *cobra.Command
Type: t,
References: references,
}
compatible, err := cl.CheckCompatibility(cmd.Context(), subject, version, schema)
ctx := sr.WithParams(cmd.Context(), sr.Verbose)
compatible, err := cl.CheckCompatibility(ctx, subject, version, schema)
out.MaybeDie(err, "unable to check compatibility: %v", err)
if isText, _, s, err := f.Format(compatCheckResponse{compatible.Is}); !isText {
if isText, _, s, err := f.Format(compatCheckResponse{compatible.Is, compatible.Messages}); !isText {
out.MaybeDie(err, "unable to print in the required format %q: %v", f.Kind, err)
out.Exit(s)
}
if compatible.Is {
fmt.Println("Schema is compatible.")
} else {
fmt.Println("Schema is not compatible.")
messages := strings.Join(compatible.Messages, "\n")
fmt.Println(messages)
}
},
}
Expand Down

0 comments on commit 2825e14

Please sign in to comment.