Skip to content

fix: issues in helm apps and git provide #6523

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 4 commits into from
Apr 21, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"golang.org/x/exp/maps"
"io"
"net/http"
"regexp"
"strconv"
"strings"

Expand Down Expand Up @@ -1479,10 +1480,12 @@ func (handler *PipelineConfigRestHandlerImpl) ValidateGitMaterialUrl(gitProvider
return false, err
}
if gitProvider.AuthMode == constants.AUTH_MODE_SSH {
hasPrefixResult := strings.HasPrefix(url, SSH_URL_PREFIX)
// this regex is used to generic ssh providers like gogs where format is <user>@<host>:<org>/<repo>.git
var scpLikeSSHRegex = regexp.MustCompile(`^[\w-]+@[\w.-]+:[\w./-]+\.git$`)
hasPrefixResult := strings.HasPrefix(url, SSH_URL_PREFIX) || scpLikeSSHRegex.MatchString(url)
return hasPrefixResult, nil
}
hasPrefixResult := strings.HasPrefix(url, HTTPS_URL_PREFIX)
hasPrefixResult := strings.HasPrefix(url, HTTPS_URL_PREFIX) || strings.HasPrefix(url, HTTP_URL_PREFIX)
return hasPrefixResult, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
repository2 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
"github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics"
"github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef"
"github.com/devtron-labs/devtron/pkg/pipeline/draftAwareConfigService"
validator2 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/validator"
"github.com/devtron-labs/devtron/pkg/pipeline/draftAwareConfigService"
security2 "github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning"
"github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning/read"
read3 "github.com/devtron-labs/devtron/pkg/team/read"
Expand Down Expand Up @@ -225,6 +225,7 @@ const (
devtron = "DEVTRON"
SSH_URL_PREFIX = "git@"
HTTPS_URL_PREFIX = "https://"
HTTP_URL_PREFIX = "http://"
argoWFLogIdentifier = "argo=true"
)

Expand Down
2 changes: 1 addition & 1 deletion env_gen.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion env_gen.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
## CI_RUNNER Related Environment Variables
| Key | Type | Default Value | Description | Example | Deprecated |
|-------|----------|-------------------|-------------------|-----------------------|------------------|
| AZURE_ACCOUNT_KEY | string | | If blob storage is bieng used of azure then pass the secret key to access the bucket | | false |
| AZURE_ACCOUNT_KEY | string | | If blob storage is being used of azure then pass the secret key to access the bucket | | false |
| AZURE_ACCOUNT_NAME | string | | Account name for azure blob storage | | false |
| AZURE_BLOB_CONTAINER_CI_CACHE | string | | Cache bucket name for azure blob storage | | false |
| AZURE_BLOB_CONTAINER_CI_LOG | string | | Log bucket for azure blob storage | | false |
Expand Down
1 change: 1 addition & 0 deletions pkg/appStore/bean/bean.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ type ChartRepoSearch struct {
ChartId int `json:"chartId"`
ChartName string `json:"chartName"`
ChartRepoId int `json:"chartRepoId"`
DockerArtifactStoreId string `json:"DockerArtifactStoreId"`
ChartRepoName string `json:"chartRepoName"`
Version string `json:"version"`
Deprecated bool `json:"deprecated"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (impl *AppStoreApplicationVersionRepositoryImpl) SearchAppStoreChartByName(
var chartRepos []*appStoreBean.ChartRepoSearch
//for chart repos, created (derived through index.yaml) column of app_store_application_version is used for finding latest version and for oci repo id is used (because created is null)
queryTemp := `select asv.id as app_store_application_version_id, asv.version, asv.deprecated, aps.id as chart_id,
aps.name as chart_name, chr.id as chart_repo_id, chr.name as chart_repo_name
aps.name as chart_name, chr.id as chart_repo_id, chr.name as chart_repo_name , das.id as docker_artifact_store_id
from app_store_application_version asv
inner join app_store aps on asv.app_store_id = aps.id
left join chart_repo chr on aps.chart_repo_id = chr.id
Expand Down
5 changes: 5 additions & 0 deletions pkg/appStore/discover/service/AppStoreService.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,10 @@ func (impl *AppStoreServiceImpl) SearchAppStoreChartByName(chartName string) ([]
if err != nil && !util.IsErrNoRows(err) {
return nil, err
}
for _, appStore := range appStoreApplications {
if len(appStore.ChartRepoName) == 0 && len(appStore.DockerArtifactStoreId) != 0 {
appStore.ChartRepoName = appStore.DockerArtifactStoreId
}
}
return appStoreApplications, nil
}
63 changes: 52 additions & 11 deletions pkg/appStore/installedApp/service/AppStoreDeploymentService.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient"
"github.com/devtron-labs/devtron/client/argocdServer"
"github.com/devtron-labs/devtron/internal/sql/repository/app"
repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/timelineStatus"
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
"github.com/devtron-labs/devtron/internal/util"
Expand Down Expand Up @@ -90,6 +91,7 @@ type AppStoreDeploymentServiceImpl struct {
deletePostProcessor DeletePostProcessor
appStoreValidator AppStoreValidator
deploymentConfigService common.DeploymentConfigService
OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository
}

func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger,
Expand All @@ -109,7 +111,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger,
gitOpsConfigReadService config.GitOpsConfigReadService, deletePostProcessor DeletePostProcessor,
appStoreValidator AppStoreValidator,
deploymentConfigService common.DeploymentConfigService,
) *AppStoreDeploymentServiceImpl {
OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository) *AppStoreDeploymentServiceImpl {

return &AppStoreDeploymentServiceImpl{
logger: logger,
Expand All @@ -130,6 +132,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger,
deletePostProcessor: deletePostProcessor,
appStoreValidator: appStoreValidator,
deploymentConfigService: deploymentConfigService,
OCIRegistryConfigRepository: OCIRegistryConfigRepository,
}
}

