type Version … func (v Version) String() string { … } // Older returns true if this version v is older than the other. func (v *Version) Older(other Version) bool { … } func (v *Version) Major() int { … } func (v *Version) Minor() int { … } func (v *Version) Latest() bool { … } func MajorMinorVersion(major, minor int) Version { … } // GetAPIVersion get the version of apiServer and return the version major and minor func GetAPIVersion() Version { … } func LatestVersion() Version { … } // ParseLevel returns the level that should be evaluated. // level must be "privileged", "baseline", or "restricted". // if level does not match one of those strings, "restricted" and an error is returned. func ParseLevel(level string) (Level, error) { … } // Valid checks whether the level l is a valid level. func (l *Level) Valid() bool { … } var versionRegexp … // ParseVersion returns the policy version that should be evaluated. // version must be "latest" or "v1.x". // If version does not match one of those patterns, the latest version and an error is returned. func ParseVersion(version string) (Version, error) { … } type LevelVersion … func (lv LevelVersion) String() string { … } // Equivalent determines whether two LevelVersions are functionally equivalent. LevelVersions are // considered equivalent if both are privileged, or both levels & versions are equal. func (lv *LevelVersion) Equivalent(other *LevelVersion) bool { … } type Policy … func (p *Policy) String() string { … } // Equivalent determines whether two policies are functionally equivalent. Policies are considered // equivalent if all 3 modes are considered equivalent. func (p *Policy) Equivalent(other *Policy) bool { … } // FullyPrivileged returns true if all 3 policy modes are privileged. func (p *Policy) FullyPrivileged() bool { … } // PolicyToEvaluate resolves the PodSecurity namespace labels to the policy for that namespace, // falling back to the provided defaults when a label is unspecified. A valid policy is always // returned, even when an error is returned. If labels cannot be parsed correctly, the values of // "restricted" and "latest" are used for level and version respectively. func PolicyToEvaluate(labels map[string]string, defaults Policy) (Policy, field.ErrorList) { … } // CompareLevels returns an integer comparing two levels by strictness. The result will be 0 if // a==b, -1 if a is less strict than b, and +1 if a is more strict than b. func CompareLevels(a, b Level) int { … } var labelsPath … // appendErr is a helper function to collect label-specific errors. func appendErr(errs field.ErrorList, err error, label, value string) field.ErrorList { … }