fix: error handling and style changes

Signed-off-by: Louis Cabrol <louis@cabrol.xyz>
pull/11791/head
Louis Cabrol 3 years ago
parent d1fdf41b51
commit ab7fb02af7

@ -286,6 +286,9 @@ func (secrets *Secrets) Delete(key string) (rls *rspb.Release, err error) {
// fetch main release object // fetch main release object
obj, err := secrets.impl.Get(context.Background(), key, metav1.GetOptions{}) obj, err := secrets.impl.Get(context.Background(), key, metav1.GetOptions{})
if err != nil {
return nil, errors.Wrapf(err, "delete: failed to get release %q", key)
}
// don't use _FetchReleaseData as we only need the keys, not the data // don't use _FetchReleaseData as we only need the keys, not the data
// fetch all keys that need to be deleted // fetch all keys that need to be deleted
@ -396,7 +399,7 @@ func newSecretObjects(key string, rls *rspb.Release, lbs labels) ([]*v1.Secret,
} }
// build the reference to the next chunk // build the reference to the next chunk
var currentChunkIndex int = 1 var currentChunkIndex = 1
currentChunkKey := makePartialKey(rls.Name, rls.Version, currentChunkIndex) currentChunkKey := makePartialKey(rls.Name, rls.Version, currentChunkIndex)
// add the continuedIn field // add the continuedIn field
@ -407,8 +410,8 @@ func newSecretObjects(key string, rls *rspb.Release, lbs labels) ([]*v1.Secret,
// prepare to split // prepare to split
// use a window defined by idxStart:idxStop // use a window defined by idxStart:idxStop
var idxStart int = 0 var idxStart int
var idxStop int = SizeCutoff var idxStop = SizeCutoff
for idxStop != len(releaseBytes) { for idxStop != len(releaseBytes) {
// shift window // shift window
idxStart += SizeCutoff idxStart += SizeCutoff
@ -431,7 +434,7 @@ func newSecretObjects(key string, rls *rspb.Release, lbs labels) ([]*v1.Secret,
} }
// check if we'll need another partial chunk // check if we'll need another partial chunk
if idxStop != len(releaseBytes) { if idxStop != len(releaseBytes) {
currentChunkIndex += 1 // increment current chunk currentChunkIndex++ // increment current chunk
currentChunkKey = makePartialKey(rls.Name, rls.Version, currentChunkIndex) // make key for the next chunk currentChunkKey = makePartialKey(rls.Name, rls.Version, currentChunkIndex) // make key for the next chunk
currentSecret.ObjectMeta.Labels["continuedIn"] = currentChunkKey // store reference to it currentSecret.ObjectMeta.Labels["continuedIn"] = currentChunkKey // store reference to it
} }

Loading…
Cancel
Save