mirror of
https://github.com/pgsty/minio.git
synced 2026-07-22 05:30:24 +03:00
avoid using os.Getenv for internal code, use env.Get() instead (#17688)
This commit is contained in:
@@ -21,7 +21,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"math/rand"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"sync"
|
||||
@@ -29,6 +28,7 @@ import (
|
||||
|
||||
"github.com/minio/minio/internal/mcontext"
|
||||
"github.com/minio/pkg/console"
|
||||
"github.com/minio/pkg/env"
|
||||
)
|
||||
|
||||
// Indicator if logging is enabled.
|
||||
@@ -41,10 +41,10 @@ var lockRetryBackOff func(*rand.Rand, uint) time.Duration
|
||||
|
||||
func init() {
|
||||
// Check for MINIO_DSYNC_TRACE env variable, if set logging will be enabled for failed REST operations.
|
||||
dsyncLog = os.Getenv("_MINIO_DSYNC_TRACE") == "1"
|
||||
dsyncLog = env.Get("_MINIO_DSYNC_TRACE", "0") == "1"
|
||||
|
||||
lockRetryMinInterval = 250 * time.Millisecond
|
||||
if lri := os.Getenv("_MINIO_LOCK_RETRY_INTERVAL"); lri != "" {
|
||||
if lri := env.Get("_MINIO_LOCK_RETRY_INTERVAL", ""); lri != "" {
|
||||
v, err := strconv.Atoi(lri)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -26,18 +26,19 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/klauspost/compress/s2"
|
||||
"github.com/klauspost/compress/zstd"
|
||||
gzip "github.com/klauspost/pgzip"
|
||||
"github.com/minio/minio/internal/config"
|
||||
"github.com/minio/minio/internal/s3select/csv"
|
||||
"github.com/minio/minio/internal/s3select/json"
|
||||
"github.com/minio/minio/internal/s3select/parquet"
|
||||
"github.com/minio/minio/internal/s3select/simdj"
|
||||
"github.com/minio/minio/internal/s3select/sql"
|
||||
"github.com/minio/pkg/env"
|
||||
"github.com/minio/simdjson-go"
|
||||
"github.com/pierrec/lz4"
|
||||
)
|
||||
@@ -73,6 +74,12 @@ const (
|
||||
maxRecordSize = 1 << 20 // 1 MiB
|
||||
)
|
||||
|
||||
var parquetSupport bool
|
||||
|
||||
func init() {
|
||||
parquetSupport = env.Get("MINIO_API_SELECT_PARQUET", config.EnableOff) == config.EnableOn
|
||||
}
|
||||
|
||||
var bufPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
// make a buffer with a reasonable capacity.
|
||||
@@ -439,7 +446,7 @@ func (s3Select *S3Select) Open(rsc io.ReadSeekCloser) error {
|
||||
|
||||
return nil
|
||||
case parquetFormat:
|
||||
if !strings.EqualFold(os.Getenv("MINIO_API_SELECT_PARQUET"), "on") {
|
||||
if !parquetSupport {
|
||||
return errors.New("parquet format parsing not enabled on server")
|
||||
}
|
||||
if offset != 0 || length != -1 {
|
||||
|
||||
@@ -1684,7 +1684,11 @@ func TestCSVRanges(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParquetInput(t *testing.T) {
|
||||
t.Setenv("MINIO_API_SELECT_PARQUET", "on")
|
||||
saved := parquetSupport
|
||||
defer func() {
|
||||
parquetSupport = saved
|
||||
}()
|
||||
parquetSupport = true
|
||||
|
||||
testTable := []struct {
|
||||
requestXML []byte
|
||||
@@ -1785,7 +1789,11 @@ func TestParquetInput(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParquetInputSchema(t *testing.T) {
|
||||
t.Setenv("MINIO_API_SELECT_PARQUET", "on")
|
||||
saved := parquetSupport
|
||||
defer func() {
|
||||
parquetSupport = saved
|
||||
}()
|
||||
parquetSupport = true
|
||||
|
||||
testTable := []struct {
|
||||
requestXML []byte
|
||||
@@ -1887,7 +1895,11 @@ func TestParquetInputSchema(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParquetInputSchemaCSV(t *testing.T) {
|
||||
t.Setenv("MINIO_API_SELECT_PARQUET", "on")
|
||||
saved := parquetSupport
|
||||
defer func() {
|
||||
parquetSupport = saved
|
||||
}()
|
||||
parquetSupport = true
|
||||
|
||||
testTable := []struct {
|
||||
requestXML []byte
|
||||
|
||||
Reference in New Issue
Block a user