Skip to content
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

🐛 deep merge of cloud config broken for maps in slices #1343

Merged
merged 5 commits into from
Apr 25, 2023

Conversation

mauromorales
Copy link
Member

What this PR does / why we need it:
Removes use of mergo to deep merge cloud configs, because it cannot merge maps in slices, see darccio/mergo#204

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
fixes #1341

@netlify
Copy link

netlify bot commented Apr 23, 2023

Deploy Preview for kairos-io canceled.

Name Link
🔨 Latest commit cb7db7d
🔍 Latest deploy log https://app.netlify.com/sites/kairos-io/deploys/6447811659b9b50008feee62

Itxaka
Itxaka previously approved these changes Apr 24, 2023
Signed-off-by: Mauro Morales <[email protected]>
Signed-off-by: Mauro Morales <[email protected]>
Itxaka
Itxaka previously approved these changes Apr 24, 2023
@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2023

Codecov Report

Merging #1343 (cb7db7d) into master (7bb9af9) will increase coverage by 3.13%.
The diff coverage is 51.05%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #1343      +/-   ##
==========================================
+ Coverage   22.79%   25.92%   +3.13%     
==========================================
  Files          22       17       -5     
  Lines        1610     1427     -183     
==========================================
+ Hits          367      370       +3     
+ Misses       1179      997     -182     
+ Partials       64       60       -4     
Impacted Files Coverage Δ
internal/agent/config.go 0.00% <ø> (ø)
internal/agent/interactive_install.go 0.00% <ø> (ø)
internal/agent/notify.go 0.00% <0.00%> (ø)
internal/agent/recovery.go 0.00% <ø> (ø)
internal/agent/reset.go 0.00% <0.00%> (ø)
internal/agent/upgrade.go 0.00% <0.00%> (ø)
pkg/config/config.go 0.00% <0.00%> (-51.36%) ⬇️
internal/agent/install.go 5.10% <21.21%> (+5.10%) ⬆️
pkg/config/collector/options.go 64.51% <37.50%> (ø)
pkg/config/collector/collector.go 66.55% <66.55%> (ø)
... and 3 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -63,9 +63,141 @@ func (c *Config) MergeConfigURL() error {
return c.MergeConfig(remoteConfig)
}

func (c *Config) toMap() (map[string]interface{}, error) {
var result map[string]interface{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Config is a map[string]interface{}. Can't we use it as it is? (maybe with type casting or directly)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I guess it should be possible but I didn't go with that for two reasons:

  1. For iterations of the items, I still had to convert to map[string]interface{}
  2. It feels weird to put everything on a Config for example, when I'm deep merging the map inside an array, that is not a full config but just a map in an array, so to keep DeepMerge as generic as possible I decided to only use maps and not having the need to know anything about Config

Signed-off-by: Mauro Morales <[email protected]>
Itxaka
Itxaka previously approved these changes Apr 25, 2023
Signed-off-by: Mauro Morales <[email protected]>
@Itxaka
Copy link
Member

Itxaka commented Apr 25, 2023

@mauromorales all green!

@mauromorales mauromorales merged commit eff6f1d into master Apr 25, 2023
@mauromorales mauromorales deleted the 1341-merge-maps-in-arrays branch April 25, 2023 09:32
Itxaka pushed a commit to Itxaka/kairos that referenced this pull request Apr 25, 2023
Itxaka added a commit that referenced this pull request Apr 25, 2023
* 🐛 Add missing lvm packages in fedora+rockylinux

Signed-off-by: Itxaka <[email protected]>
(cherry picked from commit 72ba26c)

* 🤖 Fix releases test

Leftover broken tests for releases functions

Signed-off-by: Itxaka <[email protected]>
(cherry picked from commit 1261d4b)

* 🤖 Download only the x86 iso for testing

As we now have also arm generic images, the download-latest job is now
downsloading both isos as they match in name.

Adds a tighter regex to download the proper images

Signed-off-by: Itxaka <[email protected]>
(cherry picked from commit f7cbb63)

* 🐛 deep merge of cloud config broken for maps in slices (#1343)

(cherry picked from commit eff6f1d)

---------

Co-authored-by: Mauro Morales <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

🐛 Incorrect merging of cloud-config files with same stages
4 participants