Skip to content

Commit

Permalink
Replace manifests after apply
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole Markus With committed Jun 21, 2022
1 parent f1a948b commit 2547eea
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions channels/pkg/channels/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,28 @@ func Apply(data []byte) error {
if err := os.WriteFile(localManifestFile, data, 0o600); err != nil {
return fmt.Errorf("error writing temp file: %v", err)
}
{
_, err := execKubectl("apply", "-f", localManifestFile, "--server-side", "--force-conflicts", "--field-manager=kops")
if err != nil {
klog.Errorf("failed to apply the manifest: %v", err)
}
}
{
_, err := execKubectl("replace", "-f", localManifestFile, "--field-manager=kops")
if err != nil {
return fmt.Errorf("failed to replace manifest: %w", err)
}
}

// Remove this one. Just to show that apply works properly after replace
{
_, err := execKubectl("apply", "-f", localManifestFile, "--server-side", "--force-conflicts", "--field-manager=kops")
if err != nil {
return fmt.Errorf("failed to apply the manifest: %w", err)
}
}

_, err = execKubectl("apply", "-f", localManifestFile, "--server-side", "--force-conflicts", "--field-manager=kops")
return err
return nil
}

func execKubectl(args ...string) (string, error) {
Expand Down

0 comments on commit 2547eea

Please sign in to comment.