@@ -2,11 +2,13 @@ package adapter
22
33import (
44 "github.com/devtron-labs/common-lib/helmLib/registry"
5- "github.com/devtron-labs/common-lib/utils/remoteConnection/bean"
5+ remoteConnection "github.com/devtron-labs/common-lib/utils/remoteConnection/bean"
66 client "github.com/devtron-labs/kubelink/grpc"
7+ "github.com/devtron-labs/kubelink/pkg/service/helmApplicationService/release"
78 "github.com/devtron-labs/kubelink/pkg/util"
89 "google.golang.org/protobuf/types/known/timestamppb"
9- "helm.sh/helm/v3/pkg/release"
10+ helmChart "helm.sh/helm/v3/pkg/chart"
11+ helmRelease "helm.sh/helm/v3/pkg/release"
1012)
1113
1214func NewRegistryConfig (credential * client.RegistryCredential ) (* registry.Configuration , error ) {
@@ -36,36 +38,36 @@ func NewRegistryConfig(credential *client.RegistryCredential) (*registry.Configu
3638
3739 connectionConfig := credential .RemoteConnectionConfig
3840 if connectionConfig != nil {
39- registryConfig .RemoteConnectionConfig = & bean .RemoteConnectionConfigBean {}
41+ registryConfig .RemoteConnectionConfig = & remoteConnection .RemoteConnectionConfigBean {}
4042 switch connectionConfig .RemoteConnectionMethod {
4143 case client .RemoteConnectionMethod_DIRECT :
42- registryConfig .RemoteConnectionConfig .ConnectionMethod = bean .RemoteConnectionMethodDirect
44+ registryConfig .RemoteConnectionConfig .ConnectionMethod = remoteConnection .RemoteConnectionMethodDirect
4345 case client .RemoteConnectionMethod_PROXY :
44- registryConfig .RemoteConnectionConfig .ConnectionMethod = bean .RemoteConnectionMethodProxy
46+ registryConfig .RemoteConnectionConfig .ConnectionMethod = remoteConnection .RemoteConnectionMethodProxy
4547 registryConfig .RemoteConnectionConfig .ProxyConfig = ConvertConfigToProxyConfig (connectionConfig )
4648 case client .RemoteConnectionMethod_SSH :
47- registryConfig .RemoteConnectionConfig .ConnectionMethod = bean .RemoteConnectionMethodSSH
49+ registryConfig .RemoteConnectionConfig .ConnectionMethod = remoteConnection .RemoteConnectionMethodSSH
4850 registryConfig .RemoteConnectionConfig .SSHTunnelConfig = ConvertConfigToSSHTunnelConfig (connectionConfig )
4951 }
5052 }
5153 }
5254 return registryConfig , nil
5355}
5456
55- func ConvertConfigToProxyConfig (config * client.RemoteConnectionConfig ) * bean .ProxyConfig {
56- var proxyConfig * bean .ProxyConfig
57+ func ConvertConfigToProxyConfig (config * client.RemoteConnectionConfig ) * remoteConnection .ProxyConfig {
58+ var proxyConfig * remoteConnection .ProxyConfig
5759 if config .ProxyConfig != nil {
58- proxyConfig = & bean .ProxyConfig {
60+ proxyConfig = & remoteConnection .ProxyConfig {
5961 ProxyUrl : config .ProxyConfig .ProxyUrl ,
6062 }
6163 }
6264 return proxyConfig
6365}
6466
65- func ConvertConfigToSSHTunnelConfig (config * client.RemoteConnectionConfig ) * bean .SSHTunnelConfig {
66- var sshConfig * bean .SSHTunnelConfig
67+ func ConvertConfigToSSHTunnelConfig (config * client.RemoteConnectionConfig ) * remoteConnection .SSHTunnelConfig {
68+ var sshConfig * remoteConnection .SSHTunnelConfig
6769 if config .SSHTunnelConfig != nil {
68- sshConfig = & bean .SSHTunnelConfig {
70+ sshConfig = & remoteConnection .SSHTunnelConfig {
6971 SSHUsername : config .SSHTunnelConfig .SSHUsername ,
7072 SSHPassword : config .SSHTunnelConfig .SSHPassword ,
7173 SSHAuthKey : config .SSHTunnelConfig .SSHAuthKey ,
@@ -119,3 +121,46 @@ func GetAppDetailRequestFromGetResourceTreeRequest(req *client.GetResourceTreeRe
119121 CacheConfig : req .CacheConfig ,
120122 }
121123}
124+
125+ func NewRelease (helmRelease * helmRelease.Release ) * release.Release {
126+ if helmRelease == nil {
127+ return nil
128+ }
129+ return & release.Release {
130+ Name : helmRelease .Name ,
131+ Namespace : helmRelease .Namespace ,
132+ Info : NewReleaseInfo (helmRelease .Info ),
133+ Chart : NewChart (helmRelease .Chart ),
134+ }
135+ }
136+
137+ func NewReleaseInfo (helmReleaseInfo * helmRelease.Info ) * release.Info {
138+ if helmReleaseInfo == nil {
139+ return nil
140+ }
141+ return & release.Info {
142+ LastDeployed : helmReleaseInfo .LastDeployed ,
143+ Status : helmReleaseInfo .Status ,
144+ }
145+ }
146+
147+ func NewChart (helmChart * helmChart.Chart ) * release.Chart {
148+ if helmChart == nil {
149+ return nil
150+ }
151+ return & release.Chart {
152+ Metadata : NewChartMetadata (helmChart .Metadata ),
153+ }
154+ }
155+
156+ func NewChartMetadata (helmChartMetadata * helmChart.Metadata ) * release.Metadata {
157+ if helmChartMetadata == nil {
158+ return nil
159+ }
160+ return & release.Metadata {
161+ Name : helmChartMetadata .Name ,
162+ Version : helmChartMetadata .Version ,
163+ Icon : helmChartMetadata .Icon ,
164+ Home : helmChartMetadata .Home ,
165+ }
166+ }
0 commit comments