Skip to content
Snippets Groups Projects
Select Git revision
  • 3629499bfbbd8f6fdeccff1847cad97ab64f43ae
  • master default protected
  • bugfix/fix-return-var-in-find
  • feature/upgrade2
  • v1.11.0
  • v1.10.0
  • v1.8.2
  • v1.8.1
  • v1.8.0
  • 1.7.3
  • v1.7.1
  • v1.6.1
  • v1.6.0
  • v1.5.0
  • v1.4.1
  • v1.3.0
  • v1.2.2
  • v1.2.1
  • v1.2.0
  • v1.0.1
  • v1.0.0
  • v0.0.23
  • v0.0.17
  • v0.0.10
24 results

MANIFEST.in

Blame
  • options.go 20.36 KiB
    package items
    
    import (
    	"maps"
    	"slices"
    
    	"git.perx.ru/perxis/perxis-go/pkg/options"
    	pb "git.perx.ru/perxis/perxis-go/proto/items"
    )
    
    type Options struct {
    	Env               map[string]interface{}
    	Filter            []string
    	PermissionsFilter []string
    }
    
    func MergeOptions(opts ...Options) Options {
    	o := Options{
    		Env:    make(map[string]interface{}),
    		Filter: make([]string, 0),
    	}
    
    	for _, opt := range opts {
    
    		for k, v := range opt.Env {
    			o.Env[k] = v
    		}
    
    		o.Filter = append(o.Filter, opt.Filter...)
    		o.PermissionsFilter = append(o.PermissionsFilter, opt.PermissionsFilter...)
    	}
    
    	return o
    }
    
    type CreateOptions struct {
    	Options
    
    	UpdateAttrs bool
    }
    
    func MergeCreateOptions(opts ...*CreateOptions) *CreateOptions {
    	o := &CreateOptions{}
    	for _, opt := range opts {
    		if opt == nil {
    			continue
    		}
    		if opt.UpdateAttrs {
    			o.UpdateAttrs = true
    		}
    
    		o.Options = MergeOptions(o.Options, opt.Options)
    	}
    	return o
    }
    
    func CreateOptionsToProto(opts ...*CreateOptions) *pb.CreateOptions {
    	if opts == nil {
    		return nil
    	}
    	o := MergeCreateOptions(opts...)
    	return &pb.CreateOptions{
    		UpdateAttrs: o.UpdateAttrs,
    	}
    }
    
    func CreateOptionsFromProto(opts *pb.CreateOptions) *CreateOptions {
    	if opts == nil {
    		return nil
    	}