-
Notifications
You must be signed in to change notification settings - Fork 2
fix(input): cleanup legacy object-format changesets support #855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
graham-chainlink
wants to merge
1
commit into
main
Choose a base branch
from
ggoh/NO-JIRA/remove-object-format-input
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "chainlink-deployments-framework": patch | ||
| --- | ||
|
|
||
| fix(input): remove handling of object format | ||
|
|
||
| object format for input yaml is no longer supported, | ||
| only array format is supported. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -322,37 +322,11 @@ func (c Commands) newDurablePipelineInputGenerate( | |
| } | ||
| } | ||
|
|
||
| // Resolve every changeset in the file | ||
| var orderedChangesets []map[string]any // For both formats to preserve order and duplicates | ||
| // Resolve every changeset in the file. | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is a duplication of the other changed file generate.go, is it part of the migration being done by Adrian, eventually this file will be deleted in favour of the other one, but i made the same change in both places anyway to be safe. |
||
| var orderedChangesets []map[string]any | ||
|
|
||
| // Handle both object and array formats for changesets | ||
| //nolint:exhaustive // Only handling MappingNode and SequenceNode cases for changesets | ||
| //nolint:exhaustive // SequenceNode is the only valid format for changesets | ||
| switch dpFile.Changesets.Kind { | ||
| case yaml.MappingNode: | ||
| // Object format: changesets: { key1: {payload: ...}, key2: {payload: ...} } | ||
| orderedChangesets = make([]map[string]any, 0, len(dpFile.Changesets.Content)/2) | ||
| // yaml.Node for a mapping has Content with alternating key-value pairs | ||
| for i := 0; i < len(dpFile.Changesets.Content); i += 2 { | ||
| keyNode := dpFile.Changesets.Content[i] | ||
| valueNode := dpFile.Changesets.Content[i+1] | ||
|
|
||
| csName := keyNode.Value | ||
| resolver, ok := resolverByKey[csName] | ||
| if !ok { | ||
| resolver = nil // No resolver registered for this changeset | ||
| } | ||
|
|
||
| resolvedCfg, err2 := resolveChangesetConfig(valueNode, csName, resolver) | ||
| if err2 != nil { | ||
| return err2 | ||
| } | ||
|
|
||
| // For object format, store each changeset as a separate item (same as array format) | ||
| changesetItem := map[string]any{ | ||
| csName: map[string]any{"payload": resolvedCfg}, | ||
| } | ||
| orderedChangesets = append(orderedChangesets, changesetItem) | ||
| } | ||
| case yaml.SequenceNode: | ||
| // Array format: changesets: [ { key1: {payload: ...} }, { key2: {payload: ...} } ] | ||
| orderedChangesets = make([]map[string]any, 0, len(dpFile.Changesets.Content)) | ||
|
|
@@ -383,73 +357,38 @@ func (c Commands) newDurablePipelineInputGenerate( | |
| orderedChangesets = append(orderedChangesets, changesetItem) | ||
| } | ||
| default: | ||
| return fmt.Errorf("changesets must be either an object (mapping) or an array (sequence), got %v", dpFile.Changesets.Kind) | ||
| return fmt.Errorf("changesets must be an array (sequence), got %v", dpFile.Changesets.Kind) | ||
graham-chainlink marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // Build ordered output structure using yaml.Node to preserve order and original format | ||
| var changesetsNode *yaml.Node | ||
| changesetsNode := &yaml.Node{ | ||
| Kind: yaml.SequenceNode, | ||
| } | ||
|
|
||
| if dpFile.Changesets.Kind == yaml.MappingNode { | ||
| // Object format: preserve as object | ||
| changesetsNode = &yaml.Node{ | ||
| for _, changesetItem := range orderedChangesets { | ||
| // Create a mapping node for each changeset item. | ||
| itemNode := &yaml.Node{ | ||
| Kind: yaml.MappingNode, | ||
| } | ||
|
|
||
| for _, changesetItem := range orderedChangesets { | ||
| // Each changesetItem has one key-value pair | ||
| for csName, csConfig := range changesetItem { | ||
| // Add key node | ||
| keyNode := &yaml.Node{ | ||
| Kind: yaml.ScalarNode, | ||
| Value: csName, | ||
| } | ||
| changesetsNode.Content = append(changesetsNode.Content, keyNode) | ||
|
|
||
| // Add value node | ||
| valueNode := &yaml.Node{} | ||
| err = valueNode.Encode(csConfig) | ||
| if err != nil { | ||
| return fmt.Errorf("encode changeset value for %s: %w", csName, err) | ||
| } | ||
| changesetsNode.Content = append(changesetsNode.Content, valueNode) | ||
|
|
||
| break // Only one key-value pair per item | ||
| } | ||
| } | ||
| } else { | ||
| // Array format: preserve as array | ||
| changesetsNode = &yaml.Node{ | ||
| Kind: yaml.SequenceNode, | ||
| } | ||
|
|
||
| for _, changesetItem := range orderedChangesets { | ||
| // Create a mapping node for each changeset item | ||
| itemNode := &yaml.Node{ | ||
| Kind: yaml.MappingNode, | ||
| // Each changesetItem has one key-value pair. | ||
| for csName, csConfig := range changesetItem { | ||
| keyNode := &yaml.Node{ | ||
| Kind: yaml.ScalarNode, | ||
| Value: csName, | ||
| } | ||
| itemNode.Content = append(itemNode.Content, keyNode) | ||
|
|
||
| // Each changesetItem has one key-value pair | ||
| for csName, csConfig := range changesetItem { | ||
| // Add key node | ||
| keyNode := &yaml.Node{ | ||
| Kind: yaml.ScalarNode, | ||
| Value: csName, | ||
| } | ||
| itemNode.Content = append(itemNode.Content, keyNode) | ||
|
|
||
| // Add value node | ||
| valueNode := &yaml.Node{} | ||
| err = valueNode.Encode(csConfig) | ||
| if err != nil { | ||
| return fmt.Errorf("encode changeset value for %s: %w", csName, err) | ||
| } | ||
| itemNode.Content = append(itemNode.Content, valueNode) | ||
|
|
||
| break // Only one key-value pair per item | ||
| valueNode := &yaml.Node{} | ||
| err = valueNode.Encode(csConfig) | ||
| if err != nil { | ||
| return fmt.Errorf("encode changeset value for %s: %w", csName, err) | ||
| } | ||
| itemNode.Content = append(itemNode.Content, valueNode) | ||
graham-chainlink marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| changesetsNode.Content = append(changesetsNode.Content, itemNode) | ||
| break // Only one key-value pair per item. | ||
| } | ||
|
|
||
| changesetsNode.Content = append(changesetsNode.Content, itemNode) | ||
| } | ||
|
|
||
| // Create the final output structure | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.