@@ -22,16 +22,15 @@ import (
2222 "context"
2323 "encoding/json"
2424 "fmt"
25+
2526 "github.com/devtron-labs/devtron/internal/constants"
27+
2628 //"github.com/devtron-labs/devtron/pkg/pipeline"
2729
2830 "github.com/devtron-labs/devtron/internal/sql/repository/app"
2931 chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository"
3032 "github.com/devtron-labs/devtron/pkg/pipeline/history"
3133
32- repository4 "github.com/devtron-labs/devtron/pkg/cluster/repository"
33- "github.com/devtron-labs/devtron/pkg/sql"
34- dirCopy "github.com/otiai10/copy"
3534 "io/ioutil"
3635 "net/http"
3736 "os"
@@ -41,6 +40,10 @@ import (
4140 "strings"
4241 "time"
4342
43+ repository4 "github.com/devtron-labs/devtron/pkg/cluster/repository"
44+ "github.com/devtron-labs/devtron/pkg/sql"
45+ dirCopy "github.com/otiai10/copy"
46+
4447 repository2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/repository"
4548 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
4649 "github.com/devtron-labs/devtron/client/argocdServer/repository"
@@ -951,11 +954,16 @@ type chartRef struct {
951954 UserUploaded bool `json:"userUploaded"`
952955}
953956
957+ type ChartRefMetaData struct {
958+ ChartDescription string `json:"chartDescription"`
959+ }
960+
954961type chartRefResponse struct {
955- ChartRefs []chartRef `json:"chartRefs"`
956- LatestChartRef int `json:"latestChartRef"`
957- LatestAppChartRef int `json:"latestAppChartRef"`
958- LatestEnvChartRef int `json:"latestEnvChartRef,omitempty"`
962+ ChartRefs []chartRef `json:"chartRefs"`
963+ LatestChartRef int `json:"latestChartRef"`
964+ LatestAppChartRef int `json:"latestAppChartRef"`
965+ LatestEnvChartRef int `json:"latestEnvChartRef,omitempty"`
966+ ChartsMetadata map [string ]ChartRefMetaData `json:"chartMetadata"` // chartName vs Metadata
959967}
960968
961969type ChartYamlStruct struct {
@@ -995,14 +1003,28 @@ func (impl ChartServiceImpl) ChartRefAutocomplete() ([]chartRef, error) {
9951003}
9961004
9971005func (impl ChartServiceImpl ) ChartRefAutocompleteForAppOrEnv (appId int , envId int ) (* chartRefResponse , error ) {
998- chartRefResponse := & chartRefResponse {}
1006+ chartRefResponse := & chartRefResponse {
1007+ ChartsMetadata : make (map [string ]ChartRefMetaData ),
1008+ }
9991009 var chartRefs []chartRef
1010+
10001011 results , err := impl .chartRefRepository .GetAll ()
10011012 if err != nil {
10021013 impl .logger .Errorw ("error in fetching chart config" , "err" , err )
10031014 return chartRefResponse , err
10041015 }
10051016
1017+ resultsMetadata , err := impl .chartRefRepository .GetAllChartMetadata ()
1018+ if err != nil {
1019+ impl .logger .Errorw ("error in fetching chart metadata" , "err" , err )
1020+ return chartRefResponse , err
1021+ }
1022+ for _ , resultMetadata := range resultsMetadata {
1023+ chartRefMetadata := ChartRefMetaData {
1024+ ChartDescription : resultMetadata .ChartDescription ,
1025+ }
1026+ chartRefResponse .ChartsMetadata [resultMetadata .ChartName ] = chartRefMetadata
1027+ }
10061028 var LatestAppChartRef int
10071029 for _ , result := range results {
10081030 if len (result .Name ) == 0 {
@@ -1013,6 +1035,7 @@ func (impl ChartServiceImpl) ChartRefAutocompleteForAppOrEnv(appId int, envId in
10131035 LatestAppChartRef = result .Id
10141036 }
10151037 }
1038+
10161039 chart , err := impl .chartRepository .FindLatestChartForAppByAppId (appId )
10171040 if err != nil && err != pg .ErrNoRows {
10181041 impl .logger .Errorw ("error in fetching latest chart" , "err" , err )
0 commit comments