Documentation
¶
Overview ¶
Package cncf provides functionality for interacting with the Cloud Native Computing Foundation (CNCF) landscape.
The package allows fetching and querying the official CNCF landscape data, which contains information about all CNCF projects, their status, and related metadata. It includes built-in caching to minimize network requests and provides a simple interface for finding projects by various identifiers.
Basic usage:
client := &cncf.DefaultHTTPClient{}
landscape, err := cncf.GetLandscape(client)
if err != nil {
// Handle error
}
// Find a project
project := landscape.FindProject(cncf.FindProjectOptions{
Name: "Kubernetes",
})
The landscape data is automatically cached for one hour (configurable via CacheTTL) to reduce network requests and improve performance.
Projects can be found by:
- Repository URL
- Homepage URL
- Project name (case-insensitive matching)
Index ¶
Constants ¶
const LandscapeURL = "https://raw.githubusercontent.com/cncf/landscape/master/landscape.yml"
Variables ¶
var CacheTTL = 1 * time.Hour
Functions ¶
func ClearCache ¶ added in v0.21.0
func ClearCache()
ClearCache clears the cache of the landscape data.
Types ¶
type Category ¶
type Category struct {
Name string `yaml:"name"`
Subcategories []Subcategory `yaml:"subcategories"`
}
type DefaultHTTPClient ¶
type DefaultHTTPClient struct{}
DefaultHTTPClient is the default implementation of HTTPClient that uses http.Get.
type FindProjectOptions ¶
type FindProjectOptions struct {
// RepoURL is the URL of the repository.
RepoURL string
// HomepageURL is the URL of the project's homepage.
HomepageURL string
// Name is the name of the project.
Name string
}
FindProjectOptions is a set of options to find a project in the landscape.
type HTTPClient ¶
type HTTPClient interface {
// Get gets the content of the URL and returns the response.
Get(ctx context.Context, rawURL string) (*http.Response, error)
}
HTTPClient is an interface that abstracts the http.Get function.
type Landscape ¶
type Landscape struct {
Categories []Category `yaml:"landscape"`
}
func GetLandscape ¶
func GetLandscape(ctx context.Context, client HTTPClient) (*Landscape, error)
GetLandscape fetches the CNCF landscape from the official repository
func (*Landscape) FindProject ¶
func (l *Landscape) FindProject(opts FindProjectOptions) *Project
FindProject finds a project in the landscape by repo URL, homepage URL, or name.