github.com/Beeketing/helm@v2.12.1+incompatible/pkg/hooks/hooks.go (about) 1 /* 2 Copyright The Helm Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package hooks 18 19 import ( 20 "k8s.io/helm/pkg/proto/hapi/release" 21 ) 22 23 // HookAnno is the label name for a hook 24 const HookAnno = "helm.sh/hook" 25 26 // HookWeightAnno is the label name for a hook weight 27 const HookWeightAnno = "helm.sh/hook-weight" 28 29 // HookDeleteAnno is the label name for the delete policy for a hook 30 const HookDeleteAnno = "helm.sh/hook-delete-policy" 31 32 // Types of hooks 33 const ( 34 PreInstall = "pre-install" 35 PostInstall = "post-install" 36 PreDelete = "pre-delete" 37 PostDelete = "post-delete" 38 PreUpgrade = "pre-upgrade" 39 PostUpgrade = "post-upgrade" 40 PreRollback = "pre-rollback" 41 PostRollback = "post-rollback" 42 ReleaseTestSuccess = "test-success" 43 ReleaseTestFailure = "test-failure" 44 CRDInstall = "crd-install" 45 ) 46 47 // Type of policy for deleting the hook 48 const ( 49 HookSucceeded = "hook-succeeded" 50 HookFailed = "hook-failed" 51 BeforeHookCreation = "before-hook-creation" 52 ) 53 54 // FilterTestHooks filters the list of hooks are returns only testing hooks. 55 func FilterTestHooks(hooks []*release.Hook) []*release.Hook { 56 testHooks := []*release.Hook{} 57 58 for _, h := range hooks { 59 for _, e := range h.Events { 60 if e == release.Hook_RELEASE_TEST_SUCCESS || e == release.Hook_RELEASE_TEST_FAILURE { 61 testHooks = append(testHooks, h) 62 continue 63 } 64 } 65 } 66 67 return testHooks 68 }