Skip to content

feat: updated kubelink grpc client cfg #5426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 8 additions & 2 deletions api/helm-app/gRPC/applicationClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"github.com/caarlos0/env"
grpcUtil "github.com/devtron-labs/common-lib/utils/grpc"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"go.opentelemetry.io/otel"
"go.uber.org/zap"
Expand Down Expand Up @@ -55,12 +56,16 @@ type HelmAppClientImpl struct {
logger *zap.SugaredLogger
helmClientConfig *HelmClientConfig
applicationServiceClient ApplicationServiceClient
grpcConfig *grpcUtil.Configuration
}

func NewHelmAppClientImpl(logger *zap.SugaredLogger, helmClientConfig *HelmClientConfig) *HelmAppClientImpl {
func NewHelmAppClientImpl(logger *zap.SugaredLogger,
helmClientConfig *HelmClientConfig,
grpcConfig *grpcUtil.Configuration) *HelmAppClientImpl {
return &HelmAppClientImpl{
logger: logger,
helmClientConfig: helmClientConfig,
grpcConfig: grpcConfig,
}
}

Expand Down Expand Up @@ -94,7 +99,8 @@ func (impl *HelmAppClientImpl) getConnection() (*grpc.ClientConn, error) {
grpc.WithBlock(),
grpc.WithInsecure(),
grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(20*1024*1024),
grpc.MaxCallRecvMsgSize(impl.grpcConfig.KubelinkMaxSendMsgSize*1024*1024), // GRPC Request size
grpc.MaxCallSendMsgSize(impl.grpcConfig.KubelinkMaxRecvMsgSize*1024*1024), // GRPC Response size
),
grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`),
)
Expand Down
2 changes: 2 additions & 0 deletions api/helm-app/wire_helmApp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package client

import (
grpcUtil "github.com/devtron-labs/common-lib/utils/grpc"
"github.com/devtron-labs/devtron/api/helm-app/gRPC"
"github.com/devtron-labs/devtron/api/helm-app/service"
"github.com/devtron-labs/devtron/util/rbac"
"github.com/google/wire"
)

var HelmAppWireSet = wire.NewSet(
grpcUtil.GetConfiguration,
gRPC.NewHelmAppClientImpl,
wire.Bind(new(gRPC.HelmAppClient), new(*gRPC.HelmAppClientImpl)),
service.GetHelmReleaseConfig,
Expand Down
7 changes: 6 additions & 1 deletion cmd/external-app/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion env_gen.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
| K8s_TCP_KEEPALIVE | 30 | |
| K8s_TCP_TIMEOUT | 30 | |
| K8s_TLS_HANDSHAKE_TIMEOUT | 10 | |
| KUBELINK_GRPC_MAX_RECEIVE_MSG_SIZE | 20 | |
| KUBELINK_GRPC_MAX_SEND_MSG_SIZE | 4 | |
| LENS_TIMEOUT | 0 | |
| LENS_URL | http://lens-milandevtron-service:80 | |
| LIMIT_CI_CPU | 0.5 | |
Expand Down Expand Up @@ -245,8 +247,8 @@
| USE_BLOB_STORAGE_CONFIG_IN_CD_WORKFLOW | true | |
| USE_BLOB_STORAGE_CONFIG_IN_CI_WORKFLOW | true | |
| USE_BUILDX | false | |
| USE_CUSTOM_HTTP_TRANSPORT | false | |
| USE_CASBIN_V2 | false | |
| USE_CUSTOM_HTTP_TRANSPORT | false | |
| USE_EXTERNAL_NODE | false | |
| USE_GIT_CLI | false | |
| USE_IMAGE_TAG_FROM_GIT_PROVIDER_FOR_TAG_BASED_BUILD | false | |
Expand Down
8 changes: 6 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ require (
github.com/casbin/casbin v1.9.1
github.com/casbin/casbin/v2 v2.97.0
github.com/casbin/xorm-adapter v1.0.1-0.20190716004226-a317737a1007
github.com/casbin/xorm-adapter/v2 v2.5.1
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set v1.8.0
github.com/devtron-labs/authenticator v0.4.35-0.20240607135426-c86e868ecee1
github.com/devtron-labs/common-lib v0.0.21-0.20240628105542-603b4f777e00
github.com/devtron-labs/common-lib v0.0.21
github.com/devtron-labs/go-bitbucket v0.9.60-beta
github.com/devtron-labs/protos v0.0.3-0.20240527113333-08a3be5ec6c1
github.com/evanphx/json-patch v5.7.0+incompatible
Expand Down Expand Up @@ -82,6 +83,7 @@ require (
gopkg.in/go-playground/validator.v9 v9.30.0
gopkg.in/igm/sockjs-go.v3 v3.0.0
gopkg.in/yaml.v2 v2.4.0
helm.sh/helm/v3 v3.14.3
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
k8s.io/client-go v0.29.0
Expand Down Expand Up @@ -130,13 +132,13 @@ require (
github.com/bombsimon/logrusr/v2 v2.0.1 // indirect
github.com/bradleyfalzon/ghinstallation/v2 v2.5.0 // indirect
github.com/casbin/govaluate v1.1.0 // indirect
github.com/casbin/xorm-adapter/v2 v2.5.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/colinmarc/hdfs v1.1.4-0.20180805212432-9746310a4d31 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/denisenkom/go-mssqldb v0.9.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/doublerebel/bellows v0.0.0-20160303004610-f177d92a03d3 // indirect
Expand Down Expand Up @@ -201,6 +203,7 @@ require (
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-ieproxy v0.0.1 // indirect
github.com/mattn/go-sqlite3 v1.14.15 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
Expand Down Expand Up @@ -304,6 +307,7 @@ require (
replace (
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.7-v3refs
helm.sh/helm/v3 v3.14.3 => helm.sh/helm/v3 v3.10.0
k8s.io/api => k8s.io/api v0.26.11
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.26.11
k8s.io/apimachinery => k8s.io/apimachinery v0.26.11
Expand Down
16 changes: 10 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/o
cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E=
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
github.com/Azure/azure-pipeline-go v0.2.3 h1:7U9HBg1JFK3jHl5qmo4CTZKFTVgMwdFHMVtCdfBE21U=
github.com/Azure/azure-pipeline-go v0.2.3/go.mod h1:x841ezTBIMG6O3lAcl8ATHnsOPVl2bqk7S3ta6S6u4k=
Expand Down Expand Up @@ -191,13 +192,14 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4 h1:YcpmyvADGYw5LqMnHqSkyIELsHCGF6PkrmM31V8rF7o=
github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM=
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/denisenkom/go-mssqldb v0.9.0 h1:RSohk2RsiZqLZ0zCjtfn3S4Gp4exhpBWHyQ7D0yGjAk=
github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/devtron-labs/authenticator v0.4.35-0.20240607135426-c86e868ecee1 h1:qdkpTAo2Kr0ZicZIVXfNwsGSshpc9OB9j9RzmKYdIwY=
github.com/devtron-labs/authenticator v0.4.35-0.20240607135426-c86e868ecee1/go.mod h1:IkKPPEfgLCMR29he5yv2OCC6iM2R7K5/0AA3k8b9XNc=
github.com/devtron-labs/common-lib v0.0.21-0.20240628105542-603b4f777e00 h1:xSZulEz0PaTA7tL4Es/uNFUmgjD6oAv8gxJV49GPWHk=
github.com/devtron-labs/common-lib v0.0.21-0.20240628105542-603b4f777e00/go.mod h1:UZGPt1ep9Tnd9Ak2sibGSiLr7p3ijO2/JLT+h+pqBuU=
github.com/devtron-labs/common-lib v0.0.21 h1:vbydiTCdZDtVTPnbB3frJvX/HM0oDe1wA2Schjn6xgw=
github.com/devtron-labs/common-lib v0.0.21/go.mod h1:UZGPt1ep9Tnd9Ak2sibGSiLr7p3ijO2/JLT+h+pqBuU=
github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU=
github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y=
github.com/devtron-labs/protos v0.0.3-0.20240527113333-08a3be5ec6c1 h1:R6qVeFaayqstBSu4w+ipWQqJyMKDqBVV3a11qoA2IaM=
Expand Down Expand Up @@ -317,7 +319,6 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
github.com/go-xorm/xorm v0.7.9 h1:LZze6n1UvRmM5gpL9/U9Gucwqo6aWlFVlfcHKH10qA0=
github.com/go-xorm/xorm v0.7.9/go.mod h1:XiVxrMMIhFkwSkh96BW7PACl7UhLtx2iJIHMdmjh5sQ=
Expand All @@ -331,6 +332,7 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo=
Expand Down Expand Up @@ -593,9 +595,10 @@ github.com/mattn/go-ieproxy v0.0.1 h1:qiyop7gCflfhwCzGyeT0gro3sF9AIg9HU98JORTkqf
github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/gNWuh88E=
github.com/mattn/go-isatty v0.0.0-20160806122752-66b8e73f3f5c/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
Expand Down Expand Up @@ -1234,6 +1237,8 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
helm.sh/helm/v3 v3.10.0 h1:y/MYONZ/bsld9kHwqgBX2uPggnUr5hahpjwt9/jrHlI=
helm.sh/helm/v3 v3.10.0/go.mod h1:paPw0hO5KVfrCMbi1M8+P8xdfBri3IiJiVKATZsFR94=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down Expand Up @@ -1303,7 +1308,6 @@ sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
upper.io/db.v3 v3.8.0+incompatible h1:XNeEO2vQRVqq70M98ghzq6M30F5Bzo+99ess5v+eVYw=
upper.io/db.v3 v3.8.0+incompatible/go.mod h1:FgTdD24eBjJAbPKsQSiHUNgXjOR4Lub3u1UMHSIh82Y=
xorm.io/builder v0.3.6 h1:ha28mQ2M+TFx96Hxo+iq6tQgnkC9IZkM6D8w9sKHHF8=
xorm.io/builder v0.3.6/go.mod h1:LEFAPISnRzG+zxaxj2vPicRwz67BdhFreKg8yv8/TgU=
xorm.io/builder v0.3.7 h1:2pETdKRK+2QG4mLX4oODHEhn5Z8j1m8sXa7jfu+/SZI=
xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
Expand Down
68 changes: 33 additions & 35 deletions internal/util/ChartTemplateService.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@ package util
import (
"compress/gzip"
"context"
"encoding/json"
"fmt"
dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
dirCopy "github.com/otiai10/copy"
"go.opentelemetry.io/otel"
"go.uber.org/zap"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/chartutil"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
"sigs.k8s.io/yaml"
"strconv"
"strings"
"time"

dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
dirCopy "github.com/otiai10/copy"
"go.opentelemetry.io/otel"
"go.uber.org/zap"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/proto/hapi/chart"
"sigs.k8s.io/yaml"
)

const (
Expand Down Expand Up @@ -101,13 +102,7 @@ func (impl ChartTemplateServiceImpl) GetChartVersion(location string) (string, e
if _, err := os.Stat(chartYaml); os.IsNotExist(err) {
return "", fmt.Errorf("Chart.yaml file not present in the directory %q", location)
}
//chartYaml = filepath.Join(chartYaml,filepath.Clean(chartYaml))
chartYamlContent, err := ioutil.ReadFile(filepath.Clean(chartYaml))
if err != nil {
return "", fmt.Errorf("cannot read Chart.Yaml in directory %q", location)
}

chartContent, err := chartutil.UnmarshalChartfile(chartYamlContent)
chartContent, err := chartutil.LoadChartfile(filepath.Clean(chartYaml))
if err != nil {
return "", fmt.Errorf("cannot read Chart.Yaml in directory %q", location)
}
Expand All @@ -116,7 +111,7 @@ func (impl ChartTemplateServiceImpl) GetChartVersion(location string) (string, e
}

func (impl ChartTemplateServiceImpl) FetchValuesFromReferenceChart(chartMetaData *chart.Metadata, refChartLocation string, templateName string, userId int32, pipelineStrategyPath string) (*ChartValues, error) {
chartMetaData.ApiVersion = "v1" // ensure always v1
chartMetaData.APIVersion = "v1" // ensure always v1
dir := impl.GetDir()
chartDir := filepath.Join(CHART_WORKING_DIR_PATH, dir)
impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", chartDir)
Expand Down Expand Up @@ -155,7 +150,9 @@ func (impl ChartTemplateServiceImpl) FetchValuesFromReferenceChart(chartMetaData

// TODO: convert BuildChart and BuildChartProxyForHelmApps into one function
func (impl ChartTemplateServiceImpl) BuildChart(ctx context.Context, chartMetaData *chart.Metadata, referenceTemplatePath string) (string, error) {
chartMetaData.ApiVersion = "v1" // ensure always v1
if chartMetaData.APIVersion == "" {
chartMetaData.APIVersion = "v1" // ensure always v1
}
dir := impl.GetDir()
tempReferenceTemplateDir := filepath.Join(CHART_WORKING_DIR_PATH, dir)
impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", tempReferenceTemplateDir)
Expand Down Expand Up @@ -183,7 +180,7 @@ func (impl ChartTemplateServiceImpl) BuildChart(ctx context.Context, chartMetaDa
func (impl ChartTemplateServiceImpl) BuildChartProxyForHelmApps(chartCreateRequest *ChartCreateRequest) (*ChartCreateResponse, error) {
chartCreateResponse := &ChartCreateResponse{}
chartMetaData := chartCreateRequest.ChartMetaData
chartMetaData.ApiVersion = "v2" // ensure always v2
chartMetaData.APIVersion = "v2" // ensure always v2
dir := impl.GetDir()
chartDir := filepath.Join(CHART_WORKING_DIR_PATH, dir)
impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", chartDir)
Expand Down Expand Up @@ -292,32 +289,34 @@ func (impl ChartTemplateServiceImpl) PackageChart(tempReferenceTemplateDir strin
impl.logger.Errorw("invalid chart at ", "dir", tempReferenceTemplateDir)
return nil, "", fmt.Errorf("invalid base chart")
}

b, err := yaml.Marshal(chartMetaData)
chart, err := loader.LoadDir(tempReferenceTemplateDir)
if err != nil {
impl.logger.Errorw("error in marshaling chartMetadata", "err", err)
impl.logger.Errorw("error in loading template chart", "chartPath", tempReferenceTemplateDir, "err", err)
return nil, "", err
}
err = ioutil.WriteFile(filepath.Join(tempReferenceTemplateDir, "Chart.yaml"), b, 0600)
if err != nil {
impl.logger.Errorw("err in writing Chart.yaml", "err", err)
return nil, "", err
if len(chartMetaData.Name) > 0 {
chart.Metadata.Name = chartMetaData.Name
}
chart, err := chartutil.LoadDir(tempReferenceTemplateDir)
if err != nil {
impl.logger.Errorw("error in loading chart dir", "err", err, "dir", tempReferenceTemplateDir)
return nil, "", err
if len(chartMetaData.Version) > 0 {
chart.Metadata.Version = chartMetaData.Version
}
if len(chartMetaData.APIVersion) > 0 {
chart.Metadata.APIVersion = chartMetaData.APIVersion
}

archivePath, err := chartutil.Save(chart, tempReferenceTemplateDir)
if err != nil {
impl.logger.Errorw("error in saving", "err", err, "dir", tempReferenceTemplateDir)
return nil, "", err
}
impl.logger.Debugw("chart archive path", "path", archivePath)
var valuesYaml string
byteValues, err := json.Marshal(chart.Values)
if err != nil {
impl.logger.Errorw("error in json Marshal values", "values", chart.Values, "err", err)
return nil, "", err
}
if chart.Values != nil {
valuesYaml = chart.Values.Raw
valuesYaml = string(byteValues)
} else {
impl.logger.Warnw("values.yaml not found in helm chart", "dir", tempReferenceTemplateDir)
}
Expand All @@ -339,7 +338,7 @@ func (impl ChartTemplateServiceImpl) GetDir() string {

// GetByteArrayRefChart this method will be used for getting byte array from reference chart to store in db
func (impl ChartTemplateServiceImpl) GetByteArrayRefChart(chartMetaData *chart.Metadata, referenceTemplatePath string) ([]byte, error) {
chartMetaData.ApiVersion = "v1" // ensure always v1
chartMetaData.APIVersion = "v1" // ensure always v1
dir := impl.GetDir()
tempReferenceTemplateDir := filepath.Join(CHART_WORKING_DIR_PATH, dir)
impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", tempReferenceTemplateDir)
Expand Down Expand Up @@ -377,8 +376,7 @@ func (impl ChartTemplateServiceImpl) GetByteArrayRefChart(chartMetaData *chart.M
func (impl ChartTemplateServiceImpl) LoadChartInBytes(ChartPath string, deleteChart bool) ([]byte, error) {

var chartBytesArr []byte
//this function is removed in latest helm release and is replaced by Loader in loader package
chart, err := chartutil.LoadDir(ChartPath)
chart, err := loader.LoadDir(ChartPath)
if err != nil {
impl.logger.Errorw("error in loading chart dir", "err", err, "dir")
return chartBytesArr, err
Expand All @@ -398,7 +396,7 @@ func (impl ChartTemplateServiceImpl) LoadChartInBytes(ChartPath string, deleteCh

func (impl ChartTemplateServiceImpl) LoadChartFromDir(dir string) (*chart.Chart, error) {
//this function is removed in latest helm release and is replaced by Loader in loader package
chart, err := chartutil.LoadDir(dir)
chart, err := loader.LoadDir(dir)
if err != nil {
impl.logger.Errorw("error in loading chart dir", "err", err, "dir")
return chart, err
Expand Down
Loading
Loading