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

Update pmtiles upload --help #195

Merged
merged 5 commits into from
Dec 4, 2024
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
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main

Check warning on line 1 in main.go

View workflow job for this annotation

GitHub Actions / fmt_vet_lint

should have a package comment

import (
"fmt"
Expand Down Expand Up @@ -39,7 +39,7 @@
Path string `arg:""`
Bucket string `help:"Remote bucket"`
Metadata bool `help:"Print only the JSON metadata."`
HeaderJson bool `help:"Print a JSON representation of the header information."`

Check warning on line 42 in main.go

View workflow job for this annotation

GitHub Actions / fmt_vet_lint

struct field HeaderJson should be HeaderJSON
Tilejson bool `help:"Print the TileJSON."`
PublicURL string `help:"Public base URL of tile endpoint for TileJSON e.g. https://example.com/tiles"`
} `cmd:"" help:"Inspect a local or remote archive."`
Expand All @@ -54,7 +54,7 @@

Write struct {
Input string `arg:"" help:"Input archive file." type:"existingfile"`
HeaderJson string `help:"Input header JSON file (written by show --header-json)." type:"existingfile"`

Check warning on line 57 in main.go

View workflow job for this annotation

GitHub Actions / fmt_vet_lint

struct field HeaderJson should be HeaderJSON
Metadata string `help:"Input metadata JSON (written by show --metadata)." type:"existingfile"`
} `cmd:"" help:"Write header data or metadata to an existing archive." hidden:""`

Expand Down Expand Up @@ -109,8 +109,8 @@
} `cmd:"" help:"Download a local archive to remote storage." hidden:""`

Upload struct {
Input string `arg:"" type:"existingfile"`
Key string `arg:""`
InputPmtiles string `arg:"" type:"existingfile" help:"The local PMTiles file"`
RemotePmtiles string `arg:"" help:"The name for the remote PMTiles source"`
MaxConcurrency int `default:"2" help:"# of upload threads"`
Bucket string `required:"" help:"Bucket to upload to."`
} `cmd:"" help:"Upload a local archive to remote storage."`
Expand Down Expand Up @@ -203,8 +203,8 @@
if err != nil {
logger.Fatalf("Failed to convert %s, %v", path, err)
}
case "upload <input> <key>":
err := pmtiles.Upload(logger, cli.Upload.Input, cli.Upload.Bucket, cli.Upload.Key, cli.Upload.MaxConcurrency)
case "upload <inputpmtiles> <remotepmtiles>":
err := pmtiles.Upload(logger, cli.Upload.InputPmtiles, cli.Upload.Bucket, cli.Upload.RemotePmtiles, cli.Upload.MaxConcurrency)

if err != nil {
logger.Fatalf("Failed to upload file, %v", err)
Expand Down
6 changes: 3 additions & 3 deletions pmtiles/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func partSizeBytes(totalSize int64) int {
}

// Upload a pmtiles archive to a bucket.
func Upload(logger *log.Logger, input string, bucket string, key string, maxConcurrency int) error {
func Upload(logger *log.Logger, InputPMTiles string, bucket string, RemotePMTiles string, maxConcurrency int) error {
ctx := context.Background()

b, err := blob.OpenBucket(ctx, bucket)
Expand All @@ -28,7 +28,7 @@ func Upload(logger *log.Logger, input string, bucket string, key string, maxConc
}
defer b.Close()

f, err := os.Open(input)
f, err := os.Open(InputPMTiles)
if err != nil {
return fmt.Errorf("Failed to open file: %w", err)
}
Expand All @@ -44,7 +44,7 @@ func Upload(logger *log.Logger, input string, bucket string, key string, maxConc
MaxConcurrency: maxConcurrency,
}

w, err := b.NewWriter(ctx, key, opts)
w, err := b.NewWriter(ctx, RemotePMTiles, opts)
if err != nil {
return fmt.Errorf("Failed to obtain writer: %w", err)
}
Expand Down
Loading