Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mirror] Add mirror pull/push --tmp-dir flag #93

Merged
merged 3 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/mirror/cmd/pull/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package pull

import (
"os"
"path/filepath"

"github.com/spf13/pflag"
)
Expand Down Expand Up @@ -142,4 +143,10 @@ func addFlags(flagSet *pflag.FlagSet) {
false,
"Interact with registries over HTTP.",
)
flagSet.StringVar(
&TempDir,
"tmp-dir",
filepath.Join(os.TempDir(), "mirror"),
"Temporary directory to use for image pulling",
)
}
4 changes: 2 additions & 2 deletions internal/mirror/cmd/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var ErrPullFailed = errors.New("pull failed, see the log for details")

// CLI Parameters
var (
TempDir = filepath.Join(os.TempDir(), "mirror")
TempDir string

Insecure bool
TLSSkipVerify bool
Expand Down Expand Up @@ -204,7 +204,7 @@ func pull(cmd *cobra.Command, _ []string) error {
if err = os.WriteFile(
filepath.Join(pullParams.BundleDir, bundlePackage.Name())+".gostsum",
[]byte(digest),
0644,
0o644,
); err != nil {
merr = multierror.Append(merr, fmt.Errorf("Could not write digest to .gostsum file: %w", err))
}
Expand Down
7 changes: 7 additions & 0 deletions internal/mirror/cmd/push/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package push

import (
"os"
"path/filepath"

"github.com/spf13/pflag"
)
Expand Down Expand Up @@ -49,4 +50,10 @@ func addFlags(flagSet *pflag.FlagSet) {
false,
"Interact with registries over HTTP.",
)
flagSet.StringVar(
&TempDir,
"tmp-dir",
filepath.Join(os.TempDir(), "mirror"),
"Temporary directory to use for image pushing",
)
}
2 changes: 1 addition & 1 deletion internal/mirror/cmd/push/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (

// CLI Parameters
var (
TempDir = filepath.Join(os.TempDir(), "mirror")
TempDir string

RegistryHost string
RegistryPath string
Expand Down