| 1365 | } |
| 1366 | |
| 1367 | func (ws *WshServer) GetAllVarsCommand(ctx context.Context, data wshrpc.CommandVarData) ([]wshrpc.CommandVarResponseData, error) { |
| 1368 | _, fileData, err := filestore.WFS.ReadFile(ctx, data.ZoneId, data.FileName) |
| 1369 | if err == fs.ErrNotExist { |
| 1370 | return []wshrpc.CommandVarResponseData{}, nil |
| 1371 | } |
| 1372 | if err != nil { |
| 1373 | return nil, fmt.Errorf("error reading blockfile: %w", err) |
| 1374 | } |
| 1375 | envMap := envutil.EnvToMap(string(fileData)) |
| 1376 | keys := make([]string, 0, len(envMap)) |
| 1377 | for k := range envMap { |
| 1378 | keys = append(keys, k) |
| 1379 | } |
| 1380 | sort.Strings(keys) |
| 1381 | result := make([]wshrpc.CommandVarResponseData, 0, len(keys)) |
| 1382 | for _, k := range keys { |
| 1383 | result = append(result, wshrpc.CommandVarResponseData{ |
| 1384 | Key: k, |
| 1385 | Val: envMap[k], |
| 1386 | Exists: true, |
| 1387 | }) |
| 1388 | } |
| 1389 | return result, nil |
| 1390 | } |
| 1391 | |
| 1392 | func (ws *WshServer) SetVarCommand(ctx context.Context, data wshrpc.CommandVarData) error { |
| 1393 | _, fileData, err := filestore.WFS.ReadFile(ctx, data.ZoneId, data.FileName) |