github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/internal/logger/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 logger 19 20 import ( 21 "github.com/minio/minio/internal/config" 22 "github.com/minio/minio/internal/logger/target/http" 23 ) 24 25 // Legacy envs 26 const ( 27 legacyEnvAuditLoggerHTTPEndpoint = "MINIO_AUDIT_LOGGER_HTTP_ENDPOINT" 28 legacyEnvLoggerHTTPEndpoint = "MINIO_LOGGER_HTTP_ENDPOINT" 29 ) 30 31 // SetLoggerHTTPAudit - helper for migrating older config to newer KV format. 32 func SetLoggerHTTPAudit(scfg config.Config, k string, args http.Config) { 33 if !args.Enabled { 34 // Do not enable audit targets, if not enabled 35 return 36 } 37 scfg[config.AuditWebhookSubSys][k] = config.KVS{ 38 config.KV{ 39 Key: config.Enable, 40 Value: config.EnableOn, 41 }, 42 config.KV{ 43 Key: Endpoint, 44 Value: args.Endpoint.String(), 45 }, 46 config.KV{ 47 Key: AuthToken, 48 Value: args.AuthToken, 49 }, 50 } 51 } 52 53 // SetLoggerHTTP helper for migrating older config to newer KV format. 54 func SetLoggerHTTP(scfg config.Config, k string, args http.Config) { 55 if !args.Enabled { 56 // Do not enable logger http targets, if not enabled 57 return 58 } 59 60 scfg[config.LoggerWebhookSubSys][k] = config.KVS{ 61 config.KV{ 62 Key: config.Enable, 63 Value: config.EnableOn, 64 }, 65 config.KV{ 66 Key: Endpoint, 67 Value: args.Endpoint.String(), 68 }, 69 config.KV{ 70 Key: AuthToken, 71 Value: args.AuthToken, 72 }, 73 } 74 }