Capture context from cobra CLI and pass forward (#2551)

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2022-09-22 13:54:05 +05:30
committed by GitHub
parent d03395949b
commit e87c84ee2c
33 changed files with 93 additions and 83 deletions
+2 -4
View File
@@ -17,7 +17,6 @@ limitations under the License.
package _package
import (
"context"
"fmt"
"net/http"
"os"
@@ -128,7 +127,7 @@ func CreateArchive(client client.Interface, input cli.Input, includeFiles []stri
return nil, err
}
file := filepath.Join(tmpDir, id.String())
err = utils.DownloadUrl(context.Background(), http.DefaultClient, fileURL, file)
err = utils.DownloadUrl(input.Context(), http.DefaultClient, fileURL, file)
if err != nil {
return nil, errors.Wrap(err, "error downloading file from the given URL")
}
@@ -193,8 +192,7 @@ func CreateArchive(client client.Interface, input cli.Input, includeFiles []stri
return nil, err
}
ctx := context.Background()
return pkgutil.UploadArchiveFile(ctx, client, archivePath)
return pkgutil.UploadArchiveFile(input.Context(), client, archivePath)
}
// makeArchiveFile creates a zip file from the given list of input files,