github.com/minio/console@v1.3.0/models/configuration_k_v.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // This file is part of MinIO Console Server
     4  // Copyright (c) 2023 MinIO, Inc.
     5  //
     6  // This program is free software: you can redistribute it and/or modify
     7  // it under the terms of the GNU Affero General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // This program is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU Affero General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU Affero General Public License
    17  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18  //
    19  
    20  package models
    21  
    22  // This file was generated by the swagger tool.
    23  // Editing this file might prove futile when you re-run the swagger generate command
    24  
    25  import (
    26  	"context"
    27  
    28  	"github.com/go-openapi/errors"
    29  	"github.com/go-openapi/strfmt"
    30  	"github.com/go-openapi/swag"
    31  )
    32  
    33  // ConfigurationKV configuration k v
    34  //
    35  // swagger:model configurationKV
    36  type ConfigurationKV struct {
    37  
    38  	// env override
    39  	EnvOverride *EnvOverride `json:"env_override,omitempty"`
    40  
    41  	// key
    42  	Key string `json:"key,omitempty"`
    43  
    44  	// value
    45  	Value string `json:"value,omitempty"`
    46  }
    47  
    48  // Validate validates this configuration k v
    49  func (m *ConfigurationKV) Validate(formats strfmt.Registry) error {
    50  	var res []error
    51  
    52  	if err := m.validateEnvOverride(formats); err != nil {
    53  		res = append(res, err)
    54  	}
    55  
    56  	if len(res) > 0 {
    57  		return errors.CompositeValidationError(res...)
    58  	}
    59  	return nil
    60  }
    61  
    62  func (m *ConfigurationKV) validateEnvOverride(formats strfmt.Registry) error {
    63  	if swag.IsZero(m.EnvOverride) { // not required
    64  		return nil
    65  	}
    66  
    67  	if m.EnvOverride != nil {
    68  		if err := m.EnvOverride.Validate(formats); err != nil {
    69  			if ve, ok := err.(*errors.Validation); ok {
    70  				return ve.ValidateName("env_override")
    71  			} else if ce, ok := err.(*errors.CompositeError); ok {
    72  				return ce.ValidateName("env_override")
    73  			}
    74  			return err
    75  		}
    76  	}
    77  
    78  	return nil
    79  }
    80  
    81  // ContextValidate validate this configuration k v based on the context it is used
    82  func (m *ConfigurationKV) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    83  	var res []error
    84  
    85  	if err := m.contextValidateEnvOverride(ctx, formats); err != nil {
    86  		res = append(res, err)
    87  	}
    88  
    89  	if len(res) > 0 {
    90  		return errors.CompositeValidationError(res...)
    91  	}
    92  	return nil
    93  }
    94  
    95  func (m *ConfigurationKV) contextValidateEnvOverride(ctx context.Context, formats strfmt.Registry) error {
    96  
    97  	if m.EnvOverride != nil {
    98  
    99  		if swag.IsZero(m.EnvOverride) { // not required
   100  			return nil
   101  		}
   102  
   103  		if err := m.EnvOverride.ContextValidate(ctx, formats); err != nil {
   104  			if ve, ok := err.(*errors.Validation); ok {
   105  				return ve.ValidateName("env_override")
   106  			} else if ce, ok := err.(*errors.CompositeError); ok {
   107  				return ce.ValidateName("env_override")
   108  			}
   109  			return err
   110  		}
   111  	}
   112  
   113  	return nil
   114  }
   115  
   116  // MarshalBinary interface implementation
   117  func (m *ConfigurationKV) MarshalBinary() ([]byte, error) {
   118  	if m == nil {
   119  		return nil, nil
   120  	}
   121  	return swag.WriteJSON(m)
   122  }
   123  
   124  // UnmarshalBinary interface implementation
   125  func (m *ConfigurationKV) UnmarshalBinary(b []byte) error {
   126  	var res ConfigurationKV
   127  	if err := swag.ReadJSON(b, &res); err != nil {
   128  		return err
   129  	}
   130  	*m = res
   131  	return nil
   132  }