cluster_configs.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package models
  2. import "gorm.io/gorm"
  3. // ClusterConfig that extends gorm.Model
  4. //
  5. // ClusterConfig represents the configuration for a single cluster-user pair. This gets
  6. // associated with a specific user, and is primarily used for simplicity.
  7. type ClusterConfig struct {
  8. gorm.Model
  9. // Name is the name of the cluster
  10. Name,
  11. // Server is the endpoint of the kube apiserver for a cluster
  12. Server,
  13. // Context is the name of the context
  14. Context,
  15. // User is the name of the user for a cluster
  16. User string
  17. // UserID is the foreign key of User, gorm creates by default
  18. UserID uint
  19. }
  20. // ClusterConfigExternal is the ClusterConfig type sent over REST
  21. type ClusterConfigExternal struct {
  22. Name string `json:"name"`
  23. Server string `json:"server"`
  24. Context string `json:"context"`
  25. User string `json:"user"`
  26. }
  27. // Externalize generates an external ClusterConfig to be shared over REST
  28. func (cc *ClusterConfig) Externalize() *ClusterConfigExternal {
  29. return &ClusterConfigExternal{
  30. Name: cc.Name,
  31. Server: cc.Server,
  32. Context: cc.Context,
  33. User: cc.User,
  34. }
  35. }