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

chore: fix implicit memory aliasing in for loop #2341

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cmd/tools/helm/load_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ func addPluginCommands(plugin *plugin.Plugin, baseCmd *cobra.Command, cmds *plug

// Recursively add any sub-commands
for _, cmd := range cmds.Commands {
cmdCopy := cmd
// Create a fake command so that completion can be done for the sub-commands of the plugin
subCmd := &cobra.Command{
// This prevents Cobra from removing the flags. We want to keep the flags to pass them
Expand All @@ -308,7 +309,7 @@ func addPluginCommands(plugin *plugin.Plugin, baseCmd *cobra.Command, cmds *plug
Run: func(_ *cobra.Command, _ []string) {},
}
baseCmd.AddCommand(subCmd)
addPluginCommands(plugin, subCmd, &cmd)
addPluginCommands(plugin, subCmd, &cmdCopy)
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/pkg/cluster/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ func (c *Cluster) InitZarfState(initOptions types.ZarfInitOptions) error {
}
// This label will tell the Zarf Agent to ignore this namespace.
namespace.Labels[agentLabel] = "ignore"
if _, err = c.UpdateNamespace(&namespace); err != nil {
namespaceCopy := namespace
if _, err = c.UpdateNamespace(&namespaceCopy); err != nil {
// This is not a hard failure, but we should log it.
message.WarnErrf(err, "Unable to mark the namespace %s as ignored by Zarf Agent", namespace.Name)
}
Expand Down
3 changes: 2 additions & 1 deletion src/pkg/cluster/zarf.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func (c *Cluster) StripZarfLabelsAndSecretsFromNamespaces() {
if _, ok := namespace.Labels[agentLabel]; ok {
spinner.Updatef("Removing Zarf Agent label for namespace %s", namespace.Name)
delete(namespace.Labels, agentLabel)
if _, err = c.UpdateNamespace(&namespace); err != nil {
namespaceCopy := namespace
if _, err = c.UpdateNamespace(&namespaceCopy); err != nil {
// This is not a hard failure, but we should log it
spinner.Errorf(err, "Unable to update the namespace labels for %s", namespace.Name)
}
Expand Down