Documentation
¶
Overview ¶
Package orders is the client of machinery-order-service's REST API (docs/adr/0002-order-through-the-order-service.md): orders go through the service, which renders with the caller's token and opens the pull request with its own GitHub identity. claims never touches git for them.
Index ¶
- Variables
- func IsFinal(phase string) bool
- type AutoMerge
- type AutoMergeRule
- type Client
- func (c *Client) Cancel(id string) (*Order, error)
- func (c *Client) Clusters() ([]Cluster, error)
- func (c *Client) Create(req CreateRequest) (*Order, error)
- func (c *Client) Get(id string) (*Order, error)
- func (c *Client) List(opt ListOptions) ([]*Order, error)
- func (c *Client) Teardown(id string, req TeardownRequest) (*Order, error)
- type Cluster
- type CreateRequest
- type ListOptions
- type Order
- type TeardownRequest
Constants ¶
This section is empty.
Variables ¶
var Final = []string{"Ready", "Failed", "Cancelled", "Deleted"}
Final phases: nothing more happens to the order without someone acting.
Functions ¶
Types ¶
type AutoMerge ¶ added in v0.29.0
type AutoMerge struct {
Method string `json:"method,omitempty"`
Rules []AutoMergeRule `json:"rules,omitempty"`
}
AutoMerge are a cluster's auto-merge rules.
type AutoMergeRule ¶ added in v0.29.0
type AutoMergeRule struct {
Name string `json:"name"`
Users []string `json:"users,omitempty"`
Groups []string `json:"groups,omitempty"`
Templates []string `json:"templates,omitempty"`
Parameters map[string][]string `json:"parameters,omitempty"`
// Actions: order, teardown; empty = order only.
Actions []string `json:"actions,omitempty"`
}
AutoMergeRule allows auto-merge for some orderers, templates and parameter values.
func (AutoMergeRule) String ¶ added in v0.29.0
func (r AutoMergeRule) String() string
String is the rule in one line, e.g. "persona-test-vms: group:default/ai-personas; templates vm; size=small".
type Client ¶
Client talks to one machinery-order-service.
func (*Client) Create ¶
func (c *Client) Create(req CreateRequest) (*Order, error)
Create places an order.
type Cluster ¶
type Cluster struct {
Name string `json:"name"`
Lab string `json:"lab,omitempty"`
Cordoned bool `json:"cordoned"`
Repository string `json:"repository,omitempty"`
OrdersPath string `json:"ordersPath,omitempty"`
// AutoMerge says who may order with --auto-merge on this cluster.
AutoMerge *AutoMerge `json:"autoMerge,omitempty"`
}
Cluster is a management cluster orders can go to.
type CreateRequest ¶
type CreateRequest struct {
Template string `json:"template"`
Parameters map[string]any `json:"parameters,omitempty"`
ManagementCluster string `json:"managementCluster"`
Reason string `json:"reason,omitempty"`
// AutoMerge asks the service to merge the pull request once its checks
// pass; the service refuses (403) unless a rule of the cluster allows it.
AutoMerge bool `json:"autoMerge,omitempty"`
}
CreateRequest is the body of POST /api/v1/orders.
type ListOptions ¶
ListOptions narrow a list.
type Order ¶
type Order struct {
Metadata struct {
Name string `json:"name"`
CreationTimestamp time.Time `json:"creationTimestamp"`
ResourceVersion string `json:"resourceVersion,omitempty"`
} `json:"metadata"`
Spec struct {
Template string `json:"template"`
RequestedBy string `json:"requestedBy,omitempty"`
Reason string `json:"reason,omitempty"`
Placement struct {
ManagementCluster string `json:"managementCluster"`
} `json:"placement"`
Cancel bool `json:"cancel,omitempty"`
AutoMerge *struct {
Rule string `json:"rule"`
} `json:"autoMerge,omitempty"`
Teardown *struct {
Attempt int `json:"attempt"`
RequestedBy string `json:"requestedBy,omitempty"`
Reason string `json:"reason,omitempty"`
AutoMerge *struct {
Rule string `json:"rule"`
} `json:"autoMerge,omitempty"`
} `json:"teardown,omitempty"`
} `json:"spec"`
Status struct {
Phase string `json:"phase,omitempty"`
Message string `json:"message,omitempty"`
Delivery *struct {
PullRequest *struct {
Number int `json:"number"`
URL string `json:"url"`
State string `json:"state"`
} `json:"pullRequest,omitempty"`
} `json:"delivery,omitempty"`
Teardown *struct {
Attempt int `json:"attempt"`
Outcome string `json:"outcome,omitempty"`
Delivery *struct {
PullRequest *struct {
Number int `json:"number"`
URL string `json:"url"`
State string `json:"state"`
} `json:"pullRequest,omitempty"`
} `json:"delivery,omitempty"`
} `json:"teardown,omitempty"`
Live *struct {
Found bool `json:"found"`
Ready bool `json:"ready"`
StatusMessage string `json:"statusMessage,omitempty"`
Address string `json:"address,omitempty"`
} `json:"live,omitempty"`
History []struct {
Phase string `json:"phase"`
Time time.Time `json:"time"`
Message string `json:"message,omitempty"`
} `json:"history,omitempty"`
Conditions []struct {
Type string `json:"type"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
} `json:"conditions,omitempty"`
} `json:"status"`
Raw json.RawMessage `json:"-"`
}
Order is the part of an Order claims shows; Raw is the full object as the service sent it (for -o json).
func (*Order) TeardownOutcome ¶ added in v0.30.0
TeardownOutcome is the outcome of the current teardown request: "" while it runs or when none was asked for, else Withdrawn, Failed or Deleted.
func (*Order) TeardownPRURL ¶ added in v0.30.0
TeardownPRURL is the teardown pull request's URL, "" before there is one.
func (*Order) TearingDown ¶ added in v0.30.0
TearingDown reports whether a teardown was asked for and has no outcome yet, so Ready is not where the order stops.
type TeardownRequest ¶ added in v0.30.0
type TeardownRequest struct {
Reason string `json:"reason,omitempty"`
AutoMerge bool `json:"autoMerge,omitempty"`
}
TeardownRequest is the body of POST /api/v1/orders/{id}/teardown.