cluster.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package models
  2. import "gorm.io/gorm"
  3. // Cluster type that extends gorm.Model
  4. type Cluster struct {
  5. gorm.Model
  6. Name string `json:"name"`
  7. ServiceAccountID uint `json:"service_account_id"`
  8. LocationOfOrigin string `json:"location_of_origin"`
  9. Server string `json:"server"`
  10. TLSServerName string `json:"tls-server-name,omitempty"`
  11. InsecureSkipTLSVerify bool `json:"insecure-skip-tls-verify,omitempty"`
  12. ProxyURL string `json:"proxy-url,omitempty"`
  13. // CertificateAuthorityData is encrypted at rest
  14. CertificateAuthorityData []byte `json:"certificate-authority-data,omitempty"`
  15. }
  16. // ClusterExternal is the external cluster type to be sent over REST
  17. type ClusterExternal struct {
  18. ID uint `json:"id"`
  19. ServiceAccountID uint `json:"service_account_id"`
  20. Name string `json:"name"`
  21. Server string `json:"server"`
  22. TLSServerName string `json:"tls-server-name,omitempty"`
  23. InsecureSkipTLSVerify bool `json:"insecure-skip-tls-verify,omitempty"`
  24. ProxyURL string `json:"proxy-url,omitempty"`
  25. }
  26. // Externalize generates an external Cluster to be shared over REST
  27. func (c *Cluster) Externalize() *ClusterExternal {
  28. return &ClusterExternal{
  29. ID: c.Model.ID,
  30. ServiceAccountID: c.ServiceAccountID,
  31. Name: c.Name,
  32. Server: c.Server,
  33. TLSServerName: c.TLSServerName,
  34. InsecureSkipTLSVerify: c.InsecureSkipTLSVerify,
  35. ProxyURL: c.ProxyURL,
  36. }
  37. }