github.com/danielqsj/helm@v2.0.0-alpha.4.0.20160908204436-976e0ba5199b+incompatible/pkg/storage/driver/driver.go (about)

     1  /*
     2  Copyright 2016 The Kubernetes Authors All rights reserved.
     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  	"errors"
    21  
    22  	rspb "k8s.io/helm/pkg/proto/hapi/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  )
    31  
    32  // Creator is the interface that wraps the Create method.
    33  //
    34  // Create stores the release or returns ErrReleaseExists
    35  // if an identical release already exists.
    36  type Creator interface {
    37  	Create(rls *rspb.Release) error
    38  }
    39  
    40  // Updator is the interface that wraps the Update method.
    41  //
    42  // Update updates an existing release or returns
    43  // ErrReleaseNotFound if the release does not exist.
    44  type Updator interface {
    45  	Update(rls *rspb.Release) error
    46  }
    47  
    48  // Deletor is the interface that wraps the Delete method.
    49  //
    50  // Delete deletes the release named by key or returns
    51  // ErrReleaseNotFound if the release does not exist.
    52  type Deletor interface {
    53  	Delete(key string) (*rspb.Release, error)
    54  }
    55  
    56  // Queryor is the interface that wraps the Get and List methods.
    57  //
    58  // Get returns the release named by key or returns ErrReleaseNotFound
    59  // if the release does not exist.
    60  //
    61  // List returns the set of all releases that satisfy the filter predicate.
    62  type Queryor interface {
    63  	Get(key string) (*rspb.Release, error)
    64  	List(filter func(*rspb.Release) bool) ([]*rspb.Release, error)
    65  }
    66  
    67  // Driver is the interface composed of Creator, Updator, Deletor, Queryor
    68  // interfaces. It defines the behavior for storing, updating, deleted,
    69  // and retrieving tiller releases from some underlying storage mechanism,
    70  // e.g. memory, configmaps.
    71  type Driver interface {
    72  	Creator
    73  	Updator
    74  	Deletor
    75  	Queryor
    76  	Name() string
    77  }