mirror of
				https://github.com/containers/podman.git
				synced 2025-10-31 18:08:51 +08:00 
			
		
		
		
	![dependabot-preview[bot]](/assets/img/avatar_default.png) 08d8290f1d
			
		
	
	08d8290f1d
	
	
	
		
			
			Bumps [github.com/containers/ocicrypt](https://github.com/containers/ocicrypt) from 1.0.3 to 1.1.0. - [Release notes](https://github.com/containers/ocicrypt/releases) - [Commits](https://github.com/containers/ocicrypt/compare/v1.0.3...v1.1.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
		
			
				
	
	
		
			80 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| /*
 | |
|  *
 | |
|  * Copyright 2019 gRPC authors.
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *     http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  *
 | |
|  */
 | |
| 
 | |
| // Package attributes defines a generic key/value store used in various gRPC
 | |
| // components.
 | |
| //
 | |
| // Experimental
 | |
| //
 | |
| // Notice: This package is EXPERIMENTAL and may be changed or removed in a
 | |
| // later release.
 | |
| package attributes
 | |
| 
 | |
| import "fmt"
 | |
| 
 | |
| // Attributes is an immutable struct for storing and retrieving generic
 | |
| // key/value pairs.  Keys must be hashable, and users should define their own
 | |
| // types for keys.
 | |
| type Attributes struct {
 | |
| 	m map[interface{}]interface{}
 | |
| }
 | |
| 
 | |
| // New returns a new Attributes containing all key/value pairs in kvs.  If the
 | |
| // same key appears multiple times, the last value overwrites all previous
 | |
| // values for that key.  Panics if len(kvs) is not even.
 | |
| func New(kvs ...interface{}) *Attributes {
 | |
| 	if len(kvs)%2 != 0 {
 | |
| 		panic(fmt.Sprintf("attributes.New called with unexpected input: len(kvs) = %v", len(kvs)))
 | |
| 	}
 | |
| 	a := &Attributes{m: make(map[interface{}]interface{}, len(kvs)/2)}
 | |
| 	for i := 0; i < len(kvs)/2; i++ {
 | |
| 		a.m[kvs[i*2]] = kvs[i*2+1]
 | |
| 	}
 | |
| 	return a
 | |
| }
 | |
| 
 | |
| // WithValues returns a new Attributes containing all key/value pairs in a and
 | |
| // kvs.  Panics if len(kvs) is not even.  If the same key appears multiple
 | |
| // times, the last value overwrites all previous values for that key.  To
 | |
| // remove an existing key, use a nil value.
 | |
| func (a *Attributes) WithValues(kvs ...interface{}) *Attributes {
 | |
| 	if a == nil {
 | |
| 		return New(kvs...)
 | |
| 	}
 | |
| 	if len(kvs)%2 != 0 {
 | |
| 		panic(fmt.Sprintf("attributes.New called with unexpected input: len(kvs) = %v", len(kvs)))
 | |
| 	}
 | |
| 	n := &Attributes{m: make(map[interface{}]interface{}, len(a.m)+len(kvs)/2)}
 | |
| 	for k, v := range a.m {
 | |
| 		n.m[k] = v
 | |
| 	}
 | |
| 	for i := 0; i < len(kvs)/2; i++ {
 | |
| 		n.m[kvs[i*2]] = kvs[i*2+1]
 | |
| 	}
 | |
| 	return n
 | |
| }
 | |
| 
 | |
| // Value returns the value associated with these attributes for key, or nil if
 | |
| // no value is associated with key.
 | |
| func (a *Attributes) Value(key interface{}) interface{} {
 | |
| 	if a == nil {
 | |
| 		return nil
 | |
| 	}
 | |
| 	return a.m[key]
 | |
| }
 |