refactor!: working WD-4 user discovery

This commit is contained in:
DevMiner 2024-08-20 22:43:26 +02:00
parent cf0053312d
commit 61891d891a
91 changed files with 12768 additions and 5562 deletions

View file

@ -45,6 +45,18 @@ func (f ImageFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ImageMutation", m)
}
// The InstanceMetadataFunc type is an adapter to allow the use of ordinary
// function as InstanceMetadata mutator.
type InstanceMetadataFunc func(context.Context, *ent.InstanceMetadataMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f InstanceMetadataFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.InstanceMetadataMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.InstanceMetadataMutation", m)
}
// The NoteFunc type is an adapter to allow the use of ordinary
// function as Note mutator.
type NoteFunc func(context.Context, *ent.NoteMutation) (ent.Value, error)
@ -57,18 +69,6 @@ func (f NoteFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.NoteMutation", m)
}
// The ServerMetadataFunc type is an adapter to allow the use of ordinary
// function as ServerMetadata mutator.
type ServerMetadataFunc func(context.Context, *ent.ServerMetadataMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ServerMetadataFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ServerMetadataMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ServerMetadataMutation", m)
}
// The UserFunc type is an adapter to allow the use of ordinary
// function as User mutator.
type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)