(ctx context.Context, auth *coreauth.Auth)
| 1643 | } |
| 1644 | |
| 1645 | func (a *executorAdapter) Refresh(ctx context.Context, auth *coreauth.Auth) (refreshed *coreauth.Auth, err error) { |
| 1646 | if a == nil || a.executor == nil || a.host.isPluginFused(a.pluginID) || !a.host.pluginIdentityCurrent(a.pluginID, a.path, a.version) { |
| 1647 | return nil, fmt.Errorf("plugin executor %s is unavailable", a.Identifier()) |
| 1648 | } |
| 1649 | record := a.host.authProviderRecord(authProvider(auth)) |
| 1650 | if record == nil || record.plugin.Capabilities.AuthProvider == nil { |
| 1651 | return auth.Clone(), nil |
| 1652 | } |
| 1653 | defer func() { |
| 1654 | if recovered := recover(); recovered != nil { |
| 1655 | a.host.fusePlugin(record.id, "AuthProvider.RefreshAuth", recovered) |
| 1656 | refreshed = nil |
| 1657 | err = fmt.Errorf("plugin executor %s refresh panic: %v", a.Identifier(), recovered) |
| 1658 | } |
| 1659 | }() |
| 1660 | |
| 1661 | pluginResp, errRefresh := record.plugin.Capabilities.AuthProvider.RefreshAuth(ctx, pluginapi.AuthRefreshRequest{ |
| 1662 | AuthID: authID(auth), |
| 1663 | AuthProvider: authProvider(auth), |
| 1664 | StorageJSON: storageJSONFromAuth(auth), |
| 1665 | Metadata: cloneAnyMap(authMetadata(auth)), |
| 1666 | Attributes: authAttributes(auth), |
| 1667 | Host: a.host.hostConfigSummary(), |
| 1668 | HTTPClient: a.host.newHTTPClient(auth), |
| 1669 | }) |
| 1670 | if errRefresh != nil { |
| 1671 | return nil, errRefresh |
| 1672 | } |
| 1673 | data := pluginResp.Auth |
| 1674 | if strings.TrimSpace(data.Provider) == "" { |
| 1675 | data.Provider = authProvider(auth) |
| 1676 | } |
| 1677 | if strings.TrimSpace(data.ID) == "" { |
| 1678 | data.ID = authID(auth) |
| 1679 | } |
| 1680 | if strings.TrimSpace(data.FileName) == "" && auth != nil { |
| 1681 | data.FileName = auth.FileName |
| 1682 | } |
| 1683 | if strings.TrimSpace(data.Label) == "" && auth != nil { |
| 1684 | data.Label = auth.Label |
| 1685 | } |
| 1686 | if strings.TrimSpace(data.Prefix) == "" && auth != nil { |
| 1687 | data.Prefix = auth.Prefix |
| 1688 | } |
| 1689 | if strings.TrimSpace(data.ProxyURL) == "" && auth != nil { |
| 1690 | data.ProxyURL = auth.ProxyURL |
| 1691 | } |
| 1692 | if len(data.Metadata) == 0 && auth != nil { |
| 1693 | data.Metadata = cloneAnyMap(auth.Metadata) |
| 1694 | } |
| 1695 | if len(data.Attributes) == 0 && auth != nil { |
| 1696 | data.Attributes = cloneStringMap(auth.Attributes) |
| 1697 | } |
| 1698 | if len(data.StorageJSON) == 0 { |
| 1699 | data.StorageJSON = storageJSONFromAuth(auth) |
| 1700 | } |
| 1701 | if pluginResp.NextRefreshAfter.IsZero() && auth != nil { |
| 1702 | data.NextRefreshAfter = auth.NextRefreshAfter |
nothing calls this directly
no test coverage detected