Skip to content

Commit

Permalink
fix: Pass user team to Docker auth endpoint (#210)
Browse files Browse the repository at this point in the history

Needed to track downloads

---
  • Loading branch information
erezrokah authored Jan 2, 2024
1 parent 19c848f commit 452df35
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion managedplugin/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func isDockerImageAvailable(ctx context.Context, imageName string) (bool, error)
return len(images) > 0, nil
}

func pullDockerImage(ctx context.Context, imageName string, authToken string) error {
func pullDockerImage(ctx context.Context, imageName string, authToken string, teamName string) error {
// Pull the image
additionalHeaders := make(map[string]string)
opts := types.ImagePullOptions{}
Expand All @@ -98,6 +98,7 @@ func pullDockerImage(ctx context.Context, imageName string, authToken string) er
return fmt.Errorf("failed to parse Docker image tag: %v", err)
}
additionalHeaders["X-Meta-Plugin-Version"] = nameWithTag.Tag()
additionalHeaders["X-Meta-User-Team-Name"] = teamName
authConfig := registry.AuthConfig{
Username: "managedplugin",
Password: authToken,
Expand Down
2 changes: 1 addition & 1 deletion managedplugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (c *Client) downloadPlugin(ctx context.Context, typ PluginType) error {
if imageAvailable, err := isDockerImageAvailable(ctx, c.config.Path); err != nil {
return err
} else if !imageAvailable {
return pullDockerImage(ctx, c.config.Path, c.authToken)
return pullDockerImage(ctx, c.config.Path, c.authToken, c.teamName)
}
return nil
case RegistryCloudQuery:
Expand Down

0 comments on commit 452df35

Please sign in to comment.