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