@@ -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 ) {
@@ -37,36 +39,36 @@ func NewRegistryConfig(credential *client.RegistryCredential) (*registry.Configu
3739
3840 connectionConfig := credential .RemoteConnectionConfig
3941 if connectionConfig != nil {
40- registryConfig .RemoteConnectionConfig = & bean .RemoteConnectionConfigBean {}
42+ registryConfig .RemoteConnectionConfig = & remoteConnection .RemoteConnectionConfigBean {}
4143 switch connectionConfig .RemoteConnectionMethod {
4244 case client .RemoteConnectionMethod_DIRECT :
43- registryConfig .RemoteConnectionConfig .ConnectionMethod = bean .RemoteConnectionMethodDirect
45+ registryConfig .RemoteConnectionConfig .ConnectionMethod = remoteConnection .RemoteConnectionMethodDirect
4446 case client .RemoteConnectionMethod_PROXY :
45- registryConfig .RemoteConnectionConfig .ConnectionMethod = bean .RemoteConnectionMethodProxy
47+ registryConfig .RemoteConnectionConfig .ConnectionMethod = remoteConnection .RemoteConnectionMethodProxy
4648 registryConfig .RemoteConnectionConfig .ProxyConfig = ConvertConfigToProxyConfig (connectionConfig )
4749 case client .RemoteConnectionMethod_SSH :
48- registryConfig .RemoteConnectionConfig .ConnectionMethod = bean .RemoteConnectionMethodSSH
50+ registryConfig .RemoteConnectionConfig .ConnectionMethod = remoteConnection .RemoteConnectionMethodSSH
4951 registryConfig .RemoteConnectionConfig .SSHTunnelConfig = ConvertConfigToSSHTunnelConfig (connectionConfig )
5052 }
5153 }
5254 }
5355 return registryConfig , nil
5456}
5557
56- func ConvertConfigToProxyConfig (config * client.RemoteConnectionConfig ) * bean .ProxyConfig {
57- var proxyConfig * bean .ProxyConfig
58+ func ConvertConfigToProxyConfig (config * client.RemoteConnectionConfig ) * remoteConnection .ProxyConfig {
59+ var proxyConfig * remoteConnection .ProxyConfig
5860 if config .ProxyConfig != nil {
59- proxyConfig = & bean .ProxyConfig {
61+ proxyConfig = & remoteConnection .ProxyConfig {
6062 ProxyUrl : config .ProxyConfig .ProxyUrl ,
6163 }
6264 }
6365 return proxyConfig
6466}
6567
66- func ConvertConfigToSSHTunnelConfig (config * client.RemoteConnectionConfig ) * bean .SSHTunnelConfig {
67- var sshConfig * bean .SSHTunnelConfig
68+ func ConvertConfigToSSHTunnelConfig (config * client.RemoteConnectionConfig ) * remoteConnection .SSHTunnelConfig {
69+ var sshConfig * remoteConnection .SSHTunnelConfig
6870 if config .SSHTunnelConfig != nil {
69- sshConfig = & bean .SSHTunnelConfig {
71+ sshConfig = & remoteConnection .SSHTunnelConfig {
7072 SSHUsername : config .SSHTunnelConfig .SSHUsername ,
7173 SSHPassword : config .SSHTunnelConfig .SSHPassword ,
7274 SSHAuthKey : config .SSHTunnelConfig .SSHAuthKey ,
@@ -120,3 +122,46 @@ func GetAppDetailRequestFromGetResourceTreeRequest(req *client.GetResourceTreeRe
120122 CacheConfig : req .CacheConfig ,
121123 }
122124}
125+
126+ func NewRelease (helmRelease * helmRelease.Release ) * release.Release {
127+ if helmRelease == nil {
128+ return nil
129+ }
130+ return & release.Release {
131+ Name : helmRelease .Name ,
132+ Namespace : helmRelease .Namespace ,
133+ Info : NewReleaseInfo (helmRelease .Info ),
134+ Chart : NewChart (helmRelease .Chart ),
135+ }
136+ }
137+
138+ func NewReleaseInfo (helmReleaseInfo * helmRelease.Info ) * release.Info {
139+ if helmReleaseInfo == nil {
140+ return nil
141+ }
142+ return & release.Info {
143+ LastDeployed : helmReleaseInfo .LastDeployed ,
144+ Status : helmReleaseInfo .Status ,
145+ }
146+ }
147+
148+ func NewChart (helmChart * helmChart.Chart ) * release.Chart {
149+ if helmChart == nil {
150+ return nil
151+ }
152+ return & release.Chart {
153+ Metadata : NewChartMetadata (helmChart .Metadata ),
154+ }
155+ }
156+
157+ func NewChartMetadata (helmChartMetadata * helmChart.Metadata ) * release.Metadata {
158+ if helmChartMetadata == nil {
159+ return nil
160+ }
161+ return & release.Metadata {
162+ Name : helmChartMetadata .Name ,
163+ Version : helmChartMetadata .Version ,
164+ Icon : helmChartMetadata .Icon ,
165+ Home : helmChartMetadata .Home ,
166+ }
167+ }
0 commit comments