feature: allow manager to preapre query context (#19451)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2024-02-05 20:06:40 +08:00
committed by GitHub
parent 7ad776ed5d
commit 81a12d1f16
270 changed files with 1460 additions and 1323 deletions

View File

@@ -215,7 +215,7 @@ func (man *SForwardManager) PerformCreateFromServer(ctx context.Context, userCre
validators.NewNonNegativeValidator("last_seen_timeout").Optional(true),
} {
if err := v.Validate(data); err != nil {
if err := v.Validate(ctx, data); err != nil {
return nil, err
}
}
@@ -285,7 +285,7 @@ func (man *SForwardManager) ValidateCreateData(ctx context.Context, userCred mcc
validators.NewNonNegativeValidator("last_seen_timeout").Optional(true),
} {
if err := v.Validate(data); err != nil {
if err := v.Validate(ctx, data); err != nil {
return nil, err
}
}
@@ -322,7 +322,7 @@ func (fwd *SForward) ValidateUpdateData(ctx context.Context, userCred mcclient.T
validators.NewNonNegativeValidator("last_seen_timeout"),
} {
v.Optional(true)
if err := v.Validate(data); err != nil {
if err := v.Validate(ctx, data); err != nil {
return nil, err
}
}

View File

@@ -58,7 +58,7 @@ func (man *SProxyAgentManager) ValidateCreateData(ctx context.Context, userCred
validators.NewIPv4AddrValidator("advertise_addr").Optional(true),
}
for _, v := range vs {
if err := v.Validate(data); err != nil {
if err := v.Validate(ctx, data); err != nil {
return nil, err
}
}
@@ -72,7 +72,7 @@ func (proxyagent *SProxyAgent) ValidateUpdateData(ctx context.Context, userCred
}
for _, v := range vs {
v.Optional(true)
if err := v.Validate(data); err != nil {
if err := v.Validate(ctx, data); err != nil {
return nil, err
}
}

View File

@@ -103,7 +103,7 @@ func (man *SProxyEndpointManager) PerformCreateFromServer(ctx context.Context, u
return nil, errors.Wrapf(err, "db.GenerateName")
}
}
if err := db.NewNameValidator(man, userCred, name, nil); err != nil {
if err := db.NewNameValidator(ctx, man, userCred, name, nil); err != nil {
return nil, httperrors.NewGeneralError(err)
}
@@ -187,7 +187,7 @@ func (man *SProxyEndpointManager) ValidateCreateData(
validators.NewIPv4AddrValidator("intranet_ip_addr"),
}
for _, v := range vs {
if err := v.Validate(data); err != nil {
if err := v.Validate(ctx, data); err != nil {
return nil, err
}
}
@@ -229,7 +229,7 @@ func (proxyendpoint *SProxyEndpoint) ValidateUpdateData(ctx context.Context, use
}
for _, v := range vs {
v.Optional(true)
if err := v.Validate(data); err != nil {
if err := v.Validate(ctx, data); err != nil {
return input, err
}
}

View File

@@ -61,7 +61,7 @@ func (man *SProxyMatchManager) ValidateCreateData(ctx context.Context, userCred
matchScopeV,
endpointV,
} {
if err := v.Validate(data); err != nil {
if err := v.Validate(ctx, data); err != nil {
return nil, err
}
}
@@ -76,7 +76,7 @@ func (pm *SProxyMatch) ValidateUpdateData(ctx context.Context, userCred mcclient
endpointV,
} {
v.Optional(true)
if err := v.Validate(data); err != nil {
if err := v.Validate(ctx, data); err != nil {
return nil, err
}
}
@@ -126,7 +126,7 @@ func (man *SProxyMatchManager) ListItemFilter(
}
if len(input.ProxyEndpointId) > 0 {
_, err := validators.ValidateModel(userCred, ProxyEndpointManager, &input.ProxyEndpointId)
_, err := validators.ValidateModel(ctx, userCred, ProxyEndpointManager, &input.ProxyEndpointId)
if err != nil {
return nil, err
}