mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 10:28:00 +00:00
remove old ValidateEnvironmentName check
This commit is contained in:
@@ -220,11 +220,11 @@ func GetAllEnvironmentVariables(params models.GetAllSecretsParameters) ([]models
|
|||||||
workspaceFile.WorkspaceId = params.WorkspaceId
|
workspaceFile.WorkspaceId = params.WorkspaceId
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify environment
|
// // Verify environment
|
||||||
err = ValidateEnvironmentName(params.Environment, workspaceFile.WorkspaceId, loggedInUserDetails.UserCredentials)
|
// err = ValidateEnvironmentName(params.Environment, workspaceFile.WorkspaceId, loggedInUserDetails.UserCredentials)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, fmt.Errorf("unable to validate environment name because [err=%s]", err)
|
// return nil, fmt.Errorf("unable to validate environment name because [err=%s]", err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
secretsToReturn, errorToReturn = GetPlainTextSecretsViaJTW(loggedInUserDetails.UserCredentials.JTWToken, loggedInUserDetails.UserCredentials.PrivateKey, workspaceFile.WorkspaceId,
|
secretsToReturn, errorToReturn = GetPlainTextSecretsViaJTW(loggedInUserDetails.UserCredentials.JTWToken, loggedInUserDetails.UserCredentials.PrivateKey, workspaceFile.WorkspaceId,
|
||||||
params.Environment, params.TagSlugs, params.SecretsPath, params.IncludeImport)
|
params.Environment, params.TagSlugs, params.SecretsPath, params.IncludeImport)
|
||||||
@@ -253,32 +253,32 @@ func GetAllEnvironmentVariables(params models.GetAllSecretsParameters) ([]models
|
|||||||
return secretsToReturn, errorToReturn
|
return secretsToReturn, errorToReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateEnvironmentName(environmentName string, workspaceId string, userLoggedInDetails models.UserCredentials) error {
|
// func ValidateEnvironmentName(environmentName string, workspaceId string, userLoggedInDetails models.UserCredentials) error {
|
||||||
httpClient := resty.New()
|
// httpClient := resty.New()
|
||||||
httpClient.SetAuthToken(userLoggedInDetails.JTWToken).
|
// httpClient.SetAuthToken(userLoggedInDetails.JTWToken).
|
||||||
SetHeader("Accept", "application/json")
|
// SetHeader("Accept", "application/json")
|
||||||
|
|
||||||
response, err := api.CallGetAccessibleEnvironments(httpClient, api.GetAccessibleEnvironmentsRequest{WorkspaceId: workspaceId})
|
// response, err := api.CallGetAccessibleEnvironments(httpClient, api.GetAccessibleEnvironmentsRequest{WorkspaceId: workspaceId})
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
listOfEnvSlugs := []string{}
|
// listOfEnvSlugs := []string{}
|
||||||
mapOfEnvSlugs := make(map[string]interface{})
|
// mapOfEnvSlugs := make(map[string]interface{})
|
||||||
|
|
||||||
for _, environment := range response.AccessibleEnvironments {
|
// for _, environment := range response.AccessibleEnvironments {
|
||||||
listOfEnvSlugs = append(listOfEnvSlugs, environment.Slug)
|
// listOfEnvSlugs = append(listOfEnvSlugs, environment.Slug)
|
||||||
mapOfEnvSlugs[environment.Slug] = environment
|
// mapOfEnvSlugs[environment.Slug] = environment
|
||||||
}
|
// }
|
||||||
|
|
||||||
_, exists := mapOfEnvSlugs[environmentName]
|
// _, exists := mapOfEnvSlugs[environmentName]
|
||||||
if !exists {
|
// if !exists {
|
||||||
HandleError(fmt.Errorf("the environment [%s] does not exist in project with [id=%s]. Only [%s] are available", environmentName, workspaceId, strings.Join(listOfEnvSlugs, ",")))
|
// HandleError(fmt.Errorf("the environment [%s] does not exist in project with [id=%s]. Only [%s] are available", environmentName, workspaceId, strings.Join(listOfEnvSlugs, ",")))
|
||||||
}
|
// }
|
||||||
|
|
||||||
return nil
|
// return nil
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
func getExpandedEnvVariable(secrets []models.SingleEnvironmentVariable, variableWeAreLookingFor string, hashMapOfCompleteVariables map[string]string, hashMapOfSelfRefs map[string]string) string {
|
func getExpandedEnvVariable(secrets []models.SingleEnvironmentVariable, variableWeAreLookingFor string, hashMapOfCompleteVariables map[string]string, hashMapOfSelfRefs map[string]string) string {
|
||||||
if value, found := hashMapOfCompleteVariables[variableWeAreLookingFor]; found {
|
if value, found := hashMapOfCompleteVariables[variableWeAreLookingFor]; found {
|
||||||
|
|||||||
Reference in New Issue
Block a user