github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/apis/projectcalico/v3/uisettingsgroup.go (about)

     1  // Copyright (c) 2021 Tigera, Inc. All rights reserved.
     2  
     3  package v3
     4  
     5  import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     6  
     7  const (
     8  	KindUISettingsGroup     = "UISettingsGroup"
     9  	KindUISettingsGroupList = "UISettingsGroupList"
    10  )
    11  
    12  const (
    13  	FilterTypeNone = "None"
    14  	FilterTypeUser = "User"
    15  )
    16  
    17  // +genclient
    18  // +genclient:nonNamespaced
    19  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    20  
    21  // UISettingsGroup contains the settings that dictate how many UI settings may be created for a
    22  // specific cluster/user combination. UI settings may only be persisted if there is a
    23  // corresponding UISettingsGroup resource.
    24  type UISettingsGroup struct {
    25  	metav1.TypeMeta `json:",inline"`
    26  	// Standard object's metadata.
    27  	metav1.ObjectMeta `json:"metadata,omitempty"`
    28  	// Specification of the UISettingsGroup.
    29  	Spec UISettingsGroupSpec `json:"spec,omitempty"`
    30  }
    31  
    32  // UISettingsGroupSpec contains the specification for a UISettingsGroup resource.
    33  type UISettingsGroupSpec struct {
    34  	// This description is displayed by the UI when asking where to store any UI-specific settings
    35  	// such as views, layers, dashboards etc. This name should be a short description that relates
    36  	// the settings to the set of clusters defined below, the set of users or groups that are able to
    37  	// access to these settings (defined via RBAC) or the set of applications common to the set of
    38  	// users or groups that can access these settings.
    39  	// Examples might be:
    40  	// - "cluster" when these settings apply to the whole cluster
    41  	// - "global" when these settings apply to all clusters (in an Multi-Cluster environment)
    42  	// - "security team" if these settings are accessible only to the security group and therefore
    43  	//   applicable to the applications accessible by that team
    44  	// - "storefront" if these settings are accessible to all users and groups that can access the
    45  	//   storefront set of applications
    46  	// - "user" if these settings are accessible to only a single user
    47  	Description string `json:"description" validate:"uiDescription"`
    48  
    49  	// The type of filter to use when listing and watching the UISettings associated with this group. If set to None
    50  	// a List/watch of UISettings in this group will return all UISettings. If set to User a list/watch of UISettings
    51  	// in this group will return only UISettings created by the user making the request.
    52  	// For settings groups that are specific to users and where multiple users may access the settings in this group
    53  	// we recommend setting this to "User" to avoid cluttering up the UI with settings for other users.
    54  	// Note this is only a filter. Full lockdown of UISettings for specific users should be handled using appropriate
    55  	// RBAC.
    56  	// +kubebuilder:validation:Enum=None;User
    57  	FilterType string `json:"filterType,omitempty" validate:"omitempty"`
    58  }
    59  
    60  // +genclient:nonNamespaced
    61  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    62  
    63  // UISettingsGroupList contains a list of UISettingsGroup resources.
    64  type UISettingsGroupList struct {
    65  	metav1.TypeMeta `json:",inline"`
    66  	metav1.ListMeta `json:"metadata"`
    67  	Items           []UISettingsGroup `json:"items"`
    68  }
    69  
    70  // NewUISettingsGroup creates a new (zeroed) UISettingsGroup struct with the TypeMetadata
    71  // initialised to the current version.
    72  func NewUISettingsGroup() *UISettingsGroup {
    73  	return &UISettingsGroup{
    74  		TypeMeta: metav1.TypeMeta{
    75  			Kind:       KindUISettingsGroup,
    76  			APIVersion: GroupVersionCurrent,
    77  		},
    78  	}
    79  }
    80  
    81  // NewUISettingsGroupList creates a new (zeroed) UISettingsGroupList struct with the
    82  // TypeMetadata initialised to the current version.
    83  func NewUISettingsGroupList() *UISettingsGroupList {
    84  	return &UISettingsGroupList{
    85  		TypeMeta: metav1.TypeMeta{
    86  			Kind:       KindUISettingsGroupList,
    87  			APIVersion: GroupVersionCurrent,
    88  		},
    89  	}
    90  }