Skip to content

Commit

Permalink
[mirror] Add mirror pull/push --tmp-dir flag (#93)
Browse files Browse the repository at this point in the history
* d8 mirror pull/push --tmp-dir flag

Signed-off-by: borg-z <me@nikolay-z.top>

Signed-off-by: borg-z <me@nikolay-z.top>
Signed-off-by: Maxim Vasilenko <5184586+mvasl@users.noreply.github.com>
Co-authored-by: Maxim Vasilenko <5184586+mvasl@users.noreply.github.com>
  • Loading branch information
borg-z and mvasl authored Feb 24, 2025
1 parent 8c02acd commit 4c456ba
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
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

0 comments on commit 4c456ba

Please sign in to comment.