Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Revert "feat: confirm environment exists when running `run` command"
Maidul Islam18c32d872ce8
diff --git a/.gitignore b/.gitignoreindex f21c85c41e..f2a23324b8 100644--- a/.gitignore+++ b/.gitignore@@ -1,5 +1,3 @@-.direnv/-# backendnode_modules.env@@ -28,6 +26,8 @@ node_modules/.pnp.pnp.js+.env+# testingcoveragereports@@ -63,12 +63,10 @@ yarn-error.log*# Editor specific.vscode/*-**/.idea/*+.idea/*frontend-build-# cli-.go/*.tgzcli/infisical-mergecli/test/infisical-mergediff --git a/cli/packages/api/model.go b/cli/packages/api/model.goindex 1eb936f245..72dbbc97b5 100644--- a/cli/packages/api/model.go+++ b/cli/packages/api/model.go@@ -2,12 +2,6 @@ package apiimport "time"-type Environment struct {- Name string `json:"name"`- Slug string `json:"slug"`- ID string `json:"id"`-}-// Stores info for login onetype LoginOneRequest struct {Email string `json:"email"`@@ -20,6 +14,7 @@ type LoginOneResponse struct {}// Stores info for login two+type LoginTwoRequest struct {Email string `json:"email"`ClientProof string `json:"clientProof"`@@ -173,10 +168,9 @@ type Secret struct {}type Project struct {- ID string `json:"id"`- Name string `json:"name"`- Slug string `json:"slug"`- Environments []Environment `json:"environments"`+ ID string `json:"id"`+ Name string `json:"name"`+ Slug string `json:"slug"`}type RawSecret struct {diff --git a/cli/packages/cmd/run.go b/cli/packages/cmd/run.goindex 388a4861de..7f11a3f95e 100644--- a/cli/packages/cmd/run.go+++ b/cli/packages/cmd/run.go@@ -15,9 +15,6 @@ import ("syscall""time"- "github.com/Infisical/infisical-merge/packages/api"- "github.com/go-resty/resty/v2"-"github.com/Infisical/infisical-merge/packages/models""github.com/Infisical/infisical-merge/packages/util""github.com/fatih/color"@@ -62,11 +59,11 @@ var runCmd = &cobra.Command{return nil},Run: func(cmd *cobra.Command, args []string) {- environmentSlug, _ := cmd.Flags().GetString("env")+ environmentName, _ := cmd.Flags().GetString("env")if !cmd.Flags().Changed("env") {environmentFromWorkspace := util.GetEnvFromWorkspaceFile()if environmentFromWorkspace != "" {- environmentSlug = environmentFromWorkspace+ environmentName = environmentFromWorkspace}}@@ -139,20 +136,8 @@ var runCmd = &cobra.Command{util.HandleError(err, "Unable to parse flag")}- log.Debug().Msgf("Confirming selected environment is valid: %s", environmentSlug)-- hasEnvironment, err := confirmProjectHasEnvironment(environmentSlug, projectId, token)- if err != nil {- util.HandleError(err, "Could not confirm project has environment")- }- if !hasEnvironment {- util.HandleError(fmt.Errorf("project does not have environment '%s'", environmentSlug))- }-- log.Debug().Msgf("Project '%s' has environment '%s'", projectId, environmentSlug)-request := models.GetAllSecretsParameters{- Environment: environmentSlug,+ Environment: environmentName,WorkspaceId: projectId,TagSlugs: tagSlugs,SecretsPath: secretsPath,@@ -323,6 +308,7 @@ func waitForExitCommand(cmd *exec.Cmd) (int, error) {}func executeCommandWithWatchMode(commandFlag string, args []string, watchModeInterval int, request models.GetAllSecretsParameters, projectConfigDir string, secretOverriding bool, token *models.TokenDetails) {+var cmd *exec.Cmdvar err errorvar lastSecretsFetch time.Time@@ -453,53 +439,8 @@ func executeCommandWithWatchMode(commandFlag string, args []string, watchModeInt}}-func confirmProjectHasEnvironment(environmentSlug, projectId string, token *models.TokenDetails) (bool, error) {- var accessToken string-- if token != nil && (token.Type == util.SERVICE_TOKEN_IDENTIFIER || token.Type == util.UNIVERSAL_AUTH_TOKEN_IDENTIFIER) {- accessToken = token.Token- } else {- util.RequireLogin()- util.RequireLocalWorkspaceFile()-- loggedInUserDetails, err := util.GetCurrentLoggedInUserDetails(true)- if err != nil {- util.HandleError(err, "Unable to authenticate")- }-- if loggedInUserDetails.LoginExpired {- util.PrintErrorMessageAndExit("Your login session has expired, please run [infisical login] and try again")- }- accessToken = loggedInUserDetails.UserCredentials.JTWToken- }-- if projectId == "" {- workspaceFile, err := util.GetWorkSpaceFromFile()- if err != nil {- util.HandleError(err, "Unable to get local project details")- }-- projectId = workspaceFile.WorkspaceId- }-- httpClient := resty.New()- httpClient.SetAuthToken(accessToken).- SetHeader("Accept", "application/json")-- project, err := api.CallGetProjectById(httpClient, projectId)- if err != nil {- return false, err- }-- for _, env := range project.Environments {- if env.Slug == environmentSlug {- return true, nil- }- }- return false, nil-}-func fetchAndFormatSecretsForShell(request models.GetAllSecretsParameters, projectConfigDir string, secretOverriding bool, token *models.TokenDetails) (models.InjectableEnvironmentResult, error) {+if token != nil && token.Type == util.SERVICE_TOKEN_IDENTIFIER {request.InfisicalToken = token.Token} else if token != nil && token.Type == util.UNIVERSAL_AUTH_TOKEN_IDENTIFIER {diff --git a/cli/packages/util/secrets.go b/cli/packages/util/secrets.goindex 0e26e03b08..5a2a0ec24c 100644--- a/cli/packages/util/secrets.go+++ b/cli/packages/util/secrets.go@@ -232,6 +232,7 @@ func FilterSecretsByTag(plainTextSecrets []models.SingleEnvironmentVariable, tagfunc GetAllEnvironmentVariables(params models.GetAllSecretsParameters, projectConfigFilePath string) ([]models.SingleEnvironmentVariable, error) {var secretsToReturn []models.SingleEnvironmentVariable+ // var serviceTokenDetails api.GetServiceTokenDetailsResponsevar errorToReturn errorif params.InfisicalToken == "" && params.UniversalAuthAccessToken == "" {diff --git a/cli/test/secrets_test.go b/cli/test/secrets_test.goindex 642d332771..f7f0f13ffd 100644--- a/cli/test/secrets_test.go+++ b/cli/test/secrets_test.go@@ -76,6 +76,7 @@ func TestUniversalAuth_SecretsGetWrongEnvironment(t *testing.T) {if err != nil {t.Fatalf("snapshot failed: %v", err)}+}func TestUserAuth_SecretsGetAll(t *testing.T) {diff --git a/flake.nix b/flake.nixindex cc4cf8d65e..094cfedc62 100644--- a/flake.nix+++ b/flake.nix@@ -14,21 +14,11 @@gitlazygit- gopython312Fullnodejs_20nodePackages.prettierinfisical];-- env = {- GOROOT = "${pkgs.go}/share/go";- };-- shellHook = ''- export GOPATH="$(pwd)/.go"- mkdir -p "$GOPATH"- '';};};}