-
Notifications
You must be signed in to change notification settings - Fork 7
Conversation
Signed-off-by: wangxiaoxuan273 <[email protected]>
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #46 +/- ##
==========================================
- Coverage 78.32% 77.67% -0.65%
==========================================
Files 3 4 +1
Lines 203 224 +21
==========================================
+ Hits 159 174 +15
- Misses 33 37 +4
- Partials 11 13 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: wangxiaoxuan273 <[email protected]>
Signed-off-by: wangxiaoxuan273 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need better documentations for the behaviors.
store_with_fallbacks.go
Outdated
|
||
// NewStoreWithFallbacks returns a new store based on the given stores. | ||
// The second and the subsequent stores will be used as fallbacks for the first store. | ||
func NewStoreWithFallbacks(store Store, fallbacks ...Store) Store { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still struggling between
NewStoreWithFallbacks(store Store, fallbacks ...Store) Store
and
NewStoreWithFallbacks(stores ...Store) Store
Later we will have a docker store which is based on the docker configuration file at the default location. I'm wondering how we should use it together with StoreWithFallbacks
.
If we go for option 1, the experience would be:
ns := NewNativeStore()
store := NewStoreWithFallbacks(ns, NewStoreFromDocker())
or
dockerStore := NewStoreFromDocker()
store := NewStoreWithFallbacks(dockerStore)
If we go for option 2, we should have the docker store to be the default store when no store is passed.
So
dockerStore := NewStoreFromDocker()
store := NewStoreWithFallbacks(dockerStore)
is equivalent to
store := NewStoreWithFallbacks()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I still prefer option 1.
Good advice. Added more detailed documentations for |
Signed-off-by: wangxiaoxuan273 <[email protected]>
store_with_fallbacks.go
Outdated
} | ||
|
||
// NewStoreWithFallbacks returns a new store based on the given stores. | ||
// The first store in the array is used as the primary store. The second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first store in the array is used as the primary store
This looks a bit strange as this function does not accept an array of stores for the primary store.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the description about the array.
store_with_fallbacks.go
Outdated
} | ||
|
||
// Get retrieves credentials from the StoreWithFallbacks for the given server. | ||
// It searches the array of stores for the credentials of serverAddress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The array of stores is invisible to users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the description about the array.
store_with_fallbacks.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put everything in store.go
instead of having a new file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved.
store_with_fallbacks.go
Outdated
// StoreWithFallbacks is a store that has multiple fallback stores. | ||
// Please use the NewStoreWithFallbacks to create new instances of | ||
// StoreWithFallbacks. | ||
type StoreWithFallbacks struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to export this struct? Can we make it private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made it private.
store_with_fallbacks.go
Outdated
func NewStoreWithFallbacks(store Store, fallbacks ...Store) Store { | ||
return &StoreWithFallbacks{ | ||
stores: append([]Store{store}, fallbacks...), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If len(fallbacks) == 0
, should we just return store
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed it.
Signed-off-by: wangxiaoxuan273 <[email protected]>
Signed-off-by: wangxiaoxuan273 <[email protected]>
store.go
Outdated
// Please use the NewStoreWithFallbacks to create new instances of | ||
// storeWithFallbacks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
store.go
Outdated
// The first store is used as the primary store. The second and the | ||
// subsequent stores will be used as fallbacks for the first store. | ||
func NewStoreWithFallbacks(store Store, fallbacks ...Store) Store { | ||
if fallbacks == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if fallbacks == nil { | |
if len(fallbacks) == 0 { |
fallbacks
can be not-nil but empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed.
// It searches the primary and the fallback stores for the credentials of serverAddress | ||
// and returns when it finds the credentials in any of the stores. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if users can see these comments. We may need to move them to NewStoreWithFallbacks
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved.
} | ||
|
||
// Put saves credentials into the StoreWithFallbacks. It puts | ||
// the credentials into the primary store. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved.
Signed-off-by: wangxiaoxuan273 <[email protected]>
Signed-off-by: wangxiaoxuan273 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Resolves #35