lxd icon indicating copy to clipboard operation
lxd copied to clipboard

DB: Consolidate entity URL methods

Open markylaing opened this issue 1 year ago • 2 comments

There are two different methods for getting the URL of a LXD entity by it's type and ID.

  • getWarningEntityURL in lxd/warnings.go which accepts a *sql.Tx but doesn't cover all entity types.
  • (*Cluster).GetURIFromEntity in lxd/db/entity.go which handles it's own transactions.

I can see that GetURIFromEntity will be moved to ClusterTx in #12754. When this is done, I think the performance of this function can be improved and used in place of getWarningEntityURL.

Originally posted by @markylaing in https://github.com/canonical/lxd/pull/12853#discussion_r1486035350

markylaing avatar Feb 12 '24 11:02 markylaing

@markylaing we should also consider the .URL() functions in shared/api/* and think about if these can be consolidated too.

tomponline avatar Feb 13 '24 15:02 tomponline

@markylaing we should also consider the .URL() functions in shared/api/* and think about if these can be consolidated too.

See https://github.com/canonical/lxd/pull/12872#discussion_r1488121382

markylaing avatar Feb 13 '24 16:02 markylaing