MCPcopy Create free account
hub / github.com/bytebase/bytebase / convertInstanceRoles

Function convertInstanceRoles

backend/api/v1/instance_service_converter.go:48–63  ·  view source on GitHub ↗
(instance *store.InstanceMessage, roles []*storepb.InstanceRole)

Source from the content-addressed store, hash-verified

46}
47
48func convertInstanceRoles(instance *store.InstanceMessage, roles []*storepb.InstanceRole) []*v1pb.InstanceRole {
49 var v1Roles []*v1pb.InstanceRole
50 var b strings.Builder
51
52 // preallocate memory for the builder
53 b.Grow(len(common.InstanceNamePrefix) + len(instance.ResourceID) + 1 + len(common.RolePrefix) + 20)
54
55 for _, role := range roles {
56 v1Roles = append(v1Roles, &v1pb.InstanceRole{
57 Name: buildRoleName(&b, instance.ResourceID, role.Name),
58 RoleName: role.Name,
59 Attribute: role.Attribute,
60 })
61 }
62 return v1Roles
63}
64
65func convertToStoreInstance(instanceID string, instance *v1pb.Instance) (*store.InstanceMessage, error) {
66 datasources, err := convertV1DataSources(instance.DataSources)

Callers 2

ListInstanceRolesMethod · 0.85
convertToV1InstanceFunction · 0.85

Calls 1

buildRoleNameFunction · 0.85

Tested by

no test coverage detected