@ -30,15 +30,23 @@ import (
)
const searchHubDesc = `
Search the Helm Hub or an instance of Monocular for Helm charts .
The Helm Hub provides a centralized search for publicly available distributed
charts . It is maintained by the Helm project . It can be visited at
https : //hub.helm.sh
Monocular is a web - based application that enables the search and discovery of
charts from multiple Helm Chart repositories . It is the codebase that powers the
Helm Hub . You can find it at https : //github.com/helm/monocular
Search for Helm charts in the Artifact Hub or your own hub instance .
Artifact Hub is a web - based application that enables finding , installing , and
publishing packages and configurations for CNCF projects , including publicly
available distributed charts Helm charts . It is a Cloud Native Computing
Foundation sandbox project . You can browse the hub at https : //artifacthub.io/
The [ KEYWORD ] argument accepts either a keyword string , or quoted string of rich
query options . For rich query options documentation , see
https : //artifacthub.github.io/hub/api/?urls.primaryName=Monocular%20compatible%20search%20API#/Monocular/get_api_chartsvc_v1_charts_search
Previous versions of Helm used an instance of Monocular as the default
' endpoint ' , so for backwards compatibility Artifact Hub is compatible with the
Monocular search API . Similarly , when setting the ' endpoint ' flag , the specified
endpoint must also be implement a Monocular compatible search API endpoint .
Note that when specifying a Monocular instance as the ' endpoint ' , rich queries
are not supported . For API details , see https : //github.com/helm/monocular
`
type searchHubOptions struct {
@ -51,8 +59,8 @@ func newSearchHubCmd(out io.Writer) *cobra.Command {
o := & searchHubOptions { }
cmd := & cobra . Command {
Use : "hub [ keyword ]",
Short : "search for charts in the Helm Hub or an instance of Monocular ",
Use : "hub [ KEYWORD ]",
Short : "search for charts in the Artifact Hub or your own hub instance ",
Long : searchHubDesc ,
RunE : func ( cmd * cobra . Command , args [ ] string ) error {
return o . run ( out , args )
@ -60,7 +68,7 @@ func newSearchHubCmd(out io.Writer) *cobra.Command {
}
f := cmd . Flags ( )
f . StringVar ( & o . searchEndpoint , "endpoint" , "https://hub.helm.sh" , " monocular instance to query for charts")
f . StringVar ( & o . searchEndpoint , "endpoint" , "https://hub.helm.sh" , " Hub instance to query for charts")
f . UintVar ( & o . maxColWidth , "max-col-width" , 50 , "maximum column width for output table" )
bindOutputFlag ( cmd , & o . outputFormat )
@ -98,7 +106,14 @@ type hubSearchWriter struct {
func newHubSearchWriter ( results [ ] monocular . SearchResult , endpoint string , columnWidth uint ) * hubSearchWriter {
var elements [ ] hubChartElement
for _ , r := range results {
// Backwards compatibility for Monocular
url := endpoint + "/charts/" + r . ID
// Check for artifactHub compatibility
if r . ArtifactHub . PackageURL != "" {
url = r . ArtifactHub . PackageURL
}
elements = append ( elements , hubChartElement { url , r . Relationships . LatestChartVersion . Data . Version , r . Relationships . LatestChartVersion . Data . AppVersion , r . Attributes . Description } )
}
return & hubSearchWriter { elements , columnWidth }