|
| 1 | +package kubernetes |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + opengovernance "github.com/opengovern/og-describer-kubernetes/discovery/pkg/es" |
| 6 | + "github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto" |
| 7 | + "github.com/turbot/steampipe-plugin-sdk/v5/plugin" |
| 8 | + "github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform" |
| 9 | +) |
| 10 | + |
| 11 | +func tableKubernetesDeployment(ctx context.Context) *plugin.Table { |
| 12 | + return &plugin.Table{ |
| 13 | + Name: "kubernetes_deployment", |
| 14 | + Description: "Kubernetes Deployment enables declarative updates for Pods and ReplicaSets.", |
| 15 | + Get: &plugin.GetConfig{ |
| 16 | + Hydrate: opengovernance.GetKubernetesDeployment, |
| 17 | + }, |
| 18 | + List: &plugin.ListConfig{ |
| 19 | + Hydrate: opengovernance.ListKubernetesDeployment, |
| 20 | + }, |
| 21 | + Columns: commonColumns([]*plugin.Column{ |
| 22 | + //// Spec Columns |
| 23 | + { |
| 24 | + Name: "replicas", |
| 25 | + Type: proto.ColumnType_INT, |
| 26 | + Description: "Number of desired pods. Defaults to 1.", |
| 27 | + Transform: transform.FromField("Description.Deployment.Spec.Replicas"), |
| 28 | + }, |
| 29 | + { |
| 30 | + Name: "selector_query", |
| 31 | + Type: proto.ColumnType_STRING, |
| 32 | + Description: "A query string representation of the selector.", |
| 33 | + Transform: transform.FromField("Description.Deployment.Spec.Selector").Transform(labelSelectorToString), |
| 34 | + }, |
| 35 | + { |
| 36 | + Name: "selector", |
| 37 | + Type: proto.ColumnType_JSON, |
| 38 | + Description: "Label selector for pods. A label selector is a label query over a set of resources.", |
| 39 | + Transform: transform.FromField("Description.Deployment.Spec.Selector"), |
| 40 | + }, |
| 41 | + { |
| 42 | + Name: "template", |
| 43 | + Type: proto.ColumnType_JSON, |
| 44 | + Description: "Template describes the pods that will be created.", |
| 45 | + Transform: transform.FromField("Description.Deployment.Spec.Template"), |
| 46 | + }, |
| 47 | + { |
| 48 | + Name: "strategy", |
| 49 | + Type: proto.ColumnType_JSON, |
| 50 | + Description: "The deployment strategy to use to replace existing pods with new ones.", |
| 51 | + Transform: transform.FromField("Description.Deployment.Spec.Strategy"), |
| 52 | + }, |
| 53 | + { |
| 54 | + Name: "min_ready_seconds", |
| 55 | + Type: proto.ColumnType_INT, |
| 56 | + Description: "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0.", |
| 57 | + Transform: transform.FromField("Description.Deployment.Spec.MinReadySeconds"), |
| 58 | + }, |
| 59 | + { |
| 60 | + Name: "revision_history_limit", |
| 61 | + Type: proto.ColumnType_INT, |
| 62 | + Description: "The number of old ReplicaSets to retain to allow rollback.", |
| 63 | + Transform: transform.FromField("Description.Deployment.Spec.RevisionHistoryLimit"), |
| 64 | + }, |
| 65 | + { |
| 66 | + Name: "paused", |
| 67 | + Type: proto.ColumnType_BOOL, |
| 68 | + Description: "Indicates that the deployment is paused.", |
| 69 | + Transform: transform.FromField("Description.Deployment.Spec.Paused"), |
| 70 | + }, |
| 71 | + { |
| 72 | + Name: "progress_deadline_seconds", |
| 73 | + Type: proto.ColumnType_INT, |
| 74 | + Description: "The maximum time in seconds for a deployment to make progress before it is considered to be failed.", |
| 75 | + Transform: transform.FromField("Description.Deployment.Spec.ProgressDeadlineSeconds"), |
| 76 | + }, |
| 77 | + |
| 78 | + //// Status Columns |
| 79 | + { |
| 80 | + Name: "observed_generation", |
| 81 | + Type: proto.ColumnType_INT, |
| 82 | + Description: "The generation observed by the deployment controller.", |
| 83 | + Transform: transform.FromField("Description.Deployment.Status.ObservedGeneration"), |
| 84 | + }, |
| 85 | + { |
| 86 | + Name: "status_replicas", |
| 87 | + Type: proto.ColumnType_INT, |
| 88 | + Description: "Total number of non-terminated pods targeted by this deployment (their labels match the selector).", |
| 89 | + Transform: transform.FromField("Description.Deployment.Status.Replicas"), |
| 90 | + }, |
| 91 | + { |
| 92 | + Name: "updated_replicas", |
| 93 | + Type: proto.ColumnType_INT, |
| 94 | + Description: "Total number of non-terminated pods targeted by this deployment that have the desired template spec.", |
| 95 | + Transform: transform.FromField("Description.Deployment.Status.UpdatedReplicas"), |
| 96 | + }, |
| 97 | + { |
| 98 | + Name: "ready_replicas", |
| 99 | + Type: proto.ColumnType_INT, |
| 100 | + Description: "Total number of ready pods targeted by this deployment.", |
| 101 | + Transform: transform.FromField("Description.Deployment.Status.ReadyReplicas"), |
| 102 | + }, |
| 103 | + { |
| 104 | + Name: "available_replicas", |
| 105 | + Type: proto.ColumnType_INT, |
| 106 | + Description: "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.", |
| 107 | + Transform: transform.FromField("Description.Deployment.Status.AvailableReplicas"), |
| 108 | + }, |
| 109 | + { |
| 110 | + Name: "unavailable_replicas", |
| 111 | + Type: proto.ColumnType_INT, |
| 112 | + Description: "Total number of unavailable pods targeted by this deployment.", |
| 113 | + Transform: transform.FromField("Description.Deployment.Status.UnavailableReplicas"), |
| 114 | + }, |
| 115 | + { |
| 116 | + Name: "conditions", |
| 117 | + Type: proto.ColumnType_JSON, |
| 118 | + Description: "Represents the latest available observations of a deployment's current state.", |
| 119 | + Transform: transform.FromField("Description.Deployment.Status.Conditions"), |
| 120 | + }, |
| 121 | + { |
| 122 | + Name: "collision_count", |
| 123 | + Type: proto.ColumnType_INT, |
| 124 | + Description: "Count of hash collisions for the Deployment. The Deployment controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ReplicaSet.", |
| 125 | + Transform: transform.FromField("Description.Deployment.Status.CollisionCount"), |
| 126 | + }, |
| 127 | + { |
| 128 | + Name: "title", |
| 129 | + Type: proto.ColumnType_STRING, |
| 130 | + Description: ColumnDescriptionTitle, |
| 131 | + Transform: transform.FromField("Description.Deployment.Name"), |
| 132 | + }, |
| 133 | + { |
| 134 | + Name: "tags", |
| 135 | + Type: proto.ColumnType_JSON, |
| 136 | + Description: ColumnDescriptionTags, |
| 137 | + Transform: transform.From(transformDeploymentTags), |
| 138 | + }, |
| 139 | + }), |
| 140 | + } |
| 141 | +} |
| 142 | + |
| 143 | +func transformDeploymentTags(_ context.Context, d *transform.TransformData) (interface{}, error) { |
| 144 | + obj := d.HydrateItem.(opengovernance.KubernetesDeployment).Description.Deployment |
| 145 | + return mergeTags(obj.Labels, obj.Annotations), nil |
| 146 | +} |
0 commit comments