Skip to content

apply -f: detect binary protobuf payload by content#104

Open
Copilot wants to merge 5 commits intomainfrom
copilot/allow-protobuf-serialized-payload
Open

apply -f: detect binary protobuf payload by content#104
Copilot wants to merge 5 commits intomainfrom
copilot/allow-protobuf-serialized-payload

Conversation

Copy link

Copilot AI commented Feb 28, 2026

  • Explore codebase and understand apply command structure
  • Add isJSONContent helper — detects JSON by first non-whitespace byte ({/[ → true, binary protobuf → false)
  • Add parseActions helper — does detection + parsing, returns []parsedAction
  • apply now takes []parsedAction directly (no raw bytes, no format flag)
  • Command.RunE calls parseActions before apply (parse then execute)
  • Extract JSON parsing into parseActionFromJSON
  • Move all input parsing implementations to new parse.go
  • Rename apply_test.go to parse_test.go
  • Tests updated and passing
Original prompt

This section details on the original issue you should resolve

<issue_title>Allow passing protobuf searlized payload in apply -f command</issue_title>
<issue_description>Expected experience:

aks-flex-node apply -f <input.json>
aks-flex-node apply -f <input.binpb>
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Copilot AI changed the title [WIP] Allow passing protobuf serialized payload in apply -f command apply -f: detect binary protobuf payload by content Feb 28, 2026
Copy link
Member

@bcho bcho left a comment

Choose a reason for hiding this comment

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

Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Copy link
Member

@bcho bcho left a comment

Choose a reason for hiding this comment

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

// parseActions detects the input format and returns the pre-parsed actions.
func parseActions(input []byte) ([]parsedAction, error) {
if isJSONContent(input) {
tok, err := json.NewDecoder(bytes.NewBuffer(input)).Token()
Copy link
Member

Choose a reason for hiding this comment

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

extract this part to a function parseActionFromJSON. Move input parsing implementations to a new file.

Copy link
Author

Choose a reason for hiding this comment

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

Done in 725bb94. The JSON parsing block is now extracted into parseActionFromJSON and all input parsing implementations (isJSONContent, parseActions, parseActionFromJSON, parseAction, parseActionFromProto) have been moved to the new parse.go file.

Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Copy link
Member

@bcho bcho left a comment

Choose a reason for hiding this comment

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

_ "github.com/Azure/AKSFlexNode/components/linux" // register linux action types
)

func TestIsJSONContent(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

rename this file to parse_test.go

Copy link
Author

Choose a reason for hiding this comment

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

Done in 494e582. apply_test.go has been renamed to parse_test.go.

Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
@bcho bcho marked this pull request as ready for review February 28, 2026 06:24
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.

Allow passing protobuf searlized payload in apply -f command

2 participants