|
| 1 | +// Copyright (c) HashiCorp, Inc. |
| 2 | +// SPDX-License-Identifier: MPL-2.0 |
| 3 | + |
| 4 | +package v1alpha2 |
| 5 | + |
| 6 | +import ( |
| 7 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 8 | +) |
| 9 | + |
| 10 | +type RunsCollectorSpec struct { |
| 11 | + // Organization name where the Workspace will be created. |
| 12 | + // More information: |
| 13 | + // - https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/organizations |
| 14 | + // |
| 15 | + //+kubebuilder:validation:MinLength:=1 |
| 16 | + Organization string `json:"organization"` |
| 17 | + // API Token to be used for API calls. |
| 18 | + Token Token `json:"token"` |
| 19 | + |
| 20 | + // The Agent Pool name or ID from which the controller will collect runs. |
| 21 | + // More information: |
| 22 | + // - https://developer.hashicorp.com/terraform/cloud-docs/run/states |
| 23 | + AgentPool *AgentPoolRef `json:"agentPool"` |
| 24 | +} |
| 25 | + |
| 26 | +type RunsCollectorStatus struct { |
| 27 | + // Real world state generation. |
| 28 | + ObservedGeneration int64 `json:"observedGeneration"` |
| 29 | + // The Agent Pool name or ID from which the controller will collect runs. |
| 30 | + AgentPool *AgentPoolRef `json:"agentPool,omitempty"` |
| 31 | +} |
| 32 | + |
| 33 | +//+kubebuilder:object:root=true |
| 34 | +//+kubebuilder:subresource:status |
| 35 | +//+kubebuilder:printcolumn:name="Pool ID",type=string,JSONPath=`.status.pool.ID` |
| 36 | +//+kubebuilder:printcolumn:name="Pool Name",type=string,JSONPath=`.status.pool.Name` |
| 37 | +//+kubebuilder:metadata:labels="app.terraform.io/crd-schema-version=v25.9.0" |
| 38 | + |
| 39 | +// Runs Collector scraptes HCP Terraform Run statuses from a given Agent Pool and exposes them as Prometheus-compatible metrics. |
| 40 | +// More information: |
| 41 | +// - https://developer.hashicorp.com/terraform/cloud-docs/run/remote-operations |
| 42 | +type RunsCollector struct { |
| 43 | + metav1.TypeMeta `json:",inline"` |
| 44 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 45 | + |
| 46 | + Spec RunsCollectorSpec `json:"spec"` |
| 47 | + Status RunsCollectorStatus `json:"status,omitempty"` |
| 48 | +} |
| 49 | + |
| 50 | +// +kubebuilder:object:root=true |
| 51 | + |
| 52 | +// RunsCollectorList contains a list of RunsCollector. |
| 53 | +type RunsCollectorList struct { |
| 54 | + metav1.TypeMeta `json:",inline"` |
| 55 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 56 | + Items []RunsCollector `json:"items"` |
| 57 | +} |
| 58 | + |
| 59 | +func init() { |
| 60 | + SchemeBuilder.Register(&RunsCollector{}, &RunsCollectorList{}) |
| 61 | +} |
0 commit comments