Expand Down Expand Up @@ -951,7 +954,49 @@ func (impl *AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(insta
}

// STEP-2 update APP with chart info
chartRepoInfo := appStoreAppVersion.AppStore.ChartRepo
//TODO: below code is duplicated
var IsOCIRepo bool
var registryCredential *bean4.RegistryCredential
var chartRepository *bean4.ChartRepository
dockerRegistryId := appStoreAppVersion.AppStore.DockerArtifactStoreId
if dockerRegistryId != "" {
ociRegistryConfigs, err := impl.OCIRegistryConfigRepository.FindByDockerRegistryId(dockerRegistryId)
if err != nil {
impl.logger.Errorw("error in fetching oci registry config", "err", err)
return nil, err
}
var ociRegistryConfig *repository2.OCIRegistryConfig
for _, config := range ociRegistryConfigs {
if config.RepositoryAction == repository2.STORAGE_ACTION_TYPE_PULL || config.RepositoryAction == repository2.STORAGE_ACTION_TYPE_PULL_AND_PUSH {
ociRegistryConfig = config
break
}
}
IsOCIRepo = true
registryCredential = &bean4.RegistryCredential{
RegistryUrl: appStoreAppVersion.AppStore.DockerArtifactStore.RegistryURL,
Username: appStoreAppVersion.AppStore.DockerArtifactStore.Username,
Password: appStoreAppVersion.AppStore.DockerArtifactStore.Password,
AwsRegion: appStoreAppVersion.AppStore.DockerArtifactStore.AWSRegion,
AccessKey: appStoreAppVersion.AppStore.DockerArtifactStore.AWSAccessKeyId,
SecretKey: appStoreAppVersion.AppStore.DockerArtifactStore.AWSSecretAccessKey,
RegistryType: string(appStoreAppVersion.AppStore.DockerArtifactStore.RegistryType),
RepoName: appStoreAppVersion.AppStore.Name,
IsPublic: ociRegistryConfig.IsPublic,
Connection: appStoreAppVersion.AppStore.DockerArtifactStore.Connection,
RegistryName: appStoreAppVersion.AppStore.DockerArtifactStore.Id,
RegistryCertificate: appStoreAppVersion.AppStore.DockerArtifactStore.Cert,
}
} else {
chartRepository = &bean4.ChartRepository{
Name: appStoreAppVersion.AppStore.ChartRepo.Name,
Url: appStoreAppVersion.AppStore.ChartRepo.Url,
Username: appStoreAppVersion.AppStore.ChartRepo.UserName,
Password: appStoreAppVersion.AppStore.ChartRepo.Password,
AllowInsecureConnection: appStoreAppVersion.AppStore.ChartRepo.AllowInsecureConnection,
}
}

updateReleaseRequest := &bean3.UpdateApplicationWithChartInfoRequestDto{
InstallReleaseRequest: &bean4.InstallReleaseRequest{
ValuesYaml: installAppVersionRequest.ValuesOverrideYaml,
Expand All @@ -961,18 +1006,14 @@ func (impl *AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(insta
ReleaseNamespace: installAppVersionRequest.Namespace,
ReleaseName: installAppVersionRequest.DisplayName,
},
RegistryCredential: registryCredential,
ChartRepository: chartRepository,
IsOCIRepo: IsOCIRepo,
InstallAppVersionHistoryId: 0,
},
SourceAppType: bean3.SOURCE_HELM_APP,
}
if chartRepoInfo != nil {
updateReleaseRequest.ChartRepository = &bean4.ChartRepository{
Name: chartRepoInfo.Name,
Url: chartRepoInfo.Url,
Username: chartRepoInfo.UserName,
Password: chartRepoInfo.Password,
AllowInsecureConnection: chartRepoInfo.AllowInsecureConnection,
}
}

res, err := impl.helmAppService.UpdateApplicationWithChartInfo(ctx, installAppVersionRequest.ClusterId, updateReleaseRequest)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE docker_artifact_store DROP COLUMN IF EXISTS credentials_type;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE docker_artifact_store ADD COLUMN IF NOT EXISTS credentials_type VARCHAR(124);
2 changes: 1 addition & 1 deletion wire_gen.go

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

Loading