feat(database): share more database code between CE and EE BE-11303 (#43)

pull/12341/head
andres-portainer 2024-10-18 10:33:10 -03:00 committed by GitHub
parent 7b88975bcb
commit ac293cda1c
2 changed files with 24 additions and 18 deletions

View File

@ -49,8 +49,8 @@ func (c *DbConnection) ExportJSON(databasePath string, metadata bool) ([]byte, e
backup["__metadata"] = meta backup["__metadata"] = meta
} }
err = connection.View(func(tx *bolt.Tx) error { if err := connection.View(func(tx *bolt.Tx) error {
err = tx.ForEach(func(name []byte, bucket *bolt.Bucket) error { return tx.ForEach(func(name []byte, bucket *bolt.Bucket) error {
bucketName := string(name) bucketName := string(name)
var list []any var list []any
version := make(map[string]string) version := make(map[string]string)
@ -84,27 +84,22 @@ func (c *DbConnection) ExportJSON(databasePath string, metadata bool) ([]byte, e
return nil return nil
} }
if len(list) > 0 { if bucketName == "ssl" ||
if bucketName == "ssl" || bucketName == "settings" ||
bucketName == "settings" || bucketName == "tunnel_server" {
bucketName == "tunnel_server" { backup[bucketName] = nil
backup[bucketName] = nil if len(list) > 0 {
if len(list) > 0 { backup[bucketName] = list[0]
backup[bucketName] = list[0]
}
return nil
} }
backup[bucketName] = list
return nil return nil
} }
backup[bucketName] = list
return nil return nil
}) })
}); err != nil {
return err
})
if err != nil {
return []byte("{}"), err return []byte("{}"), err
} }

View File

@ -1,10 +1,15 @@
{ {
"api_key": null,
"customtemplates": null,
"dockerhub": [ "dockerhub": [
{ {
"Authentication": false, "Authentication": false,
"Username": "" "Username": ""
} }
], ],
"edge_stack": null,
"edgegroups": null,
"edgejobs": null,
"endpoint_groups": [ "endpoint_groups": [
{ {
"AuthorizedTeams": null, "AuthorizedTeams": null,
@ -103,6 +108,9 @@
"UserAccessPolicies": {} "UserAccessPolicies": {}
} }
], ],
"extension": null,
"helm_user_repository": null,
"pending_actions": null,
"registries": [ "registries": [
{ {
"Authentication": true, "Authentication": true,
@ -860,6 +868,8 @@
"UpdatedBy": "" "UpdatedBy": ""
} }
], ],
"tags": null,
"team_membership": null,
"teams": [ "teams": [
{ {
"Id": 1, "Id": 1,
@ -933,5 +943,6 @@
], ],
"version": { "version": {
"VERSION": "{\"SchemaVersion\":\"2.23.0\",\"MigratorCount\":0,\"Edition\":1,\"InstanceID\":\"463d5c47-0ea5-4aca-85b1-405ceefee254\"}" "VERSION": "{\"SchemaVersion\":\"2.23.0\",\"MigratorCount\":0,\"Edition\":1,\"InstanceID\":\"463d5c47-0ea5-4aca-85b1-405ceefee254\"}"
} },
"webhooks": null
} }