-
Notifications
You must be signed in to change notification settings - Fork 569
Expand file tree
/
Copy pathinfraConfigService_ent.go
More file actions
85 lines (73 loc) · 3.12 KB
/
infraConfigService_ent.go
File metadata and controls
85 lines (73 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* Copyright (c) 2024. Devtron Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package service
import (
v1 "github.com/devtron-labs/devtron/pkg/infraConfig/bean/v1"
"github.com/devtron-labs/devtron/pkg/infraConfig/repository"
"github.com/devtron-labs/devtron/pkg/resourceQualifiers"
"github.com/go-pg/pg"
"github.com/pkg/errors"
)
type InfraConfigServiceEnt interface {
}
func (impl *InfraConfigServiceImpl) isMigrationRequired() (bool, error) {
return true, nil
}
func (impl *InfraConfigServiceImpl) markMigrationComplete(tx *pg.Tx) error {
return nil
}
func (impl *InfraConfigServiceImpl) resolveScopeVariablesForAppliedProfile(scope resourceQualifiers.Scope, appliedProfileConfig *v1.ProfileBeanDto) (*v1.ProfileBeanDto, map[string]map[string]string, error) {
return appliedProfileConfig, nil, nil
}
func (impl *InfraConfigServiceImpl) updateBuildxDriverTypeInExistingProfiles(tx *pg.Tx) error {
return nil
}
func (impl *InfraConfigServiceImpl) getCreatableK8sDriverConfigs(profileId int, envConfigs []*repository.InfraProfileConfigurationEntity) ([]*repository.InfraProfileConfigurationEntity, error) {
return make([]*repository.InfraProfileConfigurationEntity, 0), nil
}
func (impl *InfraConfigServiceImpl) getDefaultBuildxDriverType() v1.BuildxDriver {
return v1.BuildxDockerContainerDriver
}
func (impl *InfraConfigServiceImpl) getInfraProfileIdsByScope(scope *v1.Scope) ([]int, error) {
// First check if there's a pipeline-level infra profile
if scope.PipelineId > 0 {
pipelineInfraProfileId, err := impl.getPipelineInfraProfileId(scope.PipelineId)
if err != nil {
impl.logger.Errorw("error in fetching pipeline-level infra profile", "pipelineId", scope.PipelineId, "error", err)
return make([]int, 0), err
}
if pipelineInfraProfileId != nil {
impl.logger.Debugw("found pipeline-level infra profile", "pipelineId", scope.PipelineId, "infraProfileId", *pipelineInfraProfileId)
return []int{*pipelineInfraProfileId}, nil
}
}
// For OSS, user can't create infra profiles so no need to fetch infra profiles
// Falls back to global profile
return make([]int, 0), nil
}
func (impl *InfraConfigServiceImpl) getPipelineInfraProfileId(pipelineId int) (*int, error) {
// Query the ci_pipeline table directly for the infra_profile_id
var infraProfileId *int
query := `SELECT infra_profile_id FROM ci_pipeline WHERE id = ? AND deleted = false`
_, err := impl.infraProfileRepo.GetDbConnection().Query(&infraProfileId, query, pipelineId)
if err != nil {
if errors.Is(err, pg.ErrNoRows) {
return nil, nil // Pipeline not found, fall back to app-level profile
}
return nil, err
}
return infraProfileId, nil
}