github.com/rancher/types@v0.0.0-20220328215343-4370ff10ecd5/apis/management.cattle.io/v3/logging_types.go (about) 1 package v3 2 3 import ( 4 "strings" 5 6 "github.com/rancher/norman/condition" 7 "github.com/rancher/norman/types" 8 v1 "k8s.io/api/core/v1" 9 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 10 ) 11 12 type ClusterLogging struct { 13 types.Namespaced 14 15 metav1.TypeMeta `json:",inline"` 16 // Standard object’s metadata. More info: 17 // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata 18 metav1.ObjectMeta `json:"metadata,omitempty"` 19 // Specification of the desired behavior of the the cluster. More info: 20 // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status 21 Spec ClusterLoggingSpec `json:"spec"` 22 // Most recent observed status of the cluster. More info: 23 // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status 24 Status ClusterLoggingStatus `json:"status"` 25 } 26 27 func (c *ClusterLogging) ObjClusterName() string { 28 return c.Spec.ObjClusterName() 29 } 30 31 type ProjectLogging struct { 32 types.Namespaced 33 34 metav1.TypeMeta `json:",inline"` 35 // Standard object’s metadata. More info: 36 // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata 37 metav1.ObjectMeta `json:"metadata,omitempty"` 38 // Specification of the desired behavior of the the cluster. More info: 39 // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status 40 Spec ProjectLoggingSpec `json:"spec"` 41 // Most recent observed status of the cluster. More info: 42 // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status 43 Status ProjectLoggingStatus `json:"status"` 44 } 45 46 func (p *ProjectLogging) ObjClusterName() string { 47 return p.Spec.ObjClusterName() 48 } 49 50 type LoggingCommonField struct { 51 DisplayName string `json:"displayName,omitempty"` 52 OutputFlushInterval int `json:"outputFlushInterval,omitempty" norman:"default=60"` 53 OutputTags map[string]string `json:"outputTags,omitempty"` 54 EnableJSONParsing bool `json:"enableJSONParsing,omitempty"` 55 } 56 57 type LoggingTargets struct { 58 ElasticsearchConfig *ElasticsearchConfig `json:"elasticsearchConfig,omitempty"` 59 SplunkConfig *SplunkConfig `json:"splunkConfig,omitempty"` 60 KafkaConfig *KafkaConfig `json:"kafkaConfig,omitempty"` 61 SyslogConfig *SyslogConfig `json:"syslogConfig,omitempty"` 62 FluentForwarderConfig *FluentForwarderConfig `json:"fluentForwarderConfig,omitempty"` 63 CustomTargetConfig *CustomTargetConfig `json:"customTargetConfig,omitempty"` 64 } 65 66 type ClusterLoggingSpec struct { 67 LoggingTargets 68 LoggingCommonField 69 ClusterName string `json:"clusterName" norman:"type=reference[cluster]"` 70 IncludeSystemComponent *bool `json:"includeSystemComponent,omitempty" norman:"default=true"` 71 } 72 73 func (c *ClusterLoggingSpec) ObjClusterName() string { 74 return c.ClusterName 75 } 76 77 type ProjectLoggingSpec struct { 78 LoggingTargets 79 LoggingCommonField 80 ProjectName string `json:"projectName" norman:"type=reference[project]"` 81 } 82 83 func (p *ProjectLoggingSpec) ObjClusterName() string { 84 if parts := strings.SplitN(p.ProjectName, ":", 2); len(parts) == 2 { 85 return parts[0] 86 } 87 return "" 88 } 89 90 type ClusterLoggingStatus struct { 91 Conditions []LoggingCondition `json:"conditions,omitempty"` 92 AppliedSpec ClusterLoggingSpec `json:"appliedSpec,omitempty"` 93 FailedSpec *ClusterLoggingSpec `json:"failedSpec,omitempty"` 94 } 95 96 type ProjectLoggingStatus struct { 97 Conditions []LoggingCondition `json:"conditions,omitempty"` 98 AppliedSpec ProjectLoggingSpec `json:"appliedSpec,omitempty"` 99 } 100 101 var ( 102 LoggingConditionProvisioned condition.Cond = "Provisioned" 103 LoggingConditionUpdated condition.Cond = "Updated" 104 ) 105 106 type LoggingCondition struct { 107 // Type of cluster condition. 108 Type condition.Cond `json:"type"` 109 // Status of the condition, one of True, False, Unknown. 110 Status v1.ConditionStatus `json:"status"` 111 // The last time this condition was updated. 112 LastUpdateTime string `json:"lastUpdateTime,omitempty"` 113 // Last time the condition transitioned from one status to another. 114 LastTransitionTime string `json:"lastTransitionTime,omitempty"` 115 // The reason for the condition's last transition. 116 Reason string `json:"reason,omitempty"` 117 // Human-readable message indicating details about last transition 118 Message string `json:"message,omitempty"` 119 } 120 121 type ElasticsearchConfig struct { 122 Endpoint string `json:"endpoint,omitempty" norman:"required"` 123 IndexPrefix string `json:"indexPrefix,omitempty" norman:"required"` 124 DateFormat string `json:"dateFormat,omitempty" norman:"required,type=enum,options=YYYY-MM-DD|YYYY-MM|YYYY,default=YYYY-MM-DD"` 125 AuthUserName string `json:"authUsername,omitempty"` 126 AuthPassword string `json:"authPassword,omitempty" norman:"type=password"` 127 Certificate string `json:"certificate,omitempty"` 128 ClientCert string `json:"clientCert,omitempty"` 129 ClientKey string `json:"clientKey,omitempty"` 130 ClientKeyPass string `json:"clientKeyPass,omitempty"` 131 SSLVerify bool `json:"sslVerify,omitempty"` 132 SSLVersion string `json:"sslVersion,omitempty" norman:"type=enum,options=SSLv23|TLSv1|TLSv1_1|TLSv1_2,default=TLSv1_2"` 133 } 134 135 type SplunkConfig struct { 136 Endpoint string `json:"endpoint,omitempty" norman:"required"` 137 Source string `json:"source,omitempty"` 138 Token string `json:"token,omitempty" norman:"required,type=password"` 139 Certificate string `json:"certificate,omitempty"` 140 ClientCert string `json:"clientCert,omitempty"` 141 ClientKey string `json:"clientKey,omitempty"` 142 ClientKeyPass string `json:"clientKeyPass,omitempty"` 143 SSLVerify bool `json:"sslVerify,omitempty"` 144 Index string `json:"index,omitempty"` 145 } 146 147 type KafkaConfig struct { 148 ZookeeperEndpoint string `json:"zookeeperEndpoint,omitempty"` 149 BrokerEndpoints []string `json:"brokerEndpoints,omitempty"` 150 Topic string `json:"topic,omitempty" norman:"required"` 151 Certificate string `json:"certificate,omitempty"` 152 ClientCert string `json:"clientCert,omitempty"` 153 ClientKey string `json:"clientKey,omitempty"` 154 SaslUsername string `json:"saslUsername,omitempty"` 155 SaslPassword string `json:"saslPassword,omitempty" norman:"type=password"` 156 SaslScramMechanism string `json:"saslScramMechanism,omitempty" norman:"type=enum,options=sha256|sha512"` 157 SaslType string `json:"saslType,omitempty" norman:"type=enum,options=plain|scram"` 158 } 159 160 type SyslogConfig struct { 161 Endpoint string `json:"endpoint,omitempty" norman:"required"` 162 Severity string `json:"severity,omitempty" norman:"default=notice,type=enum,options=emerg|alert|crit|err|warning|notice|info|debug"` 163 Program string `json:"program,omitempty"` 164 Protocol string `json:"protocol,omitempty" norman:"default=udp,type=enum,options=udp|tcp"` 165 Token string `json:"token,omitempty" norman:"type=password"` 166 EnableTLS bool `json:"enableTls,omitempty" norman:"default=false"` 167 Certificate string `json:"certificate,omitempty"` 168 ClientCert string `json:"clientCert,omitempty"` 169 ClientKey string `json:"clientKey,omitempty"` 170 SSLVerify bool `json:"sslVerify,omitempty"` 171 } 172 173 type FluentForwarderConfig struct { 174 EnableTLS bool `json:"enableTls,omitempty" norman:"default=false"` 175 Certificate string `json:"certificate,omitempty"` 176 ClientCert string `json:"clientCert,omitempty"` 177 ClientKey string `json:"clientKey,omitempty"` 178 ClientKeyPass string `json:"clientKeyPass,omitempty"` 179 SSLVerify bool `json:"sslVerify,omitempty"` 180 Compress *bool `json:"compress,omitempty" norman:"default=true"` 181 FluentServers []FluentServer `json:"fluentServers,omitempty" norman:"required"` 182 } 183 184 type FluentServer struct { 185 Endpoint string `json:"endpoint,omitempty" norman:"required"` 186 Hostname string `json:"hostname,omitempty"` 187 Weight int `json:"weight,omitempty" norman:"default=100"` 188 Standby bool `json:"standby,omitempty" norman:"default=false"` 189 Username string `json:"username,omitempty"` 190 Password string `json:"password,omitempty" norman:"type=password"` 191 SharedKey string `json:"sharedKey,omitempty" norman:"type=password"` 192 } 193 194 type CustomTargetConfig struct { 195 Content string `json:"content,omitempty"` 196 Certificate string `json:"certificate,omitempty"` 197 ClientCert string `json:"clientCert,omitempty"` 198 ClientKey string `json:"clientKey,omitempty"` 199 } 200 201 type ClusterTestInput struct { 202 ClusterName string `json:"clusterId" norman:"required,type=reference[cluster]"` 203 LoggingTargets 204 OutputTags map[string]string `json:"outputTags,omitempty"` 205 } 206 207 func (c *ClusterTestInput) ObjClusterName() string { 208 return c.ClusterName 209 } 210 211 type ProjectTestInput struct { 212 ProjectName string `json:"projectId" norman:"required,type=reference[project]"` 213 LoggingTargets 214 OutputTags map[string]string `json:"outputTags,omitempty"` 215 } 216 217 func (p *ProjectTestInput) ObjClusterName() string { 218 if parts := strings.SplitN(p.ProjectName, ":", 2); len(parts) == 2 { 219 return parts[0] 220 } 221 return "" 222 }