mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(common): supported dry run
This commit is contained in:
@@ -183,6 +183,10 @@ type StandaloneAnonResourceCreateInput struct {
|
||||
// 标签列表,最多支持20个
|
||||
// example: { "user:rd": "op" }
|
||||
Metadata map[string]string `json:"__meta__" token:"tag" help:"tags in the form of key=value"`
|
||||
|
||||
// 预检验参数,若为true则仅检查参数,并不真正创建变更
|
||||
// default: false
|
||||
DryRun bool `json:"dry_run"`
|
||||
}
|
||||
|
||||
type StandaloneResourceCreateInput struct {
|
||||
|
||||
@@ -1269,6 +1269,15 @@ func _doCreateItem(
|
||||
if err != nil {
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
}
|
||||
|
||||
dryRun := struct {
|
||||
DryRun bool
|
||||
}{}
|
||||
data.Unmarshal(&dryRun)
|
||||
if dryRun.DryRun {
|
||||
return model, nil
|
||||
}
|
||||
|
||||
err = manager.TableSpec().InsertOrUpdate(ctx, model)
|
||||
if err != nil {
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
|
||||
Reference in New Issue
Block a user