Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions api/helm-app/HelmAppService.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,12 +693,7 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart
}
return nil, clusterNotFoundErr
}
discoveryClient, err := impl.K8sUtil.GetK8sDiscoveryClientInCluster()
if err != nil {
impl.logger.Errorw("eexception caught in getting discoveryClient", "err", err)
return nil, err
}
k8sServerVersion, err := discoveryClient.ServerVersion()
k8sServerVersion, err := impl.K8sUtil.GetKubeVersion()
if err != nil {
impl.logger.Errorw("exception caught in getting k8sServerVersion", "err", err)
return nil, err
Expand Down
14 changes: 14 additions & 0 deletions internal/util/K8sUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/version"
"net/http"
"os/user"
"path/filepath"
Expand Down Expand Up @@ -748,3 +749,16 @@ func OverrideK8sHttpClientWithTracer(restConfig *rest.Config) (*http.Client, err
httpClientFor.Transport = otelhttp.NewTransport(httpClientFor.Transport)
return httpClientFor, nil
}
func (impl K8sUtil) GetKubeVersion() (*version.Info, error) {
discoveryClient, err := impl.GetK8sDiscoveryClientInCluster()
if err != nil {
impl.logger.Errorw("eexception caught in getting discoveryClient", "err", err)
return nil, err
}
k8sServerVersion, err := discoveryClient.ServerVersion()
if err != nil {
impl.logger.Errorw("exception caught in getting k8sServerVersion", "err", err)
return nil, err
}
return k8sServerVersion, err
}
10 changes: 9 additions & 1 deletion pkg/appStore/deployment/service/InstalledAppService.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ type InstalledAppServiceImpl struct {
helmAppService client.HelmAppService
attributesRepository repository3.AttributesRepository
appStatusService appStatus.AppStatusService
K8sUtil *util.K8sUtil
}

func NewInstalledAppServiceImpl(logger *zap.SugaredLogger,
Expand All @@ -134,7 +135,7 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger,
installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository,
argoUserService argo.ArgoUserService, helmAppClient client.HelmAppClient, helmAppService client.HelmAppService,
attributesRepository repository3.AttributesRepository,
appStatusService appStatus.AppStatusService) (*InstalledAppServiceImpl, error) {
appStatusService appStatus.AppStatusService, K8sUtil *util.K8sUtil) (*InstalledAppServiceImpl, error) {
impl := &InstalledAppServiceImpl{
logger: logger,
installedAppRepository: installedAppRepository,
Expand Down Expand Up @@ -164,6 +165,7 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger,
helmAppService: helmAppService,
attributesRepository: attributesRepository,
appStatusService: appStatusService,
K8sUtil: K8sUtil,
}
err := impl.Subscribe()
if err != nil {
Expand Down Expand Up @@ -796,11 +798,17 @@ func (impl *InstalledAppServiceImpl) FindNotesForArgoApplication(installedAppId,
impl.logger.Errorw("error fetching app store app version in installed app service", "err", err)
return notes, appName, err
}
k8sServerVersion, err := impl.K8sUtil.GetKubeVersion()
if err != nil {
impl.logger.Errorw("exception caught in getting k8sServerVersion", "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create one function in k8s util and use that for this version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return notes, appName, err
}

installReleaseRequest := &client.InstallReleaseRequest{
ChartName: appStoreAppVersion.Name,
ChartVersion: appStoreAppVersion.Version,
ValuesYaml: installedAppVerison.ValuesYaml,
K8SVersion: k8sServerVersion.String(),
ChartRepository: &client.ChartRepository{
Name: appStoreAppVersion.AppStore.ChartRepo.Name,
Url: appStoreAppVersion.AppStore.ChartRepo.Url,
Expand Down