github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/internal/config/compress/legacy.go (about)

     1  // Copyright (c) 2015-2021 MinIO, Inc.
     2  //
     3  // This file is part of MinIO Object Storage stack
     4  //
     5  // This program is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU Affero General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  //
    10  // This program is distributed in the hope that it will be useful
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  // GNU Affero General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Affero General Public License
    16  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17  
    18  package compress
    19  
    20  import (
    21  	"strings"
    22  
    23  	"github.com/minio/minio/internal/config"
    24  )
    25  
    26  // Legacy envs.
    27  const (
    28  	EnvCompress                 = "MINIO_COMPRESS"
    29  	EnvCompressMimeTypesLegacy1 = "MINIO_COMPRESS_MIMETYPES"
    30  
    31  	// These envs were wrong but we supported them for a long time
    32  	// so keep them here to support existing deployments.
    33  	EnvCompressAllowEncryptionLegacy = "MINIO_COMPRESS_ALLOW_ENCRYPTION"
    34  	EnvCompressExtensionsLegacy      = "MINIO_COMPRESS_EXTENSIONS"
    35  	EnvCompressMimeTypesLegacy2      = "MINIO_COMPRESS_MIME_TYPES"
    36  )
    37  
    38  // SetCompressionConfig - One time migration code needed, for migrating from older config to new for Compression.
    39  func SetCompressionConfig(s config.Config, cfg Config) {
    40  	if !cfg.Enabled {
    41  		// No need to save disabled settings in new config.
    42  		return
    43  	}
    44  	s[config.CompressionSubSys][config.Default] = config.KVS{
    45  		config.KV{
    46  			Key:   config.Enable,
    47  			Value: config.EnableOn,
    48  		},
    49  		config.KV{
    50  			Key:   Extensions,
    51  			Value: strings.Join(cfg.Extensions, config.ValueSeparator),
    52  		},
    53  		config.KV{
    54  			Key:   MimeTypes,
    55  			Value: strings.Join(cfg.MimeTypes, config.ValueSeparator),
    56  		},
    57  	}
    58  }