@ -30,15 +30,23 @@ import (
)
)
const searchHubDesc = `
const searchHubDesc = `
Search the Helm Hub or an instance of Monocular for Helm charts .
Search for Helm charts in the Artifact Hub or your own hub instance .
The Helm Hub provides a centralized search for publicly available distributed
Artifact Hub is a web - based application that enables finding , installing , and
charts . It is maintained by the Helm project . It can be visited at
publishing packages and configurations for CNCF projects , including publicly
https : //hub.helm.sh
available distributed charts Helm charts . It is a Cloud Native Computing
Foundation sandbox project . You can browse the hub at https : //artifacthub.io/
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
The [ KEYWORD ] argument accepts either a keyword string , or quoted string of rich
Helm Hub . You can find it at https : //github.com/helm/monocular
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 {
type searchHubOptions struct {
@ -51,8 +59,8 @@ func newSearchHubCmd(out io.Writer) *cobra.Command {
o := & searchHubOptions { }
o := & searchHubOptions { }
cmd := & cobra . Command {
cmd := & cobra . Command {
Use : "hub [ keyword ]",
Use : "hub [ KEYWORD ]",
Short : "search for charts in the Helm Hub or an instance of Monocular ",
Short : "search for charts in the Artifact Hub or your own hub instance ",
Long : searchHubDesc ,
Long : searchHubDesc ,
RunE : func ( cmd * cobra . Command , args [ ] string ) error {
RunE : func ( cmd * cobra . Command , args [ ] string ) error {
return o . run ( out , args )
return o . run ( out , args )
@ -60,7 +68,7 @@ func newSearchHubCmd(out io.Writer) *cobra.Command {
}
}
f := cmd . Flags ( )
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" )
f . UintVar ( & o . maxColWidth , "max-col-width" , 50 , "maximum column width for output table" )
bindOutputFlag ( cmd , & o . outputFormat )
bindOutputFlag ( cmd , & o . outputFormat )
@ -98,7 +106,14 @@ type hubSearchWriter struct {
func newHubSearchWriter ( results [ ] monocular . SearchResult , endpoint string , columnWidth uint ) * hubSearchWriter {
func newHubSearchWriter ( results [ ] monocular . SearchResult , endpoint string , columnWidth uint ) * hubSearchWriter {
var elements [ ] hubChartElement
var elements [ ] hubChartElement
for _ , r := range results {
for _ , r := range results {
// Backwards compatibility for Monocular
url := endpoint + "/charts/" + r . ID
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 } )
elements = append ( elements , hubChartElement { url , r . Relationships . LatestChartVersion . Data . Version , r . Relationships . LatestChartVersion . Data . AppVersion , r . Attributes . Description } )
}
}
return & hubSearchWriter { elements , columnWidth }
return & hubSearchWriter { elements , columnWidth }