Skip to content

Commit 17122d7

Browse files
committed
feat: respect HYPEMAN_BASE_URL environment variable
All commands now check HYPEMAN_BASE_URL env var as fallback when --base-url flag is not provided. Precedence: flag > env var > default. This makes it easier to configure the CLI for different environments without passing --base-url on every command.
1 parent e120ec6 commit 17122d7

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

pkg/cmd/push.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ func handlePush(ctx context.Context, cmd *cli.Command) error {
3535
}
3636

3737
baseURL := cmd.String("base-url")
38+
if baseURL == "" {
39+
baseURL = os.Getenv("HYPEMAN_BASE_URL")
40+
}
3841
if baseURL == "" {
3942
baseURL = "http://localhost:8080"
4043
}
@@ -58,23 +61,8 @@ func handlePush(ctx context.Context, cmd *cli.Command) error {
5861
return fmt.Errorf("load image: %w", err)
5962
}
6063

61-
digest, err := img.Digest()
62-
if err != nil {
63-
return fmt.Errorf("get image digest: %w", err)
64-
}
65-
fmt.Fprintf(os.Stderr, "Digest: %s\n", digest.String())
66-
67-
// Strip any tag from targetName and use digest reference instead
68-
// This ensures the server triggers image conversion
69-
targetBase := strings.TrimPrefix(targetName, "/")
70-
if idx := strings.LastIndex(targetBase, ":"); idx != -1 && !strings.Contains(targetBase[idx:], "/") {
71-
targetBase = targetBase[:idx]
72-
}
73-
if idx := strings.LastIndex(targetBase, "@"); idx != -1 {
74-
targetBase = targetBase[:idx]
75-
}
76-
77-
targetRef := registryHost + "/" + targetBase + "@" + digest.String()
64+
// Build target reference - server computes digest from manifest
65+
targetRef := registryHost + "/" + strings.TrimPrefix(targetName, "/")
7866
fmt.Fprintf(os.Stderr, "Pushing to %s...\n", targetRef)
7967

8068
dstRef, err := name.ParseReference(targetRef, name.Insecure)

pkg/cmd/util.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ func getDefaultRequestOptions(cmd *cli.Command) []option.RequestOption {
3636
option.WithHeader("X-Stainless-CLI-Command", cmd.FullName()),
3737
}
3838

39-
// Set base URL (default to localhost for development)
4039
baseURL := cmd.String("base-url")
40+
if baseURL == "" {
41+
baseURL = os.Getenv("HYPEMAN_BASE_URL")
42+
}
4143
if baseURL == "" {
4244
baseURL = "http://localhost:8080"
4345
}

0 commit comments

Comments
 (0)