gcp

package
v0.0.0-...-03d4dc7 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GCloudAccessToken

func GCloudAccessToken(ctx context.Context) (string, error)

func GCloudActiveUser

func GCloudActiveUser(ctx context.Context) (string, error)

func GetClusterServerForLegacyGCP

func GetClusterServerForLegacyGCP(name string) string

func GetUserEmails

func GetUserEmails(ctx context.Context) ([]string, error)

func ValidateUserLogin

func ValidateUserLogin(ctx context.Context) error

Types

type Cluster

type Cluster struct {
	Name        string
	Endpoint    string
	Location    string
	CA          string
	Tenant      string
	User        *OnpremUser
	Kind        Kind
	Environment string
}

func GetClusters

func GetClusters(ctx context.Context) ([]Cluster, error)

type Entitlement

type Entitlement struct {
	Name               string `json:"name"`
	MaxRequestDuration string `json:"maxRequestDuration"`
	PrivilegedAccess   struct {
		GCPIAMAccess struct {
			RoleBindings []struct {
				Role string `json:"role"`
			} `json:"roleBindings"`
		} `json:"gcpIamAccess"`
	} `json:"privilegedAccess"`
}

From Google API.

func (Entitlement) ListActiveGrants

func (ent Entitlement) ListActiveGrants(ctx context.Context, userName string) ([]Grant, error)

List all grants for a given entitlement, looping through pagination as needed.

func (Entitlement) MaxDuration

func (ent Entitlement) MaxDuration() time.Duration

Parse duration to a known type

func (Entitlement) Roles

func (ent Entitlement) Roles() []string

Extract roles as a simple slice

func (Entitlement) ShortName

func (ent Entitlement) ShortName() string

Convert `folders/448765591554/locations/global/entitlements/nais-admin` -> `nais-admin`

type EntitlementsResponse

type EntitlementsResponse struct {
	Entitlements []Entitlement `json:"entitlements"`
}

Actual Entitlements response from GCP

func ListEntitlements

func ListEntitlements(ctx context.Context, folderID FolderID) (*EntitlementsResponse, error)

Return a list of possible entitlements that can be granted.

The folder ID is a reference to the `nais` folder of a specific tenant.

func ParseEntitlementResponse

func ParseEntitlementResponse(entitlementData []byte) (EntitlementsResponse, error)

func (EntitlementsResponse) GetByName

func (r EntitlementsResponse) GetByName(tenantName string) *Entitlement

type FolderID

type FolderID string

type Grant

type Grant struct {
	// Name              string `json:"name"`
	CreateTime        string        `json:"createTime,omitempty"`
	Requester         string        `json:"requester,omitempty"`
	RequestedDuration string        `json:"requestedDuration"`
	Justification     Justification `json:"justification"`
}

func (Grant) Duration

func (grant Grant) Duration() time.Duration

func (Grant) TimeRemaining

func (grant Grant) TimeRemaining() time.Duration

type Justification

type Justification struct {
	Text string `json:"unstructuredJustification"`
}

From Google API.

type Kind

type Kind int64
const (
	KindOnprem Kind = iota
	KindKNADA
	KindNAIS
	KindLegacy
	KindManagment
	KindUnknown
)

func ParseKind

func ParseKind(in string) Kind

type OnpremUser

type OnpremUser struct {
	ServerID string `json:"serverID"`
	ClientID string `json:"clientID"`
	TenantID string `json:"tenantID"`
	UserName string `json:"userName"`
}

type Project

type Project struct {
	ID     string
	Tenant string
	Name   string
	Kind   Kind
}

type TenantMetadata

type TenantMetadata struct {
	NaisFolderID FolderID `json:"folderId"`
}

nais-terraform-modules exports tenant metadata through a public Google storage bucket.

Each tenant corresponds to a single file on this bucket. The file has the same name as the tenant domain, suffixed with .json.

func FetchTenantMetadata

func FetchTenantMetadata(tenantName string) (*TenantMetadata, error)

Jump to

Keyboard shortcuts

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