Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/flux/main_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestMain(m *testing.M) {
// Install Flux.
output, err := executeCommand("install --components-extra=image-reflector-controller,image-automation-controller")
if err != nil {
panic(fmt.Errorf("install falied: %s error:'%w'", output, err))
panic(fmt.Errorf("install failed: %s error:'%w'", output, err))
}

// Run tests
Expand All @@ -50,7 +50,7 @@ func TestMain(m *testing.M) {
// Uninstall Flux
output, err = executeCommand("uninstall -s --keep-namespace")
if err != nil {
panic(fmt.Errorf("uninstall falied: %s error:'%w'", output, err))
panic(fmt.Errorf("uninstall failed: %s error:'%w'", output, err))
}

// Delete namespace and wait for finalisation
Expand Down
46 changes: 42 additions & 4 deletions cmd/flux/reconcile_helmrelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package main

import (
"strings"

"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/types"

Expand All @@ -36,10 +38,7 @@ The reconcile kustomization command triggers a reconciliation of a HelmRelease r
# Trigger a reconciliation of the HelmRelease's source and apply changes
flux reconcile hr podinfo --with-source`,
ValidArgsFunction: resourceNamesCompletionFunc(helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)),
RunE: reconcileWithSourceCommand{
apiType: helmReleaseType,
object: helmReleaseAdapter{&helmv2.HelmRelease{}},
}.run,
RunE: reconcileSourceAndChart,
}

type reconcileHelmReleaseFlags struct {
Expand Down Expand Up @@ -87,3 +86,42 @@ func (obj helmReleaseAdapter) getSource() (reconcileCommand, types.NamespacedNam
Namespace: obj.Spec.Chart.Spec.SourceRef.Namespace,
}
}

func (obj helmChartAdapter) lastHandledReconcileRequest() string {
return obj.Status.GetLastHandledReconcileRequest()
}

func reconcileSourceAndChart(cmd *cobra.Command, args []string) error {
hr := helmv2.HelmRelease{}
reconcile := reconcileWithSourceCommand{
apiType: helmReleaseType,
object: helmReleaseAdapter{&hr},
}

if err := reconcile.run(cmd, args); err != nil {
return err
}

if reconcile.object.reconcileSource() {
nsName := strings.Split(hr.Status.HelmChart, "/")
if len(nsName) != 2 {
return nil
}

nsCopy := *kubeconfigArgs.Namespace
reconcileChart := reconcileCommand{
apiType: helmChartType,
object: helmChartAdapter{&sourcev1.HelmChart{}},
}

if nsName[0] != "" {
*kubeconfigArgs.Namespace = nsName[0]
}

err := reconcileChart.run(nil, []string{nsName[1]})
*kubeconfigArgs.Namespace = nsCopy
return err
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
✔ HelmRelease annotated
◎ waiting for HelmRelease reconciliation
✔ applied revision 6.0.0
► annotating HelmChart {{ .ns }}-thrfg in {{ .ns }} namespace
✔ HelmChart annotated
◎ waiting for HelmChart reconciliation
✔ fetched revision 6.0.0