Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ vendor/
# Files used by the taskfile.
.task

# JetBrains IDEs
.idea/
.run/
5 changes: 4 additions & 1 deletion cmd/milo/controller-manager/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ func NewOptions() (*Options, error) {
KubeControllerManagerOptions: baseOpts,
InfraCluster: &infracluster.Options{
KubeconfigFile: baseOpts.Generic.ClientConnection.Kubeconfig,
LeaderElection: &infracluster.LeaderElectionConfig{
CandidateNamespace: "datum-system",
},
},
ControlPlane: &controlplane.Options{},
}
Expand Down Expand Up @@ -669,7 +672,7 @@ func Run(ctx context.Context, c *config.CompletedConfig, opts *Options) error {
// Start lease candidate controller for coordinated leader election
leaseCandidate, waitForSync, err := leaderelection.NewCandidate(
c.Client,
"datum-system",
opts.InfraCluster.LeaderElection.CandidateNamespace,
id,
"datum-controller-manager",
binaryVersion.FinalizeVersion(),
Expand Down
3 changes: 3 additions & 0 deletions config/controller-manager/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ spec:
- --leader-elect-renew-deadline=10s
- --leader-elect-retry-period=2s
- --leader-elect-resource-namespace=$(LEADER_ELECT_RESOURCE_NAMESPACE)
- --leader-election-candidate-namespace=$(LEADER_ELECTION_CANDIDATE_NAMESPACE)
- --authentication-skip-lookup
- --client-ca-file=$(CLIENT_CA_FILE)
- --secure-port=6443
Expand All @@ -45,6 +46,8 @@ spec:
env:
- name: LEADER_ELECT_RESOURCE_NAMESPACE
value: milo-system
- name: LEADER_ELECTION_CANDIDATE_NAMESPACE
value: datum-system
# Default to INFO level logging
- name: LOG_LEVEL
value: "4"
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/iam/iam.miloapis.com_userpreferences.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ spec:
spec:
description: UserPreferenceSpec defines the desired state of UserPreference
properties:
displayName:
description: DisplayName is the user's preferred display name.
type: string
theme:
default: system
description: The user's theme preference.
Expand All @@ -60,6 +63,12 @@ spec:
- dark
- system
type: string
timeZone:
description: The user's time zone preference.
type: string
title:
description: Title is the user's title or role.
type: string
userRef:
description: Reference to the user these preferences belong to.
properties:
Expand Down
4 changes: 3 additions & 1 deletion config/samples/iam/v1alpha1/userpreference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ metadata:
spec:
userRef:
name: user-sample
theme: "dark"
theme: "dark"
displayName: my display name
title: my title
21 changes: 21 additions & 0 deletions docs/api/iam.md
Original file line number Diff line number Diff line change
Expand Up @@ -2597,6 +2597,27 @@ UserPreferenceSpec defines the desired state of UserPreference
<i>Default</i>: system<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>displayName</b></td>
<td>string</td>
<td>
DisplayName is the user's preferred display name.<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>title</b></td>
<td>string</td>
<td>
Title is the user's title or role.<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>timeZone</b></td>
<td>string</td>
<td>
The user's time zone preference.<br/>
</td>
<td>false</td>
</tr></tbody>
</table>

Expand Down
7 changes: 7 additions & 0 deletions internal/infra-cluster/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ import (
"k8s.io/client-go/tools/clientcmd"
)

type LeaderElectionConfig struct {
CandidateNamespace string
}

// Options defines the configuration options available for modifying the
// behavior of the infrastructure cluster client.
type Options struct {
KubeconfigFile string
LeaderElection *LeaderElectionConfig
}

func (o *Options) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.KubeconfigFile, "infra-cluster-kubeconfig", "-", "The path to the kubeconfig file for the infrastructure cluster. Use '-' to use the in-cluster config.")
fs.StringVar(&o.LeaderElection.CandidateNamespace, "leader-election-candidate-namespace", o.LeaderElection.CandidateNamespace, "The candidate namespace in which the leader election will be created.")

}

func (o *Options) GetClient() (*rest.Config, error) {
Expand Down
4 changes: 3 additions & 1 deletion internal/webhooks/iam/v1alpha1/user_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ func (v *UserValidator) createUserPreference(ctx context.Context, user *iamv1alp
UserRef: iamv1alpha1.UserReference{
Name: user.Name,
},
Theme: "system", // Default theme
Theme: "system", // Default theme
DisplayName: "",
Title: "",
},
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/apis/iam/v1alpha1/userpreference_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,23 @@ type UserPreferenceSpec struct {
// +kubebuilder:validation:Required
UserRef UserReference `json:"userRef"`

// DisplayName is the user's preferred display name.
// +kubebuilder:validation:Optional
DisplayName string `json:"displayName,omitempty"`

// Title is the user's title or role.
// +kubebuilder:validation:Optional
Title string `json:"title,omitempty"`

// The user's theme preference.
// +kubebuilder:validation:Enum=light;dark;system
// +kubebuilder:validation:Optional
// +kubebuilder:default=system
Theme string `json:"theme,omitempty"`

// The user's time zone preference.
// +kubebuilder:validation:Optional'
TimeZone string `json:"timeZone,omitempty"`
}

// UserPreferenceStatus defines the observed state of UserPreference
Expand Down