104
}
105
106
>
func (a *localActivities) ValidateNexusEndpointsActivity(ctx context.Context, nsID namespace.ID, nsName namespace.Name) error {
activities.go
107
>
if a.allowDeleteNamespaceIfNexusEndpointTarget() {
108
return nil
109
}
110
// Prevent deletion of a namespace that is targeted by a Nexus endpoint.
112
>
for {
113
>
resp, err := a.nexusEndpointManager.ListNexusEndpoints(ctx, &persistence.ListNexusEndpointsRequest{
114
>
LastKnownTableVersion: 0,
115
>
NextPageToken: nextPageToken,
116
>
PageSize: a.nexusEndpointListDefaultPageSize(),
117
>
})
118
>
if err != nil {
119
>
a.logger.Error("Unable to list Nexus endpoints from persistence.", tag.WorkflowNamespace(nsName.String()), tag.WorkflowNamespaceID(nsID.String()), tag.Error(err))
120
>
return fmt.Errorf("unable to list Nexus endpoints for namespace %s: %w", nsName, err)
121
>
}
122
124
>
if endpointNsID := entry.GetEndpoint().GetSpec().GetTarget().GetWorker().GetNamespaceId(); endpointNsID == nsID.String() {
125
>
return errors.NewFailedPrecondition(fmt.Sprintf("cannot delete a namespace that is a target of a Nexus endpoint %s", entry.GetEndpoint().GetSpec().GetName()), nil)
126
>
}
127
}
129
>
if len(nextPageToken) == 0 {
130
>
break
131
}
132
}
134
}
135