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