storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/cmd/config/cache/legacy.go (about) 1 /* 2 * MinIO Cloud Storage, (C) 2019 MinIO, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package cache 18 19 import ( 20 "fmt" 21 "strings" 22 23 "storj.io/minio/cmd/config" 24 ) 25 26 const ( 27 cacheDelimiterLegacy = ";" 28 ) 29 30 // SetCacheConfig - One time migration code needed, for migrating from older config to new for Cache. 31 func SetCacheConfig(s config.Config, cfg Config) { 32 if len(cfg.Drives) == 0 { 33 // Do not save cache if no settings available. 34 return 35 } 36 s[config.CacheSubSys][config.Default] = config.KVS{ 37 config.KV{ 38 Key: Drives, 39 Value: strings.Join(cfg.Drives, cacheDelimiter), 40 }, 41 config.KV{ 42 Key: Exclude, 43 Value: strings.Join(cfg.Exclude, cacheDelimiter), 44 }, 45 config.KV{ 46 Key: Expiry, 47 Value: fmt.Sprintf("%d", cfg.Expiry), 48 }, 49 config.KV{ 50 Key: Quota, 51 Value: fmt.Sprintf("%d", cfg.MaxUse), 52 }, 53 } 54 }