github.com/mhutchinson/trillian@v1.2.1/trees/types.go (about)

     1  // Copyright 2018 Google Inc. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package trees
    16  
    17  import "github.com/google/trillian"
    18  
    19  // OpType indicates how a tree is to be used and participates in permissions
    20  // decisions.
    21  type OpType int
    22  
    23  const (
    24  	// Unknown is an access type that will always get rejected.
    25  	Unknown OpType = iota
    26  	// Admin access is for general administration purposes.
    27  	Admin
    28  	// Query implies access to serve query, typically readonly.
    29  	Query
    30  	// QueueLog is log specific - adding entries to the queue.
    31  	QueueLog
    32  	// SequenceLog is log specific - integrating entries into the tree.
    33  	SequenceLog
    34  	// UpdateMap is map specific - set / update leaves.
    35  	UpdateMap
    36  )
    37  
    38  // GetOpts contains validation options for GetTree.
    39  type GetOpts struct {
    40  	// TreeTypes is a set of allowed tree types. If empty, any type is allowed.
    41  	TreeTypes map[trillian.TreeType]bool
    42  	// Operation indicates what operation is being performed.
    43  	Operation OpType
    44  }
    45  
    46  // NewGetOpts creates GetOps that allows the listed set of tree types, and
    47  // optionally forces the tree to be readonly.
    48  func NewGetOpts(op OpType, types ...trillian.TreeType) GetOpts {
    49  	m := make(map[trillian.TreeType]bool)
    50  	for _, t := range types {
    51  		m[t] = true
    52  	}
    53  	return GetOpts{Operation: op, TreeTypes: m}
    54  }