Movatterモバイル変換


[0]ホーム

URL:


policytest

package
v1.92.2Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License:BSD-3-ClauseImports:9Imported by:0

Details

Repository

github.com/tailscale/tailscale

Links

Documentation

Overview

Package policytest contains test helpers for the syspolicy packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeConfig

type Config map[pkey.Key]any

Config is apolicyclient.Client implementation with a static mapping ofvalues.

It is used for testing purposes to simulate policy client behavior.

It panics if a value is Set with one type and then accessed with a differentexpected type and/or value. Some accessors such as GetPreferenceOption andGetVisibility support either a ptype.PreferenceOption/ptype.Visibility in themap, or the string representation as supported by their UnmarshalTextmethods.

The map value may be an error to return that error value from the accessor.

func (*Config)EnableRegisterChangeCallback

func (c *Config) EnableRegisterChangeCallback()

EnableRegisterChangeCallback makes c support the RegisterChangeCallbackfor testing. Without calling this, the RegisterChangeCallback does nothing.For watchers to be notified, use theConfig.Set method. Changing the mapdirectly obviously wouldn't work.

func (Config)GetBoolean

func (cConfig) GetBoolean(keypkey.Key, defaultValbool) (bool,error)

func (Config)GetDuration

func (cConfig) GetDuration(keypkey.Key, defaultValtime.Duration) (time.Duration,error)

func (Config)GetPreferenceOption

func (cConfig) GetPreferenceOption(keypkey.Key, defaultValptype.PreferenceOption) (ptype.PreferenceOption,error)

func (Config)GetString

func (cConfig) GetString(keypkey.Key, defaultValstring) (string,error)

func (Config)GetStringArray

func (cConfig) GetStringArray(keypkey.Key, defaultVal []string) ([]string,error)

func (Config)GetUint64

func (cConfig) GetUint64(keypkey.Key, defaultValuint64) (uint64,error)

func (Config)GetVisibility

func (cConfig) GetVisibility(keypkey.Key) (ptype.Visibility,error)

func (Config)HasAnyOf

func (cConfig) HasAnyOf(keys ...pkey.Key) (bool,error)

func (Config)RegisterChangeCallback

func (cConfig) RegisterChangeCallback(callback func(policyclient.PolicyChange)) (func(),error)

func (*Config)Set

func (c *Config) Set(keypkey.Key, valueany)

Set sets key to value. The value should be of the correct type that it willbe read as later. For PreferenceOption and Visibility, you may also set themto 'string' values and they'll be UnmarshalText'ed into their correct valueat Get time.

As a special case, the value can also be of type error to make the accessorsreturn that error value.

func (Config)SetDebugLoggingEnabled

func (spConfig) SetDebugLoggingEnabled(enabledbool)

func (*Config)SetMultiple

func (c *Config) SetMultiple(oConfig)

SetMultiple is a batch version ofConfig.Set. It copies the contents of ointo c and does at most one notification wake-up for the whole batch.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp