(req Request)
| 151 | } |
| 152 | |
| 153 | func buildCommandEnv(req Request) []string { |
| 154 | env := append([]string{}, os.Environ()...) |
| 155 | overrides := map[string]string{} |
| 156 | for k, v := range req.Env { |
| 157 | overrides[k] = v |
| 158 | } |
| 159 | // Keep user-token injection scoped to user-only test commands so bot |
| 160 | // commands continue to use config-init credentials in the same process. |
| 161 | if req.DefaultAs == "user" { |
| 162 | if appID := os.Getenv("TEST_BOT1_APP_ID"); appID != "" { |
| 163 | if token := os.Getenv("TEST_USER_ACCESS_TOKEN"); token != "" { |
| 164 | overrides["LARKSUITE_CLI_APP_ID"] = appID |
| 165 | overrides["LARKSUITE_CLI_USER_ACCESS_TOKEN"] = token |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | for k, v := range overrides { |
| 170 | prefix := k + "=" |
| 171 | replaced := false |
| 172 | for i, item := range env { |
| 173 | if strings.HasPrefix(item, prefix) { |
| 174 | env[i] = prefix + v |
| 175 | replaced = true |
| 176 | break |
| 177 | } |
| 178 | } |
| 179 | if !replaced { |
| 180 | env = append(env, prefix+v) |
| 181 | } |
| 182 | } |
| 183 | return env |
| 184 | } |
| 185 | |
| 186 | // RunCmdWithRetry reruns a command when the result matches the configured retry condition. |
| 187 | func RunCmdWithRetry(ctx context.Context, req Request, opts RetryOptions) (*Result, error) { |
no outgoing calls