allow to reference via zitadel too
All checks were successful
Build and Publish / build-release (push) Successful in 2m9s
All checks were successful
Build and Publish / build-release (push) Successful in 2m9s
This commit is contained in:
@@ -124,13 +124,11 @@ func (wr *wrappedProjectReconciler) Reconcile(ctx context.Context, ztdClient *cl
|
||||
}
|
||||
|
||||
func (wr *wrappedProjectReconciler) reconcileProject(ctx context.Context, ztdClient *clientv2.Client) error {
|
||||
org, err := wr.refResolver.OrganizationRef(ctx, &wr.project.Spec.OrganizationRef, wr.project.Namespace)
|
||||
orgRef, err := wr.refResolver.ResolveOrganization(ctx, &wr.project.Spec.OrganizationRef, wr.project.Namespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if org.Status.OrganizationId == nil {
|
||||
return fmt.Errorf("Organization not created yet")
|
||||
}
|
||||
|
||||
var projectId *string
|
||||
projectList, err := ztdClient.ProjectServiceV2().ListProjects(ctx, &project.ListProjectsRequest{
|
||||
Filters: []*project.ProjectSearchFilter{
|
||||
@@ -145,7 +143,7 @@ func (wr *wrappedProjectReconciler) reconcileProject(ctx context.Context, ztdCli
|
||||
&project.ProjectSearchFilter{
|
||||
Filter: &project.ProjectSearchFilter_OrganizationIdFilter{
|
||||
OrganizationIdFilter: &project.ProjectOrganizationIDFilter{
|
||||
OrganizationId: *org.Status.OrganizationId,
|
||||
OrganizationId: orgRef.ID,
|
||||
Type: project.ProjectOrganizationIDFilter_OWNED,
|
||||
},
|
||||
},
|
||||
@@ -163,7 +161,7 @@ func (wr *wrappedProjectReconciler) reconcileProject(ctx context.Context, ztdCli
|
||||
resp, err :=
|
||||
ztdClient.ProjectServiceV2().CreateProject(ctx,
|
||||
&project.CreateProjectRequest{
|
||||
OrganizationId: *org.Status.OrganizationId,
|
||||
OrganizationId: orgRef.ID,
|
||||
Name: wr.project.Spec.ProjectName,
|
||||
ProjectRoleAssertion: wr.project.Spec.ProjectRoleAssertion,
|
||||
AuthorizationRequired: wr.project.Spec.ProjectRoleCheck,
|
||||
@@ -254,16 +252,13 @@ func (wr *wrappedProjectReconciler) reconcileGrants(ctx context.Context, ztdClie
|
||||
return fmt.Errorf("Error listing project grants: %v", err)
|
||||
}
|
||||
for _, grant := range wr.project.DeepCopy().Spec.Grants {
|
||||
grantedOrg, err := wr.refResolver.OrganizationRef(ctx, &grant.OrganizationRef, wr.project.Namespace)
|
||||
grantedOrgRef, err := wr.refResolver.ResolveOrganization(ctx, &grant.OrganizationRef, wr.project.Namespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if grantedOrg.Status.OrganizationId == nil {
|
||||
continue
|
||||
}
|
||||
var existingGrant *project.ProjectGrant
|
||||
for _, eGrant := range existingGrants.ProjectGrants {
|
||||
if eGrant.GrantedOrganizationId == *grantedOrg.Status.OrganizationId {
|
||||
if eGrant.GrantedOrganizationId == grantedOrgRef.ID {
|
||||
existingGrant = eGrant
|
||||
break
|
||||
}
|
||||
@@ -271,7 +266,7 @@ func (wr *wrappedProjectReconciler) reconcileGrants(ctx context.Context, ztdClie
|
||||
if existingGrant == nil {
|
||||
_, err := ztdClient.ProjectServiceV2().CreateProjectGrant(ctx, &project.CreateProjectGrantRequest{
|
||||
ProjectId: *wr.project.Status.ProjectId,
|
||||
GrantedOrganizationId: *grantedOrg.Status.OrganizationId,
|
||||
GrantedOrganizationId: grantedOrgRef.ID,
|
||||
RoleKeys: grant.RoleKeys,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user