Skip to content

Commit

Permalink
Make reconcile command work for helmrepository and helmchart kinds
Browse files Browse the repository at this point in the history
  • Loading branch information
dzsak committed Mar 28, 2024
1 parent e8666b7 commit afc8ff7
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/flux/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ func NewReconcileCommand(resource string) *reconcileCommand {
groupVersion: sourcev1beta2.GroupVersion,
kind: sourcev1beta2.BucketKind,
}
case sourcev1beta2.HelmRepositoryKind:
return &reconcileCommand{
object: helmRepositoryAdapter{&sourcev1beta2.HelmRepository{}},
groupVersion: sourcev1beta2.GroupVersion,
kind: sourcev1beta2.HelmRepositoryKind,
}
case sourcev1beta2.HelmChartKind:
return &reconcileCommand{
object: helmChartAdapter{&sourcev1beta2.HelmChart{}},
groupVersion: sourcev1beta2.GroupVersion,
kind: sourcev1beta2.HelmChartKind,
}
}

return nil
Expand Down
40 changes: 40 additions & 0 deletions pkg/flux/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,43 @@ func (obj bucketAdapter) lastHandledReconcileRequest() string {
func (obj bucketAdapter) successMessage() string {
return fmt.Sprintf("fetched revision %s", obj.Status.Artifact.Revision)
}

type helmRepositoryAdapter struct {
*sourcev1beta2.HelmRepository
}

func (a helmRepositoryAdapter) asClientObject() client.Object {
return a.HelmRepository
}

func (obj helmRepositoryAdapter) isSuspended() bool {
return obj.HelmRepository.Spec.Suspend
}

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

func (obj helmRepositoryAdapter) successMessage() string {
return fmt.Sprintf("fetched revision %s", obj.Status.Artifact.Revision)
}

type helmChartAdapter struct {
*sourcev1beta2.HelmChart
}

func (a helmChartAdapter) asClientObject() client.Object {
return a.HelmChart
}

func (obj helmChartAdapter) isSuspended() bool {
return obj.HelmChart.Spec.Suspend
}

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

func (obj helmChartAdapter) successMessage() string {
return fmt.Sprintf("fetched revision %s", obj.Status.Artifact.Revision)
}

0 comments on commit afc8ff7

Please sign in to comment.