Skip to content

Commit

Permalink
Add missing validator for respository resource in chart (#628)
Browse files Browse the repository at this point in the history
Fixes #627

Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Dec 9, 2018
1 parent d9d7f1d commit d5086aa
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 28 deletions.
21 changes: 21 additions & 0 deletions chart/stash/templates/validating-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,25 @@ webhooks:
{{- if and (ge $major 1) (ge $minor 12) }}
sideEffects: None
{{- end }}
- name: repository.admission.stash.appscode.com
clientConfig:
service:
namespace: default
name: kubernetes
path: /apis/admission.stash.appscode.com/v1alpha1/repositories
caBundle: {{ b64enc .Values.apiserver.ca }}
rules:
- operations:
- CREATE
- UPDATE
apiGroups:
- stash.appscode.com
apiVersions:
- "*"
resources:
- repositories
failurePolicy: Fail
{{- if and (ge $major 1) (ge $minor 12) }}
sideEffects: None
{{- end }}
{{ end }}
6 changes: 3 additions & 3 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions pkg/controller/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ func (c *StashController) NewRepositoryWebhook() hooks.AdmissionHook {
}
func (c *StashController) initRepositoryWatcher() {
c.repoInformer = c.stashInformerFactory.Stash().V1alpha1().Repositories().Informer()
c.repoQueue = queue.New("Repository", c.MaxNumRequeues, c.NumThreads, c.runRepositoryInjector)
c.repoQueue = queue.New("Repository", c.MaxNumRequeues, c.NumThreads, c.runRepositoryReconciler)
c.repoInformer.AddEventHandler(queue.DefaultEventHandler(c.repoQueue.GetQueue()))
c.repoLister = c.stashInformerFactory.Stash().V1alpha1().Repositories().Lister()
}

func (c *StashController) runRepositoryInjector(key string) error {
func (c *StashController) runRepositoryReconciler(key string) error {
obj, exist, err := c.repoInformer.GetIndexer().GetByKey(key)
if err != nil {
glog.Errorf("Fetching object with key %s from store failed with %v", key, err)
Expand All @@ -61,7 +61,8 @@ func (c *StashController) runRepositoryInjector(key string) error {

if repo.DeletionTimestamp != nil {
if core_util.HasFinalizer(repo.ObjectMeta, util.RepositoryFinalizer) {
if repo.Spec.WipeOut {
// ignore invalid repository objects (eg: created by xray).
if repo.IsValid() == nil && repo.Spec.WipeOut {
err = c.deleteResticRepository(repo)
if err != nil {
return err
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/appscode/kutil/apps/v1/kubernetes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/appscode/kutil/core/v1/kubernetes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/appscode/kutil/discovery/lib.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion vendor/github.com/appscode/kutil/dynamic/kubernetes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/appscode/kutil/meta/cmp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/appscode/kutil/meta/hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/appscode/kutil/meta/patch.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/appscode/kutil/rbac/v1/kubernetes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/appscode/kutil/tools/cli/cli.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d5086aa

Please sign in to comment.