Help us shape the future of Go! Take the 2026 Go Developer Survey

gcpiampolicy

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gcpiampolicy holds the google.iam.v1 policy semantics shared by GCP service emulators: etag compare-and-set, policy versions with conditional bindings, and permission filtering.

Index

Constants

View Source
const ConditionalVersion = conditionalVer

ConditionalVersion is the policy version required to read or write conditional bindings.

Variables

This section is empty.

Functions

func Apply

func Apply(current, in *iampb.Policy, etag func() []byte) (*iampb.Policy, error)

Apply validates in and builds the policy to store in place of current (nil when unset). A non-empty etag in in must match current's. etag mints the new etag.

func Empty

func Empty() *iampb.Policy

Empty returns the policy of a resource that has none set.

func EmptyEtag

func EmptyEtag() []byte

EmptyEtag is the etag of a resource that has no policy yet.

func Granted

func Granted(requested []string, prefix string) []string

Granted returns the requested permissions that start with prefix: the emulator performs no authorization, so every permission that applies to the resource type counts as granted.

func HasConditions

func HasConditions(p *iampb.Policy) bool

HasConditions reports whether any binding of p carries a condition.

func SetView

func SetView(stored *iampb.Policy) *iampb.Policy

SetView is the response to a successful SetIamPolicy: the stored policy at version 3.

func Validate

func Validate(p *iampb.Policy) error

Validate checks the shape of a policy supplied to SetIamPolicy.

func View

func View(stored *iampb.Policy, requestedVersion int32) *iampb.Policy

View renders a stored policy (nil when unset) for a reader asking for requestedVersion.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store keeps policies by resource name; callers serialise access with their own lock.

func NewStore

func NewStore() *Store

NewStore returns an empty Store.

func (*Store) Drop

func (s *Store) Drop(name string)

Drop forgets the policy of a deleted resource.

func (*Store) Get

func (s *Store) Get(name string, requestedVersion int32) *iampb.Policy

Get returns the policy of name, or an empty policy when none is set.

func (*Store) Reset

func (s *Store) Reset()

Reset drops every policy and restarts the etag sequence.

func (*Store) Restore

func (s *Store) Restore(policies map[string]*iampb.Policy, seq uint64)

Restore replaces the stored policies and etag sequence.

func (*Store) Set

func (s *Store) Set(name string, in *iampb.Policy) (*iampb.Policy, error)

Set validates and stores in as the policy of name. A non-empty etag must match the stored one.

func (*Store) Snapshot

func (s *Store) Snapshot() (map[string]*iampb.Policy, uint64)

Snapshot returns copies of the stored policies and the etag sequence.

Directories

Path Synopsis
Package iamtest runs the shared google.iam.v1 conformance cases against a service's IAM endpoints.
Package iamtest runs the shared google.iam.v1 conformance cases against a service's IAM endpoints.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL