Skip to content

feat: create a project for a user on signup as well as an org#179

Merged
mattdjenkinson merged 2 commits intomainfrom
feat/create-project-on-signup
Feb 20, 2026
Merged

feat: create a project for a user on signup as well as an org#179
mattdjenkinson merged 2 commits intomainfrom
feat/create-project-on-signup

Conversation

@mattdjenkinson
Copy link
Contributor

@mattdjenkinson mattdjenkinson commented Feb 19, 2026

As part of datum-cloud/enhancements#602 we want to create a default project for new users on signup.

@mattdjenkinson mattdjenkinson marked this pull request as ready for review February 19, 2026 18:52
@mattdjenkinson mattdjenkinson requested a review from a team as a code owner February 19, 2026 18:52
Copy link
Collaborator

@scotwells scotwells left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple minor things!

}
_, err = controllerutil.CreateOrUpdate(ctx, r.Client, personalProject, func() error {
logger.Info("Creating or updating personal project", "organization", personalOrg.Name, "project", personalProject.Name)
metav1.SetMetaDataAnnotation(&personalProject.ObjectMeta, "kubernetes.io/display-name", "Personal Project")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we show both the Description and the Display Name in the staff portal when listing projects? If we don't, we'll just see a big list of projects with the same display name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout, i didn't think of that. We only show the Display name and Name atm but i can update the staff-portal to show both?

Screenshot 2026-02-19 at 18 58 32

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably do with adding a user column to that table as well to make it even easier to see the customer details quickly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the description would work. Getting the user into that view doesn't make much sense because there's no single owner of a project and this table needs to support projects associated with single-user organizations and standard organizations.

@mattdjenkinson mattdjenkinson merged commit a9d39c5 into main Feb 20, 2026
6 checks passed
@mattdjenkinson mattdjenkinson deleted the feat/create-project-on-signup branch February 20, 2026 09:03
@scotwells
Copy link
Collaborator

Implementation Guidance: Fix Personal Project Creation

The webhook error occurs because Milo's mproject.datum.net webhook expects parent context in UserInfo.Extra fields that controller-initiated requests don't have.

Solution: Client Impersonation with Extra Fields

Milo already has a pattern for this in user_webhook.go#L186-L208. Apply the same approach:

impersonatedConfig := rest.CopyConfig(r.RestConfig)
impersonatedConfig.Impersonate = rest.ImpersonationConfig{
    Extra: map[string][]string{
        "iam.miloapis.com/parent-name":      {org.Name},
        "iam.miloapis.com/parent-type":      {"Organization"},
        "iam.miloapis.com/parent-api-group": {"resourcemanager.miloapis.com"},
    },
}

impersonatedClient, err := client.New(impersonatedConfig, client.Options{Scheme: r.Scheme})
// Use impersonatedClient.Create() for project creation

The controller needs access to *rest.Config and RBAC permissions for impersonation with Extra fields.

See: project_webhook.go#L63-L71 for where validation fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants