Skip to content

Commit

Permalink
fix: use YAML representation in omnictl get
Browse files Browse the repository at this point in the history
The benefit is that if `omnictl` is out of sync with the server, it will
still show correct server-side representation.

(If protobuf representation is out of sync with the server, it might
skip unknown fields).

This doesn't affect other commands, like `apply` or `cluster template`
family of functions, they still use protobuf representation.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Sep 9, 2024
1 parent 44e1c5d commit b6b252e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions client/pkg/omnictl/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func getResources(cmd *cobra.Command, args []string) func(ctx context.Context, c
items, err := st.List(ctx, md,
state.WithLabelQuery(labelQuery...),
state.WithIDQuery(idQuery...),
state.WithListUnmarshalOptions(state.WithSkipProtobufUnmarshal()),
)
if err != nil {
return err
Expand All @@ -134,6 +135,7 @@ func getResources(cmd *cobra.Command, args []string) func(ctx context.Context, c
state.WithBootstrapContents(true),
state.WatchWithLabelQuery(labelQuery...),
state.WatchWithIDQuery(idQuery...),
state.WithWatchKindUnmarshalOptions(state.WithSkipProtobufUnmarshal()),
)
if err != nil {
return err
Expand Down Expand Up @@ -177,7 +179,9 @@ func getResources(cmd *cobra.Command, args []string) func(ctx context.Context, c
}
}
case resourceID != "" && !getCmdFlags.watch:
res, err := st.Get(ctx, md)
res, err := st.Get(ctx, md,
state.WithGetUnmarshalOptions(state.WithSkipProtobufUnmarshal()),
)
if err != nil {
return err
}
Expand All @@ -188,7 +192,9 @@ func getResources(cmd *cobra.Command, args []string) func(ctx context.Context, c
case resourceID != "" && getCmdFlags.watch:
watchCh := make(chan state.Event)

err := st.Watch(ctx, md, watchCh)
err := st.Watch(ctx, md, watchCh,
state.WithWatchUnmarshalOptions(state.WithSkipProtobufUnmarshal()),
)
if err != nil {
return err
}
Expand Down

0 comments on commit b6b252e

Please sign in to comment.