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
7 changes: 3 additions & 4 deletions pkg/repository/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func (r *networkRepository) create(ctx context.Context, req *adminv2.NetworkServ
return nil, err
}

var vrf uint
if parent.Vrf > 0 {
vrf = parent.Vrf
}
Expand Down Expand Up @@ -636,7 +635,7 @@ func (r *networkRepository) createChildPrefix(ctx context.Context, namespace *st
if namespace != nil {
_, err := r.s.ipam.CreateNamespace(ctx, &ipamv1.CreateNamespaceRequest{Namespace: *namespace})
if err != nil {
return nil, errorutil.Internal("unable to create namespace:%v", err)
return nil, errorutil.Internal("unable to create namespace:%w", err)
}
for _, parentPrefix := range parentPrefixes.OfFamily(af) {
_, err := r.s.ipam.GetPrefix(ctx, &ipamv1.GetPrefixRequest{
Expand All @@ -647,15 +646,15 @@ func (r *networkRepository) createChildPrefix(ctx context.Context, namespace *st
continue
}
if !errorutil.IsNotFound(err) {
return nil, errorutil.Internal("unable to get prefix %s from super network in ipam:%v", parentPrefix.String(), err)
return nil, errorutil.Internal("unable to get prefix %s from super network in ipam:%w", parentPrefix.String(), err)
}

_, err = r.s.ipam.CreatePrefix(ctx, &ipamv1.CreatePrefixRequest{
Cidr: parentPrefix.String(),
Namespace: namespace,
})
if err != nil {
return nil, errorutil.Internal("unable to create namespaced super network:%v", err)
return nil, errorutil.Internal("unable to create namespaced super network:%w", err)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/request/authorize.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ func NewAuthorizer(log *slog.Logger, patg api.ProjectsAndTenantsGetter) Authoriz
}

func (a *authorizer) Authorize(ctx context.Context, token *apiv2.Token, req connect.AnyRequest) error {
if req == nil {
return errorutil.Internal("request is nil")
}
var (
method = req.Spec().Procedure
subject string
)
if req == nil {
return errorutil.Internal("request is nil")
}

if permissions.IsProjectScope(req) {
project, ok := permissions.GetProjectFromRequest(req)
Expand Down
2 changes: 1 addition & 1 deletion pkg/service/admin/machine/machine-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (m *machineServiceServer) List(ctx context.Context, rq *adminv2.MachineServ
}

partition := rq.Partition
if partition != nil {
if partition == nil {
if len(partitions) > 1 {
return nil, errorutil.InvalidArgument("no partition specified, but %d partitions available", len(partitions))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/service/admin/tenant/tenant-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (t *tenantServiceServer) AddMember(ctx context.Context, req *adminv2.Tenant
existing, err := t.repo.Tenant().AdditionalMethods().Member(req.Tenant).Get(ctx, req.Member)

if err != nil && !errorutil.IsNotFound(err) {
return nil, errorutil.Internal("error reading tenant member:%v", err)
return nil, errorutil.Internal("error reading tenant member:%w", err)
}
if existing != nil {
return nil, errorutil.Conflict("tenant with id %q already is member in tenant: %q", req.Member, req.Tenant)
Expand Down
4 changes: 0 additions & 4 deletions pkg/service/api/tenant/tenant-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ func (u *tenantServiceServer) Create(ctx context.Context, req *apiv2.TenantServi

if pointer.SafeDeref(req.Email) == "" && ownTenant.Email != "" {
req.Email = new(ownTenant.Email)

if pointer.SafeDeref(req.Email) == "" {
return nil, errorutil.FailedPrecondition("email is required")
}
Comment on lines -122 to -125

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we still check if email is empty? Maybe move this check one line lower?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, shouldn't email be a required field?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

but req.Email is overwritten in L121 with ownTenant.Email which is checked for not "" in L120

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, but in case ownTenant.Email == "" it will remain empty and should be checked if we require it. If an email is not required then it's fine like this.

}

tenant, err := u.repo.Tenant().Create(ctx, req)
Expand Down