...

Source file src/github.com/sigstore/rekor/pkg/generated/models/alpine_v001_schema.go

Documentation: github.com/sigstore/rekor/pkg/generated/models

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  //
     4  // Copyright 2021 The Sigstore Authors.
     5  //
     6  // Licensed under the Apache License, Version 2.0 (the "License");
     7  // you may not use this file except in compliance with the License.
     8  // You may obtain a copy of the License at
     9  //
    10  //     http://www.apache.org/licenses/LICENSE-2.0
    11  //
    12  // Unless required by applicable law or agreed to in writing, software
    13  // distributed under the License is distributed on an "AS IS" BASIS,
    14  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15  // See the License for the specific language governing permissions and
    16  // limitations under the License.
    17  //
    18  
    19  package models
    20  
    21  // This file was generated by the swagger tool.
    22  // Editing this file might prove futile when you re-run the swagger generate command
    23  
    24  import (
    25  	"context"
    26  	"encoding/json"
    27  
    28  	"github.com/go-openapi/errors"
    29  	"github.com/go-openapi/strfmt"
    30  	"github.com/go-openapi/swag"
    31  	"github.com/go-openapi/validate"
    32  )
    33  
    34  // AlpineV001Schema Alpine v0.0.1 Schema
    35  //
    36  // # Schema for Alpine Package entries
    37  //
    38  // swagger:model alpineV001Schema
    39  type AlpineV001Schema struct {
    40  
    41  	// package
    42  	// Required: true
    43  	Package *AlpineV001SchemaPackage `json:"package"`
    44  
    45  	// public key
    46  	// Required: true
    47  	PublicKey *AlpineV001SchemaPublicKey `json:"publicKey"`
    48  }
    49  
    50  // Validate validates this alpine v001 schema
    51  func (m *AlpineV001Schema) Validate(formats strfmt.Registry) error {
    52  	var res []error
    53  
    54  	if err := m.validatePackage(formats); err != nil {
    55  		res = append(res, err)
    56  	}
    57  
    58  	if err := m.validatePublicKey(formats); err != nil {
    59  		res = append(res, err)
    60  	}
    61  
    62  	if len(res) > 0 {
    63  		return errors.CompositeValidationError(res...)
    64  	}
    65  	return nil
    66  }
    67  
    68  func (m *AlpineV001Schema) validatePackage(formats strfmt.Registry) error {
    69  
    70  	if err := validate.Required("package", "body", m.Package); err != nil {
    71  		return err
    72  	}
    73  
    74  	if m.Package != nil {
    75  		if err := m.Package.Validate(formats); err != nil {
    76  			if ve, ok := err.(*errors.Validation); ok {
    77  				return ve.ValidateName("package")
    78  			} else if ce, ok := err.(*errors.CompositeError); ok {
    79  				return ce.ValidateName("package")
    80  			}
    81  			return err
    82  		}
    83  	}
    84  
    85  	return nil
    86  }
    87  
    88  func (m *AlpineV001Schema) validatePublicKey(formats strfmt.Registry) error {
    89  
    90  	if err := validate.Required("publicKey", "body", m.PublicKey); err != nil {
    91  		return err
    92  	}
    93  
    94  	if m.PublicKey != nil {
    95  		if err := m.PublicKey.Validate(formats); err != nil {
    96  			if ve, ok := err.(*errors.Validation); ok {
    97  				return ve.ValidateName("publicKey")
    98  			} else if ce, ok := err.(*errors.CompositeError); ok {
    99  				return ce.ValidateName("publicKey")
   100  			}
   101  			return err
   102  		}
   103  	}
   104  
   105  	return nil
   106  }
   107  
   108  // ContextValidate validate this alpine v001 schema based on the context it is used
   109  func (m *AlpineV001Schema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   110  	var res []error
   111  
   112  	if err := m.contextValidatePackage(ctx, formats); err != nil {
   113  		res = append(res, err)
   114  	}
   115  
   116  	if err := m.contextValidatePublicKey(ctx, formats); err != nil {
   117  		res = append(res, err)
   118  	}
   119  
   120  	if len(res) > 0 {
   121  		return errors.CompositeValidationError(res...)
   122  	}
   123  	return nil
   124  }
   125  
   126  func (m *AlpineV001Schema) contextValidatePackage(ctx context.Context, formats strfmt.Registry) error {
   127  
   128  	if m.Package != nil {
   129  
   130  		if err := m.Package.ContextValidate(ctx, formats); err != nil {
   131  			if ve, ok := err.(*errors.Validation); ok {
   132  				return ve.ValidateName("package")
   133  			} else if ce, ok := err.(*errors.CompositeError); ok {
   134  				return ce.ValidateName("package")
   135  			}
   136  			return err
   137  		}
   138  	}
   139  
   140  	return nil
   141  }
   142  
   143  func (m *AlpineV001Schema) contextValidatePublicKey(ctx context.Context, formats strfmt.Registry) error {
   144  
   145  	if m.PublicKey != nil {
   146  
   147  		if err := m.PublicKey.ContextValidate(ctx, formats); err != nil {
   148  			if ve, ok := err.(*errors.Validation); ok {
   149  				return ve.ValidateName("publicKey")
   150  			} else if ce, ok := err.(*errors.CompositeError); ok {
   151  				return ce.ValidateName("publicKey")
   152  			}
   153  			return err
   154  		}
   155  	}
   156  
   157  	return nil
   158  }
   159  
   160  // MarshalBinary interface implementation
   161  func (m *AlpineV001Schema) MarshalBinary() ([]byte, error) {
   162  	if m == nil {
   163  		return nil, nil
   164  	}
   165  	return swag.WriteJSON(m)
   166  }
   167  
   168  // UnmarshalBinary interface implementation
   169  func (m *AlpineV001Schema) UnmarshalBinary(b []byte) error {
   170  	var res AlpineV001Schema
   171  	if err := swag.ReadJSON(b, &res); err != nil {
   172  		return err
   173  	}
   174  	*m = res
   175  	return nil
   176  }
   177  
   178  // AlpineV001SchemaPackage Information about the package associated with the entry
   179  //
   180  // swagger:model AlpineV001SchemaPackage
   181  type AlpineV001SchemaPackage struct {
   182  
   183  	// Specifies the package inline within the document
   184  	// Format: byte
   185  	Content strfmt.Base64 `json:"content,omitempty"`
   186  
   187  	// hash
   188  	Hash *AlpineV001SchemaPackageHash `json:"hash,omitempty"`
   189  
   190  	// Values of the .PKGINFO key / value pairs
   191  	// Read Only: true
   192  	Pkginfo map[string]string `json:"pkginfo,omitempty"`
   193  }
   194  
   195  // Validate validates this alpine v001 schema package
   196  func (m *AlpineV001SchemaPackage) Validate(formats strfmt.Registry) error {
   197  	var res []error
   198  
   199  	if err := m.validateHash(formats); err != nil {
   200  		res = append(res, err)
   201  	}
   202  
   203  	if len(res) > 0 {
   204  		return errors.CompositeValidationError(res...)
   205  	}
   206  	return nil
   207  }
   208  
   209  func (m *AlpineV001SchemaPackage) validateHash(formats strfmt.Registry) error {
   210  	if swag.IsZero(m.Hash) { // not required
   211  		return nil
   212  	}
   213  
   214  	if m.Hash != nil {
   215  		if err := m.Hash.Validate(formats); err != nil {
   216  			if ve, ok := err.(*errors.Validation); ok {
   217  				return ve.ValidateName("package" + "." + "hash")
   218  			} else if ce, ok := err.(*errors.CompositeError); ok {
   219  				return ce.ValidateName("package" + "." + "hash")
   220  			}
   221  			return err
   222  		}
   223  	}
   224  
   225  	return nil
   226  }
   227  
   228  // ContextValidate validate this alpine v001 schema package based on the context it is used
   229  func (m *AlpineV001SchemaPackage) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   230  	var res []error
   231  
   232  	if err := m.contextValidateHash(ctx, formats); err != nil {
   233  		res = append(res, err)
   234  	}
   235  
   236  	if err := m.contextValidatePkginfo(ctx, formats); err != nil {
   237  		res = append(res, err)
   238  	}
   239  
   240  	if len(res) > 0 {
   241  		return errors.CompositeValidationError(res...)
   242  	}
   243  	return nil
   244  }
   245  
   246  func (m *AlpineV001SchemaPackage) contextValidateHash(ctx context.Context, formats strfmt.Registry) error {
   247  
   248  	if m.Hash != nil {
   249  
   250  		if swag.IsZero(m.Hash) { // not required
   251  			return nil
   252  		}
   253  
   254  		if err := m.Hash.ContextValidate(ctx, formats); err != nil {
   255  			if ve, ok := err.(*errors.Validation); ok {
   256  				return ve.ValidateName("package" + "." + "hash")
   257  			} else if ce, ok := err.(*errors.CompositeError); ok {
   258  				return ce.ValidateName("package" + "." + "hash")
   259  			}
   260  			return err
   261  		}
   262  	}
   263  
   264  	return nil
   265  }
   266  
   267  func (m *AlpineV001SchemaPackage) contextValidatePkginfo(ctx context.Context, formats strfmt.Registry) error {
   268  
   269  	return nil
   270  }
   271  
   272  // MarshalBinary interface implementation
   273  func (m *AlpineV001SchemaPackage) MarshalBinary() ([]byte, error) {
   274  	if m == nil {
   275  		return nil, nil
   276  	}
   277  	return swag.WriteJSON(m)
   278  }
   279  
   280  // UnmarshalBinary interface implementation
   281  func (m *AlpineV001SchemaPackage) UnmarshalBinary(b []byte) error {
   282  	var res AlpineV001SchemaPackage
   283  	if err := swag.ReadJSON(b, &res); err != nil {
   284  		return err
   285  	}
   286  	*m = res
   287  	return nil
   288  }
   289  
   290  // AlpineV001SchemaPackageHash Specifies the hash algorithm and value for the package
   291  //
   292  // swagger:model AlpineV001SchemaPackageHash
   293  type AlpineV001SchemaPackageHash struct {
   294  
   295  	// The hashing function used to compute the hash value
   296  	// Required: true
   297  	// Enum: [sha256]
   298  	Algorithm *string `json:"algorithm"`
   299  
   300  	// The hash value for the package
   301  	// Required: true
   302  	Value *string `json:"value"`
   303  }
   304  
   305  // Validate validates this alpine v001 schema package hash
   306  func (m *AlpineV001SchemaPackageHash) Validate(formats strfmt.Registry) error {
   307  	var res []error
   308  
   309  	if err := m.validateAlgorithm(formats); err != nil {
   310  		res = append(res, err)
   311  	}
   312  
   313  	if err := m.validateValue(formats); err != nil {
   314  		res = append(res, err)
   315  	}
   316  
   317  	if len(res) > 0 {
   318  		return errors.CompositeValidationError(res...)
   319  	}
   320  	return nil
   321  }
   322  
   323  var alpineV001SchemaPackageHashTypeAlgorithmPropEnum []interface{}
   324  
   325  func init() {
   326  	var res []string
   327  	if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
   328  		panic(err)
   329  	}
   330  	for _, v := range res {
   331  		alpineV001SchemaPackageHashTypeAlgorithmPropEnum = append(alpineV001SchemaPackageHashTypeAlgorithmPropEnum, v)
   332  	}
   333  }
   334  
   335  const (
   336  
   337  	// AlpineV001SchemaPackageHashAlgorithmSha256 captures enum value "sha256"
   338  	AlpineV001SchemaPackageHashAlgorithmSha256 string = "sha256"
   339  )
   340  
   341  // prop value enum
   342  func (m *AlpineV001SchemaPackageHash) validateAlgorithmEnum(path, location string, value string) error {
   343  	if err := validate.EnumCase(path, location, value, alpineV001SchemaPackageHashTypeAlgorithmPropEnum, true); err != nil {
   344  		return err
   345  	}
   346  	return nil
   347  }
   348  
   349  func (m *AlpineV001SchemaPackageHash) validateAlgorithm(formats strfmt.Registry) error {
   350  
   351  	if err := validate.Required("package"+"."+"hash"+"."+"algorithm", "body", m.Algorithm); err != nil {
   352  		return err
   353  	}
   354  
   355  	// value enum
   356  	if err := m.validateAlgorithmEnum("package"+"."+"hash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
   357  		return err
   358  	}
   359  
   360  	return nil
   361  }
   362  
   363  func (m *AlpineV001SchemaPackageHash) validateValue(formats strfmt.Registry) error {
   364  
   365  	if err := validate.Required("package"+"."+"hash"+"."+"value", "body", m.Value); err != nil {
   366  		return err
   367  	}
   368  
   369  	return nil
   370  }
   371  
   372  // ContextValidate validate this alpine v001 schema package hash based on the context it is used
   373  func (m *AlpineV001SchemaPackageHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   374  	var res []error
   375  
   376  	if len(res) > 0 {
   377  		return errors.CompositeValidationError(res...)
   378  	}
   379  	return nil
   380  }
   381  
   382  // MarshalBinary interface implementation
   383  func (m *AlpineV001SchemaPackageHash) MarshalBinary() ([]byte, error) {
   384  	if m == nil {
   385  		return nil, nil
   386  	}
   387  	return swag.WriteJSON(m)
   388  }
   389  
   390  // UnmarshalBinary interface implementation
   391  func (m *AlpineV001SchemaPackageHash) UnmarshalBinary(b []byte) error {
   392  	var res AlpineV001SchemaPackageHash
   393  	if err := swag.ReadJSON(b, &res); err != nil {
   394  		return err
   395  	}
   396  	*m = res
   397  	return nil
   398  }
   399  
   400  // AlpineV001SchemaPublicKey The public key that can verify the package signature
   401  //
   402  // swagger:model AlpineV001SchemaPublicKey
   403  type AlpineV001SchemaPublicKey struct {
   404  
   405  	// Specifies the content of the public key inline within the document
   406  	// Required: true
   407  	// Format: byte
   408  	Content *strfmt.Base64 `json:"content"`
   409  }
   410  
   411  // Validate validates this alpine v001 schema public key
   412  func (m *AlpineV001SchemaPublicKey) Validate(formats strfmt.Registry) error {
   413  	var res []error
   414  
   415  	if err := m.validateContent(formats); err != nil {
   416  		res = append(res, err)
   417  	}
   418  
   419  	if len(res) > 0 {
   420  		return errors.CompositeValidationError(res...)
   421  	}
   422  	return nil
   423  }
   424  
   425  func (m *AlpineV001SchemaPublicKey) validateContent(formats strfmt.Registry) error {
   426  
   427  	if err := validate.Required("publicKey"+"."+"content", "body", m.Content); err != nil {
   428  		return err
   429  	}
   430  
   431  	return nil
   432  }
   433  
   434  // ContextValidate validates this alpine v001 schema public key based on context it is used
   435  func (m *AlpineV001SchemaPublicKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   436  	return nil
   437  }
   438  
   439  // MarshalBinary interface implementation
   440  func (m *AlpineV001SchemaPublicKey) MarshalBinary() ([]byte, error) {
   441  	if m == nil {
   442  		return nil, nil
   443  	}
   444  	return swag.WriteJSON(m)
   445  }
   446  
   447  // UnmarshalBinary interface implementation
   448  func (m *AlpineV001SchemaPublicKey) UnmarshalBinary(b []byte) error {
   449  	var res AlpineV001SchemaPublicKey
   450  	if err := swag.ReadJSON(b, &res); err != nil {
   451  		return err
   452  	}
   453  	*m = res
   454  	return nil
   455  }
   456  

View as plain text