Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Fix syncing with --k8s-default-namespace #2799

Merged
merged 1 commit into from
Jan 30, 2020
Merged

Fix syncing with --k8s-default-namespace #2799

merged 1 commit into from
Jan 30, 2020

Conversation

michaelbeaumont
Copy link
Contributor

@michaelbeaumont michaelbeaumont commented Jan 29, 2020

Fixes #2797

The problem was that the namespace was set on the KubeManifest next to the raw Resource but then when the KubeManifest is synced as a Resource, the raw bytes are taken.
Since we're reserializing in applyMetadata anyway, I just update the namespace there.

@michaelbeaumont michaelbeaumont marked this pull request as ready for review January 29, 2020 16:07
@@ -377,6 +377,11 @@ func applyMetadata(res resource.Resource, syncSetName, checksum string) ([]byte,
mixin["labels"] = mixinLabels
}

namespace, _, _ := res.ResourceID().Components()
if namespace != kresource.ClusterScope {
mixin["namespace"] = namespace
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice and simple. Much better than my suggestion at #2797 (comment)

Can you please add a detailed comment explaining why we are doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

Fantastic

@2opremio
Copy link
Contributor

Can you squash the commits?

@2opremio
Copy link
Contributor

And rebase on top of the current master?

@michaelbeaumont
Copy link
Contributor Author

done

@2opremio 2opremio added the bug label Jan 30, 2020
@2opremio 2opremio added this to the 1.18.0 milestone Jan 30, 2020
@2opremio 2opremio merged commit 0810999 into fluxcd:master Jan 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default namespace option (--k8s-default-namespace) has no effect
2 participants