serviceaccounts

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoogleEmail

func GoogleEmail(sa *corev1.ServiceAccount) (string, error)

GoogleEmail returns the Google service account email from the same annotation used in native GKE Workload Identity. The annotation is:

iam.gke.io/gcp-service-account

func IsGoogleEmail added in v0.3.0

func IsGoogleEmail(s string) bool

IsGoogleEmail returns true if the string is a valid Google service account email. The email must match the following pattern:

^[a-zA-Z0-9-]+@[a-zA-Z0-9-]+\.iam\.gserviceaccount\.com$

Types

type Provider

type Provider interface {
	Get(ctx context.Context, ref *Reference) (*corev1.ServiceAccount, error)
}

type Reference added in v0.7.0

type Reference struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

func ReferenceFromNode added in v0.7.0

func ReferenceFromNode(node *corev1.Node, defaultRef *Reference) *Reference

ReferenceFromNode returns a ServiceAccount reference from the Node object annotations or labels. Annotations take precedence over labels because we encourage users to use annotations instead of labels in this case since. Labels are more impactful to etcd since they are indexed, and we don't need indexing here so we prefer annotations.

The ServiceAccount reference is retrieved from the following pair of annotations or labels:

gke-metadata-server.matheuscscp.io/serviceAccountName

gke-metadata-server.matheuscscp.io/serviceAccountNamespace

If the annotations or labels are not found, defaultRef is returned.

func ReferenceFromObject added in v0.7.0

func ReferenceFromObject(sa *corev1.ServiceAccount) *Reference

ReferenceFromObject returns a ServiceAccount reference from a ServiceAccount object.

func ReferenceFromPod added in v0.7.0

func ReferenceFromPod(pod *corev1.Pod) *Reference

ReferenceFromPod returns a ServiceAccount reference from a Pod object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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