Skip to content

Commit 5fbd651

Browse files
authored
internal/plugins/helm/v1/scaffolds/templates/role.go: simplify updates (operator-framework#3482)
1 parent d4c3303 commit 5fbd651

File tree

13 files changed

+139
-1394
lines changed

13 files changed

+139
-1394
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ require (
2727
github.com/spf13/pflag v1.0.5
2828
github.com/spf13/viper v1.4.0
2929
github.com/stretchr/testify v1.5.1
30-
github.com/xenolf/lego v2.7.2+incompatible
3130
go.uber.org/zap v1.14.1
3231
golang.org/x/tools v0.0.0-20200403190813-44a64ad78b9b
3332
gomodules.xyz/jsonpatch/v3 v3.0.1

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,6 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:
927927
github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs=
928928
github.com/xeipuuv/gojsonschema v1.1.0 h1:ngVtJC9TY/lg0AA/1k48FYhBrhRoFlEmWzsehpNAaZg=
929929
github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs=
930-
github.com/xenolf/lego v2.7.2+incompatible h1:aGxxYqhnQLQ71HsvEAjJVw6ao14APwPpRk0mpFroPXk=
931-
github.com/xenolf/lego v2.7.2+incompatible/go.mod h1:fwiGnfsIjG7OHPfOvgK7Y/Qo6+2Ox0iozjNTkZICKbY=
932930
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
933931
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
934932
github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSfTONNIgpN5RA8prR7fF8nkF6cTWTcNerRO8=

internal/plugins/helm/v1/scaffolds/api.go

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ import (
2323
"os"
2424
"path/filepath"
2525

26-
"github.com/xenolf/lego/log"
27-
"k8s.io/client-go/discovery"
28-
crconfig "sigs.k8s.io/controller-runtime/pkg/client/config"
2926
"sigs.k8s.io/kubebuilder/pkg/model"
3027
"sigs.k8s.io/kubebuilder/pkg/model/config"
3128
"sigs.k8s.io/kubebuilder/pkg/model/resource"
@@ -108,27 +105,13 @@ func (s *apiScaffolder) scaffold() error {
108105
return fmt.Errorf("error scaffolding kustomization: %v", err)
109106
}
110107

111-
// TODO(joelanford): encapsulate this in the role discovery/generation into the scaffold?
112-
roleScaffold := templates.DefaultRoleScaffold
113-
if k8sCfg, err := crconfig.GetConfig(); err != nil {
114-
log.Warnf("Using default RBAC rules: failed to get Kubernetes config: %s", err)
115-
} else if dc, err := discovery.NewDiscoveryClientForConfig(k8sCfg); err != nil {
116-
log.Warnf("Using default RBAC rules: failed to create Kubernetes discovery client: %s", err)
117-
} else {
118-
roleScaffold = templates.GenerateRoleScaffold(dc, chrt)
119-
}
120-
121108
if err := machinery.NewScaffold().Execute(
122109
s.newUniverse(res),
123-
&roleScaffold,
110+
&templates.Role{},
111+
&templates.RoleUpdater{Chart: chrt},
124112
); err != nil {
125113
return fmt.Errorf("error scaffolding role: %v", err)
126114
}
127115

128-
if err = templates.MergeRoleForResource(res, projectDir, roleScaffold); err != nil {
129-
return fmt.Errorf("failed to merge rules in the RBAC manifest for resource (%s/%s, %v): %v",
130-
r.Group, r.Version, r.Kind, err)
131-
}
132-
133116
return nil
134117
}

0 commit comments

Comments
 (0)