github.com/latiif/helm@v2.15.0+incompatible/pkg/storage/driver/driver.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 driver // import "k8s.io/helm/pkg/storage/driver" 18 19 import ( 20 rspb "k8s.io/helm/pkg/proto/hapi/release" 21 storageerrors "k8s.io/helm/pkg/storage/errors" 22 ) 23 24 var ( 25 // ErrReleaseNotFound has been deprecated; please use storageerrors.ErrReleaseNotFound instead. 26 ErrReleaseNotFound = storageerrors.ErrReleaseNotFound 27 // ErrReleaseExists has been deprecated; please use storageerrors.ErrReleaseExists instead. 28 ErrReleaseExists = storageerrors.ErrReleaseExists 29 // ErrInvalidKey has been deprecated; please use storageerrors.ErrInvalidKey instead. 30 ErrInvalidKey = storageerrors.ErrInvalidKey 31 ) 32 33 // Creator is the interface that wraps the Create method. 34 // 35 // Create stores the release or returns ErrReleaseExists 36 // if an identical release already exists. 37 type Creator interface { 38 Create(key string, rls *rspb.Release) error 39 } 40 41 // Updator is the interface that wraps the Update method. 42 // 43 // Update updates an existing release or returns 44 // ErrReleaseNotFound if the release does not exist. 45 type Updator interface { 46 Update(key string, rls *rspb.Release) error 47 } 48 49 // Deletor is the interface that wraps the Delete method. 50 // 51 // Delete deletes the release named by key or returns 52 // ErrReleaseNotFound if the release does not exist. 53 type Deletor interface { 54 Delete(key string) (*rspb.Release, error) 55 } 56 57 // Queryor is the interface that wraps the Get and List methods. 58 // 59 // Get returns the release named by key or returns ErrReleaseNotFound 60 // if the release does not exist. 61 // 62 // List returns the set of all releases that satisfy the filter predicate. 63 // 64 // Query returns the set of all releases that match the provided label set. 65 type Queryor interface { 66 Get(key string) (*rspb.Release, error) 67 List(filter func(*rspb.Release) bool) ([]*rspb.Release, error) 68 Query(labels map[string]string) ([]*rspb.Release, error) 69 } 70 71 // Driver is the interface composed of Creator, Updator, Deletor, and Queryor 72 // interfaces. It defines the behavior for storing, updating, deleted, 73 // and retrieving Tiller releases from some underlying storage mechanism, 74 // e.g. memory, configmaps. 75 type Driver interface { 76 Creator 77 Updator 78 Deletor 79 Queryor 80 Name() string 81 }