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

fix: Pass user team to Docker auth endpoint #210

Merged
merged 2 commits into from
Jan 2, 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
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
Loading