runinhibit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package runinhibit contains operations for establishing, removing and querying snap run inhibition lock.

Index

Constants

This section is empty.

Variables

View Source
var InhibitDir = defaultInhibitDir

InhibitDir is the directory where inhibition files are stored. This value can be changed by calling dirs.SetRootDir.

Functions

func LockWithHint

func LockWithHint(snapName string, hint Hint) error

LockWithHint sets a persistent "snap run" inhibition lock, for the given snap, with a given hint.

The hint cannot be empty. It should be one of the Hint constants defined in this package. With the hint in place "snap run" will not allow the snap to start and will block, presenting a user interface if possible.

func RemoveLockFile

func RemoveLockFile(snapName string) error

RemoveLockFile removes the run inhibition lock for the given snap.

This function should not be used as a substitute of Unlock, as race-free ability to inspect the inhibition state relies on flock(2) which requires the file to exist in the first place and non-privileged processes cannot create it.

The function does not fail if the inhibition lock does not exist.

func Unlock

func Unlock(snapName string) error

Unlock truncates the run inhibition lock, for the given snap.

An empty inhibition lock means uninhibited "snap run".

Types

type Hint

type Hint string

Hint is a string representing reason for the inhibition of "snap run".

const (
	// HintNotInhibited is used when "snap run" is not inhibited.
	HintNotInhibited Hint = ""
	// HintInhibitedGateRefresh represents inhibition of a "snap run" while gate-auto-refresh hook is run.
	HintInhibitedGateRefresh Hint = "gate-refresh"
	// HintInhibitedForRefresh represents inhibition of a "snap run" while a refresh change is being performed.
	HintInhibitedForRefresh Hint = "refresh"
)

func IsLocked

func IsLocked(snapName string) (Hint, error)

IsLocked returns the state of the run inhibition lock for the given snap.

It returns the current, non-empty hint if inhibition is in place. Otherwise it returns an empty hint.

Jump to

Keyboard shortcuts

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