Documentation
¶
Overview ¶
Package qiniu implements certificate upload and exact-domain certificate deployment for Qiniu CDN products.
The certificate API and domain API use different hosts and authentication schemes. Keeping the request construction here makes it possible to sign the same bytes that are ultimately sent to the domain API.
Index ¶
- type APIError
- type CertificateUploadResult
- type HTTPClient
- type Options
- type Product
- type Provider
- func (p *Provider) BindCertificate(ctx context.Context, product Product, certID, domain string) (*TargetDeploymentResult, error)
- func (p *Provider) DeployCertificate(ctx context.Context, certificate providers.CertificateMaterial, ...) (providers.DeploymentResult, error)
- func (p *Provider) DeployTargetCertificate(ctx context.Context, product Product, name, domain, cert, key string) (*TargetDeploymentResult, error)
- func (p *Provider) DiscoverResources(ctx context.Context, deploymentType deployPB.DeploymentType) providers.ResourceCatalogResult
- func (p *Provider) ResolveResource(ctx context.Context, deploymentType deployPB.DeploymentType, targetRef string) (providers.DeploymentResource, error)
- func (p *Provider) TestConnection(ctx context.Context) (bool, error)
- func (p *Provider) TestConnectionWithContext(ctx context.Context) (bool, error)
- func (p *Provider) TestResource(ctx context.Context, deploymentType deployPB.DeploymentType, targetRef string) error
- func (p *Provider) UploadCertificate(ctx context.Context, certificate providers.CertificateMaterial) error
- func (p *Provider) UploadCertificateWithContext(ctx context.Context, name, domain, cert, key string) (*CertificateUploadResult, error)
- type TargetDeploymentResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶ added in v0.6.4
type APIError struct {
// Operation identifies the failed Qiniu API operation.
Operation string
// StatusCode is the provider HTTP status code, or zero before a response exists.
StatusCode int
// ProviderRequestID is Qiniu's request identifier when the response included one.
ProviderRequestID string
// Retryable reports whether retrying the operation may succeed without configuration changes.
Retryable bool
// Message is a sanitized provider or local failure description.
Message string
// Cause retains the underlying transport or parsing error.
Cause error
}
APIError carries enough provider context for a later caller to decide whether to retry.
type CertificateUploadResult ¶ added in v0.6.4
type CertificateUploadResult struct {
// CertificateID is Qiniu's certID and is required by the domain binding API.
CertificateID string
// ProviderRequestID is Qiniu's request identifier for the upload operation.
ProviderRequestID string
}
CertificateUploadResult contains the certificate identity returned by Qiniu.
type HTTPClient ¶ added in v0.6.4
type HTTPClient interface {
// Do sends one HTTP request and returns its response.
Do(*http.Request) (*http.Response, error)
}
HTTPClient is the subset of http.Client used by Provider. It allows unit tests to inject an httptest client without global state.
type Options ¶ added in v0.6.4
type Options struct {
// HTTPClient sends signed API requests. A timeout-enabled default is used when nil.
HTTPClient HTTPClient
// APIBaseURL overrides the Qiniu domain API host. It is intended for tests.
APIBaseURL string
// FusionBaseURL overrides the Qiniu certificate API host. It is intended for tests.
FusionBaseURL string
}
Options configures a Provider instance.
type Product ¶ added in v0.6.4
type Product string
Product identifies the Qiniu domain product that owns a custom domain.
type Provider ¶
type Provider struct {
// AccessKey is retained for compatibility with existing callers. Do not log it.
AccessKey string
// AccessSecret is retained for compatibility with existing callers. Do not log it.
AccessSecret string
// contains filtered or unexported fields
}
Provider owns the Qiniu credentials and HTTP transport used for certificate operations.
func NewWithOptions ¶ added in v0.6.4
NewWithOptions creates a Provider with an injectable HTTP transport and API endpoints.
func (*Provider) BindCertificate ¶ added in v0.6.4
func (p *Provider) BindCertificate(ctx context.Context, product Product, certID, domain string) (*TargetDeploymentResult, error)
BindCertificate validates one exact Qiniu domain, binds an existing certID, and reads it back.
func (*Provider) DeployCertificate ¶ added in v0.6.4
func (p *Provider) DeployCertificate(ctx context.Context, certificate providers.CertificateMaterial, deploymentType deployPB.DeploymentType, target providers.DeploymentResource) (providers.DeploymentResult, error)
DeployCertificate 为明确的七牛 CDN 或 DCDN 业务部署精确域名证书。
func (*Provider) DeployTargetCertificate ¶ added in v0.6.4
func (p *Provider) DeployTargetCertificate(ctx context.Context, product Product, name, domain, cert, key string) (*TargetDeploymentResult, error)
DeployTargetCertificate validates one exact Qiniu domain, uploads a certificate, binds it, and reads it back.
func (*Provider) DiscoverResources ¶ added in v0.7.0
func (p *Provider) DiscoverResources(ctx context.Context, deploymentType deployPB.DeploymentType) providers.ResourceCatalogResult
DiscoverResources 实时发现七牛 CDN 或 DCDN 域名资源。
func (*Provider) ResolveResource ¶ added in v0.7.0
func (p *Provider) ResolveResource(ctx context.Context, deploymentType deployPB.DeploymentType, targetRef string) (providers.DeploymentResource, error)
ResolveResource 实时发现目录并按引用唯一解析七牛域名。
func (*Provider) TestConnection ¶
TestConnection tests QBox credentials against the Qiniu certificate API.
func (*Provider) TestConnectionWithContext ¶ added in v0.6.4
TestConnectionWithContext tests QBox credentials while respecting caller cancellation.
func (*Provider) TestResource ¶ added in v0.7.0
func (p *Provider) TestResource(ctx context.Context, deploymentType deployPB.DeploymentType, targetRef string) error
TestResource 只读确认七牛域名仍存在、产品一致且已启用 HTTPS。
func (*Provider) UploadCertificate ¶
func (p *Provider) UploadCertificate(ctx context.Context, certificate providers.CertificateMaterial) error
UploadCertificate 将证书上传到七牛云证书中心,供 v2 无资源部署类型复用。 需要七牛云 certID 时使用 UploadCertificateWithContext。
func (*Provider) UploadCertificateWithContext ¶ added in v0.6.4
func (p *Provider) UploadCertificateWithContext(ctx context.Context, name, domain, cert, key string) (*CertificateUploadResult, error)
UploadCertificateWithContext uploads a PEM certificate with QBox authentication and retains certID.
type TargetDeploymentResult ¶ added in v0.6.4
type TargetDeploymentResult struct {
// CertificateID is the Qiniu certID bound to the custom domain.
CertificateID string
// Domain is the exact custom domain that was verified and updated.
Domain string
// Product is the Qiniu product validated before the update.
Product Product
// UploadRequestID identifies the certificate upload request when this method uploaded a certificate.
UploadRequestID string
// ProviderRequestID identifies the domain update request.
ProviderRequestID string
}
TargetDeploymentResult describes one exact-domain certificate deployment at the Qiniu API layer.