2023-06-02 03:19:23 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-06-07 10:16:32 -04:00
|
|
|
package versionsapi
|
2023-06-02 03:19:23 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/api/fetcher"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Fetcher fetches version API resources without authentication.
|
|
|
|
type Fetcher struct {
|
|
|
|
fetcher.HTTPClient
|
|
|
|
}
|
|
|
|
|
2023-06-07 10:16:32 -04:00
|
|
|
// NewFetcher returns a new Fetcher.
|
|
|
|
func NewFetcher() *Fetcher {
|
2023-06-02 03:19:23 -04:00
|
|
|
return &Fetcher{fetcher.NewHTTPClient()}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FetchVersionList fetches the given version list from the versions API.
|
2023-06-07 10:16:32 -04:00
|
|
|
func (f *Fetcher) FetchVersionList(ctx context.Context, list List) (List, error) {
|
2023-06-02 03:19:23 -04:00
|
|
|
return fetcher.Fetch(ctx, f.HTTPClient, list)
|
|
|
|
}
|
|
|
|
|
|
|
|
// FetchVersionLatest fetches the latest version from the versions API.
|
2023-06-07 10:16:32 -04:00
|
|
|
func (f *Fetcher) FetchVersionLatest(ctx context.Context, latest Latest) (Latest, error) {
|
2023-06-02 03:19:23 -04:00
|
|
|
return fetcher.Fetch(ctx, f.HTTPClient, latest)
|
|
|
|
}
|
|
|
|
|
|
|
|
// FetchImageInfo fetches the given image info from the versions API.
|
2023-06-07 10:16:32 -04:00
|
|
|
func (f *Fetcher) FetchImageInfo(ctx context.Context, imageInfo ImageInfo) (ImageInfo, error) {
|
2023-06-02 03:19:23 -04:00
|
|
|
return fetcher.Fetch(ctx, f.HTTPClient, imageInfo)
|
|
|
|
}
|
|
|
|
|
|
|
|
// FetchCLIInfo fetches the given cli info from the versions API.
|
2023-06-07 10:16:32 -04:00
|
|
|
func (f *Fetcher) FetchCLIInfo(ctx context.Context, cliInfo CLIInfo) (CLIInfo, error) {
|
2023-06-02 03:19:23 -04:00
|
|
|
return fetcher.Fetch(ctx, f.HTTPClient, cliInfo)
|
|
|
|
}
|