Documentation
¶
Overview ¶
Package gcponboard is the logic of the CLI's Google Cloud onboarding.
Index ¶
- Constants
- func CheckFallbackTypes(types []string) error
- func CheckIPLists(lists []IPList, none bool) error
- func Connect(ctx context.Context, d Deps, r ConnectRequest) int
- func DefaultRouterVersion() string
- func Disconnect(ctx context.Context, d Deps, r ConnectRequest) int
- func Install(ctx context.Context, d Deps, r Request) int
- func PrintJSON(w io.Writer, r Report) error
- func PrintStatus(w io.Writer, rep StatusReport) error
- func PrintText(w io.Writer, r Report) error
- func RouterPageClear(ctx context.Context, d Deps, r Request) int
- func RouterPageSet(ctx context.Context, d Deps, r Request) int
- func RouterPageShow(ctx context.Context, d Deps, r Request) int
- func RouterPause(ctx context.Context, d Deps, r Request) int
- func RouterResume(ctx context.Context, d Deps, r Request) int
- func RouterSettings(ctx context.Context, d Deps, r Request) int
- func RunCheck(ctx context.Context, d Deps, r Request) int
- func RunStatus(ctx context.Context, d Deps, r Request) int
- func RunWhoami(ctx context.Context, d Deps, r Request) int
- func Uninstall(ctx context.Context, d Deps, r Request) int
- func WorkloadsAccessGrant(ctx context.Context, d Deps, r Request) int
- func WorkloadsAccessRevoke(ctx context.Context, d Deps, r Request) int
- func WorkloadsAccessShow(ctx context.Context, d Deps, r Request) int
- func WorkloadsList(ctx context.Context, d Deps, r Request) int
- func WorkloadsNap(ctx context.Context, d Deps, r Request) int
- func WorkloadsOffboard(ctx context.Context, d Deps, r Request) int
- func WorkloadsOnboard(ctx context.Context, d Deps, r Request) int
- func WorkloadsPageClear(ctx context.Context, d Deps, r Request) int
- func WorkloadsPageSet(ctx context.Context, d Deps, r Request) int
- func WorkloadsPageShow(ctx context.Context, d Deps, r Request) int
- func WorkloadsPause(ctx context.Context, d Deps, r Request) int
- func WorkloadsResume(ctx context.Context, d Deps, r Request) int
- func WorkloadsScheduleChange(ctx context.Context, d Deps, r Request) int
- func WorkloadsScheduleClear(ctx context.Context, d Deps, r Request) int
- func WorkloadsScheduleList(ctx context.Context, d Deps, r Request) int
- func WorkloadsScheduleSet(ctx context.Context, d Deps, r Request) int
- func WorkloadsScheduleShow(ctx context.Context, d Deps, r Request) int
- func WorkloadsSettings(ctx context.Context, d Deps, r Request) int
- func WorkloadsShow(ctx context.Context, d Deps, r Request) int
- func WorkloadsWake(ctx context.Context, d Deps, r Request) int
- type APIReport
- type BillingReport
- type Binding
- type CommandReport
- type Condition
- type ConnectRequest
- type Deps
- type GoogleGrant
- type Grant
- type GrantStatus
- type IPList
- type Manager
- type ManagerInfo
- type Policy
- type ProjectInfo
- type Rbac
- type RbacPlan
- type RbacRemoval
- type Record
- type RecordBinding
- type RecordGrant
- type RecordIPList
- type RecordRbac
- type Report
- type Request
- type Resource
- type ResourcePolicy
- type ResourceStatus
- type Result
- type RouterStatus
- type StatusReport
- type WhoamiReport
Constants ¶
const (
// MinWakeTimeout and MaxWakeTimeout are the wake timeout's range on Google Cloud, for every command that takes one (onboard and
// the settings): a wake fits the controller's request, whose range is the router's (router/gcp/src/onboarding.mjs).
MinWakeTimeout, MaxWakeTimeout = 60, 1700
)
Variables ¶
This section is empty.
Functions ¶
func CheckFallbackTypes ¶ added in v0.14.0
CheckFallbackTypes validates --fallback-type: at most 5, each a machine type's name, none twice. The router checks each against the VMs' zones.
func CheckIPLists ¶
CheckIPLists refuses a bad set of lists, and --ip-list with --no-ip-lists.
func Connect ¶ added in v0.14.0
func Connect(ctx context.Context, d Deps, r ConnectRequest) int
Connect is `dormeto gcp connect`: 0 when connected or up to date (or the plan only, with DryRun, or declined), 1 when the manager or a check refuses or Google does, 2 for a bad project or scope or no --yes without a terminal, 130 when interrupted.
func DefaultRouterVersion ¶ added in v0.14.0
func DefaultRouterVersion() string
DefaultRouterVersion is the install's default router version, the newest --version takes: embeddedRouterVersion.
func Disconnect ¶ added in v0.14.0
func Disconnect(ctx context.Context, d Deps, r ConnectRequest) int
Disconnect is `dormeto gcp disconnect`: 0 when disconnected (or the plan only, with DryRun, or declined), 1 when the manager has no connection through the project, a check fails or Google refuses, 2 for a bad project or no --yes without a terminal, 130 when interrupted.
func Install ¶
Install is `dormeto gcp routers install`: 0 when installed or up to date (or the plan only, with DryRun, or declined), 1 when a check fails or Google refuses, 2 for a bad region, image or version, flags that contradict one another, or no --yes without a terminal, 130 when interrupted.
func PrintStatus ¶
func PrintStatus(w io.Writer, rep StatusReport) error
PrintStatus prints the report, one line each.
func RouterPageClear ¶ added in v0.14.0
func RouterPageSet ¶ added in v0.14.0
func RouterPageShow ¶ added in v0.14.0
RouterPageShow, RouterPageSet and RouterPageClear are `dormeto gcp routers waiting-page show|set|clear`.
func RouterPause ¶ added in v0.14.0
RouterPause is `dormeto gcp routers pause --reason <text> [--until <time>] [--keep-asleep]`.
func RouterResume ¶ added in v0.14.0
RouterResume is `dormeto gcp routers resume`.
func RouterSettings ¶ added in v0.14.0
RouterSettings is `dormeto gcp routers settings [flags]`: with no flag, the router's level is shown.
func RunCheck ¶
RunCheck is `dormeto gcp check`: the report printed, and the exit code: 0 when every command is allowed, 1 when any is not or Google refuses.
func RunWhoami ¶ added in v0.15.0
RunWhoami is `dormeto gcp whoami`: 0, or 1 when the project is not visible to the account or Google refuses.
func Uninstall ¶
Uninstall is `dormeto gcp routers uninstall`: 0 when uninstalled (or the plan only, with DryRun, or declined), 1 when a check fails, workloads are onboarded without Force, there is no router or Google refuses, 2 for a bad region or no --yes without a terminal, 130 when interrupted.
func WorkloadsAccessGrant ¶
WorkloadsAccessGrant is `dormeto gcp workloads access grant`.
func WorkloadsAccessRevoke ¶
WorkloadsAccessRevoke is `dormeto gcp workloads access revoke`.
func WorkloadsAccessShow ¶
WorkloadsAccessShow is `dormeto gcp workloads access show`: what is in the cluster and what grant would write.
func WorkloadsList ¶
WorkloadsList is `dormeto gcp workloads list`.
func WorkloadsNap ¶
WorkloadsNap is `dormeto gcp workloads nap <id>`.
func WorkloadsOffboard ¶
WorkloadsOffboard is `dormeto gcp workloads offboard <id>`.
func WorkloadsOnboard ¶
WorkloadsOnboard is `dormeto gcp workloads onboard`.
func WorkloadsPageClear ¶ added in v0.14.0
func WorkloadsPageSet ¶ added in v0.14.0
func WorkloadsPageShow ¶ added in v0.14.0
WorkloadsPageShow, WorkloadsPageSet and WorkloadsPageClear are `dormeto gcp workloads waiting-page show|set|clear <id>`.
func WorkloadsPause ¶
WorkloadsPause is `dormeto gcp workloads pause <id> --reason <text>`.
func WorkloadsResume ¶
WorkloadsResume is `dormeto gcp workloads resume <id>`.
func WorkloadsScheduleChange ¶ added in v0.15.0
WorkloadsScheduleChange is `dormeto gcp schedule add|remove|except|edit <id>`: r.ScheduleChange.
func WorkloadsScheduleClear ¶
WorkloadsScheduleClear is `dormeto gcp schedule clear <id>`.
func WorkloadsScheduleList ¶ added in v0.15.0
WorkloadsScheduleList is `dormeto gcp schedule list`.
func WorkloadsScheduleSet ¶
WorkloadsScheduleSet is `dormeto gcp schedule set <id> --file <schedule.json>`.
func WorkloadsScheduleShow ¶
WorkloadsScheduleShow is `dormeto gcp schedule show <id>`.
func WorkloadsSettings ¶ added in v0.14.0
WorkloadsSettings is `dormeto gcp workloads settings <id>... [flags]`.
func WorkloadsShow ¶
WorkloadsShow is `dormeto gcp workloads show <id>`.
Types ¶
type BillingReport ¶
BillingReport tells whether the project is linked to an open billing account (Checked false: it could not be read, a warning says why). Without billing, Google refuses to turn the APIs on.
type Binding ¶
type Binding struct {
Role string `json:"role"`
Members []string `json:"members"`
Condition *Condition `json:"condition,omitempty"`
// contains filtered or unexported fields
}
Binding is a role given to members, under an optional condition.
func (Binding) MarshalJSON ¶
func (*Binding) UnmarshalJSON ¶
type CommandReport ¶
type CommandReport struct {
Command string `json:"command"`
Held []string `json:"held"`
Missing []string `json:"missing"`
// Optional is a line that does not fail the check: onboard --resource's, the load-balancer check's reads.
Optional bool `json:"optional,omitempty"`
}
CommandReport is the verdict for one command.
func (CommandReport) OK ¶
func (c CommandReport) OK() bool
OK tells that the caller holds every permission of the command.
type Condition ¶
type Condition struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Expression string `json:"expression"`
Location string `json:"location,omitempty"`
// contains filtered or unexported fields
}
Condition is an IAM condition; two conditions are equal when their titles and expressions are.
func (Condition) MarshalJSON ¶
func (*Condition) UnmarshalJSON ¶
type ConnectRequest ¶ added in v0.14.0
type ConnectRequest struct {
Project string
Scopes []string
Configuration string
Profile, Env string
ManagerRegion, APIURL string
Yes, DryRun, JSON bool
// DeleteRoles is disconnect's --delete-roles: the custom roles deleted, not left in place.
DeleteRoles bool
Manager Manager
}
ConnectRequest is what the flags of connect and disconnect ask: the host project, the scopes (connect's --scope, organizations/<n>, folders/<n> or projects/<id>), the gcloud configuration, the AWS profile, environment, region and API URL of the manager (named in the commands the runs tell to run; Env is used when the manager does not say its own), and the manager.
type Deps ¶
type Deps struct {
Google *gcp.Client
// Prompter asks for a confirmation; only when Terminal (stdin is a terminal) and --yes is not given.
Prompter install.Prompter
Terminal bool
Out io.Writer
Err io.Writer
Now func() time.Time
// Sleep waits between the retries of a call Google is not ready for yet.
Sleep func(ctx context.Context, d time.Duration) error
// Cache is the user's cache directory ($XDG_CACHE_HOME, else ~/.cache): an install's pending record waits in
// <Cache>/dormeto/gcp/ until the router's database holds it.
Cache string
Version string // the CLI's own version
}
Deps are what the runs use: the Google client (its token source names the account), the person's terminal, the output, the clock, the cache directory and the CLI's version.
type GoogleGrant ¶
type GoogleGrant struct {
Role string `json:"role"`
Member string `json:"member"`
Step string `json:"step"`
}
GoogleGrant is a grant Google added on its own during the install, after Step; "<step> (seen later)" when the run after a stopped one found it (Google acting after the stop), "install (seen later)" when a run after a finished install did.
type Grant ¶
type Grant struct {
Role string `json:"role"`
Member string `json:"member"`
Condition *Condition `json:"condition,omitempty"`
}
Grant is one member of one role, under an optional condition.
func Add ¶
Add gives each grant's member its role under its condition, joining the binding of the same role and condition (or creating one). It never removes anything and returns the grants that were not there yet.
func Diff ¶
Diff lists the grants in after and not in before, and those in before and not in after, each sorted by role, member and condition. Either policy may be nil.
func Remove ¶
Remove takes each grant's member out of the binding of its role and condition, and only that member; a binding left empty is dropped. A deleted service account's member (deleted:serviceAccount:<email>?uid=<n>) is matched by its email. It returns the grants removed, with the member as it was in the policy.
type GrantStatus ¶
type GrantStatus struct {
RecordGrant
Present bool `json:"present"`
Error string `json:"error,omitempty"`
}
GrantStatus is a recorded grant and whether its resource's policy holds it now; Error why that policy was not read.
type IPList ¶
IPList is one list of --ip-list; RefreshHours is how often the router downloads it again.
func ParseIPList ¶
ParseIPList reads the value of one --ip-list. An error is a bad flag (exit 2). The period is refresh_hours, AWS's name (the router module's).
type Manager ¶ added in v0.14.0
type Manager interface {
About(ctx context.Context) (ManagerInfo, error)
// GoogleConnection is the record, nil when there is none.
GoogleConnection(ctx context.Context) (*fleet.GoogleConnection, error)
PutGoogleConnection(ctx context.Context, rec fleet.GoogleConnection) (*fleet.GoogleConnection, error)
DeleteGoogleConnection(ctx context.Context) error
// Disconnected is when the manager's audit last recorded the disconnect of a host project, zero when it holds none.
Disconnected(ctx context.Context, host string) (time.Time, error)
}
Manager is the Dormeto manager as connect and disconnect use it, through its /iam API: what it says of itself, its connection's record, and when its audit last recorded a disconnect.
type ManagerInfo ¶ added in v0.14.0
type ManagerInfo struct {
Version, Account, Env, URL string
}
ManagerInfo is what the manager says of itself: its version (/health), its AWS account (the caller's: the manager's API admits IAM callers of its own account only), its environment (/update; empty: --env's) and its API's URL.
type Policy ¶
type Policy struct {
Version int `json:"version,omitempty"`
Etag string `json:"etag,omitempty"`
Bindings []Binding `json:"bindings,omitempty"`
// contains filtered or unexported fields
}
Policy is an IAM policy. Fields the CLI does not know are kept as they were read, so that writing the policy back never drops them.
func (Policy) MarshalJSON ¶
MarshalJSON writes the known fields and the kept ones.
func (*Policy) UnmarshalJSON ¶
UnmarshalJSON keeps the fields other than version, etag and bindings.
type ProjectInfo ¶
type ProjectInfo struct {
ID string `json:"id"`
Number string `json:"number"`
Parent string `json:"parent"`
}
ProjectInfo is the project as the report names it; Number is empty when the caller cannot see it.
type Rbac ¶
type Rbac struct {
Cluster string `json:"cluster"`
Namespace string `json:"namespace"`
Workload string `json:"workload"`
ServiceAccount string `json:"serviceAccount"`
}
Rbac is the Kubernetes access of one workload: its cluster as <location>/<name>, its namespace, its ID, and the router's service account (an email) that gets the access.
type RbacPlan ¶
type RbacPlan struct {
Rbac
Endpoint string `json:"endpoint"`
Role rbacChange `json:"role"`
RoleBinding rbacChange `json:"roleBinding"`
}
RbacPlan is what is in the cluster and what a grant would write.
type RbacRemoval ¶
type RbacRemoval struct {
Removed []string `json:"removed"`
Left []string `json:"left"`
Subjects []string `json:"subjects,omitempty"`
}
RbacRemoval is what a removal did: what it removed, the objects it left (someone else's, or ours while another subject holds them), and the subjects that still hold those of ours.
type Record ¶
type Record struct {
CLI string `json:"cli"`
Image string `json:"image"`
RouterVersion string `json:"routerVersion"`
Region string `json:"region"`
ServiceAccount string `json:"serviceAccount"`
Resources []Resource `json:"resources"`
Grants []RecordGrant `json:"grants"`
Google []GoogleGrant `json:"google"`
Before []RecordBinding `json:"before"`
InstalledAt string `json:"installedAt"`
UpdatedAt string `json:"updatedAt"`
By string `json:"by"`
// Running is the step an install was at when it wrote the record without having finished ("" once one has): the
// next run shows the project's grants that appeared since and that the record does not explain, and records those of
// Google's service agents as Google's, after "<Running> (seen later)".
Running string `json:"running,omitempty"`
// Enabling are the APIs an apis step asked Google to turn on and did not see on before it stopped: the next run
// records those it finds on.
Enabling []string `json:"enabling,omitempty"`
// Features are the optional features installed (--with), sorted; a run without --with keeps them.
Features []string `json:"features,omitempty"`
// IPLists are the router's IP lists, as DMT_IP_LISTS holds them on both services; a run without --ip-list nor
// --no-ip-lists keeps them.
IPLists []RecordIPList `json:"ipLists,omitempty"`
// CustomPages is the router's custom waiting pages switch, as DMT_CUSTOM_PAGES=1 holds it on both services; a run without
// --custom-pages keeps it.
CustomPages bool `json:"customPages,omitempty"`
// Rbac is the Kubernetes access written in clusters for the workloads, listed before it is applied and until it is
// removed. The uninstall says what is left of it: it does not reach clusters.
Rbac []RecordRbac `json:"rbac,omitempty"`
// Digest is the digest Dormeto's public image is deployed by (--version, or the default version): the services run
// Image's name without its tag, @Digest (<name>@sha256:…). Empty for an image of --image, deployed as given.
Digest string `json:"digest,omitempty"`
// AccessOnly is an install of the access without the router (--access-only): later runs keep it until one with
// --version or --image. An older CLI's record without an image is read as such.
AccessOnly bool `json:"accessOnly,omitempty"`
// NoLogView says that the logView step found no _Default bucket in the global location (the view's creation answered 404):
// the router has no log view, nor its grant, nor DMT_LOG_VIEW, and its idle check counts every request. A later run tries
// the view again.
NoLogView bool `json:"noLogView,omitempty"`
// Operations are the names of the Google operations that create a resource, by "<kind>/<name>" as Resources lists it:
// written when the install starts the creation, removed once the resource is seen. The uninstall waits for one before
// it deletes a resource that answers 404 meanwhile, so a creation still running is not orphaned.
Operations map[string]string `json:"operations,omitempty"`
}
Record is the install record. Its rule: Grants and Resources are Dormeto's that are present after the install, added by it or found by it (a run adds what it finds of the router's, so a record rebuilt after a loss is whole again); Google lists the grants Google added, during an install or seen by a later run, never removed; Before is the project's bindings before the first install, for the uninstall only (which removes only the grants that are not in it; an install's verification compares with its own run's first read). Image and RouterVersion are the router part's (empty for the access alone); times are RFC 3339 UTC; By is the gcloud account that ran the install.
type RecordBinding ¶
type RecordBinding struct {
Role string `json:"role"`
Members []string `json:"members"`
Condition *Condition `json:"condition,omitempty"`
}
RecordBinding is a binding of the project's policy before the first install.
type RecordGrant ¶
type RecordGrant struct {
Role string `json:"role"`
Member string `json:"member"`
On string `json:"on"`
Condition *Condition `json:"condition,omitempty"`
}
RecordGrant is one of the router's grants; On is project, queue, serviceAccount (the router's own ones) or controller.
type RecordIPList ¶
type RecordIPList struct {
Name string `json:"name"`
URL string `json:"url"`
Action string `json:"action"`
RefreshHours int `json:"refreshHours"`
}
RecordIPList is a list as the install record and the router's DMT_IP_LISTS hold it.
type RecordRbac ¶
type RecordRbac struct {
Cluster string `json:"cluster"`
Namespace string `json:"namespace"`
Workload string `json:"workload"`
}
RecordRbac is the Role and RoleBinding dormeto-<workload> of a namespace, in a cluster named <location>/<name>.
type Report ¶
type Report struct {
Project ProjectInfo `json:"project"`
Account string `json:"account"`
Commands []CommandReport `json:"commands"`
APIs APIReport `json:"apis"`
Billing BillingReport `json:"billing"`
Warnings []string `json:"warnings"`
// Visible is false when the caller has no role in the project; the APIs were then not checked.
Visible bool `json:"-"`
// APIsNote is why the APIs were not checked, when the services listing was refused.
APIsNote string `json:"-"`
// contains filtered or unexported fields
}
Report is the result of Check.
func Check ¶
Check tells, per command, the permissions the caller lacks in the project. A caller with no role in the project is a report (every command refused), not an error; any other refusal by Google is an error.
type Request ¶
type Request struct {
Project, Region, Image string
Configuration string
Yes, DryRun, JSON, Force bool
// The install's router (design §4): Version is --version (Dormeto's public image of that version), AccessOnly
// --access-only (the access without the router); Image, --image, is a router image of the customer's own.
Version string
AccessOnly bool
// The workloads commands: the workload's ID (an argument, or --id of onboard), the URL map and backend service to
// onboard, and the settings given (nil: not given).
ID, URLMap, BackendService string
// Resource is onboard's --resource: a standalone workload's resource, by its path, in place of the URL map and the backend
// service. Idle are its idle signals (idleCpuPercent, idleNetworkBytes, idleMetric: a value, "off", or nil to inherit), and
// Unchecked is --unchecked: a refused listing of the project's backend services does not stop the onboarding.
Resource string
Idle map[string]any
Unchecked bool
// Name is --name of onboard (the workload's name for people, trimmed; "": the router's, the ID) and Tags its --tag, Dormeto's
// labels (nil: none), both checked by the command.
Name string
Tags map[string]string
IdleMinutes *int
Hibernate *bool
// The onboard command's load balancer (--load-balancer: global, regional, classic, internal or cross-region-internal), wake timeout (--wake-timeout-seconds, nil:
// not given) and Cloud SQL companions (--cloud-sql); its GKE cluster is GKECluster. RequestLogs is --request-logs: the
// backend service's request logs turned on, every request, for the idle check to read (the G4 design's §5).
LoadBalancer string
WakeTimeout *int
// WakeMode is --wake-mode (any or browser) and FallbackTypes --fallback-type, the machine types a VM of an unmanaged group may
// run on while its own is out of capacity; none given, none sent.
WakeMode string
FallbackTypes []string
CloudSQL []string
RequestLogs bool
// The settings commands: the workloads' IDs (the argument of settings is one or more), and the flat body the level flags
// give: each key a value, or null to give it back to the levels. A router's: hibernate, joinMinutes and defaults.
// Empty for the router's: its level is shown.
IDs []string
Levels map[string]any
// The waiting-page commands: the document `set` writes, checked by the command before any call (ID is the workload's).
Page *fleet.PageDoc
// The schedule and pause commands: the schedule set sends (read by the command from --file: a JSON object), the pause's
// reason, --keep-asleep and --until (RFC 3339: the command reads --for and HH:MM into it).
Schedule json.RawMessage
Reason, Until string
// ScheduleChange is the change of add, remove, except or edit, and All is schedule list's --all.
ScheduleChange *schedule.Change
All bool
KeepAsleep bool
// The wake's --wait: the workload followed until it is awake, at most Timeout.
Wait bool
Timeout time.Duration
// The list's filters, applied by the CLI to the controller's list (AWS's flags): the states (upper case; any of them),
// a text the workload's ID or name holds (any case), and the Dormeto tags it carries (all of them). None: every workload.
States []string
Search string
HasTags map[string]string
// Kind is the list's --kind: http or standalone ("": both), checked by the command.
Kind string
// The access and onboard commands: the cluster as <location>/<name> (--gke-cluster); access's: the workload's namespace,
// and ID is --workload.
GKECluster, Namespace string
// With are the optional features (--with): cloud-sql, gke.
With []string
// IPLists are the router's IP lists (--ip-list); NoIPLists clears them (--no-ip-lists).
IPLists []IPList
NoIPLists bool
// DeleteRoles is routers uninstall's --delete-roles: the custom roles deleted with the last router, not left in place.
DeleteRoles bool
// CustomPages is --custom-pages: the router's custom waiting pages on, or off with --custom-pages=false; nil when not
// given, the install record's switch kept.
CustomPages *bool
}
Request is what the flags ask. Configuration is --gcloud-configuration ("": gcloud's active one), named in the gcloud commands the CLI tells to run.
type Resource ¶
Resource is one resource of the router's access. Kinds: api (an API the install turned on: never turned off), role (projects/<id>/roles/<role>), serviceAccount (projects/<id>/serviceAccounts/<email>), tagKey (tagKeys/<n>, or <id>/dormeto until its creation has named it), tagValue (tagValues/<n>, or <id>/dormeto/managed), database (projects/<id>/databases/<db>), queue (projects/<id>/locations/<region>/queues/<queue>), logView (projects/<id>/locations/global/buckets/_Default/views/<view>), and of the router part: service (projects/<id>/locations/<region>/services/<service>), neg (projects/<id>/regions/<region>/networkEndpointGroups/<neg>), job (projects/<id>/locations/<region>/jobs/<job>).
type ResourcePolicy ¶
ResourcePolicy is where the IAM policy of one resource is read and written. GetByQuery reads with a GET whose URL carries the requested version (Cloud Run v2); PostByQuery with a POST whose URL carries it and whose body is empty (IAM's service accounts); otherwise Get is a POST with the version in the body.
func ProjectPolicy ¶
func ProjectPolicy(project string) ResourcePolicy
ProjectPolicy is the policy of a project.
func QueuePolicy ¶
func QueuePolicy(project, region, queue string) ResourcePolicy
QueuePolicy is the policy of a Cloud Tasks queue.
func RunPolicy ¶
func RunPolicy(project, region, service string) ResourcePolicy
RunPolicy is the policy of a Cloud Run service.
func ServiceAccountPolicy ¶
func ServiceAccountPolicy(project, email string) ResourcePolicy
ServiceAccountPolicy is the policy of a service account: IAM v1 takes the requested version as a query parameter, the body empty.
type ResourceStatus ¶
type ResourceStatus struct {
Kind string `json:"kind"`
Name string `json:"name"`
OK bool `json:"ok"`
State string `json:"state"`
Detail string `json:"detail,omitempty"`
}
ResourceStatus is a resource's live state. Kinds: service, health (the controller's), neg, queue, job, database, record (an install record that cannot be read).
type Result ¶
type Result struct{ Before, After *Policy }
Result is a policy as read and as written by Update.
func Update ¶
func Update(ctx context.Context, c *gcp.Client, rp ResourcePolicy, mutate func(*Policy) error) (Result, error)
Update reads the policy, applies mutate to a copy and writes it back with the etag read; nothing is written when mutate changed no grant. A write refused for the etag (409 or ABORTED) is retried, up to 5 attempts in all, each with a fresh read. Version 3 is written whenever a binding has a condition, else the version read is kept.
type RouterStatus ¶
type RouterStatus struct {
Router string `json:"router"`
Region string `json:"region"`
OK bool `json:"ok"`
Record *Record `json:"record"`
Version string `json:"version,omitempty"`
// Report is the controller's health "report" as it answered (a router of 0.41.0 and above: where it reports to the
// manager), null when it was told nowhere; absent from a router that answers none.
Report json.RawMessage `json:"report,omitempty"`
Resources []ResourceStatus `json:"resources"`
Grants []GrantStatus `json:"grants"`
}
RouterStatus is one router: Record is nil without an install record; Version is what the controller answers; OK that every resource and grant is as it should be.
type StatusReport ¶
type StatusReport struct {
Project ProjectInfo `json:"project"`
Routers []RouterStatus `json:"routers"`
}
StatusReport is a project's routers.
type WhoamiReport ¶ added in v0.15.0
type WhoamiReport struct {
Account string `json:"account"`
Configuration string `json:"configuration"`
Project ProjectInfo `json:"project"`
}
WhoamiReport is `gcp whoami --json`.
Source Files
¶
- account.go
- apis.go
- check.go
- connect.go
- connect_scan.go
- custompages.go
- database.go
- disconnect.go
- features.go
- grants.go
- iam.go
- image.go
- install.go
- iplists.go
- logview.go
- output.go
- queue.go
- rbac.go
- record.go
- requestlogs.go
- roles.go
- router.go
- router_pause.go
- standalone.go
- status.go
- tag.go
- uninstall.go
- verify.go
- whoami.go
- workloads.go
- workloads_features.go
- workloads_page.go
- workloads_schedule.go
- workloads_settings.go
- writes.go