From c0aa63ac976185511a841a263baa0976c9db861f Mon Sep 17 00:00:00 2001 From: Eric Chiang Date: Fri, 28 Oct 2016 13:00:13 -0700 Subject: [PATCH] storage: update godocs --- storage/kubernetes/doc.go | 2 +- storage/storage.go | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/storage/kubernetes/doc.go b/storage/kubernetes/doc.go index 806104fa..1112e397 100644 --- a/storage/kubernetes/doc.go +++ b/storage/kubernetes/doc.go @@ -1,2 +1,2 @@ -// Package kubernetes provides a storage interface using Kubernetes third party APIs. +// Package kubernetes provides a storage implementation using Kubernetes third party APIs. package kubernetes diff --git a/storage/storage.go b/storage/storage.go index 032ba4ed..9c618cca 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -78,9 +78,20 @@ type Storage interface { DeleteRefresh(id string) error DeletePassword(email string) error - // Update functions are assumed to be a performed within a single object transaction. + // Update methods take a function for updating an object then performs that update within + // a transaction. "updater" functions may be called multiple times by a single update call. + // + // Because new fields may be added to resources, updaters should only modify existing + // fields on the old object rather then creating new structs. For example: + // + // updater := func(old storage.Client) (storage.Client, error) { + // old.Secret = newSecret + // return old, nil + // } + // if err := s.UpdateClient(clientID, updater); err != nil { + // // update failed, handle error + // } // - // updaters may be called multiple times. UpdateClient(id string, updater func(old Client) (Client, error)) error UpdateKeys(updater func(old Keys) (Keys, error)) error UpdateAuthRequest(id string, updater func(a AuthRequest) (AuthRequest, error)) error