(ctx context.Context, stores *store.Store, name string)
| 1148 | } |
| 1149 | |
| 1150 | func getInstanceMessage(ctx context.Context, stores *store.Store, name string) (*store.InstanceMessage, error) { |
| 1151 | instanceID, err := common.GetInstanceID(name) |
| 1152 | if err != nil { |
| 1153 | return nil, connect.NewError(connect.CodeInvalidArgument, err) |
| 1154 | } |
| 1155 | |
| 1156 | find := &store.FindInstanceMessage{ |
| 1157 | Workspace: common.GetWorkspaceIDFromContext(ctx), |
| 1158 | ResourceID: &instanceID, |
| 1159 | } |
| 1160 | instance, err := stores.GetInstance(ctx, find) |
| 1161 | if err != nil { |
| 1162 | return nil, connect.NewError(connect.CodeInternal, err) |
| 1163 | } |
| 1164 | if instance == nil { |
| 1165 | return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("instance %q not found", name)) |
| 1166 | } |
| 1167 | |
| 1168 | return instance, nil |
| 1169 | } |
| 1170 | |
| 1171 | // buildInstanceName builds the instance name with the given instance ID. |
| 1172 | func buildInstanceName(instanceID string) string { |
no test coverage detected