Skip to content
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

fix: not able to add env in global configuration #4330

Merged
merged 1 commit into from
Dec 1, 2023
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
2 changes: 1 addition & 1 deletion pkg/cluster/EnvironmentService.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (impl EnvironmentServiceImpl) Create(mappings *EnvironmentBean, userId int3

identifier := clusterBean.ClusterName + "__" + mappings.Namespace

model, err := impl.environmentRepository.FindByEnvNameOrIdentifierOrNamespace(mappings.Environment, identifier, mappings.Namespace)
model, err := impl.environmentRepository.FindByEnvNameOrIdentifierOrNamespace(mappings.ClusterId, mappings.Environment, identifier, mappings.Namespace)
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("error in finding environment for update", "err", err)
return mappings, err
Expand Down
9 changes: 5 additions & 4 deletions pkg/cluster/repository/EnvironmentRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type EnvironmentRepository interface {
FindByName(name string) (*Environment, error)
FindByIdentifier(identifier string) (*Environment, error)
FindByNameOrIdentifier(name string, identifier string) (*Environment, error)
FindByEnvNameOrIdentifierOrNamespace(envName string, identifier string, namespace string) (*Environment, error)
FindByEnvNameOrIdentifierOrNamespace(clusterId int, envName string, identifier string, namespace string) (*Environment, error)
FindByClusterId(clusterId int) ([]*Environment, error)
FindByIds(ids []*int) ([]*Environment, error)
FindByNamespaceAndClusterName(namespaces string, clusterName string) (*Environment, error)
Expand Down Expand Up @@ -183,14 +183,15 @@ func (repositoryImpl EnvironmentRepositoryImpl) FindByNameOrIdentifier(name stri
return environment, err
}

func (repositoryImpl EnvironmentRepositoryImpl) FindByEnvNameOrIdentifierOrNamespace(envName string, identifier string, namespace string) (*Environment, error) {
func (repositoryImpl EnvironmentRepositoryImpl) FindByEnvNameOrIdentifierOrNamespace(clusterId int, envName string, identifier string, namespace string) (*Environment, error) {
environment := &Environment{}
err := repositoryImpl.dbConnection.
Model(environment).
Where("active = ?", true).
WhereGroup(func(query *orm.Query) (*orm.Query, error) {
query = query.Where("environment_identifier = ?", identifier).WhereOr("environment_name = ?", envName).
WhereOr("namespace = ?", namespace)
query = query.Where("environment_identifier = ?", identifier).
WhereOr("environment_name = ?", envName).
WhereOr("cluster_id = ? AND namespace = ?", clusterId, namespace)
return query, nil
}).
Limit(1).
Expand Down
Loading