From ea7cd49f85a040098e7ddca79a43d420b5003835 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Sun, 2 Feb 2025 06:58:31 -0700 Subject: [PATCH 1/9] Simplify Makefile and spec - explicitly indicate what to include in dist - prevent duplication of files in specfile Signed-off-by: Jonathon Anderson --- .gitattributes | 1 + CHANGELOG.md | 1 + Makefile | 11 ++++---- warewulf.spec.in | 72 +++++++++++++++++++++++------------------------- 4 files changed, 43 insertions(+), 42 deletions(-) diff --git a/.gitattributes b/.gitattributes index a19ade07..c4a24eff 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ CHANGELOG.md merge=union +.github/ export-ignore diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b97196f..93b2e98b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `wwctl node list <--yaml|--json>` outputs a map keyed by node name. #1667 - Don't mount /run during wwinit. #1566 +- Simpler permissions in official RPM packages. #1696 ### Fixed diff --git a/Makefile b/Makefile index 600605a7..2b4500cc 100644 --- a/Makefile +++ b/Makefile @@ -158,13 +158,14 @@ init: restorecon -r $(WWTFTPDIR) .PHONY: dist -dist: - rm -rf .dist/ $(WAREWULF)-$(VERSION).tar.gz +dist: $(config) + rm -rf .dist/ mkdir -p .dist/$(WAREWULF)-$(VERSION) - rsync -a --exclude=".github" --exclude=".vscode" --exclude "*~" --exclude $(WAREWULF)-*.tar.gz * .dist/$(WAREWULF)-$(VERSION)/ + tar -c --files-from <(git ls-files) | tar -C .dist/$(WAREWULF)-$(VERSION) -x + cp -a vendor/ $(config) .dist/$(WAREWULF)-$(VERSION) scripts/get-version.sh >.dist/$(WAREWULF)-$(VERSION)/VERSION - cd .dist; tar -czf ../$(WAREWULF)-$(VERSION).tar.gz $(WAREWULF)-$(VERSION) - rm -rf .dist + tar -C .dist -czf $(WAREWULF)-$(VERSION).tar.gz $(WAREWULF)-$(VERSION) + rm -rf .dist/ .PHONY: reference reference: wwctl diff --git a/warewulf.spec.in b/warewulf.spec.in index aecd548e..3882a753 100644 --- a/warewulf.spec.in +++ b/warewulf.spec.in @@ -174,68 +174,66 @@ getent group %{wwgroup} >/dev/null || groupadd -r %{wwgroup} %files -%dir %{_sysconfdir}/bash_completion.d -%dir %{_sysconfdir}/logrotate.d +%defattr(-, root, root) -%defattr(-, root, %{wwgroup}) %dir %{_sysconfdir}/warewulf %config(noreplace) %{_sysconfdir}/warewulf/warewulf.conf +%config(noreplace) %attr(0640,-,%{wwgroup}) %{_sysconfdir}/warewulf/nodes.conf %config(noreplace) %{_sysconfdir}/warewulf/examples %config(noreplace) %{_sysconfdir}/warewulf/ipxe %config(noreplace) %{_sysconfdir}/warewulf/grub -%config(noreplace) %{_sysconfdir}/logrotate.d/warewulfd.conf -%config(noreplace) %attr(0640,-,-) %{_sysconfdir}/warewulf/nodes.conf - -%{_sysconfdir}/bash_completion.d/wwctl +%{_sysconfdir}/bash_completion.d +%config(noreplace) %{_sysconfdir}/logrotate.d %dir %{_sharedstatedir}/warewulf %dir %{_sharedstatedir}/warewulf/chroots %dir %{_sharedstatedir}/warewulf/overlays + +%dir %{_datadir}/warewulf +%{_datadir}/warewulf/bmc %dir %{_datadir}/warewulf/overlays %dir %{_datadir}/warewulf/overlays/* %dir %{_datadir}/warewulf/overlays/*/rootfs -%attr(-, root, root) %{_datadir}/warewulf/overlays/NetworkManager/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/debian.interfaces/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/debug/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/fstab/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/host/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/hostname/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/hosts/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/ifcfg/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/ignition/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/issue/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/netplan/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/resolv/rootfs/* -%attr(700, root, root) %{_datadir}/warewulf/overlays/ssh.authorized_keys/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/ssh.host_keys/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/syncuser/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/systemd.netname/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/udev.netname/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/wicked/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/wwclient/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/wwinit/rootfs/* -%attr(-, root, root) %{_datadir}/warewulf/overlays/localtime/rootfs/* +%{_datadir}/warewulf/overlays/NetworkManager/rootfs/* +%{_datadir}/warewulf/overlays/debian.interfaces/rootfs/* +%{_datadir}/warewulf/overlays/debug/rootfs/* +%{_datadir}/warewulf/overlays/fstab/rootfs/* +%{_datadir}/warewulf/overlays/host/rootfs/* +%{_datadir}/warewulf/overlays/hostname/rootfs/* +%{_datadir}/warewulf/overlays/hosts/rootfs/* +%{_datadir}/warewulf/overlays/ifcfg/rootfs/* +%{_datadir}/warewulf/overlays/ignition/rootfs/* +%{_datadir}/warewulf/overlays/issue/rootfs/* +%{_datadir}/warewulf/overlays/netplan/rootfs/* +%{_datadir}/warewulf/overlays/resolv/rootfs/* +%attr(700, -, -) %{_datadir}/warewulf/overlays/ssh.authorized_keys/rootfs/* +%{_datadir}/warewulf/overlays/ssh.host_keys/rootfs/* +%{_datadir}/warewulf/overlays/syncuser/rootfs/* +%{_datadir}/warewulf/overlays/systemd.netname/rootfs/* +%{_datadir}/warewulf/overlays/udev.netname/rootfs/* +%{_datadir}/warewulf/overlays/wicked/rootfs/* +%{_datadir}/warewulf/overlays/wwclient/rootfs/* +%{_datadir}/warewulf/overlays/wwinit/rootfs/* +%{_datadir}/warewulf/overlays/localtime/rootfs/* -%attr(-, root, root) %{_bindir}/wwctl -%attr(-, root, root) %{_prefix}/lib/firewalld/services/warewulf.xml -%attr(-, root, root) %{_unitdir}/warewulfd.service -%attr(-, root, root) %{_mandir}/man1/wwctl* -%attr(-, root, root) %{_mandir}/man5/*.5* -%attr(-, root, root) %{_datadir}/warewulf +%{_bindir}/wwctl +%{_prefix}/lib/firewalld/services/warewulf.xml +%{_unitdir}/warewulfd.service +%{_mandir}/man1/wwctl* +%{_mandir}/man5/*.5* %dir %{_docdir}/warewulf %license %{_docdir}/warewulf/LICENSE.md %if %{api} -%attr(-, root, root) %{_bindir}/wwapi* +%{_bindir}/wwapi* %config(noreplace) %{_sysconfdir}/warewulf/wwapi*.conf %endif %files dracut %defattr(-, root, root) -%dir %{_prefix}/lib/dracut/modules.d/90wwinit -%{_prefix}/lib/dracut/modules.d/90wwinit/*.sh +%{_prefix}/lib/dracut/modules.d/90wwinit %changelog From 6dbfa52dbcb91146805165793b12cef924a9c5be Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Wed, 5 Feb 2025 09:23:19 -0700 Subject: [PATCH 2/9] Create site overlay directory This was previously added to warewulf.spec, but the directory wasn't actually being created. Signed-off-by: Jonathon Anderson --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 2b4500cc..cabe9e1c 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,7 @@ test-cover: $(config) install: build docs install -d -m 0755 $(DESTDIR)$(BINDIR) install -d -m 0755 $(DESTDIR)$(WWCHROOTDIR) + install -d -m 0755 $(DESTDIR)$(WWOVERLAYDIR) install -d -m 0755 $(DESTDIR)$(WWPROVISIONDIR) install -d -m 0755 $(DESTDIR)$(DATADIR)/warewulf/overlays/wwinit/rootfs/$(WWCLIENTDIR) install -d -m 0755 $(DESTDIR)$(DATADIR)/warewulf/overlays/wwclient/rootfs/$(WWCLIENTDIR) From 60872bd42ed9e7b8bdb95e1c0ca78895ab3457a0 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Wed, 5 Feb 2025 21:48:07 +0100 Subject: [PATCH 3/9] Add completion for profile list - Closes: #1696 Signed-off-by: Christian Goll --- CHANGELOG.md | 1 + internal/app/wwctl/profile/list/root.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b2e98b..88cac6d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Document defining kernel args that include commas. #1679 - Recommend installing ipmitool with Warewulf package. #970 +- Add completion for profile list. #1695 ### Changed diff --git a/internal/app/wwctl/profile/list/root.go b/internal/app/wwctl/profile/list/root.go index e0317b28..ff63b599 100644 --- a/internal/app/wwctl/profile/list/root.go +++ b/internal/app/wwctl/profile/list/root.go @@ -1,6 +1,9 @@ package list -import "github.com/spf13/cobra" +import ( + "github.com/spf13/cobra" + "github.com/warewulf/warewulf/internal/pkg/node" +) type variables struct { showAll bool @@ -18,6 +21,13 @@ func GetCommand() *cobra.Command { Long: "This command will display configurations for PROFILE.", RunE: CobraRunE(&vars), Aliases: []string{"ls"}, + ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + if len(args) != 0 { + return nil, cobra.ShellCompDirectiveNoFileComp + } + nodeDB, _ := node.New() + return nodeDB.ListAllProfiles(), cobra.ShellCompDirectiveNoFileComp + }, } baseCmd.PersistentFlags().BoolVarP(&vars.showAll, "all", "a", false, "Show all profile configurations") baseCmd.PersistentFlags().BoolVarP(&vars.showYaml, "yaml", "y", false, "Show profile configurations via yaml format") From b05e384560225758dc3c1a8ad730f47b9606de61 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Wed, 5 Feb 2025 18:56:16 -0700 Subject: [PATCH 4/9] Refactor to completions.Profiles Signed-off-by: Jonathon Anderson --- internal/app/wwctl/completions/completions.go | 8 ++++++++ internal/app/wwctl/profile/delete/root.go | 10 ++-------- internal/app/wwctl/profile/list/root.go | 10 ++-------- internal/app/wwctl/profile/set/root.go | 16 ++++------------ 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/internal/app/wwctl/completions/completions.go b/internal/app/wwctl/completions/completions.go index 2dfbb2fa..19adb05f 100644 --- a/internal/app/wwctl/completions/completions.go +++ b/internal/app/wwctl/completions/completions.go @@ -52,3 +52,11 @@ func Images(cmd *cobra.Command, args []string, toComplete string) ([]string, cob sources, _ := image.ListSources() return sources, cobra.ShellCompDirectiveNoFileComp } + +func Profiles(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + if len(args) != 0 { + return nil, cobra.ShellCompDirectiveNoFileComp + } + registry, _ := node.New() + return registry.ListAllProfiles(), cobra.ShellCompDirectiveNoFileComp +} diff --git a/internal/app/wwctl/profile/delete/root.go b/internal/app/wwctl/profile/delete/root.go index 7d30b979..6c6e0df4 100644 --- a/internal/app/wwctl/profile/delete/root.go +++ b/internal/app/wwctl/profile/delete/root.go @@ -2,7 +2,7 @@ package delete import ( "github.com/spf13/cobra" - "github.com/warewulf/warewulf/internal/pkg/node" + "github.com/warewulf/warewulf/internal/app/wwctl/completions" ) var ( @@ -14,13 +14,7 @@ var ( Aliases: []string{"remove", "rm", "del"}, RunE: CobraRunE, Args: cobra.MinimumNArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - nodeDB, _ := node.New() - return nodeDB.ListAllProfiles(), cobra.ShellCompDirectiveNoFileComp - }, + ValidArgsFunction: completions.Profiles, } SetYes bool ) diff --git a/internal/app/wwctl/profile/list/root.go b/internal/app/wwctl/profile/list/root.go index ff63b599..86468943 100644 --- a/internal/app/wwctl/profile/list/root.go +++ b/internal/app/wwctl/profile/list/root.go @@ -2,7 +2,7 @@ package list import ( "github.com/spf13/cobra" - "github.com/warewulf/warewulf/internal/pkg/node" + "github.com/warewulf/warewulf/internal/app/wwctl/completions" ) type variables struct { @@ -21,13 +21,7 @@ func GetCommand() *cobra.Command { Long: "This command will display configurations for PROFILE.", RunE: CobraRunE(&vars), Aliases: []string{"ls"}, - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - nodeDB, _ := node.New() - return nodeDB.ListAllProfiles(), cobra.ShellCompDirectiveNoFileComp - }, + ValidArgsFunction: completions.Profiles, } baseCmd.PersistentFlags().BoolVarP(&vars.showAll, "all", "a", false, "Show all profile configurations") baseCmd.PersistentFlags().BoolVarP(&vars.showYaml, "yaml", "y", false, "Show profile configurations via yaml format") diff --git a/internal/app/wwctl/profile/set/root.go b/internal/app/wwctl/profile/set/root.go index 483b8901..36ed8f1c 100644 --- a/internal/app/wwctl/profile/set/root.go +++ b/internal/app/wwctl/profile/set/root.go @@ -36,18 +36,10 @@ func GetCommand() *cobra.Command { Short: "Configure node profile properties", Long: "This command sets configuration properties for the node PROFILE(s).\n\n" + "Note: use the string 'UNSET' to remove a configuration", - Aliases: []string{"modify"}, - Args: cobra.MinimumNArgs(0), - RunE: CobraRunE(&vars), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - - nodeDB, _ := node.New() - profiles := nodeDB.ListAllProfiles() - return profiles, cobra.ShellCompDirectiveNoFileComp - }, + Aliases: []string{"modify"}, + Args: cobra.MinimumNArgs(0), + RunE: CobraRunE(&vars), + ValidArgsFunction: completions.Profiles, } vars.profileConf.CreateFlags(baseCmd) vars.profileDel.CreateDelFlags(baseCmd) From 6a250f3f96c9f47a0ead6afb81682d1a812b7a4f Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Wed, 5 Feb 2025 20:03:38 -0700 Subject: [PATCH 5/9] Set execute permissions for intermediate directories - Fixes: #1655 Signed-off-by: Jonathon Anderson --- CHANGELOG.md | 2 ++ internal/app/wwctl/overlay/imprt/main.go | 8 +++++--- internal/pkg/overlay/overlay.go | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88cac6d9..86fbcb87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Specify init=/init when booting with Grub+dracut. #1573 - Fix a warewulfd panic when no kernel fields are specified. #1689 - Create site overlay directory. #1690 +- Set execute permissions for intermediate directories during `wwctl overlay import --parents`. #1655 +- Fix log output formatting during overlay build. ## v4.6.0rc1, 2025-01-29 diff --git a/internal/app/wwctl/overlay/imprt/main.go b/internal/app/wwctl/overlay/imprt/main.go index f53144f8..890950bc 100644 --- a/internal/app/wwctl/overlay/imprt/main.go +++ b/internal/app/wwctl/overlay/imprt/main.go @@ -51,11 +51,13 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { wwlog.Debug("Create dir: %s", parent) srcInfo, err := os.Stat(source) if err != nil { - return fmt.Errorf("could not retrieve the stat for file: %s", err) + return fmt.Errorf("could not retrieve the stat for file: %w", err) } - err = os.MkdirAll(parent, srcInfo.Mode()) + mode := srcInfo.Mode() + mode |= ((mode & 0444) >> 2) // add execute permission wherever srcInfo has read + err = os.MkdirAll(parent, mode) if err != nil { - return fmt.Errorf("could not create parent dif: %s: %v", parent, err) + return fmt.Errorf("could not create parent dir: %s: %w", parent, err) } } } diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index fa80ee36..3f3995f7 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -146,7 +146,7 @@ func BuildSpecificOverlays(nodes []node.Node, allNodes []node.Node, overlayNames var wg sync.WaitGroup worker := func() { for n := range nodeChan { - wwlog.Info("Building overlay for %s: %v", n, overlayNames) + wwlog.Info("Building overlay for %s: %v", n.Id(), overlayNames) for _, overlayName := range overlayNames { err := BuildOverlay(n, allNodes, "", []string{overlayName}) if err != nil { From 05923d40448217c4257a9fe47d313cf6286b53ad Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Wed, 5 Feb 2025 20:27:55 -0700 Subject: [PATCH 6/9] Create temporary files in overlay directory during `wwctl overlay edit` - Fixes: #1473 Signed-off-by: Jonathon Anderson --- CHANGELOG.md | 1 + internal/app/wwctl/overlay/edit/main.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88cac6d9..c2992e5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `wwctl node list <--yaml|--json>` outputs a map keyed by node name. #1667 - Don't mount /run during wwinit. #1566 - Simpler permissions in official RPM packages. #1696 +- Create temporary files in overlay directory during `wwctl overlay edit`. #1473 ### Fixed diff --git a/internal/app/wwctl/overlay/edit/main.go b/internal/app/wwctl/overlay/edit/main.go index bb54d563..65c930ca 100644 --- a/internal/app/wwctl/overlay/edit/main.go +++ b/internal/app/wwctl/overlay/edit/main.go @@ -48,7 +48,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { return fmt.Errorf("%s does not exist. Use '--parents' option to create automatically", overlayFileDir) } - tempFile, tempFileErr := os.CreateTemp("", "ww-overlay-edit-") + tempFile, tempFileErr := os.CreateTemp(overlay_.Path(), "ww-overlay-edit-") if tempFileErr != nil { return fmt.Errorf("unable to create temporary file for editing: %s", tempFileErr) } From e449d10d65f2db87eee73f507572a5ba8f47b245 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Wed, 5 Feb 2025 22:27:51 -0700 Subject: [PATCH 7/9] Add types to issue templates Signed-off-by: Jonathon Anderson --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + .github/ISSUE_TEMPLATE/feature_request.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index bf5f0bb7..b051b290 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,4 +1,5 @@ name: "\U0001F41E Bug report" +type: Bug description: Report a bug in Warewulf (command not working as expected, etc.) labels: [bug] body: diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index d41274ba..5d8cc5b5 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,4 +1,5 @@ name: "\U0001F38A Feature request" +type: Feature description: Suggest adding a feature labels: [enhancement] body: From a975c5efb634e64dc79ba63f12aff3de0670bd73 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Wed, 5 Feb 2025 22:29:39 -0700 Subject: [PATCH 8/9] Remove labels from issue templates Signed-off-by: Jonathon Anderson --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 - .github/ISSUE_TEMPLATE/feature_request.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index b051b290..70c68abb 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,7 +1,6 @@ name: "\U0001F41E Bug report" type: Bug description: Report a bug in Warewulf (command not working as expected, etc.) -labels: [bug] body: - type: textarea id: reproduce diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 5d8cc5b5..9c8a2873 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,7 +1,6 @@ name: "\U0001F38A Feature request" type: Feature description: Suggest adding a feature -labels: [enhancement] body: - type: textarea id: summary From 6bfcfc5fda96a616759fd330029ed1211eb8d638 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Thu, 6 Feb 2025 16:43:21 -0700 Subject: [PATCH 9/9] Prevent merging of zero-value net.IP fields - Fixes: #1710 Signed-off-by: Jonathon Anderson --- CHANGELOG.md | 1 + internal/pkg/node/mergo.go | 2 +- internal/pkg/node/mergo_test.go | 13 ++++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 051e1c01..e5836469 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Create site overlay directory. #1690 - Set execute permissions for intermediate directories during `wwctl overlay import --parents`. #1655 - Fix log output formatting during overlay build. +- Prevent merging of zero-value net.IP fields. #1710 ## v4.6.0rc1, 2025-01-29 diff --git a/internal/pkg/node/mergo.go b/internal/pkg/node/mergo.go index 7f0b3cce..cb92c5e9 100644 --- a/internal/pkg/node/mergo.go +++ b/internal/pkg/node/mergo.go @@ -71,7 +71,7 @@ type Transformer struct{} func (t Transformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error { if typ == reflect.TypeOf(net.IP{}) { return func(dst, src reflect.Value) error { - if !src.IsValid() || !src.CanSet() { + if !src.IsValid() || src.IsZero() { return nil } dst.Set(src) diff --git a/internal/pkg/node/mergo_test.go b/internal/pkg/node/mergo_test.go index 9b507d39..ac569a82 100644 --- a/internal/pkg/node/mergo_test.go +++ b/internal/pkg/node/mergo_test.go @@ -935,11 +935,14 @@ nodeprofiles: nodes: n1: profiles: - - p1`, - node: "n1", - field: "NetDevs[default].Netmask", - source: "p1", - value: "255.255.255.0", + - p1 + network devices: + default: + ipaddr: 192.168.1.1`, + nodes: []string{"n1", "n1"}, + fields: []string{"NetDevs[default].Netmask", "NetDevs[default].Ipaddr"}, + sources: []string{"p1", ""}, + values: []string{"255.255.255.0", "192.168.1.1"}, }, }