@@ -25,12 +25,15 @@ import (
25
25
"gomodules.xyz/jsonpatch/v2"
26
26
"helm.sh/helm/v3/pkg/action"
27
27
"helm.sh/helm/v3/pkg/chart"
28
+ "helm.sh/helm/v3/pkg/kube"
28
29
helmkube "helm.sh/helm/v3/pkg/kube"
30
+ "helm.sh/helm/v3/pkg/postrender"
29
31
"helm.sh/helm/v3/pkg/release"
30
32
"helm.sh/helm/v3/pkg/storage/driver"
31
33
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
32
34
apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
33
35
apierrors "k8s.io/apimachinery/pkg/api/errors"
36
+ "k8s.io/apimachinery/pkg/api/meta"
34
37
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35
38
"k8s.io/apimachinery/pkg/runtime"
36
39
apitypes "k8s.io/apimachinery/pkg/types"
@@ -100,13 +103,23 @@ func AppendInstallFailureUninstallOptions(opts ...UninstallOption) ActionClientG
100
103
return nil
101
104
}
102
105
}
106
+
103
107
func AppendUpgradeFailureRollbackOptions (opts ... RollbackOption ) ActionClientGetterOption {
104
108
return func (getter * actionClientGetter ) error {
105
109
getter .upgradeFailureRollbackOpts = append (getter .upgradeFailureRollbackOpts , opts ... )
106
110
return nil
107
111
}
108
112
}
109
113
114
+ type PostRendererGetter func (rm meta.RESTMapper , kubeClient kube.Interface , obj client.Object ) postrender.PostRenderer
115
+
116
+ func AppendPostRenderers (postRendererGetters ... PostRendererGetter ) ActionClientGetterOption {
117
+ return func (getter * actionClientGetter ) error {
118
+ getter .postRendererGetters = append (getter .postRendererGetters , postRendererGetters ... )
119
+ return nil
120
+ }
121
+ }
122
+
110
123
func NewActionClientGetter (acg ActionConfigGetter , opts ... ActionClientGetterOption ) (ActionClientGetter , error ) {
111
124
actionClientGetter := & actionClientGetter {acg : acg }
112
125
for _ , opt := range opts {
@@ -127,6 +140,8 @@ type actionClientGetter struct {
127
140
128
141
installFailureUninstallOpts []UninstallOption
129
142
upgradeFailureRollbackOpts []RollbackOption
143
+
144
+ postRendererGetters []PostRendererGetter
130
145
}
131
146
132
147
var _ ActionClientGetter = & actionClientGetter {}
@@ -140,16 +155,22 @@ func (hcg *actionClientGetter) ActionClientFor(obj client.Object) (ActionInterfa
140
155
if err != nil {
141
156
return nil , err
142
157
}
143
- postRenderer := DefaultPostRendererFunc (rm , actionConfig .KubeClient , obj )
158
+ var chainedPostRenderer = chainedPostRenderer {
159
+ DefaultPostRendererFunc (rm , actionConfig .KubeClient , obj ),
160
+ }
161
+ for _ , postRendererGetter := range hcg .postRendererGetters {
162
+ chainedPostRenderer = append (chainedPostRenderer , postRendererGetter (rm , actionConfig .KubeClient , obj ))
163
+ }
164
+
144
165
return & actionClient {
145
166
conf : actionConfig ,
146
167
147
168
// For the install and upgrade options, we put the post renderer first in the list
148
169
// on purpose because we want user-provided defaults to be able to override the
149
170
// post-renderer that we automatically configure for the client.
150
171
defaultGetOpts : hcg .defaultGetOpts ,
151
- defaultInstallOpts : append ([]InstallOption {WithInstallPostRenderer (postRenderer )}, hcg .defaultInstallOpts ... ),
152
- defaultUpgradeOpts : append ([]UpgradeOption {WithUpgradePostRenderer (postRenderer )}, hcg .defaultUpgradeOpts ... ),
172
+ defaultInstallOpts : append ([]InstallOption {WithInstallPostRenderer (chainedPostRenderer )}, hcg .defaultInstallOpts ... ),
173
+ defaultUpgradeOpts : append ([]UpgradeOption {WithUpgradePostRenderer (chainedPostRenderer )}, hcg .defaultUpgradeOpts ... ),
153
174
defaultUninstallOpts : hcg .defaultUninstallOpts ,
154
175
155
176
installFailureUninstallOpts : hcg .installFailureUninstallOpts ,
0 commit comments