From 6385b3e1b120241983c47fdf207ff9dc121a9357 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Mon, 9 Feb 2026 04:28:24 +0000 Subject: [PATCH 01/19] ping works --- tavern/app.go | 57 + tavern/internal/builder/README.md | 45 + .../internal/builder/builderpb/builder.pb.go | 161 + .../builder/builderpb/builder_grpc.pb.go | 110 + tavern/internal/builder/client.go | 41 + tavern/internal/builder/config.go | 56 + tavern/internal/builder/integration_test.go | 109 + tavern/internal/builder/proto/builder.proto | 12 + tavern/internal/builder/server.go | 28 + tavern/internal/ent/builder.go | 145 + tavern/internal/ent/builder/builder.go | 77 + tavern/internal/ent/builder/where.go | 230 + tavern/internal/ent/builder_create.go | 617 + tavern/internal/ent/builder_delete.go | 88 + tavern/internal/ent/builder_query.go | 540 + tavern/internal/ent/builder_update.go | 288 + tavern/internal/ent/client.go | 159 +- tavern/internal/ent/ent.go | 2 + tavern/internal/ent/gql_collection.go | 111 + tavern/internal/ent/gql_mutation_input.go | 21 + tavern/internal/ent/gql_node.go | 31 + tavern/internal/ent/gql_pagination.go | 351 + tavern/internal/ent/gql_where_input.go | 247 + tavern/internal/ent/hook/hook.go | 12 + tavern/internal/ent/migrate/schema.go | 18 + tavern/internal/ent/mutation.go | 506 + tavern/internal/ent/predicate/predicate.go | 3 + tavern/internal/ent/privacy/privacy.go | 24 + tavern/internal/ent/runtime/runtime.go | 16 + tavern/internal/ent/schema/builder.go | 54 + tavern/internal/ent/tx.go | 3 + .../graphql/generated/ent.generated.go | 9873 +++++++++-------- .../graphql/generated/inputs.generated.go | 167 + .../graphql/generated/mutation.generated.go | 86 + .../graphql/generated/root_.generated.go | 290 + .../internal/graphql/models/gqlgen_models.go | 11 + tavern/internal/graphql/mutation.resolvers.go | 88 + tavern/internal/graphql/schema.graphql | 158 + tavern/internal/graphql/schema/ent.graphql | 141 + tavern/internal/graphql/schema/inputs.graphql | 12 + .../internal/graphql/schema/mutation.graphql | 5 + tavern/internal/www/schema.graphql | 158 + 42 files changed, 10715 insertions(+), 4436 deletions(-) create mode 100644 tavern/internal/builder/README.md create mode 100644 tavern/internal/builder/builderpb/builder.pb.go create mode 100644 tavern/internal/builder/builderpb/builder_grpc.pb.go create mode 100644 tavern/internal/builder/client.go create mode 100644 tavern/internal/builder/config.go create mode 100644 tavern/internal/builder/integration_test.go create mode 100644 tavern/internal/builder/proto/builder.proto create mode 100644 tavern/internal/builder/server.go create mode 100644 tavern/internal/ent/builder.go create mode 100644 tavern/internal/ent/builder/builder.go create mode 100644 tavern/internal/ent/builder/where.go create mode 100644 tavern/internal/ent/builder_create.go create mode 100644 tavern/internal/ent/builder_delete.go create mode 100644 tavern/internal/ent/builder_query.go create mode 100644 tavern/internal/ent/builder_update.go create mode 100644 tavern/internal/ent/schema/builder.go diff --git a/tavern/app.go b/tavern/app.go index 30df0f83b..7027ba2df 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -22,6 +22,8 @@ import ( "golang.org/x/net/http2/h2c" "google.golang.org/grpc" "realm.pub/tavern/internal/auth" + "realm.pub/tavern/internal/builder" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2" "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/cdn" @@ -117,6 +119,34 @@ func newApp(ctx context.Context) (app *cli.App) { }, }, }, + { + Name: "builder", + Usage: "Run a builder that compiles agents for target platforms", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "config", + Usage: "Path to the builder YAML configuration file", + }, + }, + Action: func(c *cli.Context) error { + configPath := c.String("config") + if configPath == "" { + return fmt.Errorf("--config flag is required") + } + + cfg, err := builder.ParseConfig(configPath) + if err != nil { + return fmt.Errorf("failed to parse builder config: %w", err) + } + + slog.InfoContext(ctx, "starting builder", + "config", configPath, + "supported_targets", cfg.SupportedTargets, + ) + + return builder.Run(ctx, cfg) + }, + }, } return } @@ -280,6 +310,11 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { "/portal.Portal/": tavernhttp.Endpoint{ Handler: newPortalGRPCHandler(client, portalMux), }, + "/builder.Builder/": tavernhttp.Endpoint{ + Handler: newBuilderGRPCHandler(client), + AllowUnauthenticated: true, + AllowUnactivated: true, + }, "/cdn/": tavernhttp.Endpoint{ Handler: cdn.NewLinkDownloadHandler(client, "/cdn/"), AllowUnauthenticated: true, @@ -499,6 +534,28 @@ func newPortalGRPCHandler(graph *ent.Client, portalMux *mux.Mux) http.Handler { }) } +func newBuilderGRPCHandler(client *ent.Client) http.Handler { + builderSrv := builder.New(client) + grpcSrv := grpc.NewServer( + grpc.UnaryInterceptor(grpcWithUnaryMetrics), + grpc.StreamInterceptor(grpcWithStreamMetrics), + ) + builderpb.RegisterBuilderServer(grpcSrv, builderSrv) + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.ProtoMajor != 2 { + http.Error(w, "grpc requires HTTP/2", http.StatusBadRequest) + return + } + + if contentType := r.Header.Get("Content-Type"); !strings.HasPrefix(contentType, "application/grpc") { + http.Error(w, "must specify Content-Type application/grpc", http.StatusBadRequest) + return + } + + grpcSrv.ServeHTTP(w, r) + }) +} + func newGRPCHandler(client *ent.Client, grpcShellMux *stream.Mux, portalMux *mux.Mux) http.Handler { pub, priv, err := getKeyPairX25519() if err != nil { diff --git a/tavern/internal/builder/README.md b/tavern/internal/builder/README.md new file mode 100644 index 000000000..50d238fb7 --- /dev/null +++ b/tavern/internal/builder/README.md @@ -0,0 +1,45 @@ +# Builder + +The builder package orchestrates agent compilation for target platforms. It connects to the Tavern server via gRPC and compiles agents based on its configuration. + +## Overview + +- **Registration**: Builders register with Tavern via the `registerBuilder` GraphQL mutation, which returns an mTLS certificate and a YAML configuration file. +- **gRPC API**: Builders communicate with Tavern over gRPC at the `/builder.Builder/` route. Currently supports a `Ping` health check endpoint. +- **CLI**: Run a builder using the `builder` subcommand with a `--config` flag pointing to a YAML configuration file. + +## Configuration + +Builders are configured via a YAML file with the following schema: + +```yaml +supported_targets: + - linux + - macos + - windows +mtls: +``` + +| Field | Description | +|-------|-------------| +| `supported_targets` | List of platforms this builder can compile agents for. Valid values: `linux`, `macos`, `windows`. | +| `mtls` | Base64-encoded PEM bundle containing the mTLS certificate and private key for authenticating with Tavern. | + +## Usage + +```bash +# Register a builder via GraphQL (returns config YAML) +# Then run it: +go run ./tavern builder --config /path/to/builder-config.yaml +``` + +## Package Structure + +| File | Purpose | +|------|---------| +| `config.go` | YAML configuration parsing and validation | +| `server.go` | gRPC server implementation (Ping) | +| `run.go` | Builder run loop (connects to Tavern and awaits work) | +| `proto/builder.proto` | Protobuf service definition | +| `builderpb/` | Generated protobuf Go code | +| `integration_test.go` | End-to-end test covering registration and gRPC communication | diff --git a/tavern/internal/builder/builderpb/builder.pb.go b/tavern/internal/builder/builderpb/builder.pb.go new file mode 100644 index 000000000..40d023ccc --- /dev/null +++ b/tavern/internal/builder/builderpb/builder.pb.go @@ -0,0 +1,161 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.5 +// protoc v3.21.12 +// source: builder.proto + +package builderpb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type PingRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PingRequest) Reset() { + *x = PingRequest{} + mi := &file_builder_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingRequest) ProtoMessage() {} + +func (x *PingRequest) ProtoReflect() protoreflect.Message { + mi := &file_builder_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingRequest.ProtoReflect.Descriptor instead. +func (*PingRequest) Descriptor() ([]byte, []int) { + return file_builder_proto_rawDescGZIP(), []int{0} +} + +type PingResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PingResponse) Reset() { + *x = PingResponse{} + mi := &file_builder_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingResponse) ProtoMessage() {} + +func (x *PingResponse) ProtoReflect() protoreflect.Message { + mi := &file_builder_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingResponse.ProtoReflect.Descriptor instead. +func (*PingResponse) Descriptor() ([]byte, []int) { + return file_builder_proto_rawDescGZIP(), []int{1} +} + +var File_builder_proto protoreflect.FileDescriptor + +var file_builder_proto_rawDesc = string([]byte{ + 0x0a, 0x0d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x22, 0x0d, 0x0a, 0x0b, 0x50, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x69, 0x6e, 0x67, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x40, 0x0a, 0x07, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x65, 0x72, 0x12, 0x35, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x2e, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x15, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2d, 0x5a, 0x2b, 0x72, 0x65, 0x61, + 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, 0x6e, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2f, 0x62, + 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +}) + +var ( + file_builder_proto_rawDescOnce sync.Once + file_builder_proto_rawDescData []byte +) + +func file_builder_proto_rawDescGZIP() []byte { + file_builder_proto_rawDescOnce.Do(func() { + file_builder_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_builder_proto_rawDesc), len(file_builder_proto_rawDesc))) + }) + return file_builder_proto_rawDescData +} + +var file_builder_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_builder_proto_goTypes = []any{ + (*PingRequest)(nil), // 0: builder.PingRequest + (*PingResponse)(nil), // 1: builder.PingResponse +} +var file_builder_proto_depIdxs = []int32{ + 0, // 0: builder.Builder.Ping:input_type -> builder.PingRequest + 1, // 1: builder.Builder.Ping:output_type -> builder.PingResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_builder_proto_init() } +func file_builder_proto_init() { + if File_builder_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_builder_proto_rawDesc), len(file_builder_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_builder_proto_goTypes, + DependencyIndexes: file_builder_proto_depIdxs, + MessageInfos: file_builder_proto_msgTypes, + }.Build() + File_builder_proto = out.File + file_builder_proto_goTypes = nil + file_builder_proto_depIdxs = nil +} diff --git a/tavern/internal/builder/builderpb/builder_grpc.pb.go b/tavern/internal/builder/builderpb/builder_grpc.pb.go new file mode 100644 index 000000000..febce446b --- /dev/null +++ b/tavern/internal/builder/builderpb/builder_grpc.pb.go @@ -0,0 +1,110 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v3.21.12 +// source: builder.proto + +package builderpb + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.62.0 or later. +const _ = grpc.SupportPackageIsVersion8 + +const ( + Builder_Ping_FullMethodName = "/builder.Builder/Ping" +) + +// BuilderClient is the client API for Builder service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type BuilderClient interface { + Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) +} + +type builderClient struct { + cc grpc.ClientConnInterface +} + +func NewBuilderClient(cc grpc.ClientConnInterface) BuilderClient { + return &builderClient{cc} +} + +func (c *builderClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(PingResponse) + err := c.cc.Invoke(ctx, Builder_Ping_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// BuilderServer is the server API for Builder service. +// All implementations must embed UnimplementedBuilderServer +// for forward compatibility +type BuilderServer interface { + Ping(context.Context, *PingRequest) (*PingResponse, error) + mustEmbedUnimplementedBuilderServer() +} + +// UnimplementedBuilderServer must be embedded to have forward compatible implementations. +type UnimplementedBuilderServer struct { +} + +func (UnimplementedBuilderServer) Ping(context.Context, *PingRequest) (*PingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") +} +func (UnimplementedBuilderServer) mustEmbedUnimplementedBuilderServer() {} + +// UnsafeBuilderServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to BuilderServer will +// result in compilation errors. +type UnsafeBuilderServer interface { + mustEmbedUnimplementedBuilderServer() +} + +func RegisterBuilderServer(s grpc.ServiceRegistrar, srv BuilderServer) { + s.RegisterService(&Builder_ServiceDesc, srv) +} + +func _Builder_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BuilderServer).Ping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Builder_Ping_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BuilderServer).Ping(ctx, req.(*PingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Builder_ServiceDesc is the grpc.ServiceDesc for Builder service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Builder_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "builder.Builder", + HandlerType: (*BuilderServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Ping", + Handler: _Builder_Ping_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "builder.proto", +} diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go new file mode 100644 index 000000000..33674348b --- /dev/null +++ b/tavern/internal/builder/client.go @@ -0,0 +1,41 @@ +package builder + +import ( + "context" + "fmt" + "log/slog" + + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + + "realm.pub/tavern/internal/builder/builderpb" +) + +// Run starts the builder process using the provided configuration. +// It connects to the configured upstream server and sends a ping request. +func Run(ctx context.Context, cfg *Config) error { + slog.InfoContext(ctx, "builder started", + "supported_targets", cfg.SupportedTargets, + "upstream", cfg.Upstream, + ) + + conn, err := grpc.NewClient(cfg.Upstream, + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + if err != nil { + return fmt.Errorf("failed to connect to upstream %q: %w", cfg.Upstream, err) + } + defer conn.Close() + + client := builderpb.NewBuilderClient(conn) + _, err = client.Ping(ctx, &builderpb.PingRequest{}) + if err != nil { + return fmt.Errorf("failed to ping upstream: %w", err) + } + + slog.InfoContext(ctx, "successfully pinged upstream", "upstream", cfg.Upstream) + + // Wait for context cancellation + <-ctx.Done() + return ctx.Err() +} diff --git a/tavern/internal/builder/config.go b/tavern/internal/builder/config.go new file mode 100644 index 000000000..ba618463c --- /dev/null +++ b/tavern/internal/builder/config.go @@ -0,0 +1,56 @@ +package builder + +import ( + "fmt" + "os" + + "gopkg.in/yaml.v3" +) + +// Config represents the YAML configuration for a builder. +type Config struct { + SupportedTargets []string `yaml:"supported_targets"` + MTLS string `yaml:"mtls"` + Upstream string `yaml:"upstream"` +} + +// ParseConfig reads and parses a builder YAML configuration file. +func ParseConfig(path string) (*Config, error) { + data, err := os.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("failed to read config file %q: %w", path, err) + } + return ParseConfigBytes(data) +} + +// ParseConfigBytes parses builder YAML configuration from bytes. +func ParseConfigBytes(data []byte) (*Config, error) { + var cfg Config + if err := yaml.Unmarshal(data, &cfg); err != nil { + return nil, fmt.Errorf("failed to parse config: %w", err) + } + + if err := cfg.validate(); err != nil { + return nil, err + } + + return &cfg, nil +} + +func (cfg *Config) validate() error { + if len(cfg.SupportedTargets) == 0 { + return fmt.Errorf("config must specify at least one supported_target") + } + for _, target := range cfg.SupportedTargets { + switch target { + case "macos", "linux", "windows": + // valid + default: + return fmt.Errorf("unsupported target %q, must be one of: macos, linux, windows", target) + } + } + if cfg.Upstream == "" { + return fmt.Errorf("config must specify an upstream server address") + } + return nil +} diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go new file mode 100644 index 000000000..ab3e2f993 --- /dev/null +++ b/tavern/internal/builder/integration_test.go @@ -0,0 +1,109 @@ +package builder_test + +import ( + "context" + "net" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql/handler" + _ "github.com/mattn/go-sqlite3" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/test/bufconn" + + "realm.pub/tavern/internal/builder" + "realm.pub/tavern/internal/builder/builderpb" + "realm.pub/tavern/internal/ent/enttest" + "realm.pub/tavern/internal/graphql" + tavernhttp "realm.pub/tavern/internal/http" + "realm.pub/tavern/tomes" +) + +func TestBuilderE2E(t *testing.T) { + ctx := context.Background() + + // 1. Setup in-memory SQLite database + graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + defer graph.Close() + + // 2. Setup GraphQL server with authentication bypass + git := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( + tavernhttp.RouteMap{ + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), + }, + tavernhttp.WithAuthenticationBypass(graph), + ) + gqlClient := client.New(srv, client.Path("/graphql")) + + // 3. Register a builder via GraphQL mutation + var registerResp struct { + RegisterBuilder struct { + Builder struct { + ID string + } + MtlsCert string + Config string + } + } + + err := gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { + registerBuilder(input: $input) { + builder { id } + mtlsCert + config + } + }`, ®isterResp, client.Var("input", map[string]any{ + "supportedTargets": []string{"PLATFORM_LINUX", "PLATFORM_MACOS"}, + "upstream": "https://tavern.example.com:443", + })) + require.NoError(t, err) + require.NotEmpty(t, registerResp.RegisterBuilder.Builder.ID) + require.NotEmpty(t, registerResp.RegisterBuilder.MtlsCert) + require.NotEmpty(t, registerResp.RegisterBuilder.Config) + + // 4. Parse the returned YAML config + cfg, err := builder.ParseConfigBytes([]byte(registerResp.RegisterBuilder.Config)) + require.NoError(t, err) + assert.Contains(t, cfg.SupportedTargets, "linux") + assert.Contains(t, cfg.SupportedTargets, "macos") + assert.NotEmpty(t, cfg.MTLS) + assert.Equal(t, "https://tavern.example.com:443", cfg.Upstream) + + // 5. Verify builder exists in DB + builders, err := graph.Builder.Query().All(ctx) + require.NoError(t, err) + require.Len(t, builders, 1) + + // 6. Setup builder gRPC server via bufconn + lis := bufconn.Listen(1024 * 1024) + grpcSrv := grpc.NewServer() + builderSrv := builder.New(graph) + builderpb.RegisterBuilderServer(grpcSrv, builderSrv) + + go func() { + if err := grpcSrv.Serve(lis); err != nil { + t.Logf("gRPC server exited: %v", err) + } + }() + defer grpcSrv.Stop() + + // 7. Connect gRPC client via bufconn + conn, err := grpc.DialContext(ctx, "bufnet", + grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { + return lis.Dial() + }), + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + require.NoError(t, err) + defer conn.Close() + + // 8. Call Ping on the builder gRPC service + builderClient := builderpb.NewBuilderClient(conn) + pingResp, err := builderClient.Ping(ctx, &builderpb.PingRequest{}) + require.NoError(t, err) + require.NotNil(t, pingResp) +} diff --git a/tavern/internal/builder/proto/builder.proto b/tavern/internal/builder/proto/builder.proto new file mode 100644 index 000000000..138641bc3 --- /dev/null +++ b/tavern/internal/builder/proto/builder.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package builder; + +option go_package = "realm.pub/tavern/internal/builder/builderpb"; + +message PingRequest {} +message PingResponse {} + +service Builder { + rpc Ping(PingRequest) returns (PingResponse) {} +} diff --git a/tavern/internal/builder/server.go b/tavern/internal/builder/server.go new file mode 100644 index 000000000..c7f2d4c2c --- /dev/null +++ b/tavern/internal/builder/server.go @@ -0,0 +1,28 @@ +package builder + +import ( + "context" + "log/slog" + + "realm.pub/tavern/internal/builder/builderpb" + "realm.pub/tavern/internal/ent" +) + +// Server implements the Builder gRPC service. +type Server struct { + graph *ent.Client + builderpb.UnimplementedBuilderServer +} + +// New creates a new Builder gRPC server. +func New(graph *ent.Client) *Server { + return &Server{ + graph: graph, + } +} + +// Ping is a simple health check endpoint. +func (s *Server) Ping(ctx context.Context, req *builderpb.PingRequest) (*builderpb.PingResponse, error) { + slog.Info("ping!") + return &builderpb.PingResponse{}, nil +} diff --git a/tavern/internal/ent/builder.go b/tavern/internal/ent/builder.go new file mode 100644 index 000000000..dd2ea785a --- /dev/null +++ b/tavern/internal/ent/builder.go @@ -0,0 +1,145 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/builder" +) + +// Builder is the model entity for the Builder schema. +type Builder struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Timestamp of when this ent was created + CreatedAt time.Time `json:"created_at,omitempty"` + // Timestamp of when this ent was last updated + LastModifiedAt time.Time `json:"last_modified_at,omitempty"` + // The platforms this builder can build agents for. + SupportedTargets []c2pb.Host_Platform `json:"supported_targets,omitempty"` + // The server address that the builder should connect to. + Upstream string `json:"upstream,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Builder) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case builder.FieldSupportedTargets: + values[i] = new([]byte) + case builder.FieldID: + values[i] = new(sql.NullInt64) + case builder.FieldUpstream: + values[i] = new(sql.NullString) + case builder.FieldCreatedAt, builder.FieldLastModifiedAt: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Builder fields. +func (b *Builder) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case builder.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + b.ID = int(value.Int64) + case builder.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + b.CreatedAt = value.Time + } + case builder.FieldLastModifiedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_modified_at", values[i]) + } else if value.Valid { + b.LastModifiedAt = value.Time + } + case builder.FieldSupportedTargets: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field supported_targets", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &b.SupportedTargets); err != nil { + return fmt.Errorf("unmarshal field supported_targets: %w", err) + } + } + case builder.FieldUpstream: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field upstream", values[i]) + } else if value.Valid { + b.Upstream = value.String + } + default: + b.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Builder. +// This includes values selected through modifiers, order, etc. +func (b *Builder) Value(name string) (ent.Value, error) { + return b.selectValues.Get(name) +} + +// Update returns a builder for updating this Builder. +// Note that you need to call Builder.Unwrap() before calling this method if this Builder +// was returned from a transaction, and the transaction was committed or rolled back. +func (b *Builder) Update() *BuilderUpdateOne { + return NewBuilderClient(b.config).UpdateOne(b) +} + +// Unwrap unwraps the Builder entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (b *Builder) Unwrap() *Builder { + _tx, ok := b.config.driver.(*txDriver) + if !ok { + panic("ent: Builder is not a transactional entity") + } + b.config.driver = _tx.drv + return b +} + +// String implements the fmt.Stringer. +func (b *Builder) String() string { + var builder strings.Builder + builder.WriteString("Builder(") + builder.WriteString(fmt.Sprintf("id=%v, ", b.ID)) + builder.WriteString("created_at=") + builder.WriteString(b.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("last_modified_at=") + builder.WriteString(b.LastModifiedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("supported_targets=") + builder.WriteString(fmt.Sprintf("%v", b.SupportedTargets)) + builder.WriteString(", ") + builder.WriteString("upstream=") + builder.WriteString(b.Upstream) + builder.WriteByte(')') + return builder.String() +} + +// Builders is a parsable slice of Builder. +type Builders []*Builder diff --git a/tavern/internal/ent/builder/builder.go b/tavern/internal/ent/builder/builder.go new file mode 100644 index 000000000..00716d2dd --- /dev/null +++ b/tavern/internal/ent/builder/builder.go @@ -0,0 +1,77 @@ +// Code generated by ent, DO NOT EDIT. + +package builder + +import ( + "time" + + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the builder type in the database. + Label = "builder" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldLastModifiedAt holds the string denoting the last_modified_at field in the database. + FieldLastModifiedAt = "last_modified_at" + // FieldSupportedTargets holds the string denoting the supported_targets field in the database. + FieldSupportedTargets = "supported_targets" + // FieldUpstream holds the string denoting the upstream field in the database. + FieldUpstream = "upstream" + // Table holds the table name of the builder in the database. + Table = "builders" +) + +// Columns holds all SQL columns for builder fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldLastModifiedAt, + FieldSupportedTargets, + FieldUpstream, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultLastModifiedAt holds the default value on creation for the "last_modified_at" field. + DefaultLastModifiedAt func() time.Time + // UpdateDefaultLastModifiedAt holds the default value on update for the "last_modified_at" field. + UpdateDefaultLastModifiedAt func() time.Time +) + +// OrderOption defines the ordering options for the Builder queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByLastModifiedAt orders the results by the last_modified_at field. +func ByLastModifiedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastModifiedAt, opts...).ToFunc() +} + +// ByUpstream orders the results by the upstream field. +func ByUpstream(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpstream, opts...).ToFunc() +} diff --git a/tavern/internal/ent/builder/where.go b/tavern/internal/ent/builder/where.go new file mode 100644 index 000000000..d23885e58 --- /dev/null +++ b/tavern/internal/ent/builder/where.go @@ -0,0 +1,230 @@ +// Code generated by ent, DO NOT EDIT. + +package builder + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Builder { + return predicate.Builder(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Builder { + return predicate.Builder(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Builder { + return predicate.Builder(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Builder { + return predicate.Builder(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Builder { + return predicate.Builder(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Builder { + return predicate.Builder(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Builder { + return predicate.Builder(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldCreatedAt, v)) +} + +// LastModifiedAt applies equality check predicate on the "last_modified_at" field. It's identical to LastModifiedAtEQ. +func LastModifiedAt(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// Upstream applies equality check predicate on the "upstream" field. It's identical to UpstreamEQ. +func Upstream(v string) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldUpstream, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Builder { + return predicate.Builder(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Builder { + return predicate.Builder(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldLTE(FieldCreatedAt, v)) +} + +// LastModifiedAtEQ applies the EQ predicate on the "last_modified_at" field. +func LastModifiedAtEQ(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtNEQ applies the NEQ predicate on the "last_modified_at" field. +func LastModifiedAtNEQ(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldNEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtIn applies the In predicate on the "last_modified_at" field. +func LastModifiedAtIn(vs ...time.Time) predicate.Builder { + return predicate.Builder(sql.FieldIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtNotIn applies the NotIn predicate on the "last_modified_at" field. +func LastModifiedAtNotIn(vs ...time.Time) predicate.Builder { + return predicate.Builder(sql.FieldNotIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtGT applies the GT predicate on the "last_modified_at" field. +func LastModifiedAtGT(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldGT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtGTE applies the GTE predicate on the "last_modified_at" field. +func LastModifiedAtGTE(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldGTE(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLT applies the LT predicate on the "last_modified_at" field. +func LastModifiedAtLT(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldLT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLTE applies the LTE predicate on the "last_modified_at" field. +func LastModifiedAtLTE(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldLTE(FieldLastModifiedAt, v)) +} + +// UpstreamEQ applies the EQ predicate on the "upstream" field. +func UpstreamEQ(v string) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldUpstream, v)) +} + +// UpstreamNEQ applies the NEQ predicate on the "upstream" field. +func UpstreamNEQ(v string) predicate.Builder { + return predicate.Builder(sql.FieldNEQ(FieldUpstream, v)) +} + +// UpstreamIn applies the In predicate on the "upstream" field. +func UpstreamIn(vs ...string) predicate.Builder { + return predicate.Builder(sql.FieldIn(FieldUpstream, vs...)) +} + +// UpstreamNotIn applies the NotIn predicate on the "upstream" field. +func UpstreamNotIn(vs ...string) predicate.Builder { + return predicate.Builder(sql.FieldNotIn(FieldUpstream, vs...)) +} + +// UpstreamGT applies the GT predicate on the "upstream" field. +func UpstreamGT(v string) predicate.Builder { + return predicate.Builder(sql.FieldGT(FieldUpstream, v)) +} + +// UpstreamGTE applies the GTE predicate on the "upstream" field. +func UpstreamGTE(v string) predicate.Builder { + return predicate.Builder(sql.FieldGTE(FieldUpstream, v)) +} + +// UpstreamLT applies the LT predicate on the "upstream" field. +func UpstreamLT(v string) predicate.Builder { + return predicate.Builder(sql.FieldLT(FieldUpstream, v)) +} + +// UpstreamLTE applies the LTE predicate on the "upstream" field. +func UpstreamLTE(v string) predicate.Builder { + return predicate.Builder(sql.FieldLTE(FieldUpstream, v)) +} + +// UpstreamContains applies the Contains predicate on the "upstream" field. +func UpstreamContains(v string) predicate.Builder { + return predicate.Builder(sql.FieldContains(FieldUpstream, v)) +} + +// UpstreamHasPrefix applies the HasPrefix predicate on the "upstream" field. +func UpstreamHasPrefix(v string) predicate.Builder { + return predicate.Builder(sql.FieldHasPrefix(FieldUpstream, v)) +} + +// UpstreamHasSuffix applies the HasSuffix predicate on the "upstream" field. +func UpstreamHasSuffix(v string) predicate.Builder { + return predicate.Builder(sql.FieldHasSuffix(FieldUpstream, v)) +} + +// UpstreamEqualFold applies the EqualFold predicate on the "upstream" field. +func UpstreamEqualFold(v string) predicate.Builder { + return predicate.Builder(sql.FieldEqualFold(FieldUpstream, v)) +} + +// UpstreamContainsFold applies the ContainsFold predicate on the "upstream" field. +func UpstreamContainsFold(v string) predicate.Builder { + return predicate.Builder(sql.FieldContainsFold(FieldUpstream, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Builder) predicate.Builder { + return predicate.Builder(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Builder) predicate.Builder { + return predicate.Builder(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Builder) predicate.Builder { + return predicate.Builder(sql.NotPredicates(p)) +} diff --git a/tavern/internal/ent/builder_create.go b/tavern/internal/ent/builder_create.go new file mode 100644 index 000000000..c0fc84575 --- /dev/null +++ b/tavern/internal/ent/builder_create.go @@ -0,0 +1,617 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/builder" +) + +// BuilderCreate is the builder for creating a Builder entity. +type BuilderCreate struct { + config + mutation *BuilderMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreatedAt sets the "created_at" field. +func (bc *BuilderCreate) SetCreatedAt(t time.Time) *BuilderCreate { + bc.mutation.SetCreatedAt(t) + return bc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (bc *BuilderCreate) SetNillableCreatedAt(t *time.Time) *BuilderCreate { + if t != nil { + bc.SetCreatedAt(*t) + } + return bc +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (bc *BuilderCreate) SetLastModifiedAt(t time.Time) *BuilderCreate { + bc.mutation.SetLastModifiedAt(t) + return bc +} + +// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. +func (bc *BuilderCreate) SetNillableLastModifiedAt(t *time.Time) *BuilderCreate { + if t != nil { + bc.SetLastModifiedAt(*t) + } + return bc +} + +// SetSupportedTargets sets the "supported_targets" field. +func (bc *BuilderCreate) SetSupportedTargets(cp []c2pb.Host_Platform) *BuilderCreate { + bc.mutation.SetSupportedTargets(cp) + return bc +} + +// SetUpstream sets the "upstream" field. +func (bc *BuilderCreate) SetUpstream(s string) *BuilderCreate { + bc.mutation.SetUpstream(s) + return bc +} + +// Mutation returns the BuilderMutation object of the builder. +func (bc *BuilderCreate) Mutation() *BuilderMutation { + return bc.mutation +} + +// Save creates the Builder in the database. +func (bc *BuilderCreate) Save(ctx context.Context) (*Builder, error) { + bc.defaults() + return withHooks(ctx, bc.sqlSave, bc.mutation, bc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (bc *BuilderCreate) SaveX(ctx context.Context) *Builder { + v, err := bc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bc *BuilderCreate) Exec(ctx context.Context) error { + _, err := bc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bc *BuilderCreate) ExecX(ctx context.Context) { + if err := bc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (bc *BuilderCreate) defaults() { + if _, ok := bc.mutation.CreatedAt(); !ok { + v := builder.DefaultCreatedAt() + bc.mutation.SetCreatedAt(v) + } + if _, ok := bc.mutation.LastModifiedAt(); !ok { + v := builder.DefaultLastModifiedAt() + bc.mutation.SetLastModifiedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (bc *BuilderCreate) check() error { + if _, ok := bc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Builder.created_at"`)} + } + if _, ok := bc.mutation.LastModifiedAt(); !ok { + return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "Builder.last_modified_at"`)} + } + if _, ok := bc.mutation.SupportedTargets(); !ok { + return &ValidationError{Name: "supported_targets", err: errors.New(`ent: missing required field "Builder.supported_targets"`)} + } + if _, ok := bc.mutation.Upstream(); !ok { + return &ValidationError{Name: "upstream", err: errors.New(`ent: missing required field "Builder.upstream"`)} + } + return nil +} + +func (bc *BuilderCreate) sqlSave(ctx context.Context) (*Builder, error) { + if err := bc.check(); err != nil { + return nil, err + } + _node, _spec := bc.createSpec() + if err := sqlgraph.CreateNode(ctx, bc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + bc.mutation.id = &_node.ID + bc.mutation.done = true + return _node, nil +} + +func (bc *BuilderCreate) createSpec() (*Builder, *sqlgraph.CreateSpec) { + var ( + _node = &Builder{config: bc.config} + _spec = sqlgraph.NewCreateSpec(builder.Table, sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt)) + ) + _spec.OnConflict = bc.conflict + if value, ok := bc.mutation.CreatedAt(); ok { + _spec.SetField(builder.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := bc.mutation.LastModifiedAt(); ok { + _spec.SetField(builder.FieldLastModifiedAt, field.TypeTime, value) + _node.LastModifiedAt = value + } + if value, ok := bc.mutation.SupportedTargets(); ok { + _spec.SetField(builder.FieldSupportedTargets, field.TypeJSON, value) + _node.SupportedTargets = value + } + if value, ok := bc.mutation.Upstream(); ok { + _spec.SetField(builder.FieldUpstream, field.TypeString, value) + _node.Upstream = value + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Builder.Create(). +// SetCreatedAt(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.BuilderUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (bc *BuilderCreate) OnConflict(opts ...sql.ConflictOption) *BuilderUpsertOne { + bc.conflict = opts + return &BuilderUpsertOne{ + create: bc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (bc *BuilderCreate) OnConflictColumns(columns ...string) *BuilderUpsertOne { + bc.conflict = append(bc.conflict, sql.ConflictColumns(columns...)) + return &BuilderUpsertOne{ + create: bc, + } +} + +type ( + // BuilderUpsertOne is the builder for "upsert"-ing + // one Builder node. + BuilderUpsertOne struct { + create *BuilderCreate + } + + // BuilderUpsert is the "OnConflict" setter. + BuilderUpsert struct { + *sql.UpdateSet + } +) + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BuilderUpsert) SetLastModifiedAt(v time.Time) *BuilderUpsert { + u.Set(builder.FieldLastModifiedAt, v) + return u +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BuilderUpsert) UpdateLastModifiedAt() *BuilderUpsert { + u.SetExcluded(builder.FieldLastModifiedAt) + return u +} + +// SetSupportedTargets sets the "supported_targets" field. +func (u *BuilderUpsert) SetSupportedTargets(v []c2pb.Host_Platform) *BuilderUpsert { + u.Set(builder.FieldSupportedTargets, v) + return u +} + +// UpdateSupportedTargets sets the "supported_targets" field to the value that was provided on create. +func (u *BuilderUpsert) UpdateSupportedTargets() *BuilderUpsert { + u.SetExcluded(builder.FieldSupportedTargets) + return u +} + +// SetUpstream sets the "upstream" field. +func (u *BuilderUpsert) SetUpstream(v string) *BuilderUpsert { + u.Set(builder.FieldUpstream, v) + return u +} + +// UpdateUpstream sets the "upstream" field to the value that was provided on create. +func (u *BuilderUpsert) UpdateUpstream() *BuilderUpsert { + u.SetExcluded(builder.FieldUpstream) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *BuilderUpsertOne) UpdateNewValues() *BuilderUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(builder.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *BuilderUpsertOne) Ignore() *BuilderUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *BuilderUpsertOne) DoNothing() *BuilderUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the BuilderCreate.OnConflict +// documentation for more info. +func (u *BuilderUpsertOne) Update(set func(*BuilderUpsert)) *BuilderUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&BuilderUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BuilderUpsertOne) SetLastModifiedAt(v time.Time) *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BuilderUpsertOne) UpdateLastModifiedAt() *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetSupportedTargets sets the "supported_targets" field. +func (u *BuilderUpsertOne) SetSupportedTargets(v []c2pb.Host_Platform) *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.SetSupportedTargets(v) + }) +} + +// UpdateSupportedTargets sets the "supported_targets" field to the value that was provided on create. +func (u *BuilderUpsertOne) UpdateSupportedTargets() *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.UpdateSupportedTargets() + }) +} + +// SetUpstream sets the "upstream" field. +func (u *BuilderUpsertOne) SetUpstream(v string) *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.SetUpstream(v) + }) +} + +// UpdateUpstream sets the "upstream" field to the value that was provided on create. +func (u *BuilderUpsertOne) UpdateUpstream() *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.UpdateUpstream() + }) +} + +// Exec executes the query. +func (u *BuilderUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for BuilderCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *BuilderUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *BuilderUpsertOne) ID(ctx context.Context) (id int, err error) { + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *BuilderUpsertOne) IDX(ctx context.Context) int { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// BuilderCreateBulk is the builder for creating many Builder entities in bulk. +type BuilderCreateBulk struct { + config + err error + builders []*BuilderCreate + conflict []sql.ConflictOption +} + +// Save creates the Builder entities in the database. +func (bcb *BuilderCreateBulk) Save(ctx context.Context) ([]*Builder, error) { + if bcb.err != nil { + return nil, bcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(bcb.builders)) + nodes := make([]*Builder, len(bcb.builders)) + mutators := make([]Mutator, len(bcb.builders)) + for i := range bcb.builders { + func(i int, root context.Context) { + builder := bcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*BuilderMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, bcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = bcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, bcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, bcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (bcb *BuilderCreateBulk) SaveX(ctx context.Context) []*Builder { + v, err := bcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bcb *BuilderCreateBulk) Exec(ctx context.Context) error { + _, err := bcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bcb *BuilderCreateBulk) ExecX(ctx context.Context) { + if err := bcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Builder.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.BuilderUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (bcb *BuilderCreateBulk) OnConflict(opts ...sql.ConflictOption) *BuilderUpsertBulk { + bcb.conflict = opts + return &BuilderUpsertBulk{ + create: bcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (bcb *BuilderCreateBulk) OnConflictColumns(columns ...string) *BuilderUpsertBulk { + bcb.conflict = append(bcb.conflict, sql.ConflictColumns(columns...)) + return &BuilderUpsertBulk{ + create: bcb, + } +} + +// BuilderUpsertBulk is the builder for "upsert"-ing +// a bulk of Builder nodes. +type BuilderUpsertBulk struct { + create *BuilderCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *BuilderUpsertBulk) UpdateNewValues() *BuilderUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(builder.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *BuilderUpsertBulk) Ignore() *BuilderUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *BuilderUpsertBulk) DoNothing() *BuilderUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the BuilderCreateBulk.OnConflict +// documentation for more info. +func (u *BuilderUpsertBulk) Update(set func(*BuilderUpsert)) *BuilderUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&BuilderUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BuilderUpsertBulk) SetLastModifiedAt(v time.Time) *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BuilderUpsertBulk) UpdateLastModifiedAt() *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetSupportedTargets sets the "supported_targets" field. +func (u *BuilderUpsertBulk) SetSupportedTargets(v []c2pb.Host_Platform) *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.SetSupportedTargets(v) + }) +} + +// UpdateSupportedTargets sets the "supported_targets" field to the value that was provided on create. +func (u *BuilderUpsertBulk) UpdateSupportedTargets() *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.UpdateSupportedTargets() + }) +} + +// SetUpstream sets the "upstream" field. +func (u *BuilderUpsertBulk) SetUpstream(v string) *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.SetUpstream(v) + }) +} + +// UpdateUpstream sets the "upstream" field to the value that was provided on create. +func (u *BuilderUpsertBulk) UpdateUpstream() *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.UpdateUpstream() + }) +} + +// Exec executes the query. +func (u *BuilderUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the BuilderCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for BuilderCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *BuilderUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/builder_delete.go b/tavern/internal/ent/builder_delete.go new file mode 100644 index 000000000..463510b4a --- /dev/null +++ b/tavern/internal/ent/builder_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/predicate" +) + +// BuilderDelete is the builder for deleting a Builder entity. +type BuilderDelete struct { + config + hooks []Hook + mutation *BuilderMutation +} + +// Where appends a list predicates to the BuilderDelete builder. +func (bd *BuilderDelete) Where(ps ...predicate.Builder) *BuilderDelete { + bd.mutation.Where(ps...) + return bd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (bd *BuilderDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, bd.sqlExec, bd.mutation, bd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (bd *BuilderDelete) ExecX(ctx context.Context) int { + n, err := bd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (bd *BuilderDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(builder.Table, sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt)) + if ps := bd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, bd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + bd.mutation.done = true + return affected, err +} + +// BuilderDeleteOne is the builder for deleting a single Builder entity. +type BuilderDeleteOne struct { + bd *BuilderDelete +} + +// Where appends a list predicates to the BuilderDelete builder. +func (bdo *BuilderDeleteOne) Where(ps ...predicate.Builder) *BuilderDeleteOne { + bdo.bd.mutation.Where(ps...) + return bdo +} + +// Exec executes the deletion query. +func (bdo *BuilderDeleteOne) Exec(ctx context.Context) error { + n, err := bdo.bd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{builder.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (bdo *BuilderDeleteOne) ExecX(ctx context.Context) { + if err := bdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/builder_query.go b/tavern/internal/ent/builder_query.go new file mode 100644 index 000000000..71412c4b0 --- /dev/null +++ b/tavern/internal/ent/builder_query.go @@ -0,0 +1,540 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/predicate" +) + +// BuilderQuery is the builder for querying Builder entities. +type BuilderQuery struct { + config + ctx *QueryContext + order []builder.OrderOption + inters []Interceptor + predicates []predicate.Builder + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Builder) error + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the BuilderQuery builder. +func (bq *BuilderQuery) Where(ps ...predicate.Builder) *BuilderQuery { + bq.predicates = append(bq.predicates, ps...) + return bq +} + +// Limit the number of records to be returned by this query. +func (bq *BuilderQuery) Limit(limit int) *BuilderQuery { + bq.ctx.Limit = &limit + return bq +} + +// Offset to start from. +func (bq *BuilderQuery) Offset(offset int) *BuilderQuery { + bq.ctx.Offset = &offset + return bq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (bq *BuilderQuery) Unique(unique bool) *BuilderQuery { + bq.ctx.Unique = &unique + return bq +} + +// Order specifies how the records should be ordered. +func (bq *BuilderQuery) Order(o ...builder.OrderOption) *BuilderQuery { + bq.order = append(bq.order, o...) + return bq +} + +// First returns the first Builder entity from the query. +// Returns a *NotFoundError when no Builder was found. +func (bq *BuilderQuery) First(ctx context.Context) (*Builder, error) { + nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{builder.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (bq *BuilderQuery) FirstX(ctx context.Context) *Builder { + node, err := bq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Builder ID from the query. +// Returns a *NotFoundError when no Builder ID was found. +func (bq *BuilderQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{builder.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (bq *BuilderQuery) FirstIDX(ctx context.Context) int { + id, err := bq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Builder entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Builder entity is found. +// Returns a *NotFoundError when no Builder entities are found. +func (bq *BuilderQuery) Only(ctx context.Context) (*Builder, error) { + nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{builder.Label} + default: + return nil, &NotSingularError{builder.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (bq *BuilderQuery) OnlyX(ctx context.Context) *Builder { + node, err := bq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Builder ID in the query. +// Returns a *NotSingularError when more than one Builder ID is found. +// Returns a *NotFoundError when no entities are found. +func (bq *BuilderQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{builder.Label} + default: + err = &NotSingularError{builder.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (bq *BuilderQuery) OnlyIDX(ctx context.Context) int { + id, err := bq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Builders. +func (bq *BuilderQuery) All(ctx context.Context) ([]*Builder, error) { + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryAll) + if err := bq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Builder, *BuilderQuery]() + return withInterceptors[[]*Builder](ctx, bq, qr, bq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (bq *BuilderQuery) AllX(ctx context.Context) []*Builder { + nodes, err := bq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Builder IDs. +func (bq *BuilderQuery) IDs(ctx context.Context) (ids []int, err error) { + if bq.ctx.Unique == nil && bq.path != nil { + bq.Unique(true) + } + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryIDs) + if err = bq.Select(builder.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (bq *BuilderQuery) IDsX(ctx context.Context) []int { + ids, err := bq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (bq *BuilderQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryCount) + if err := bq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, bq, querierCount[*BuilderQuery](), bq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (bq *BuilderQuery) CountX(ctx context.Context) int { + count, err := bq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (bq *BuilderQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryExist) + switch _, err := bq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (bq *BuilderQuery) ExistX(ctx context.Context) bool { + exist, err := bq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the BuilderQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (bq *BuilderQuery) Clone() *BuilderQuery { + if bq == nil { + return nil + } + return &BuilderQuery{ + config: bq.config, + ctx: bq.ctx.Clone(), + order: append([]builder.OrderOption{}, bq.order...), + inters: append([]Interceptor{}, bq.inters...), + predicates: append([]predicate.Builder{}, bq.predicates...), + // clone intermediate query. + sql: bq.sql.Clone(), + path: bq.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Builder.Query(). +// GroupBy(builder.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (bq *BuilderQuery) GroupBy(field string, fields ...string) *BuilderGroupBy { + bq.ctx.Fields = append([]string{field}, fields...) + grbuild := &BuilderGroupBy{build: bq} + grbuild.flds = &bq.ctx.Fields + grbuild.label = builder.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.Builder.Query(). +// Select(builder.FieldCreatedAt). +// Scan(ctx, &v) +func (bq *BuilderQuery) Select(fields ...string) *BuilderSelect { + bq.ctx.Fields = append(bq.ctx.Fields, fields...) + sbuild := &BuilderSelect{BuilderQuery: bq} + sbuild.label = builder.Label + sbuild.flds, sbuild.scan = &bq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a BuilderSelect configured with the given aggregations. +func (bq *BuilderQuery) Aggregate(fns ...AggregateFunc) *BuilderSelect { + return bq.Select().Aggregate(fns...) +} + +func (bq *BuilderQuery) prepareQuery(ctx context.Context) error { + for _, inter := range bq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, bq); err != nil { + return err + } + } + } + for _, f := range bq.ctx.Fields { + if !builder.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if bq.path != nil { + prev, err := bq.path(ctx) + if err != nil { + return err + } + bq.sql = prev + } + return nil +} + +func (bq *BuilderQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Builder, error) { + var ( + nodes = []*Builder{} + _spec = bq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Builder).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Builder{config: bq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + if len(bq.modifiers) > 0 { + _spec.Modifiers = bq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, bq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + for i := range bq.loadTotal { + if err := bq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (bq *BuilderQuery) sqlCount(ctx context.Context) (int, error) { + _spec := bq.querySpec() + if len(bq.modifiers) > 0 { + _spec.Modifiers = bq.modifiers + } + _spec.Node.Columns = bq.ctx.Fields + if len(bq.ctx.Fields) > 0 { + _spec.Unique = bq.ctx.Unique != nil && *bq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, bq.driver, _spec) +} + +func (bq *BuilderQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(builder.Table, builder.Columns, sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt)) + _spec.From = bq.sql + if unique := bq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if bq.path != nil { + _spec.Unique = true + } + if fields := bq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, builder.FieldID) + for i := range fields { + if fields[i] != builder.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := bq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := bq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := bq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := bq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (bq *BuilderQuery) sqlQuery(ctx context.Context) *sql.Selector { + builderC := sql.Dialect(bq.driver.Dialect()) + t1 := builderC.Table(builder.Table) + columns := bq.ctx.Fields + if len(columns) == 0 { + columns = builder.Columns + } + selector := builderC.Select(t1.Columns(columns...)...).From(t1) + if bq.sql != nil { + selector = bq.sql + selector.Select(selector.Columns(columns...)...) + } + if bq.ctx.Unique != nil && *bq.ctx.Unique { + selector.Distinct() + } + for _, p := range bq.predicates { + p(selector) + } + for _, p := range bq.order { + p(selector) + } + if offset := bq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := bq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// BuilderGroupBy is the group-by builder for Builder entities. +type BuilderGroupBy struct { + selector + build *BuilderQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (bgb *BuilderGroupBy) Aggregate(fns ...AggregateFunc) *BuilderGroupBy { + bgb.fns = append(bgb.fns, fns...) + return bgb +} + +// Scan applies the selector query and scans the result into the given value. +func (bgb *BuilderGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bgb.build.ctx, ent.OpQueryGroupBy) + if err := bgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BuilderQuery, *BuilderGroupBy](ctx, bgb.build, bgb, bgb.build.inters, v) +} + +func (bgb *BuilderGroupBy) sqlScan(ctx context.Context, root *BuilderQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(bgb.fns)) + for _, fn := range bgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*bgb.flds)+len(bgb.fns)) + for _, f := range *bgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*bgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := bgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// BuilderSelect is the builder for selecting fields of Builder entities. +type BuilderSelect struct { + *BuilderQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (bs *BuilderSelect) Aggregate(fns ...AggregateFunc) *BuilderSelect { + bs.fns = append(bs.fns, fns...) + return bs +} + +// Scan applies the selector query and scans the result into the given value. +func (bs *BuilderSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bs.ctx, ent.OpQuerySelect) + if err := bs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BuilderQuery, *BuilderSelect](ctx, bs.BuilderQuery, bs, bs.inters, v) +} + +func (bs *BuilderSelect) sqlScan(ctx context.Context, root *BuilderQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(bs.fns)) + for _, fn := range bs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*bs.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := bs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/tavern/internal/ent/builder_update.go b/tavern/internal/ent/builder_update.go new file mode 100644 index 000000000..bb70a9a18 --- /dev/null +++ b/tavern/internal/ent/builder_update.go @@ -0,0 +1,288 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/dialect/sql/sqljson" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/predicate" +) + +// BuilderUpdate is the builder for updating Builder entities. +type BuilderUpdate struct { + config + hooks []Hook + mutation *BuilderMutation +} + +// Where appends a list predicates to the BuilderUpdate builder. +func (bu *BuilderUpdate) Where(ps ...predicate.Builder) *BuilderUpdate { + bu.mutation.Where(ps...) + return bu +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (bu *BuilderUpdate) SetLastModifiedAt(t time.Time) *BuilderUpdate { + bu.mutation.SetLastModifiedAt(t) + return bu +} + +// SetSupportedTargets sets the "supported_targets" field. +func (bu *BuilderUpdate) SetSupportedTargets(cp []c2pb.Host_Platform) *BuilderUpdate { + bu.mutation.SetSupportedTargets(cp) + return bu +} + +// AppendSupportedTargets appends cp to the "supported_targets" field. +func (bu *BuilderUpdate) AppendSupportedTargets(cp []c2pb.Host_Platform) *BuilderUpdate { + bu.mutation.AppendSupportedTargets(cp) + return bu +} + +// SetUpstream sets the "upstream" field. +func (bu *BuilderUpdate) SetUpstream(s string) *BuilderUpdate { + bu.mutation.SetUpstream(s) + return bu +} + +// SetNillableUpstream sets the "upstream" field if the given value is not nil. +func (bu *BuilderUpdate) SetNillableUpstream(s *string) *BuilderUpdate { + if s != nil { + bu.SetUpstream(*s) + } + return bu +} + +// Mutation returns the BuilderMutation object of the builder. +func (bu *BuilderUpdate) Mutation() *BuilderMutation { + return bu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (bu *BuilderUpdate) Save(ctx context.Context) (int, error) { + bu.defaults() + return withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (bu *BuilderUpdate) SaveX(ctx context.Context) int { + affected, err := bu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (bu *BuilderUpdate) Exec(ctx context.Context) error { + _, err := bu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bu *BuilderUpdate) ExecX(ctx context.Context) { + if err := bu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (bu *BuilderUpdate) defaults() { + if _, ok := bu.mutation.LastModifiedAt(); !ok { + v := builder.UpdateDefaultLastModifiedAt() + bu.mutation.SetLastModifiedAt(v) + } +} + +func (bu *BuilderUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := sqlgraph.NewUpdateSpec(builder.Table, builder.Columns, sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt)) + if ps := bu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := bu.mutation.LastModifiedAt(); ok { + _spec.SetField(builder.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := bu.mutation.SupportedTargets(); ok { + _spec.SetField(builder.FieldSupportedTargets, field.TypeJSON, value) + } + if value, ok := bu.mutation.AppendedSupportedTargets(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, builder.FieldSupportedTargets, value) + }) + } + if value, ok := bu.mutation.Upstream(); ok { + _spec.SetField(builder.FieldUpstream, field.TypeString, value) + } + if n, err = sqlgraph.UpdateNodes(ctx, bu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{builder.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + bu.mutation.done = true + return n, nil +} + +// BuilderUpdateOne is the builder for updating a single Builder entity. +type BuilderUpdateOne struct { + config + fields []string + hooks []Hook + mutation *BuilderMutation +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (buo *BuilderUpdateOne) SetLastModifiedAt(t time.Time) *BuilderUpdateOne { + buo.mutation.SetLastModifiedAt(t) + return buo +} + +// SetSupportedTargets sets the "supported_targets" field. +func (buo *BuilderUpdateOne) SetSupportedTargets(cp []c2pb.Host_Platform) *BuilderUpdateOne { + buo.mutation.SetSupportedTargets(cp) + return buo +} + +// AppendSupportedTargets appends cp to the "supported_targets" field. +func (buo *BuilderUpdateOne) AppendSupportedTargets(cp []c2pb.Host_Platform) *BuilderUpdateOne { + buo.mutation.AppendSupportedTargets(cp) + return buo +} + +// SetUpstream sets the "upstream" field. +func (buo *BuilderUpdateOne) SetUpstream(s string) *BuilderUpdateOne { + buo.mutation.SetUpstream(s) + return buo +} + +// SetNillableUpstream sets the "upstream" field if the given value is not nil. +func (buo *BuilderUpdateOne) SetNillableUpstream(s *string) *BuilderUpdateOne { + if s != nil { + buo.SetUpstream(*s) + } + return buo +} + +// Mutation returns the BuilderMutation object of the builder. +func (buo *BuilderUpdateOne) Mutation() *BuilderMutation { + return buo.mutation +} + +// Where appends a list predicates to the BuilderUpdate builder. +func (buo *BuilderUpdateOne) Where(ps ...predicate.Builder) *BuilderUpdateOne { + buo.mutation.Where(ps...) + return buo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (buo *BuilderUpdateOne) Select(field string, fields ...string) *BuilderUpdateOne { + buo.fields = append([]string{field}, fields...) + return buo +} + +// Save executes the query and returns the updated Builder entity. +func (buo *BuilderUpdateOne) Save(ctx context.Context) (*Builder, error) { + buo.defaults() + return withHooks(ctx, buo.sqlSave, buo.mutation, buo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (buo *BuilderUpdateOne) SaveX(ctx context.Context) *Builder { + node, err := buo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (buo *BuilderUpdateOne) Exec(ctx context.Context) error { + _, err := buo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (buo *BuilderUpdateOne) ExecX(ctx context.Context) { + if err := buo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (buo *BuilderUpdateOne) defaults() { + if _, ok := buo.mutation.LastModifiedAt(); !ok { + v := builder.UpdateDefaultLastModifiedAt() + buo.mutation.SetLastModifiedAt(v) + } +} + +func (buo *BuilderUpdateOne) sqlSave(ctx context.Context) (_node *Builder, err error) { + _spec := sqlgraph.NewUpdateSpec(builder.Table, builder.Columns, sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt)) + id, ok := buo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Builder.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := buo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, builder.FieldID) + for _, f := range fields { + if !builder.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != builder.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := buo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := buo.mutation.LastModifiedAt(); ok { + _spec.SetField(builder.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := buo.mutation.SupportedTargets(); ok { + _spec.SetField(builder.FieldSupportedTargets, field.TypeJSON, value) + } + if value, ok := buo.mutation.AppendedSupportedTargets(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, builder.FieldSupportedTargets, value) + }) + } + if value, ok := buo.mutation.Upstream(); ok { + _spec.SetField(builder.FieldUpstream, field.TypeString, value) + } + _node = &Builder{config: buo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, buo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{builder.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + buo.mutation.done = true + return _node, nil +} diff --git a/tavern/internal/ent/client.go b/tavern/internal/ent/client.go index 357480932..c7d03463c 100644 --- a/tavern/internal/ent/client.go +++ b/tavern/internal/ent/client.go @@ -17,6 +17,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -41,6 +42,8 @@ type Client struct { Asset *AssetClient // Beacon is the client for interacting with the Beacon builders. Beacon *BeaconClient + // Builder is the client for interacting with the Builder builders. + Builder *BuilderClient // Host is the client for interacting with the Host builders. Host *HostClient // HostCredential is the client for interacting with the HostCredential builders. @@ -82,6 +85,7 @@ func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) c.Asset = NewAssetClient(c.config) c.Beacon = NewBeaconClient(c.config) + c.Builder = NewBuilderClient(c.config) c.Host = NewHostClient(c.config) c.HostCredential = NewHostCredentialClient(c.config) c.HostFile = NewHostFileClient(c.config) @@ -189,6 +193,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { config: cfg, Asset: NewAssetClient(cfg), Beacon: NewBeaconClient(cfg), + Builder: NewBuilderClient(cfg), Host: NewHostClient(cfg), HostCredential: NewHostCredentialClient(cfg), HostFile: NewHostFileClient(cfg), @@ -223,6 +228,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) config: cfg, Asset: NewAssetClient(cfg), Beacon: NewBeaconClient(cfg), + Builder: NewBuilderClient(cfg), Host: NewHostClient(cfg), HostCredential: NewHostCredentialClient(cfg), HostFile: NewHostFileClient(cfg), @@ -265,8 +271,9 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Asset, c.Beacon, c.Host, c.HostCredential, c.HostFile, c.HostProcess, c.Link, - c.Portal, c.Quest, c.Repository, c.Shell, c.Tag, c.Task, c.Tome, c.User, + c.Asset, c.Beacon, c.Builder, c.Host, c.HostCredential, c.HostFile, + c.HostProcess, c.Link, c.Portal, c.Quest, c.Repository, c.Shell, c.Tag, c.Task, + c.Tome, c.User, } { n.Use(hooks...) } @@ -276,8 +283,9 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Asset, c.Beacon, c.Host, c.HostCredential, c.HostFile, c.HostProcess, c.Link, - c.Portal, c.Quest, c.Repository, c.Shell, c.Tag, c.Task, c.Tome, c.User, + c.Asset, c.Beacon, c.Builder, c.Host, c.HostCredential, c.HostFile, + c.HostProcess, c.Link, c.Portal, c.Quest, c.Repository, c.Shell, c.Tag, c.Task, + c.Tome, c.User, } { n.Intercept(interceptors...) } @@ -290,6 +298,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Asset.mutate(ctx, m) case *BeaconMutation: return c.Beacon.mutate(ctx, m) + case *BuilderMutation: + return c.Builder.mutate(ctx, m) case *HostMutation: return c.Host.mutate(ctx, m) case *HostCredentialMutation: @@ -668,6 +678,139 @@ func (c *BeaconClient) mutate(ctx context.Context, m *BeaconMutation) (Value, er } } +// BuilderClient is a client for the Builder schema. +type BuilderClient struct { + config +} + +// NewBuilderClient returns a client for the Builder from the given config. +func NewBuilderClient(c config) *BuilderClient { + return &BuilderClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `builder.Hooks(f(g(h())))`. +func (c *BuilderClient) Use(hooks ...Hook) { + c.hooks.Builder = append(c.hooks.Builder, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `builder.Intercept(f(g(h())))`. +func (c *BuilderClient) Intercept(interceptors ...Interceptor) { + c.inters.Builder = append(c.inters.Builder, interceptors...) +} + +// Create returns a builder for creating a Builder entity. +func (c *BuilderClient) Create() *BuilderCreate { + mutation := newBuilderMutation(c.config, OpCreate) + return &BuilderCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Builder entities. +func (c *BuilderClient) CreateBulk(builders ...*BuilderCreate) *BuilderCreateBulk { + return &BuilderCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *BuilderClient) MapCreateBulk(slice any, setFunc func(*BuilderCreate, int)) *BuilderCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BuilderCreateBulk{err: fmt.Errorf("calling to BuilderClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BuilderCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BuilderCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Builder. +func (c *BuilderClient) Update() *BuilderUpdate { + mutation := newBuilderMutation(c.config, OpUpdate) + return &BuilderUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *BuilderClient) UpdateOne(b *Builder) *BuilderUpdateOne { + mutation := newBuilderMutation(c.config, OpUpdateOne, withBuilder(b)) + return &BuilderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *BuilderClient) UpdateOneID(id int) *BuilderUpdateOne { + mutation := newBuilderMutation(c.config, OpUpdateOne, withBuilderID(id)) + return &BuilderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Builder. +func (c *BuilderClient) Delete() *BuilderDelete { + mutation := newBuilderMutation(c.config, OpDelete) + return &BuilderDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *BuilderClient) DeleteOne(b *Builder) *BuilderDeleteOne { + return c.DeleteOneID(b.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *BuilderClient) DeleteOneID(id int) *BuilderDeleteOne { + builderC := c.Delete().Where(builder.ID(id)) + builderC.mutation.id = &id + builderC.mutation.op = OpDeleteOne + return &BuilderDeleteOne{builderC} +} + +// Query returns a query builder for Builder. +func (c *BuilderClient) Query() *BuilderQuery { + return &BuilderQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeBuilder}, + inters: c.Interceptors(), + } +} + +// Get returns a Builder entity by its id. +func (c *BuilderClient) Get(ctx context.Context, id int) (*Builder, error) { + return c.Query().Where(builder.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *BuilderClient) GetX(ctx context.Context, id int) *Builder { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *BuilderClient) Hooks() []Hook { + return c.hooks.Builder +} + +// Interceptors returns the client interceptors. +func (c *BuilderClient) Interceptors() []Interceptor { + return c.inters.Builder +} + +func (c *BuilderClient) mutate(ctx context.Context, m *BuilderMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&BuilderCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&BuilderUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&BuilderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&BuilderDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Builder mutation op: %q", m.Op()) + } +} + // HostClient is a client for the Host schema. type HostClient struct { config @@ -3028,11 +3171,11 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) // hooks and interceptors per client, for fast access. type ( hooks struct { - Asset, Beacon, Host, HostCredential, HostFile, HostProcess, Link, Portal, Quest, - Repository, Shell, Tag, Task, Tome, User []ent.Hook + Asset, Beacon, Builder, Host, HostCredential, HostFile, HostProcess, Link, + Portal, Quest, Repository, Shell, Tag, Task, Tome, User []ent.Hook } inters struct { - Asset, Beacon, Host, HostCredential, HostFile, HostProcess, Link, Portal, Quest, - Repository, Shell, Tag, Task, Tome, User []ent.Interceptor + Asset, Beacon, Builder, Host, HostCredential, HostFile, HostProcess, Link, + Portal, Quest, Repository, Shell, Tag, Task, Tome, User []ent.Interceptor } ) diff --git a/tavern/internal/ent/ent.go b/tavern/internal/ent/ent.go index a21bd7f8d..b3c89e42e 100644 --- a/tavern/internal/ent/ent.go +++ b/tavern/internal/ent/ent.go @@ -14,6 +14,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -89,6 +90,7 @@ func checkColumn(table, column string) error { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ asset.Table: asset.ValidColumn, beacon.Table: beacon.ValidColumn, + builder.Table: builder.ValidColumn, host.Table: host.ValidColumn, hostcredential.Table: hostcredential.ValidColumn, hostfile.Table: hostfile.ValidColumn, diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index fa01756e4..2bc7ba9a9 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -12,6 +12,7 @@ import ( "github.com/99designs/gqlgen/graphql" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -653,6 +654,116 @@ func newBeaconPaginateArgs(rv map[string]any) *beaconPaginateArgs { return args } +// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. +func (b *BuilderQuery) CollectFields(ctx context.Context, satisfies ...string) (*BuilderQuery, error) { + fc := graphql.GetFieldContext(ctx) + if fc == nil { + return b, nil + } + if err := b.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + return nil, err + } + return b, nil +} + +func (b *BuilderQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { + path = append([]string(nil), path...) + var ( + unknownSeen bool + fieldSeen = make(map[string]struct{}, len(builder.Columns)) + selectedFields = []string{builder.FieldID} + ) + for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { + switch field.Name { + case "createdAt": + if _, ok := fieldSeen[builder.FieldCreatedAt]; !ok { + selectedFields = append(selectedFields, builder.FieldCreatedAt) + fieldSeen[builder.FieldCreatedAt] = struct{}{} + } + case "lastModifiedAt": + if _, ok := fieldSeen[builder.FieldLastModifiedAt]; !ok { + selectedFields = append(selectedFields, builder.FieldLastModifiedAt) + fieldSeen[builder.FieldLastModifiedAt] = struct{}{} + } + case "supportedTargets": + if _, ok := fieldSeen[builder.FieldSupportedTargets]; !ok { + selectedFields = append(selectedFields, builder.FieldSupportedTargets) + fieldSeen[builder.FieldSupportedTargets] = struct{}{} + } + case "upstream": + if _, ok := fieldSeen[builder.FieldUpstream]; !ok { + selectedFields = append(selectedFields, builder.FieldUpstream) + fieldSeen[builder.FieldUpstream] = struct{}{} + } + case "id": + case "__typename": + default: + unknownSeen = true + } + } + if !unknownSeen { + b.Select(selectedFields...) + } + return nil +} + +type builderPaginateArgs struct { + first, last *int + after, before *Cursor + opts []BuilderPaginateOption +} + +func newBuilderPaginateArgs(rv map[string]any) *builderPaginateArgs { + args := &builderPaginateArgs{} + if rv == nil { + return args + } + if v := rv[firstField]; v != nil { + args.first = v.(*int) + } + if v := rv[lastField]; v != nil { + args.last = v.(*int) + } + if v := rv[afterField]; v != nil { + args.after = v.(*Cursor) + } + if v := rv[beforeField]; v != nil { + args.before = v.(*Cursor) + } + if v, ok := rv[orderByField]; ok { + switch v := v.(type) { + case []*BuilderOrder: + args.opts = append(args.opts, WithBuilderOrder(v)) + case []any: + var orders []*BuilderOrder + for i := range v { + mv, ok := v[i].(map[string]any) + if !ok { + continue + } + var ( + err1, err2 error + order = &BuilderOrder{Field: &BuilderOrderField{}, Direction: entgql.OrderDirectionAsc} + ) + if d, ok := mv[directionField]; ok { + err1 = order.Direction.UnmarshalGQL(d) + } + if f, ok := mv[fieldField]; ok { + err2 = order.Field.UnmarshalGQL(f) + } + if err1 == nil && err2 == nil { + orders = append(orders, order) + } + } + args.opts = append(args.opts, WithBuilderOrder(orders)) + } + } + if v, ok := rv[whereField].(*BuilderWhereInput); ok { + args.opts = append(args.opts, WithBuilderFilter(v.Filter)) + } + return args +} + // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. func (h *HostQuery) CollectFields(ctx context.Context, satisfies ...string) (*HostQuery, error) { fc := graphql.GetFieldContext(ctx) diff --git a/tavern/internal/ent/gql_mutation_input.go b/tavern/internal/ent/gql_mutation_input.go index 8ab4bcc58..4ee249556 100644 --- a/tavern/internal/ent/gql_mutation_input.go +++ b/tavern/internal/ent/gql_mutation_input.go @@ -5,6 +5,7 @@ package ent import ( "time" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/c2/epb" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/tome" @@ -38,6 +39,26 @@ func (c *BeaconUpdateOne) SetInput(i UpdateBeaconInput) *BeaconUpdateOne { return c } +// CreateBuilderInput represents a mutation input for creating builders. +type CreateBuilderInput struct { + SupportedTargets []c2pb.Host_Platform + Upstream string +} + +// Mutate applies the CreateBuilderInput on the BuilderMutation builder. +func (i *CreateBuilderInput) Mutate(m *BuilderMutation) { + if v := i.SupportedTargets; v != nil { + m.SetSupportedTargets(v) + } + m.SetUpstream(i.Upstream) +} + +// SetInput applies the change-set in the CreateBuilderInput on the BuilderCreate builder. +func (c *BuilderCreate) SetInput(i CreateBuilderInput) *BuilderCreate { + i.Mutate(c.Mutation()) + return c +} + // UpdateHostInput represents a mutation input for updating hosts. type UpdateHostInput struct { LastModifiedAt *time.Time diff --git a/tavern/internal/ent/gql_node.go b/tavern/internal/ent/gql_node.go index 5b34d5212..1e4248275 100644 --- a/tavern/internal/ent/gql_node.go +++ b/tavern/internal/ent/gql_node.go @@ -17,6 +17,7 @@ import ( "golang.org/x/sync/semaphore" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -47,6 +48,11 @@ var beaconImplementors = []string{"Beacon", "Node"} // IsNode implements the Node interface check for GQLGen. func (*Beacon) IsNode() {} +var builderImplementors = []string{"Builder", "Node"} + +// IsNode implements the Node interface check for GQLGen. +func (*Builder) IsNode() {} + var hostImplementors = []string{"Host", "Node"} // IsNode implements the Node interface check for GQLGen. @@ -188,6 +194,15 @@ func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) } } return query.Only(ctx) + case builder.Table: + query := c.Builder.Query(). + Where(builder.ID(id)) + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, builderImplementors...); err != nil { + return nil, err + } + } + return query.Only(ctx) case host.Table: query := c.Host.Query(). Where(host.ID(id)) @@ -410,6 +425,22 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, *noder = node } } + case builder.Table: + query := c.Builder.Query(). + Where(builder.IDIn(ids...)) + query, err := query.CollectFields(ctx, builderImplementors...) + if err != nil { + return nil, err + } + nodes, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, node := range nodes { + for _, noder := range idmap[node.ID] { + *noder = node + } + } case host.Table: query := c.Host.Query(). Where(host.IDIn(ids...)) diff --git a/tavern/internal/ent/gql_pagination.go b/tavern/internal/ent/gql_pagination.go index 8e1cbd0ea..074020ae7 100644 --- a/tavern/internal/ent/gql_pagination.go +++ b/tavern/internal/ent/gql_pagination.go @@ -17,6 +17,7 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -902,6 +903,356 @@ func (b *Beacon) ToEdge(order *BeaconOrder) *BeaconEdge { } } +// BuilderEdge is the edge representation of Builder. +type BuilderEdge struct { + Node *Builder `json:"node"` + Cursor Cursor `json:"cursor"` +} + +// BuilderConnection is the connection containing edges to Builder. +type BuilderConnection struct { + Edges []*BuilderEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + +func (c *BuilderConnection) build(nodes []*Builder, pager *builderPager, after *Cursor, first *int, before *Cursor, last *int) { + c.PageInfo.HasNextPage = before != nil + c.PageInfo.HasPreviousPage = after != nil + if first != nil && *first+1 == len(nodes) { + c.PageInfo.HasNextPage = true + nodes = nodes[:len(nodes)-1] + } else if last != nil && *last+1 == len(nodes) { + c.PageInfo.HasPreviousPage = true + nodes = nodes[:len(nodes)-1] + } + var nodeAt func(int) *Builder + if last != nil { + n := len(nodes) - 1 + nodeAt = func(i int) *Builder { + return nodes[n-i] + } + } else { + nodeAt = func(i int) *Builder { + return nodes[i] + } + } + c.Edges = make([]*BuilderEdge, len(nodes)) + for i := range nodes { + node := nodeAt(i) + c.Edges[i] = &BuilderEdge{ + Node: node, + Cursor: pager.toCursor(node), + } + } + if l := len(c.Edges); l > 0 { + c.PageInfo.StartCursor = &c.Edges[0].Cursor + c.PageInfo.EndCursor = &c.Edges[l-1].Cursor + } + if c.TotalCount == 0 { + c.TotalCount = len(nodes) + } +} + +// BuilderPaginateOption enables pagination customization. +type BuilderPaginateOption func(*builderPager) error + +// WithBuilderOrder configures pagination ordering. +func WithBuilderOrder(order []*BuilderOrder) BuilderPaginateOption { + return func(pager *builderPager) error { + for _, o := range order { + if err := o.Direction.Validate(); err != nil { + return err + } + } + pager.order = append(pager.order, order...) + return nil + } +} + +// WithBuilderFilter configures pagination filter. +func WithBuilderFilter(filter func(*BuilderQuery) (*BuilderQuery, error)) BuilderPaginateOption { + return func(pager *builderPager) error { + if filter == nil { + return errors.New("BuilderQuery filter cannot be nil") + } + pager.filter = filter + return nil + } +} + +type builderPager struct { + reverse bool + order []*BuilderOrder + filter func(*BuilderQuery) (*BuilderQuery, error) +} + +func newBuilderPager(opts []BuilderPaginateOption, reverse bool) (*builderPager, error) { + pager := &builderPager{reverse: reverse} + for _, opt := range opts { + if err := opt(pager); err != nil { + return nil, err + } + } + for i, o := range pager.order { + if i > 0 && o.Field == pager.order[i-1].Field { + return nil, fmt.Errorf("duplicate order direction %q", o.Direction) + } + } + return pager, nil +} + +func (p *builderPager) applyFilter(query *BuilderQuery) (*BuilderQuery, error) { + if p.filter != nil { + return p.filter(query) + } + return query, nil +} + +func (p *builderPager) toCursor(b *Builder) Cursor { + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(b).Value) + } + return Cursor{ID: b.ID, Value: cs_} +} + +func (p *builderPager) applyCursors(query *BuilderQuery, after, before *Cursor) (*BuilderQuery, error) { + idDirection := entgql.OrderDirectionAsc + if p.reverse { + idDirection = entgql.OrderDirectionDesc + } + fields, directions := make([]string, 0, len(p.order)), make([]OrderDirection, 0, len(p.order)) + for _, o := range p.order { + fields = append(fields, o.Field.column) + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + directions = append(directions, direction) + } + predicates, err := entgql.MultiCursorsPredicate(after, before, &entgql.MultiCursorsOptions{ + FieldID: DefaultBuilderOrder.Field.column, + DirectionID: idDirection, + Fields: fields, + Directions: directions, + }) + if err != nil { + return nil, err + } + for _, predicate := range predicates { + query = query.Where(predicate) + } + return query, nil +} + +func (p *builderPager) applyOrder(query *BuilderQuery) *BuilderQuery { + var defaultOrdered bool + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + if o.Field.column == DefaultBuilderOrder.Field.column { + defaultOrdered = true + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } + } + if !defaultOrdered { + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(DefaultBuilderOrder.Field.toTerm(direction.OrderTermOption())) + } + return query +} + +func (p *builderPager) orderExpr(query *BuilderQuery) sql.Querier { + if len(query.ctx.Fields) > 0 { + for _, o := range p.order { + query.ctx.AppendFieldOnce(o.Field.column) + } + } + return sql.ExprFunc(func(b *sql.Builder) { + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + b.Ident(o.Field.column).Pad().WriteString(string(direction)) + b.Comma() + } + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() + } + b.Ident(DefaultBuilderOrder.Field.column).Pad().WriteString(string(direction)) + }) +} + +// Paginate executes the query and returns a relay based cursor connection to Builder. +func (b *BuilderQuery) Paginate( + ctx context.Context, after *Cursor, first *int, + before *Cursor, last *int, opts ...BuilderPaginateOption, +) (*BuilderConnection, error) { + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newBuilderPager(opts, last != nil) + if err != nil { + return nil, err + } + if b, err = pager.applyFilter(b); err != nil { + return nil, err + } + conn := &BuilderConnection{Edges: []*BuilderEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + hasPagination := after != nil || first != nil || before != nil || last != nil + if hasPagination || ignoredEdges { + c := b.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { + return nil, err + } + conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 + conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 + } + } + if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { + return conn, nil + } + if b, err = pager.applyCursors(b, after, before); err != nil { + return nil, err + } + limit := paginateLimit(first, last) + if limit != 0 { + b.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := b.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + b = pager.applyOrder(b) + nodes, err := b.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil +} + +var ( + // BuilderOrderFieldCreatedAt orders Builder by created_at. + BuilderOrderFieldCreatedAt = &BuilderOrderField{ + Value: func(b *Builder) (ent.Value, error) { + return b.CreatedAt, nil + }, + column: builder.FieldCreatedAt, + toTerm: builder.ByCreatedAt, + toCursor: func(b *Builder) Cursor { + return Cursor{ + ID: b.ID, + Value: b.CreatedAt, + } + }, + } + // BuilderOrderFieldLastModifiedAt orders Builder by last_modified_at. + BuilderOrderFieldLastModifiedAt = &BuilderOrderField{ + Value: func(b *Builder) (ent.Value, error) { + return b.LastModifiedAt, nil + }, + column: builder.FieldLastModifiedAt, + toTerm: builder.ByLastModifiedAt, + toCursor: func(b *Builder) Cursor { + return Cursor{ + ID: b.ID, + Value: b.LastModifiedAt, + } + }, + } +) + +// String implement fmt.Stringer interface. +func (f BuilderOrderField) String() string { + var str string + switch f.column { + case BuilderOrderFieldCreatedAt.column: + str = "CREATED_AT" + case BuilderOrderFieldLastModifiedAt.column: + str = "LAST_MODIFIED_AT" + } + return str +} + +// MarshalGQL implements graphql.Marshaler interface. +func (f BuilderOrderField) MarshalGQL(w io.Writer) { + io.WriteString(w, strconv.Quote(f.String())) +} + +// UnmarshalGQL implements graphql.Unmarshaler interface. +func (f *BuilderOrderField) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("BuilderOrderField %T must be a string", v) + } + switch str { + case "CREATED_AT": + *f = *BuilderOrderFieldCreatedAt + case "LAST_MODIFIED_AT": + *f = *BuilderOrderFieldLastModifiedAt + default: + return fmt.Errorf("%s is not a valid BuilderOrderField", str) + } + return nil +} + +// BuilderOrderField defines the ordering field of Builder. +type BuilderOrderField struct { + // Value extracts the ordering value from the given Builder. + Value func(*Builder) (ent.Value, error) + column string // field or computed. + toTerm func(...sql.OrderTermOption) builder.OrderOption + toCursor func(*Builder) Cursor +} + +// BuilderOrder defines the ordering of Builder. +type BuilderOrder struct { + Direction OrderDirection `json:"direction"` + Field *BuilderOrderField `json:"field"` +} + +// DefaultBuilderOrder is the default ordering of Builder. +var DefaultBuilderOrder = &BuilderOrder{ + Direction: entgql.OrderDirectionAsc, + Field: &BuilderOrderField{ + Value: func(b *Builder) (ent.Value, error) { + return b.ID, nil + }, + column: builder.FieldID, + toTerm: builder.ByID, + toCursor: func(b *Builder) Cursor { + return Cursor{ID: b.ID} + }, + }, +} + +// ToEdge converts Builder into BuilderEdge. +func (b *Builder) ToEdge(order *BuilderOrder) *BuilderEdge { + if order == nil { + order = DefaultBuilderOrder + } + return &BuilderEdge{ + Node: b, + Cursor: order.Field.toCursor(b), + } +} + // HostEdge is the edge representation of Host. type HostEdge struct { Node *Host `json:"node"` diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index 02b6a5e6c..6fa734934 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -11,6 +11,7 @@ import ( "realm.pub/tavern/internal/c2/epb" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -1039,6 +1040,252 @@ func (i *BeaconWhereInput) P() (predicate.Beacon, error) { } } +// BuilderWhereInput represents a where input for filtering Builder queries. +type BuilderWhereInput struct { + Predicates []predicate.Builder `json:"-"` + Not *BuilderWhereInput `json:"not,omitempty"` + Or []*BuilderWhereInput `json:"or,omitempty"` + And []*BuilderWhereInput `json:"and,omitempty"` + + // "id" field predicates. + ID *int `json:"id,omitempty"` + IDNEQ *int `json:"idNEQ,omitempty"` + IDIn []int `json:"idIn,omitempty"` + IDNotIn []int `json:"idNotIn,omitempty"` + IDGT *int `json:"idGT,omitempty"` + IDGTE *int `json:"idGTE,omitempty"` + IDLT *int `json:"idLT,omitempty"` + IDLTE *int `json:"idLTE,omitempty"` + + // "created_at" field predicates. + CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAtNEQ *time.Time `json:"createdAtNEQ,omitempty"` + CreatedAtIn []time.Time `json:"createdAtIn,omitempty"` + CreatedAtNotIn []time.Time `json:"createdAtNotIn,omitempty"` + CreatedAtGT *time.Time `json:"createdAtGT,omitempty"` + CreatedAtGTE *time.Time `json:"createdAtGTE,omitempty"` + CreatedAtLT *time.Time `json:"createdAtLT,omitempty"` + CreatedAtLTE *time.Time `json:"createdAtLTE,omitempty"` + + // "last_modified_at" field predicates. + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAtNEQ *time.Time `json:"lastModifiedAtNEQ,omitempty"` + LastModifiedAtIn []time.Time `json:"lastModifiedAtIn,omitempty"` + LastModifiedAtNotIn []time.Time `json:"lastModifiedAtNotIn,omitempty"` + LastModifiedAtGT *time.Time `json:"lastModifiedAtGT,omitempty"` + LastModifiedAtGTE *time.Time `json:"lastModifiedAtGTE,omitempty"` + LastModifiedAtLT *time.Time `json:"lastModifiedAtLT,omitempty"` + LastModifiedAtLTE *time.Time `json:"lastModifiedAtLTE,omitempty"` + + // "upstream" field predicates. + Upstream *string `json:"upstream,omitempty"` + UpstreamNEQ *string `json:"upstreamNEQ,omitempty"` + UpstreamIn []string `json:"upstreamIn,omitempty"` + UpstreamNotIn []string `json:"upstreamNotIn,omitempty"` + UpstreamGT *string `json:"upstreamGT,omitempty"` + UpstreamGTE *string `json:"upstreamGTE,omitempty"` + UpstreamLT *string `json:"upstreamLT,omitempty"` + UpstreamLTE *string `json:"upstreamLTE,omitempty"` + UpstreamContains *string `json:"upstreamContains,omitempty"` + UpstreamHasPrefix *string `json:"upstreamHasPrefix,omitempty"` + UpstreamHasSuffix *string `json:"upstreamHasSuffix,omitempty"` + UpstreamEqualFold *string `json:"upstreamEqualFold,omitempty"` + UpstreamContainsFold *string `json:"upstreamContainsFold,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *BuilderWhereInput) AddPredicates(predicates ...predicate.Builder) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the BuilderWhereInput filter on the BuilderQuery builder. +func (i *BuilderWhereInput) Filter(q *BuilderQuery) (*BuilderQuery, error) { + if i == nil { + return q, nil + } + p, err := i.P() + if err != nil { + if err == ErrEmptyBuilderWhereInput { + return q, nil + } + return nil, err + } + return q.Where(p), nil +} + +// ErrEmptyBuilderWhereInput is returned in case the BuilderWhereInput is empty. +var ErrEmptyBuilderWhereInput = errors.New("ent: empty predicate BuilderWhereInput") + +// P returns a predicate for filtering builders. +// An error is returned if the input is empty or invalid. +func (i *BuilderWhereInput) P() (predicate.Builder, error) { + var predicates []predicate.Builder + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, builder.Not(p)) + } + switch n := len(i.Or); { + case n == 1: + p, err := i.Or[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + predicates = append(predicates, p) + case n > 1: + or := make([]predicate.Builder, 0, n) + for _, w := range i.Or { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + or = append(or, p) + } + predicates = append(predicates, builder.Or(or...)) + } + switch n := len(i.And); { + case n == 1: + p, err := i.And[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + predicates = append(predicates, p) + case n > 1: + and := make([]predicate.Builder, 0, n) + for _, w := range i.And { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + and = append(and, p) + } + predicates = append(predicates, builder.And(and...)) + } + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, builder.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, builder.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, builder.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, builder.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, builder.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, builder.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, builder.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, builder.IDLTE(*i.IDLTE)) + } + if i.CreatedAt != nil { + predicates = append(predicates, builder.CreatedAtEQ(*i.CreatedAt)) + } + if i.CreatedAtNEQ != nil { + predicates = append(predicates, builder.CreatedAtNEQ(*i.CreatedAtNEQ)) + } + if len(i.CreatedAtIn) > 0 { + predicates = append(predicates, builder.CreatedAtIn(i.CreatedAtIn...)) + } + if len(i.CreatedAtNotIn) > 0 { + predicates = append(predicates, builder.CreatedAtNotIn(i.CreatedAtNotIn...)) + } + if i.CreatedAtGT != nil { + predicates = append(predicates, builder.CreatedAtGT(*i.CreatedAtGT)) + } + if i.CreatedAtGTE != nil { + predicates = append(predicates, builder.CreatedAtGTE(*i.CreatedAtGTE)) + } + if i.CreatedAtLT != nil { + predicates = append(predicates, builder.CreatedAtLT(*i.CreatedAtLT)) + } + if i.CreatedAtLTE != nil { + predicates = append(predicates, builder.CreatedAtLTE(*i.CreatedAtLTE)) + } + if i.LastModifiedAt != nil { + predicates = append(predicates, builder.LastModifiedAtEQ(*i.LastModifiedAt)) + } + if i.LastModifiedAtNEQ != nil { + predicates = append(predicates, builder.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) + } + if len(i.LastModifiedAtIn) > 0 { + predicates = append(predicates, builder.LastModifiedAtIn(i.LastModifiedAtIn...)) + } + if len(i.LastModifiedAtNotIn) > 0 { + predicates = append(predicates, builder.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) + } + if i.LastModifiedAtGT != nil { + predicates = append(predicates, builder.LastModifiedAtGT(*i.LastModifiedAtGT)) + } + if i.LastModifiedAtGTE != nil { + predicates = append(predicates, builder.LastModifiedAtGTE(*i.LastModifiedAtGTE)) + } + if i.LastModifiedAtLT != nil { + predicates = append(predicates, builder.LastModifiedAtLT(*i.LastModifiedAtLT)) + } + if i.LastModifiedAtLTE != nil { + predicates = append(predicates, builder.LastModifiedAtLTE(*i.LastModifiedAtLTE)) + } + if i.Upstream != nil { + predicates = append(predicates, builder.UpstreamEQ(*i.Upstream)) + } + if i.UpstreamNEQ != nil { + predicates = append(predicates, builder.UpstreamNEQ(*i.UpstreamNEQ)) + } + if len(i.UpstreamIn) > 0 { + predicates = append(predicates, builder.UpstreamIn(i.UpstreamIn...)) + } + if len(i.UpstreamNotIn) > 0 { + predicates = append(predicates, builder.UpstreamNotIn(i.UpstreamNotIn...)) + } + if i.UpstreamGT != nil { + predicates = append(predicates, builder.UpstreamGT(*i.UpstreamGT)) + } + if i.UpstreamGTE != nil { + predicates = append(predicates, builder.UpstreamGTE(*i.UpstreamGTE)) + } + if i.UpstreamLT != nil { + predicates = append(predicates, builder.UpstreamLT(*i.UpstreamLT)) + } + if i.UpstreamLTE != nil { + predicates = append(predicates, builder.UpstreamLTE(*i.UpstreamLTE)) + } + if i.UpstreamContains != nil { + predicates = append(predicates, builder.UpstreamContains(*i.UpstreamContains)) + } + if i.UpstreamHasPrefix != nil { + predicates = append(predicates, builder.UpstreamHasPrefix(*i.UpstreamHasPrefix)) + } + if i.UpstreamHasSuffix != nil { + predicates = append(predicates, builder.UpstreamHasSuffix(*i.UpstreamHasSuffix)) + } + if i.UpstreamEqualFold != nil { + predicates = append(predicates, builder.UpstreamEqualFold(*i.UpstreamEqualFold)) + } + if i.UpstreamContainsFold != nil { + predicates = append(predicates, builder.UpstreamContainsFold(*i.UpstreamContainsFold)) + } + + switch len(predicates) { + case 0: + return nil, ErrEmptyBuilderWhereInput + case 1: + return predicates[0], nil + default: + return builder.And(predicates...), nil + } +} + // HostWhereInput represents a where input for filtering Host queries. type HostWhereInput struct { Predicates []predicate.Host `json:"-"` diff --git a/tavern/internal/ent/hook/hook.go b/tavern/internal/ent/hook/hook.go index 3f2677073..6c3f39320 100644 --- a/tavern/internal/ent/hook/hook.go +++ b/tavern/internal/ent/hook/hook.go @@ -33,6 +33,18 @@ func (f BeaconFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, erro return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BeaconMutation", m) } +// The BuilderFunc type is an adapter to allow the use of ordinary +// function as Builder mutator. +type BuilderFunc func(context.Context, *ent.BuilderMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f BuilderFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.BuilderMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BuilderMutation", m) +} + // The HostFunc type is an adapter to allow the use of ordinary // function as Host mutator. type HostFunc func(context.Context, *ent.HostMutation) (ent.Value, error) diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index e5000572d..0822396a8 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -54,6 +54,20 @@ var ( }, }, } + // BuildersColumns holds the columns for the "builders" table. + BuildersColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "last_modified_at", Type: field.TypeTime}, + {Name: "supported_targets", Type: field.TypeJSON}, + {Name: "upstream", Type: field.TypeString}, + } + // BuildersTable holds the schema information for the "builders" table. + BuildersTable = &schema.Table{ + Name: "builders", + Columns: BuildersColumns, + PrimaryKey: []*schema.Column{BuildersColumns[0]}, + } // HostsColumns holds the columns for the "hosts" table. HostsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -550,6 +564,7 @@ var ( Tables = []*schema.Table{ AssetsTable, BeaconsTable, + BuildersTable, HostsTable, HostCredentialsTable, HostFilesTable, @@ -577,6 +592,9 @@ func init() { BeaconsTable.Annotation = &entsql.Annotation{ Collation: "utf8mb4_general_ci", } + BuildersTable.Annotation = &entsql.Annotation{ + Collation: "utf8mb4_general_ci", + } HostsTable.ForeignKeys[0].RefTable = TomesTable HostsTable.Annotation = &entsql.Annotation{ Collation: "utf8mb4_general_ci", diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index e82aeaf85..08b2e6411 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -15,6 +15,7 @@ import ( "realm.pub/tavern/internal/c2/epb" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -42,6 +43,7 @@ const ( // Node types. TypeAsset = "Asset" TypeBeacon = "Beacon" + TypeBuilder = "Builder" TypeHost = "Host" TypeHostCredential = "HostCredential" TypeHostFile = "HostFile" @@ -2047,6 +2049,510 @@ func (m *BeaconMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Beacon edge %s", name) } +// BuilderMutation represents an operation that mutates the Builder nodes in the graph. +type BuilderMutation struct { + config + op Op + typ string + id *int + created_at *time.Time + last_modified_at *time.Time + supported_targets *[]c2pb.Host_Platform + appendsupported_targets []c2pb.Host_Platform + upstream *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Builder, error) + predicates []predicate.Builder +} + +var _ ent.Mutation = (*BuilderMutation)(nil) + +// builderOption allows management of the mutation configuration using functional options. +type builderOption func(*BuilderMutation) + +// newBuilderMutation creates new mutation for the Builder entity. +func newBuilderMutation(c config, op Op, opts ...builderOption) *BuilderMutation { + m := &BuilderMutation{ + config: c, + op: op, + typ: TypeBuilder, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withBuilderID sets the ID field of the mutation. +func withBuilderID(id int) builderOption { + return func(m *BuilderMutation) { + var ( + err error + once sync.Once + value *Builder + ) + m.oldValue = func(ctx context.Context) (*Builder, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Builder.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withBuilder sets the old Builder of the mutation. +func withBuilder(node *Builder) builderOption { + return func(m *BuilderMutation) { + m.oldValue = func(context.Context) (*Builder, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m BuilderMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m BuilderMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *BuilderMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *BuilderMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Builder.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *BuilderMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *BuilderMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Builder entity. +// If the Builder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuilderMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *BuilderMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (m *BuilderMutation) SetLastModifiedAt(t time.Time) { + m.last_modified_at = &t +} + +// LastModifiedAt returns the value of the "last_modified_at" field in the mutation. +func (m *BuilderMutation) LastModifiedAt() (r time.Time, exists bool) { + v := m.last_modified_at + if v == nil { + return + } + return *v, true +} + +// OldLastModifiedAt returns the old "last_modified_at" field's value of the Builder entity. +// If the Builder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuilderMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastModifiedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastModifiedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastModifiedAt: %w", err) + } + return oldValue.LastModifiedAt, nil +} + +// ResetLastModifiedAt resets all changes to the "last_modified_at" field. +func (m *BuilderMutation) ResetLastModifiedAt() { + m.last_modified_at = nil +} + +// SetSupportedTargets sets the "supported_targets" field. +func (m *BuilderMutation) SetSupportedTargets(cp []c2pb.Host_Platform) { + m.supported_targets = &cp + m.appendsupported_targets = nil +} + +// SupportedTargets returns the value of the "supported_targets" field in the mutation. +func (m *BuilderMutation) SupportedTargets() (r []c2pb.Host_Platform, exists bool) { + v := m.supported_targets + if v == nil { + return + } + return *v, true +} + +// OldSupportedTargets returns the old "supported_targets" field's value of the Builder entity. +// If the Builder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuilderMutation) OldSupportedTargets(ctx context.Context) (v []c2pb.Host_Platform, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSupportedTargets is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSupportedTargets requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSupportedTargets: %w", err) + } + return oldValue.SupportedTargets, nil +} + +// AppendSupportedTargets adds cp to the "supported_targets" field. +func (m *BuilderMutation) AppendSupportedTargets(cp []c2pb.Host_Platform) { + m.appendsupported_targets = append(m.appendsupported_targets, cp...) +} + +// AppendedSupportedTargets returns the list of values that were appended to the "supported_targets" field in this mutation. +func (m *BuilderMutation) AppendedSupportedTargets() ([]c2pb.Host_Platform, bool) { + if len(m.appendsupported_targets) == 0 { + return nil, false + } + return m.appendsupported_targets, true +} + +// ResetSupportedTargets resets all changes to the "supported_targets" field. +func (m *BuilderMutation) ResetSupportedTargets() { + m.supported_targets = nil + m.appendsupported_targets = nil +} + +// SetUpstream sets the "upstream" field. +func (m *BuilderMutation) SetUpstream(s string) { + m.upstream = &s +} + +// Upstream returns the value of the "upstream" field in the mutation. +func (m *BuilderMutation) Upstream() (r string, exists bool) { + v := m.upstream + if v == nil { + return + } + return *v, true +} + +// OldUpstream returns the old "upstream" field's value of the Builder entity. +// If the Builder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuilderMutation) OldUpstream(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpstream is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpstream requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpstream: %w", err) + } + return oldValue.Upstream, nil +} + +// ResetUpstream resets all changes to the "upstream" field. +func (m *BuilderMutation) ResetUpstream() { + m.upstream = nil +} + +// Where appends a list predicates to the BuilderMutation builder. +func (m *BuilderMutation) Where(ps ...predicate.Builder) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the BuilderMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *BuilderMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Builder, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *BuilderMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *BuilderMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Builder). +func (m *BuilderMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *BuilderMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.created_at != nil { + fields = append(fields, builder.FieldCreatedAt) + } + if m.last_modified_at != nil { + fields = append(fields, builder.FieldLastModifiedAt) + } + if m.supported_targets != nil { + fields = append(fields, builder.FieldSupportedTargets) + } + if m.upstream != nil { + fields = append(fields, builder.FieldUpstream) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *BuilderMutation) Field(name string) (ent.Value, bool) { + switch name { + case builder.FieldCreatedAt: + return m.CreatedAt() + case builder.FieldLastModifiedAt: + return m.LastModifiedAt() + case builder.FieldSupportedTargets: + return m.SupportedTargets() + case builder.FieldUpstream: + return m.Upstream() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *BuilderMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case builder.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case builder.FieldLastModifiedAt: + return m.OldLastModifiedAt(ctx) + case builder.FieldSupportedTargets: + return m.OldSupportedTargets(ctx) + case builder.FieldUpstream: + return m.OldUpstream(ctx) + } + return nil, fmt.Errorf("unknown Builder field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *BuilderMutation) SetField(name string, value ent.Value) error { + switch name { + case builder.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case builder.FieldLastModifiedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastModifiedAt(v) + return nil + case builder.FieldSupportedTargets: + v, ok := value.([]c2pb.Host_Platform) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSupportedTargets(v) + return nil + case builder.FieldUpstream: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpstream(v) + return nil + } + return fmt.Errorf("unknown Builder field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *BuilderMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *BuilderMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *BuilderMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Builder numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *BuilderMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *BuilderMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *BuilderMutation) ClearField(name string) error { + return fmt.Errorf("unknown Builder nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *BuilderMutation) ResetField(name string) error { + switch name { + case builder.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case builder.FieldLastModifiedAt: + m.ResetLastModifiedAt() + return nil + case builder.FieldSupportedTargets: + m.ResetSupportedTargets() + return nil + case builder.FieldUpstream: + m.ResetUpstream() + return nil + } + return fmt.Errorf("unknown Builder field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *BuilderMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *BuilderMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *BuilderMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *BuilderMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *BuilderMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *BuilderMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *BuilderMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Builder unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *BuilderMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Builder edge %s", name) +} + // HostMutation represents an operation that mutates the Host nodes in the graph. type HostMutation struct { config diff --git a/tavern/internal/ent/predicate/predicate.go b/tavern/internal/ent/predicate/predicate.go index 349ef9c68..307d53f64 100644 --- a/tavern/internal/ent/predicate/predicate.go +++ b/tavern/internal/ent/predicate/predicate.go @@ -12,6 +12,9 @@ type Asset func(*sql.Selector) // Beacon is the predicate function for beacon builders. type Beacon func(*sql.Selector) +// Builder is the predicate function for builder builders. +type Builder func(*sql.Selector) + // Host is the predicate function for host builders. type Host func(*sql.Selector) diff --git a/tavern/internal/ent/privacy/privacy.go b/tavern/internal/ent/privacy/privacy.go index 42918df69..28cc3463a 100644 --- a/tavern/internal/ent/privacy/privacy.go +++ b/tavern/internal/ent/privacy/privacy.go @@ -158,6 +158,30 @@ func (f BeaconMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.BeaconMutation", m) } +// The BuilderQueryRuleFunc type is an adapter to allow the use of ordinary +// functions as a query rule. +type BuilderQueryRuleFunc func(context.Context, *ent.BuilderQuery) error + +// EvalQuery return f(ctx, q). +func (f BuilderQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.BuilderQuery); ok { + return f(ctx, q) + } + return Denyf("ent/privacy: unexpected query type %T, expect *ent.BuilderQuery", q) +} + +// The BuilderMutationRuleFunc type is an adapter to allow the use of ordinary +// functions as a mutation rule. +type BuilderMutationRuleFunc func(context.Context, *ent.BuilderMutation) error + +// EvalMutation calls f(ctx, m). +func (f BuilderMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { + if m, ok := m.(*ent.BuilderMutation); ok { + return f(ctx, m) + } + return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.BuilderMutation", m) +} + // The HostQueryRuleFunc type is an adapter to allow the use of ordinary // functions as a query rule. type HostQueryRuleFunc func(context.Context, *ent.HostQuery) error diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index bd7b6009e..6c0d5633d 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -7,6 +7,7 @@ import ( "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -93,6 +94,21 @@ func init() { beaconDescAgentIdentifier := beaconFields[3].Descriptor() // beacon.AgentIdentifierValidator is a validator for the "agent_identifier" field. It is called by the builders before save. beacon.AgentIdentifierValidator = beaconDescAgentIdentifier.Validators[0].(func(string) error) + builderMixin := schema.Builder{}.Mixin() + builderMixinFields0 := builderMixin[0].Fields() + _ = builderMixinFields0 + builderFields := schema.Builder{}.Fields() + _ = builderFields + // builderDescCreatedAt is the schema descriptor for created_at field. + builderDescCreatedAt := builderMixinFields0[0].Descriptor() + // builder.DefaultCreatedAt holds the default value on creation for the created_at field. + builder.DefaultCreatedAt = builderDescCreatedAt.Default.(func() time.Time) + // builderDescLastModifiedAt is the schema descriptor for last_modified_at field. + builderDescLastModifiedAt := builderMixinFields0[1].Descriptor() + // builder.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. + builder.DefaultLastModifiedAt = builderDescLastModifiedAt.Default.(func() time.Time) + // builder.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. + builder.UpdateDefaultLastModifiedAt = builderDescLastModifiedAt.UpdateDefault.(func() time.Time) hostMixin := schema.Host{}.Mixin() hostMixinFields0 := hostMixin[0].Fields() _ = hostMixinFields0 diff --git a/tavern/internal/ent/schema/builder.go b/tavern/internal/ent/schema/builder.go new file mode 100644 index 000000000..484c5be3d --- /dev/null +++ b/tavern/internal/ent/schema/builder.go @@ -0,0 +1,54 @@ +package schema + +import ( + "entgo.io/contrib/entgql" + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" +) + +// Builder holds the schema definition for the Builder entity. +type Builder struct { + ent.Schema +} + +// Fields of the Builder. +func (Builder) Fields() []ent.Field { + return []ent.Field{ + field.JSON("supported_targets", []c2pb.Host_Platform{}). + Annotations( + entgql.Type("[HostPlatform!]"), + ). + Comment("The platforms this builder can build agents for."), + field.String("upstream"). + Comment("The server address that the builder should connect to."), + } +} + +// Edges of the Builder. +func (Builder) Edges() []ent.Edge { + return nil +} + +// Annotations describes additional information for the ent. +func (Builder) Annotations() []schema.Annotation { + return []schema.Annotation{ + entgql.RelayConnection(), + entgql.MultiOrder(), + entgql.Mutations( + entgql.MutationCreate(), + ), + entsql.Annotation{ + Collation: "utf8mb4_general_ci", + }, + } +} + +// Mixin defines common shared properties for the ent. +func (Builder) Mixin() []ent.Mixin { + return []ent.Mixin{ + MixinHistory{}, // created_at, last_modified_at + } +} diff --git a/tavern/internal/ent/tx.go b/tavern/internal/ent/tx.go index 0ac7520ee..1fb27f5b7 100644 --- a/tavern/internal/ent/tx.go +++ b/tavern/internal/ent/tx.go @@ -16,6 +16,8 @@ type Tx struct { Asset *AssetClient // Beacon is the client for interacting with the Beacon builders. Beacon *BeaconClient + // Builder is the client for interacting with the Builder builders. + Builder *BuilderClient // Host is the client for interacting with the Host builders. Host *HostClient // HostCredential is the client for interacting with the HostCredential builders. @@ -175,6 +177,7 @@ func (tx *Tx) Client() *Client { func (tx *Tx) init() { tx.Asset = NewAssetClient(tx.config) tx.Beacon = NewBeaconClient(tx.config) + tx.Builder = NewBuilderClient(tx.config) tx.Host = NewHostClient(tx.config) tx.HostCredential = NewHostCredentialClient(tx.config) tx.HostFile = NewHostFileClient(tx.config) diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index 30071cd37..18ee7e36f 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -2392,12 +2392,12 @@ func (ec *executionContext) fieldContext_BeaconEdge_cursor(_ context.Context, fi return fc, nil } -func (ec *executionContext) _Host_id(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_id(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_id, + ec.fieldContext_Builder_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -2408,9 +2408,9 @@ func (ec *executionContext) _Host_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_Host_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, @@ -2421,12 +2421,12 @@ func (ec *executionContext) fieldContext_Host_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _Host_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_createdAt, + ec.fieldContext_Builder_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -2437,9 +2437,9 @@ func (ec *executionContext) _Host_createdAt(ctx context.Context, field graphql.C ) } -func (ec *executionContext) fieldContext_Host_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, @@ -2450,12 +2450,12 @@ func (ec *executionContext) fieldContext_Host_createdAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _Host_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_lastModifiedAt, + ec.fieldContext_Builder_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -2466,9 +2466,9 @@ func (ec *executionContext) _Host_lastModifiedAt(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Host_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, @@ -2479,54 +2479,54 @@ func (ec *executionContext) fieldContext_Host_lastModifiedAt(_ context.Context, return fc, nil } -func (ec *executionContext) _Host_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_supportedTargets(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_identifier, + ec.fieldContext_Builder_supportedTargets, func(ctx context.Context) (any, error) { - return obj.Identifier, nil + return obj.SupportedTargets, nil }, nil, - ec.marshalNString2string, + ec.marshalNHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ, true, true, ) } -func (ec *executionContext) fieldContext_Host_identifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_supportedTargets(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type HostPlatform does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Host_name(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_upstream(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_name, + ec.fieldContext_Builder_upstream, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.Upstream, nil }, nil, - ec.marshalOString2string, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_upstream(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, @@ -2537,547 +2537,459 @@ func (ec *executionContext) fieldContext_Host_name(_ context.Context, field grap return fc, nil } -func (ec *executionContext) _Host_primaryIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_primaryIP, + ec.fieldContext_BuilderConnection_edges, func(ctx context.Context) (any, error) { - return obj.PrimaryIP, nil + return obj.Edges, nil }, nil, - ec.marshalOString2string, + ec.marshalOBuilderEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderEdge, true, false, ) } -func (ec *executionContext) fieldContext_Host_primaryIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_BuilderEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_BuilderEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BuilderEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Host_externalIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_externalIP, + ec.fieldContext_BuilderConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.ExternalIP, nil + return obj.PageInfo, nil }, nil, - ec.marshalOString2string, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_externalIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Host_platform(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_platform, + ec.fieldContext_BuilderConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Platform, nil + return obj.TotalCount, nil }, nil, - ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Host_platform(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type HostPlatform does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Host_lastSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_lastSeenAt, + ec.fieldContext_BuilderEdge_node, func(ctx context.Context) (any, error) { - return obj.LastSeenAt, nil + return obj.Node, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalOBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder, true, false, ) } -func (ec *executionContext) fieldContext_Host_lastSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Builder_id(ctx, field) + case "createdAt": + return ec.fieldContext_Builder_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Builder_lastModifiedAt(ctx, field) + case "supportedTargets": + return ec.fieldContext_Builder_supportedTargets(ctx, field) + case "upstream": + return ec.fieldContext_Builder_upstream(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Builder", field.Name) }, } return fc, nil } -func (ec *executionContext) _Host_nextSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_nextSeenAt, + ec.fieldContext_BuilderEdge_cursor, func(ctx context.Context) (any, error) { - return obj.NextSeenAt, nil + return obj.Cursor, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_nextSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Host_tags(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_id(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_tags, + ec.fieldContext_Host_id, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) + return obj.ID, nil }, nil, - ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Host_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Host", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TagConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TagConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TagConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Host_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Host_beacons(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_beacons, + ec.fieldContext_Host_createdAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) + return obj.CreatedAt, nil }, nil, - ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Host_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Host", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_BeaconConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_BeaconConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Host_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Host_files(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_files, + ec.fieldContext_Host_lastModifiedAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Files(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostFileOrder), fc.Args["where"].(*ent.HostFileWhereInput)) + return obj.LastModifiedAt, nil }, nil, - ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Host_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Host", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostFileConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostFileConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostFileConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostFileConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Host_files_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Host_processes(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_processes, + ec.fieldContext_Host_identifier, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Processes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostProcessOrder), fc.Args["where"].(*ent.HostProcessWhereInput)) + return obj.Identifier, nil }, nil, - ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Host_processes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_identifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Host", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostProcessConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostProcessConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostProcessConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostProcessConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Host_processes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Host_credentials(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_name(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_credentials, + ec.fieldContext_Host_name, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Credentials(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostCredentialOrder), fc.Args["where"].(*ent.HostCredentialWhereInput)) + return obj.Name, nil }, nil, - ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Host_credentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Host", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostCredentialConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostCredentialConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostCredentialConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Host_credentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _HostConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_primaryIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostConnection_edges, + ec.fieldContext_Host_primaryIP, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.PrimaryIP, nil }, nil, - ec.marshalOHostEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostEdge, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_HostConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_primaryIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostConnection", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_HostEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_HostEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostEdge", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_externalIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostConnection_pageInfo, + ec.fieldContext_Host_externalIP, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.ExternalIP, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_externalIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostConnection", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_platform(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostConnection_totalCount, + ec.fieldContext_Host_platform, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.Platform, nil }, nil, - ec.marshalNInt2int, + ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform, true, true, ) } -func (ec *executionContext) fieldContext_HostConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_platform(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostConnection", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type HostPlatform does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredential_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_lastSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_id, + ec.fieldContext_Host_lastSeenAt, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.LastSeenAt, nil }, nil, - ec.marshalNID2int, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_HostCredential_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_lastSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredential_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_nextSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_createdAt, + ec.fieldContext_Host_nextSeenAt, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.NextSeenAt, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_HostCredential_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_nextSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, @@ -3088,285 +3000,292 @@ func (ec *executionContext) fieldContext_HostCredential_createdAt(_ context.Cont return fc, nil } -func (ec *executionContext) _HostCredential_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_tags(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_lastModifiedAt, + ec.fieldContext_Host_tags, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + fc := graphql.GetFieldContext(ctx) + return obj.Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_TagConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TagConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TagConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Host_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostCredential_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_beacons(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_principal, + ec.fieldContext_Host_beacons, func(ctx context.Context) (any, error) { - return obj.Principal, nil + fc := graphql.GetFieldContext(ctx) + return obj.Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) }, nil, - ec.marshalNString2string, + ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_BeaconConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_BeaconConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Host_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostCredential_secret(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_files(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_secret, + ec.fieldContext_Host_files, func(ctx context.Context) (any, error) { - return obj.Secret, nil + fc := graphql.GetFieldContext(ctx) + return obj.Files(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostFileOrder), fc.Args["where"].(*ent.HostFileWhereInput)) }, nil, - ec.marshalNString2string, + ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_secret(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_HostFileConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostFileConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostFileConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostFileConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Host_files_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostCredential_kind(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_processes(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_kind, + ec.fieldContext_Host_processes, func(ctx context.Context) (any, error) { - return obj.Kind, nil + fc := graphql.GetFieldContext(ctx) + return obj.Processes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostProcessOrder), fc.Args["where"].(*ent.HostProcessWhereInput)) }, nil, - ec.marshalNHostCredentialKind2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kind, + ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_processes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type HostCredentialKind does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_HostProcessConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostProcessConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostProcessConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostProcessConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Host_processes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostCredential_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_credentials(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_host, + ec.fieldContext_Host_credentials, func(ctx context.Context) (any, error) { - return obj.Host(ctx) + fc := graphql.GetFieldContext(ctx) + return obj.Credentials(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostCredentialOrder), fc.Args["where"].(*ent.HostCredentialWhereInput)) }, nil, - ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, + ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_credentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Host_id(ctx, field) - case "createdAt": - return ec.fieldContext_Host_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Host_lastModifiedAt(ctx, field) - case "identifier": - return ec.fieldContext_Host_identifier(ctx, field) - case "name": - return ec.fieldContext_Host_name(ctx, field) - case "primaryIP": - return ec.fieldContext_Host_primaryIP(ctx, field) - case "externalIP": - return ec.fieldContext_Host_externalIP(ctx, field) - case "platform": - return ec.fieldContext_Host_platform(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Host_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Host_nextSeenAt(ctx, field) - case "tags": - return ec.fieldContext_Host_tags(ctx, field) - case "beacons": - return ec.fieldContext_Host_beacons(ctx, field) - case "files": - return ec.fieldContext_Host_files(ctx, field) - case "processes": - return ec.fieldContext_Host_processes(ctx, field) - case "credentials": - return ec.fieldContext_Host_credentials(ctx, field) + case "edges": + return ec.fieldContext_HostCredentialConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostCredentialConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostCredentialConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", field.Name) }, } - return fc, nil -} - -func (ec *executionContext) _HostCredential_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_HostCredential_task, - func(ctx context.Context) (any, error) { - return obj.Task(ctx) - }, - nil, - ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_HostCredential_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostCredential", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) - }, + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Host_credentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err } return fc, nil } -func (ec *executionContext) _HostCredentialConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialConnection_edges, + ec.fieldContext_HostConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, - ec.marshalOHostCredentialEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialEdge, + ec.marshalOHostEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostEdge, true, false, ) } -func (ec *executionContext) fieldContext_HostCredentialConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialConnection", + Object: "HostConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "node": - return ec.fieldContext_HostCredentialEdge_node(ctx, field) + return ec.fieldContext_HostEdge_node(ctx, field) case "cursor": - return ec.fieldContext_HostCredentialEdge_cursor(ctx, field) + return ec.fieldContext_HostEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostCredentialEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostCredentialConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialConnection_pageInfo, + ec.fieldContext_HostConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -3377,9 +3296,9 @@ func (ec *executionContext) _HostCredentialConnection_pageInfo(ctx context.Conte ) } -func (ec *executionContext) fieldContext_HostCredentialConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialConnection", + Object: "HostConnection", Field: field, IsMethod: false, IsResolver: false, @@ -3400,12 +3319,12 @@ func (ec *executionContext) fieldContext_HostCredentialConnection_pageInfo(_ con return fc, nil } -func (ec *executionContext) _HostCredentialConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialConnection_totalCount, + ec.fieldContext_HostConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -3416,9 +3335,9 @@ func (ec *executionContext) _HostCredentialConnection_totalCount(ctx context.Con ) } -func (ec *executionContext) fieldContext_HostCredentialConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialConnection", + Object: "HostConnection", Field: field, IsMethod: false, IsResolver: false, @@ -3429,454 +3348,502 @@ func (ec *executionContext) fieldContext_HostCredentialConnection_totalCount(_ c return fc, nil } -func (ec *executionContext) _HostCredentialEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialEdge_node, + ec.fieldContext_HostCredential_id, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.ID, nil }, nil, - ec.marshalOHostCredential2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredential, + ec.marshalNID2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostCredentialEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialEdge", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_HostCredential_id(ctx, field) - case "createdAt": - return ec.fieldContext_HostCredential_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_HostCredential_lastModifiedAt(ctx, field) - case "principal": - return ec.fieldContext_HostCredential_principal(ctx, field) - case "secret": - return ec.fieldContext_HostCredential_secret(ctx, field) - case "kind": - return ec.fieldContext_HostCredential_kind(ctx, field) - case "host": - return ec.fieldContext_HostCredential_host(ctx, field) - case "task": - return ec.fieldContext_HostCredential_task(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostCredential", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredentialEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialEdge_cursor, + ec.fieldContext_HostCredential_createdAt, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_HostCredentialEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialEdge", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostEdge_node, + ec.fieldContext_HostCredential_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalOHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostEdge", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Host_id(ctx, field) - case "createdAt": - return ec.fieldContext_Host_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Host_lastModifiedAt(ctx, field) - case "identifier": - return ec.fieldContext_Host_identifier(ctx, field) - case "name": - return ec.fieldContext_Host_name(ctx, field) - case "primaryIP": - return ec.fieldContext_Host_primaryIP(ctx, field) - case "externalIP": - return ec.fieldContext_Host_externalIP(ctx, field) - case "platform": - return ec.fieldContext_Host_platform(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Host_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Host_nextSeenAt(ctx, field) - case "tags": - return ec.fieldContext_Host_tags(ctx, field) - case "beacons": - return ec.fieldContext_Host_beacons(ctx, field) - case "files": - return ec.fieldContext_Host_files(ctx, field) - case "processes": - return ec.fieldContext_Host_processes(ctx, field) - case "credentials": - return ec.fieldContext_Host_credentials(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostEdge_cursor, + ec.fieldContext_HostCredential_principal, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Principal, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_HostEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostEdge", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_secret(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_id, + ec.fieldContext_HostCredential_secret, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Secret, nil }, nil, - ec.marshalNID2int, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_HostFile_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_secret(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_kind(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_createdAt, + ec.fieldContext_HostCredential_kind, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Kind, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNHostCredentialKind2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kind, true, true, ) } -func (ec *executionContext) fieldContext_HostFile_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type HostCredentialKind does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_lastModifiedAt, + ec.fieldContext_HostCredential_host, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Host(ctx) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, true, ) } -func (ec *executionContext) fieldContext_HostFile_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Host_id(ctx, field) + case "createdAt": + return ec.fieldContext_Host_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Host_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Host_identifier(ctx, field) + case "name": + return ec.fieldContext_Host_name(ctx, field) + case "primaryIP": + return ec.fieldContext_Host_primaryIP(ctx, field) + case "externalIP": + return ec.fieldContext_Host_externalIP(ctx, field) + case "platform": + return ec.fieldContext_Host_platform(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Host_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Host_nextSeenAt(ctx, field) + case "tags": + return ec.fieldContext_Host_tags(ctx, field) + case "beacons": + return ec.fieldContext_Host_beacons(ctx, field) + case "files": + return ec.fieldContext_Host_files(ctx, field) + case "processes": + return ec.fieldContext_Host_processes(ctx, field) + case "credentials": + return ec.fieldContext_Host_credentials(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostFile_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_path, + ec.fieldContext_HostCredential_task, func(ctx context.Context) (any, error) { - return obj.Path, nil + return obj.Task(ctx) }, nil, - ec.marshalNString2string, - true, + ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, + false, ) } -func (ec *executionContext) fieldContext_HostFile_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostFile_owner(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_owner, + ec.fieldContext_HostCredentialConnection_edges, func(ctx context.Context) (any, error) { - return obj.Owner, nil + return obj.Edges, nil }, nil, - ec.marshalOString2string, + ec.marshalOHostCredentialEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialEdge, true, false, ) } -func (ec *executionContext) fieldContext_HostFile_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredentialConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_HostCredentialEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_HostCredentialEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostCredentialEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostFile_group(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_group, + ec.fieldContext_HostCredentialConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.Group, nil + return obj.PageInfo, nil }, nil, - ec.marshalOString2string, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFile_group(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredentialConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostFile_permissions(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_permissions, + ec.fieldContext_HostCredentialConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Permissions, nil + return obj.TotalCount, nil }, nil, - ec.marshalOString2string, + ec.marshalNInt2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFile_permissions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredentialConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_size(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_size, + ec.fieldContext_HostCredentialEdge_node, func(ctx context.Context) (any, error) { - return obj.Size, nil + return obj.Node, nil }, nil, - ec.marshalNUint642uint64, - true, + ec.marshalOHostCredential2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredential, true, + false, ) } -func (ec *executionContext) fieldContext_HostFile_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredentialEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint64 does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_HostCredential_id(ctx, field) + case "createdAt": + return ec.fieldContext_HostCredential_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_HostCredential_lastModifiedAt(ctx, field) + case "principal": + return ec.fieldContext_HostCredential_principal(ctx, field) + case "secret": + return ec.fieldContext_HostCredential_secret(ctx, field) + case "kind": + return ec.fieldContext_HostCredential_kind(ctx, field) + case "host": + return ec.fieldContext_HostCredential_host(ctx, field) + case "task": + return ec.fieldContext_HostCredential_task(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostCredential", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostFile_hash(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_hash, + ec.fieldContext_HostCredentialEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Hash, nil + return obj.Cursor, nil }, nil, - ec.marshalOString2string, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFile_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredentialEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_host, + ec.fieldContext_HostEdge_node, func(ctx context.Context) (any, error) { - return obj.Host(ctx) + return obj.Node, nil }, nil, - ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, - true, + ec.marshalOHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, + false, ) } -func (ec *executionContext) fieldContext_HostFile_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { @@ -3917,347 +3884,246 @@ func (ec *executionContext) fieldContext_HostFile_host(_ context.Context, field return fc, nil } -func (ec *executionContext) _HostFile_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_task, + ec.fieldContext_HostEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + return obj.Cursor, nil }, nil, - ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, - true, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, - ) -} - -func (ec *executionContext) fieldContext_HostFile_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostFile", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _HostFileConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_HostFileConnection_edges, - func(ctx context.Context) (any, error) { - return obj.Edges, nil - }, - nil, - ec.marshalOHostFileEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileEdge, true, - false, ) } -func (ec *executionContext) fieldContext_HostFileConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileConnection", + Object: "HostEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_HostFileEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_HostFileEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostFileEdge", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFileConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileConnection_pageInfo, + ec.fieldContext_HostFile_id, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.ID, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_HostFileConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileConnection", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFileConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileConnection_totalCount, + ec.fieldContext_HostFile_createdAt, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNInt2int, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_HostFileConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileConnection", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFileEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileEdge_node, + ec.fieldContext_HostFile_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalOHostFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFile, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFileEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileEdge", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_HostFile_id(ctx, field) - case "createdAt": - return ec.fieldContext_HostFile_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_HostFile_lastModifiedAt(ctx, field) - case "path": - return ec.fieldContext_HostFile_path(ctx, field) - case "owner": - return ec.fieldContext_HostFile_owner(ctx, field) - case "group": - return ec.fieldContext_HostFile_group(ctx, field) - case "permissions": - return ec.fieldContext_HostFile_permissions(ctx, field) - case "size": - return ec.fieldContext_HostFile_size(ctx, field) - case "hash": - return ec.fieldContext_HostFile_hash(ctx, field) - case "host": - return ec.fieldContext_HostFile_host(ctx, field) - case "task": - return ec.fieldContext_HostFile_task(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostFile", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFileEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileEdge_cursor, + ec.fieldContext_HostFile_path, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Path, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_HostFileEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileEdge", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_owner(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_id, + ec.fieldContext_HostFile_owner, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Owner, nil }, nil, - ec.marshalNID2int, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcess_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_group(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_createdAt, + ec.fieldContext_HostFile_group, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Group, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcess_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_group(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_permissions(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_lastModifiedAt, + ec.fieldContext_HostFile_permissions, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Permissions, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcess_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_permissions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_pid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_size(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_pid, + ec.fieldContext_HostFile_size, func(ctx context.Context) (any, error) { - return obj.Pid, nil + return obj.Size, nil }, nil, ec.marshalNUint642uint64, @@ -4266,9 +4132,9 @@ func (ec *executionContext) _HostProcess_pid(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_HostProcess_pid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, @@ -4279,257 +4145,54 @@ func (ec *executionContext) fieldContext_HostProcess_pid(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _HostProcess_ppid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_hash(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_ppid, + ec.fieldContext_HostFile_hash, func(ctx context.Context) (any, error) { - return obj.Ppid, nil + return obj.Hash, nil }, nil, - ec.marshalNUint642uint64, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcess_ppid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint64 does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_name(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_name, + ec.fieldContext_HostFile_host, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.Host(ctx) }, nil, - ec.marshalNString2string, + ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _HostProcess_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_HostProcess_principal, - func(ctx context.Context) (any, error) { - return obj.Principal, nil - }, - nil, - ec.marshalNString2string, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostProcess", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _HostProcess_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_HostProcess_path, - func(ctx context.Context) (any, error) { - return obj.Path, nil - }, - nil, - ec.marshalOString2string, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostProcess", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _HostProcess_cmd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_HostProcess_cmd, - func(ctx context.Context) (any, error) { - return obj.Cmd, nil - }, - nil, - ec.marshalOString2string, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_cmd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostProcess", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _HostProcess_env(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_HostProcess_env, - func(ctx context.Context) (any, error) { - return obj.Env, nil - }, - nil, - ec.marshalOString2string, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_env(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostProcess", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _HostProcess_cwd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_HostProcess_cwd, - func(ctx context.Context) (any, error) { - return obj.Cwd, nil - }, - nil, - ec.marshalOString2string, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_cwd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostProcess", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _HostProcess_status(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_HostProcess_status, - func(ctx context.Context) (any, error) { - return obj.Status, nil - }, - nil, - ec.marshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_status(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostProcess", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type HostProcessStatus does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _HostProcess_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_HostProcess_host, - func(ctx context.Context) (any, error) { - return obj.Host(ctx) - }, - nil, - ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: true, IsResolver: false, @@ -4572,12 +4235,12 @@ func (ec *executionContext) fieldContext_HostProcess_host(_ context.Context, fie return fc, nil } -func (ec *executionContext) _HostProcess_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_task, + ec.fieldContext_HostFile_task, func(ctx context.Context) (any, error) { return obj.Task(ctx) }, @@ -4588,9 +4251,9 @@ func (ec *executionContext) _HostProcess_task(ctx context.Context, field graphql ) } -func (ec *executionContext) fieldContext_HostProcess_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: true, IsResolver: false, @@ -4633,47 +4296,47 @@ func (ec *executionContext) fieldContext_HostProcess_task(_ context.Context, fie return fc, nil } -func (ec *executionContext) _HostProcessConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessConnection_edges, + ec.fieldContext_HostFileConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, - ec.marshalOHostProcessEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessEdge, + ec.marshalOHostFileEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileEdge, true, false, ) } -func (ec *executionContext) fieldContext_HostProcessConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessConnection", + Object: "HostFileConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "node": - return ec.fieldContext_HostProcessEdge_node(ctx, field) + return ec.fieldContext_HostFileEdge_node(ctx, field) case "cursor": - return ec.fieldContext_HostProcessEdge_cursor(ctx, field) + return ec.fieldContext_HostFileEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostProcessEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostFileEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostProcessConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessConnection_pageInfo, + ec.fieldContext_HostFileConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -4684,9 +4347,9 @@ func (ec *executionContext) _HostProcessConnection_pageInfo(ctx context.Context, ) } -func (ec *executionContext) fieldContext_HostProcessConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessConnection", + Object: "HostFileConnection", Field: field, IsMethod: false, IsResolver: false, @@ -4707,12 +4370,12 @@ func (ec *executionContext) fieldContext_HostProcessConnection_pageInfo(_ contex return fc, nil } -func (ec *executionContext) _HostProcessConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessConnection_totalCount, + ec.fieldContext_HostFileConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -4723,9 +4386,9 @@ func (ec *executionContext) _HostProcessConnection_totalCount(ctx context.Contex ) } -func (ec *executionContext) fieldContext_HostProcessConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessConnection", + Object: "HostFileConnection", Field: field, IsMethod: false, IsResolver: false, @@ -4736,71 +4399,65 @@ func (ec *executionContext) fieldContext_HostProcessConnection_totalCount(_ cont return fc, nil } -func (ec *executionContext) _HostProcessEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessEdge_node, + ec.fieldContext_HostFileEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOHostProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcess, + ec.marshalOHostFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFile, true, false, ) } -func (ec *executionContext) fieldContext_HostProcessEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessEdge", + Object: "HostFileEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_HostProcess_id(ctx, field) + return ec.fieldContext_HostFile_id(ctx, field) case "createdAt": - return ec.fieldContext_HostProcess_createdAt(ctx, field) + return ec.fieldContext_HostFile_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_HostProcess_lastModifiedAt(ctx, field) - case "pid": - return ec.fieldContext_HostProcess_pid(ctx, field) - case "ppid": - return ec.fieldContext_HostProcess_ppid(ctx, field) - case "name": - return ec.fieldContext_HostProcess_name(ctx, field) - case "principal": - return ec.fieldContext_HostProcess_principal(ctx, field) + return ec.fieldContext_HostFile_lastModifiedAt(ctx, field) case "path": - return ec.fieldContext_HostProcess_path(ctx, field) - case "cmd": - return ec.fieldContext_HostProcess_cmd(ctx, field) - case "env": - return ec.fieldContext_HostProcess_env(ctx, field) - case "cwd": - return ec.fieldContext_HostProcess_cwd(ctx, field) - case "status": - return ec.fieldContext_HostProcess_status(ctx, field) + return ec.fieldContext_HostFile_path(ctx, field) + case "owner": + return ec.fieldContext_HostFile_owner(ctx, field) + case "group": + return ec.fieldContext_HostFile_group(ctx, field) + case "permissions": + return ec.fieldContext_HostFile_permissions(ctx, field) + case "size": + return ec.fieldContext_HostFile_size(ctx, field) + case "hash": + return ec.fieldContext_HostFile_hash(ctx, field) case "host": - return ec.fieldContext_HostProcess_host(ctx, field) + return ec.fieldContext_HostFile_host(ctx, field) case "task": - return ec.fieldContext_HostProcess_task(ctx, field) + return ec.fieldContext_HostFile_task(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostProcess", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostFile", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostProcessEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessEdge_cursor, + ec.fieldContext_HostFileEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -4811,9 +4468,9 @@ func (ec *executionContext) _HostProcessEdge_cursor(ctx context.Context, field g ) } -func (ec *executionContext) fieldContext_HostProcessEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessEdge", + Object: "HostFileEdge", Field: field, IsMethod: false, IsResolver: false, @@ -4824,12 +4481,12 @@ func (ec *executionContext) fieldContext_HostProcessEdge_cursor(_ context.Contex return fc, nil } -func (ec *executionContext) _Link_id(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_id, + ec.fieldContext_HostProcess_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -4840,9 +4497,9 @@ func (ec *executionContext) _Link_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_Link_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, @@ -4853,12 +4510,12 @@ func (ec *executionContext) fieldContext_Link_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _Link_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_createdAt, + ec.fieldContext_HostProcess_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -4869,9 +4526,9 @@ func (ec *executionContext) _Link_createdAt(ctx context.Context, field graphql.C ) } -func (ec *executionContext) fieldContext_Link_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, @@ -4882,12 +4539,12 @@ func (ec *executionContext) fieldContext_Link_createdAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _Link_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_lastModifiedAt, + ec.fieldContext_HostProcess_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -4898,9 +4555,9 @@ func (ec *executionContext) _Link_lastModifiedAt(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Link_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, @@ -4911,804 +4568,842 @@ func (ec *executionContext) fieldContext_Link_lastModifiedAt(_ context.Context, return fc, nil } -func (ec *executionContext) _Link_path(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_pid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_path, + ec.fieldContext_HostProcess_pid, func(ctx context.Context) (any, error) { - return obj.Path, nil + return obj.Pid, nil }, nil, - ec.marshalNString2string, + ec.marshalNUint642uint64, true, true, ) } -func (ec *executionContext) fieldContext_Link_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_pid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Uint64 does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_expiresAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_ppid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_expiresAt, + ec.fieldContext_HostProcess_ppid, func(ctx context.Context) (any, error) { - return obj.ExpiresAt, nil + return obj.Ppid, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNUint642uint64, true, true, ) } -func (ec *executionContext) fieldContext_Link_expiresAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_ppid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Uint64 does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_downloadsRemaining(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_name(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_downloadsRemaining, + ec.fieldContext_HostProcess_name, func(ctx context.Context) (any, error) { - return obj.DownloadsRemaining, nil + return obj.Name, nil }, nil, - ec.marshalNInt2int, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Link_downloadsRemaining(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_asset(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_asset, + ec.fieldContext_HostProcess_principal, func(ctx context.Context) (any, error) { - return obj.Asset(ctx) + return obj.Principal, nil }, nil, - ec.marshalNAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Link_asset(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Asset_id(ctx, field) - case "createdAt": - return ec.fieldContext_Asset_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Asset_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Asset_name(ctx, field) - case "size": - return ec.fieldContext_Asset_size(ctx, field) - case "hash": - return ec.fieldContext_Asset_hash(ctx, field) - case "tomes": - return ec.fieldContext_Asset_tomes(ctx, field) - case "links": - return ec.fieldContext_Asset_links(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkConnection_edges, + ec.fieldContext_HostProcess_path, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Path, nil }, nil, - ec.marshalOLinkEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkEdge, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_LinkConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkConnection", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_LinkEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_LinkEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type LinkEdge", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_cmd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkConnection_pageInfo, + ec.fieldContext_HostProcess_cmd, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.Cmd, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_LinkConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_cmd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkConnection", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_env(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkConnection_totalCount, + ec.fieldContext_HostProcess_env, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.Env, nil }, nil, - ec.marshalNInt2int, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_LinkConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_env(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkConnection", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_cwd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkEdge_node, + ec.fieldContext_HostProcess_cwd, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.Cwd, nil }, nil, - ec.marshalOLink2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLink, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_LinkEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_cwd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkEdge", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Link_id(ctx, field) - case "createdAt": - return ec.fieldContext_Link_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Link_lastModifiedAt(ctx, field) - case "path": - return ec.fieldContext_Link_path(ctx, field) - case "expiresAt": - return ec.fieldContext_Link_expiresAt(ctx, field) - case "downloadsRemaining": - return ec.fieldContext_Link_downloadsRemaining(ctx, field) - case "asset": - return ec.fieldContext_Link_asset(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Link", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_status(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkEdge_cursor, + ec.fieldContext_HostProcess_status, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Status, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status, true, true, ) } -func (ec *executionContext) fieldContext_LinkEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_status(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkEdge", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type HostProcessStatus does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_hasNextPage, + ec.fieldContext_HostProcess_host, func(ctx context.Context) (any, error) { - return obj.HasNextPage, nil + return obj.Host(ctx) }, nil, - ec.marshalNBoolean2bool, + ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, true, ) } -func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "HostProcess", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Host_id(ctx, field) + case "createdAt": + return ec.fieldContext_Host_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Host_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Host_identifier(ctx, field) + case "name": + return ec.fieldContext_Host_name(ctx, field) + case "primaryIP": + return ec.fieldContext_Host_primaryIP(ctx, field) + case "externalIP": + return ec.fieldContext_Host_externalIP(ctx, field) + case "platform": + return ec.fieldContext_Host_platform(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Host_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Host_nextSeenAt(ctx, field) + case "tags": + return ec.fieldContext_Host_tags(ctx, field) + case "beacons": + return ec.fieldContext_Host_beacons(ctx, field) + case "files": + return ec.fieldContext_Host_files(ctx, field) + case "processes": + return ec.fieldContext_Host_processes(ctx, field) + case "credentials": + return ec.fieldContext_Host_credentials(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, } return fc, nil } -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_hasPreviousPage, + ec.fieldContext_HostProcess_task, func(ctx context.Context) (any, error) { - return obj.HasPreviousPage, nil + return obj.Task(ctx) }, nil, - ec.marshalNBoolean2bool, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, true, ) } -func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "HostProcess", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_startCursor, + ec.fieldContext_HostProcessConnection_edges, func(ctx context.Context) (any, error) { - return obj.StartCursor, nil + return obj.Edges, nil }, nil, - ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalOHostProcessEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessEdge, true, false, ) } -func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "HostProcessConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_HostProcessEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_HostProcessEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostProcessEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_endCursor, + ec.fieldContext_HostProcessConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.EndCursor, nil + return obj.PageInfo, nil }, nil, - ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, true, - false, ) } -func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "HostProcessConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Portal_id(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_id, + ec.fieldContext_HostProcessConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.TotalCount, nil }, nil, - ec.marshalNID2int, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Portal_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "HostProcessConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_createdAt, + ec.fieldContext_HostProcessEdge_node, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Node, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOHostProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcess, true, + false, ) } -func (ec *executionContext) fieldContext_Portal_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "HostProcessEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_HostProcess_id(ctx, field) + case "createdAt": + return ec.fieldContext_HostProcess_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_HostProcess_lastModifiedAt(ctx, field) + case "pid": + return ec.fieldContext_HostProcess_pid(ctx, field) + case "ppid": + return ec.fieldContext_HostProcess_ppid(ctx, field) + case "name": + return ec.fieldContext_HostProcess_name(ctx, field) + case "principal": + return ec.fieldContext_HostProcess_principal(ctx, field) + case "path": + return ec.fieldContext_HostProcess_path(ctx, field) + case "cmd": + return ec.fieldContext_HostProcess_cmd(ctx, field) + case "env": + return ec.fieldContext_HostProcess_env(ctx, field) + case "cwd": + return ec.fieldContext_HostProcess_cwd(ctx, field) + case "status": + return ec.fieldContext_HostProcess_status(ctx, field) + case "host": + return ec.fieldContext_HostProcess_host(ctx, field) + case "task": + return ec.fieldContext_HostProcess_task(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostProcess", field.Name) }, } return fc, nil } -func (ec *executionContext) _Portal_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_lastModifiedAt, + ec.fieldContext_HostProcessEdge_cursor, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Cursor, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Portal_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "HostProcessEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_id(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_closedAt, + ec.fieldContext_Link_id, func(ctx context.Context) (any, error) { - return obj.ClosedAt, nil + return obj.ID, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNID2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Portal_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_task(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_task, + ec.fieldContext_Link_createdAt, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + return obj.CreatedAt, nil }, nil, - ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Portal_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_beacon, + ec.fieldContext_Link_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Beacon(ctx) + return obj.LastModifiedAt, nil }, nil, - ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Portal_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Beacon_id(ctx, field) - case "createdAt": - return ec.fieldContext_Beacon_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Beacon_name(ctx, field) - case "principal": - return ec.fieldContext_Beacon_principal(ctx, field) - case "identifier": - return ec.fieldContext_Beacon_identifier(ctx, field) - case "agentIdentifier": - return ec.fieldContext_Beacon_agentIdentifier(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Beacon_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Beacon_nextSeenAt(ctx, field) - case "interval": - return ec.fieldContext_Beacon_interval(ctx, field) - case "transport": - return ec.fieldContext_Beacon_transport(ctx, field) - case "host": - return ec.fieldContext_Beacon_host(ctx, field) - case "tasks": - return ec.fieldContext_Beacon_tasks(ctx, field) - case "shells": - return ec.fieldContext_Beacon_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_path(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_owner, + ec.fieldContext_Link_path, func(ctx context.Context) (any, error) { - return obj.Owner(ctx) + return obj.Path, nil }, nil, - ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Portal_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_expiresAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_activeUsers, + ec.fieldContext_Link_expiresAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ActiveUsers(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) + return obj.ExpiresAt, nil }, nil, - ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Portal_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_expiresAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Link_downloadsRemaining(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Link_downloadsRemaining, + func(ctx context.Context) (any, error) { + return obj.DownloadsRemaining, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Link_downloadsRemaining(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Link", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Link_asset(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Link_asset, + func(ctx context.Context) (any, error) { + return obj.Asset(ctx) + }, + nil, + ec.marshalNAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Link_asset(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Link", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_UserConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_UserConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_UserConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_Asset_id(ctx, field) + case "createdAt": + return ec.fieldContext_Asset_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Asset_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Asset_name(ctx, field) + case "size": + return ec.fieldContext_Asset_size(ctx, field) + case "hash": + return ec.fieldContext_Asset_hash(ctx, field) + case "tomes": + return ec.fieldContext_Asset_tomes(ctx, field) + case "links": + return ec.fieldContext_Asset_links(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Portal_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _PortalConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalConnection_edges, + ec.fieldContext_LinkConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, - ec.marshalOPortalEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalEdge, + ec.marshalOLinkEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkEdge, true, false, ) } -func (ec *executionContext) fieldContext_PortalConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalConnection", + Object: "LinkConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "node": - return ec.fieldContext_PortalEdge_node(ctx, field) + return ec.fieldContext_LinkEdge_node(ctx, field) case "cursor": - return ec.fieldContext_PortalEdge_cursor(ctx, field) + return ec.fieldContext_LinkEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PortalEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type LinkEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _PortalConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalConnection_pageInfo, + ec.fieldContext_LinkConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -5719,9 +5414,9 @@ func (ec *executionContext) _PortalConnection_pageInfo(ctx context.Context, fiel ) } -func (ec *executionContext) fieldContext_PortalConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalConnection", + Object: "LinkConnection", Field: field, IsMethod: false, IsResolver: false, @@ -5742,12 +5437,12 @@ func (ec *executionContext) fieldContext_PortalConnection_pageInfo(_ context.Con return fc, nil } -func (ec *executionContext) _PortalConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalConnection_totalCount, + ec.fieldContext_LinkConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -5758,9 +5453,9 @@ func (ec *executionContext) _PortalConnection_totalCount(ctx context.Context, fi ) } -func (ec *executionContext) fieldContext_PortalConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalConnection", + Object: "LinkConnection", Field: field, IsMethod: false, IsResolver: false, @@ -5771,59 +5466,57 @@ func (ec *executionContext) fieldContext_PortalConnection_totalCount(_ context.C return fc, nil } -func (ec *executionContext) _PortalEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalEdge_node, + ec.fieldContext_LinkEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOPortal2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortal, + ec.marshalOLink2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLink, true, false, ) } -func (ec *executionContext) fieldContext_PortalEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalEdge", + Object: "LinkEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Portal_id(ctx, field) + return ec.fieldContext_Link_id(ctx, field) case "createdAt": - return ec.fieldContext_Portal_createdAt(ctx, field) + return ec.fieldContext_Link_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Portal_lastModifiedAt(ctx, field) - case "closedAt": - return ec.fieldContext_Portal_closedAt(ctx, field) - case "task": - return ec.fieldContext_Portal_task(ctx, field) - case "beacon": - return ec.fieldContext_Portal_beacon(ctx, field) - case "owner": - return ec.fieldContext_Portal_owner(ctx, field) - case "activeUsers": - return ec.fieldContext_Portal_activeUsers(ctx, field) + return ec.fieldContext_Link_lastModifiedAt(ctx, field) + case "path": + return ec.fieldContext_Link_path(ctx, field) + case "expiresAt": + return ec.fieldContext_Link_expiresAt(ctx, field) + case "downloadsRemaining": + return ec.fieldContext_Link_downloadsRemaining(ctx, field) + case "asset": + return ec.fieldContext_Link_asset(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Portal", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Link", field.Name) }, } return fc, nil } -func (ec *executionContext) _PortalEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalEdge_cursor, + ec.fieldContext_LinkEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -5834,9 +5527,9 @@ func (ec *executionContext) _PortalEdge_cursor(ctx context.Context, field graphq ) } -func (ec *executionContext) fieldContext_PortalEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalEdge", + Object: "LinkEdge", Field: field, IsMethod: false, IsResolver: false, @@ -5847,665 +5540,426 @@ func (ec *executionContext) fieldContext_PortalEdge_cursor(_ context.Context, fi return fc, nil } -func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_node, + ec.fieldContext_PageInfo_hasNextPage, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Node(ctx, fc.Args["id"].(int)) + return obj.HasNextPage, nil }, nil, - ec.marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder, + ec.marshalNBoolean2bool, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_nodes, + ec.fieldContext_PageInfo_hasPreviousPage, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Nodes(ctx, fc.Args["ids"].([]int)) + return obj.HasPreviousPage, nil }, nil, - ec.marshalNNode2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚐNoder, + ec.marshalNBoolean2bool, true, true, ) } -func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_assets(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_assets, + ec.fieldContext_PageInfo_startCursor, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Assets(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AssetOrder), fc.Args["where"].(*ent.AssetWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.AssetConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.AssetConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.StartCursor, nil }, - ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, - true, + nil, + ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, true, + false, ) } -func (ec *executionContext) fieldContext_Query_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_AssetConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_AssetConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_AssetConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AssetConnection", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_quests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_quests, + ec.fieldContext_PageInfo_endCursor, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Quests(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.QuestOrder), fc.Args["where"].(*ent.QuestWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.QuestConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.QuestConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.EndCursor, nil }, - ec.marshalNQuestConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestConnection, - true, + nil, + ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, true, + false, ) } -func (ec *executionContext) fieldContext_Query_quests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_QuestConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_QuestConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_QuestConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type QuestConnection", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_quests_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_id(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tasks, + ec.fieldContext_Portal_id, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Tasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.TaskConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.TaskConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.ID, nil }, - ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, + nil, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TaskConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TaskConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TaskConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_repositories(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_repositories, + ec.fieldContext_Portal_createdAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Repositories(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.RepositoryOrder), fc.Args["where"].(*ent.RepositoryWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.RepositoryConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.RepositoryConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.CreatedAt, nil }, - ec.marshalNRepositoryConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryConnection, + nil, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Query_repositories(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_RepositoryConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_RepositoryConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_RepositoryConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type RepositoryConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_repositories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_beacons, + ec.fieldContext_Portal_lastModifiedAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.BeaconConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.BeaconConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.LastModifiedAt, nil }, - ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + nil, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Query_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_BeaconConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_BeaconConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_hosts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_hosts, + ec.fieldContext_Portal_closedAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Hosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.HostConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.HostConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.ClosedAt, nil }, - ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, - true, + nil, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Query_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_task(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tags, + ec.fieldContext_Portal_task, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.TagConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.TagConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.Task(ctx) }, - ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, + nil, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, true, ) } -func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_TagConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TagConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TagConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tomes, + ec.fieldContext_Portal_beacon, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) + return obj.Beacon(ctx) }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next + nil, + ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + true, + true, + ) +} - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.TomeConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.TomeConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) +func (ec *executionContext) fieldContext_Portal_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Portal", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Beacon_name(ctx, field) + case "principal": + return ec.fieldContext_Beacon_principal(ctx, field) + case "identifier": + return ec.fieldContext_Beacon_identifier(ctx, field) + case "agentIdentifier": + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Beacon_nextSeenAt(ctx, field) + case "interval": + return ec.fieldContext_Beacon_interval(ctx, field) + case "transport": + return ec.fieldContext_Beacon_transport(ctx, field) + case "host": + return ec.fieldContext_Beacon_host(ctx, field) + case "tasks": + return ec.fieldContext_Beacon_tasks(ctx, field) + case "shells": + return ec.fieldContext_Beacon_shells(ctx, field) } + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + }, + } + return fc, nil +} - next = directive1 - return next +func (ec *executionContext) _Portal_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Portal_owner, + func(ctx context.Context) (any, error) { + return obj.Owner(ctx) }, - ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + nil, + ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, true, ) } -func (ec *executionContext) fieldContext_Query_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_TomeConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TomeConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TomeConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_users, + ec.fieldContext_Portal_activeUsers, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Users(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.UserConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.UserConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.ActiveUsers(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) }, + nil, ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, true, true, ) } -func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": @@ -6525,648 +5979,660 @@ func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Portal_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_portals(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PortalConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_portals, + ec.fieldContext_PortalConnection_edges, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Portals(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.PortalOrder), fc.Args["where"].(*ent.PortalWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.PortalConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.PortalConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.Edges, nil }, - ec.marshalNPortalConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalConnection, - true, + nil, + ec.marshalOPortalEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalEdge, true, + false, ) } -func (ec *executionContext) fieldContext_Query_portals(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PortalConnection", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_PortalConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_PortalConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_PortalConnection_totalCount(ctx, field) + case "node": + return ec.fieldContext_PortalEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_PortalEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PortalConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PortalEdge", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_portals_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_shells(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PortalConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_shells, + ec.fieldContext_PortalConnection_pageInfo, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Shells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.ShellConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.ShellConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.PageInfo, nil }, - ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + nil, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Query_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PortalConnection", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_ShellConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_ShellConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_ShellConnection_totalCount(ctx, field) + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PortalConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_me, + ec.fieldContext_PortalConnection_totalCount, func(ctx context.Context) (any, error) { - return ec.resolvers.Query().Me(ctx) + return obj.TotalCount, nil }, nil, - ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, - true, + ec.marshalNInt2int, true, - ) -} - -func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Query___type, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.introspectType(fc.Args["name"].(string)) - }, - nil, - ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType, true, - false, ) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PortalConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PortalEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query___schema, + ec.fieldContext_PortalEdge_node, func(ctx context.Context) (any, error) { - return ec.introspectSchema() + return obj.Node, nil }, nil, - ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema, + ec.marshalOPortal2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortal, true, false, ) } -func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PortalEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) + case "id": + return ec.fieldContext_Portal_id(ctx, field) + case "createdAt": + return ec.fieldContext_Portal_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Portal_lastModifiedAt(ctx, field) + case "closedAt": + return ec.fieldContext_Portal_closedAt(ctx, field) + case "task": + return ec.fieldContext_Portal_task(ctx, field) + case "beacon": + return ec.fieldContext_Portal_beacon(ctx, field) + case "owner": + return ec.fieldContext_Portal_owner(ctx, field) + case "activeUsers": + return ec.fieldContext_Portal_activeUsers(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Portal", field.Name) }, } return fc, nil } -func (ec *executionContext) _Quest_id(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _PortalEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_id, + ec.fieldContext_PortalEdge_cursor, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Cursor, nil }, nil, - ec.marshalNID2int, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Quest_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "PortalEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Quest_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_createdAt, + ec.fieldContext_Query_node, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Node(ctx, fc.Args["id"].(int)) }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder, true, + false, ) } -func (ec *executionContext) fieldContext_Quest_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_lastModifiedAt, + ec.fieldContext_Query_nodes, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Nodes(ctx, fc.Args["ids"].([]int)) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNNode2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚐNoder, true, true, ) } -func (ec *executionContext) fieldContext_Quest_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_name(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_assets(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_name, + ec.fieldContext_Query_assets, func(ctx context.Context) (any, error) { - return obj.Name, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Assets(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AssetOrder), fc.Args["where"].(*ent.AssetWhereInput)) }, - nil, - ec.marshalNString2string, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.AssetConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.AssetConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, true, true, ) } -func (ec *executionContext) fieldContext_Quest_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_AssetConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_AssetConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_AssetConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type AssetConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_parameters(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_quests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_parameters, + ec.fieldContext_Query_quests, func(ctx context.Context) (any, error) { - return obj.Parameters, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Quests(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.QuestOrder), fc.Args["where"].(*ent.QuestWhereInput)) }, - nil, - ec.marshalOString2string, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.QuestConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.QuestConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNQuestConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_parameters(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_quests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_QuestConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_QuestConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_QuestConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type QuestConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_quests_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_paramDefsAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_paramDefsAtCreation, + ec.fieldContext_Query_tasks, func(ctx context.Context) (any, error) { - return obj.ParamDefsAtCreation, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Tasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) }, - nil, - ec.marshalOString2string, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.TaskConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.TaskConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_paramDefsAtCreation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_TaskConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TaskConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TaskConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_eldritchAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_repositories(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_eldritchAtCreation, + ec.fieldContext_Query_repositories, func(ctx context.Context) (any, error) { - return obj.EldritchAtCreation, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Repositories(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.RepositoryOrder), fc.Args["where"].(*ent.RepositoryWhereInput)) }, - nil, - ec.marshalOString2string, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.RepositoryConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.RepositoryConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNRepositoryConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_eldritchAtCreation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_repositories(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_RepositoryConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_RepositoryConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_RepositoryConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RepositoryConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_repositories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_tome(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_tome, + ec.fieldContext_Query_beacons, func(ctx context.Context) (any, error) { - return obj.Tome(ctx) + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) }, - nil, - ec.marshalNTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, - true, - true, - ) -} + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next -func (ec *executionContext) fieldContext_Quest_tome(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Quest", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tome_id(ctx, field) - case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Tome_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Tome_name(ctx, field) - case "description": - return ec.fieldContext_Tome_description(ctx, field) - case "author": - return ec.fieldContext_Tome_author(ctx, field) - case "supportModel": - return ec.fieldContext_Tome_supportModel(ctx, field) - case "tactic": - return ec.fieldContext_Tome_tactic(ctx, field) - case "runOnNewBeaconCallback": - return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) - case "runOnFirstHostCallback": - return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) - case "runOnSchedule": - return ec.fieldContext_Tome_runOnSchedule(ctx, field) - case "paramDefs": - return ec.fieldContext_Tome_paramDefs(ctx, field) - case "eldritch": - return ec.fieldContext_Tome_eldritch(ctx, field) - case "assets": - return ec.fieldContext_Tome_assets(ctx, field) - case "uploader": - return ec.fieldContext_Tome_uploader(ctx, field) - case "repository": - return ec.fieldContext_Tome_repository(ctx, field) - case "scheduledHosts": - return ec.fieldContext_Tome_scheduledHosts(ctx, field) + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.BeaconConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.BeaconConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) } - return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) - }, - } - return fc, nil -} -func (ec *executionContext) _Quest_bundle(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Quest_bundle, - func(ctx context.Context) (any, error) { - return obj.Bundle(ctx) + next = directive1 + return next }, - nil, - ec.marshalOAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, + ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_bundle(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Asset_id(ctx, field) - case "createdAt": - return ec.fieldContext_Asset_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Asset_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Asset_name(ctx, field) - case "size": - return ec.fieldContext_Asset_size(ctx, field) - case "hash": - return ec.fieldContext_Asset_hash(ctx, field) - case "tomes": - return ec.fieldContext_Asset_tomes(ctx, field) - case "links": - return ec.fieldContext_Asset_links(ctx, field) + case "edges": + return ec.fieldContext_BeaconConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_BeaconConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) + return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_tasks(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_hosts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_tasks, + ec.fieldContext_Query_hosts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return obj.Tasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) + return ec.resolvers.Query().Hosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) }, - nil, - ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.HostConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.HostConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, true, true, ) } -func (ec *executionContext) fieldContext_Quest_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_TaskConnection_edges(ctx, field) + return ec.fieldContext_HostConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_TaskConnection_pageInfo(ctx, field) + return ec.fieldContext_HostConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_TaskConnection_totalCount(ctx, field) + return ec.fieldContext_HostConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) }, } defer func() { @@ -7176,1961 +6642,2171 @@ func (ec *executionContext) fieldContext_Quest_tasks(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Quest_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Quest_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_creator, + ec.fieldContext_Query_tags, func(ctx context.Context) (any, error) { - return obj.Creator(ctx) + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) }, - nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.TagConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.TagConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_creator(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) + case "edges": + return ec.fieldContext_TagConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TagConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TagConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _QuestConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestConnection_edges, + ec.fieldContext_Query_tomes, func(ctx context.Context) (any, error) { - return obj.Edges, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) }, - nil, - ec.marshalOQuestEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestEdge, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.TomeConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.TomeConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_QuestConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "node": - return ec.fieldContext_QuestEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_QuestEdge_cursor(ctx, field) + case "edges": + return ec.fieldContext_TomeConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TomeConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TomeConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type QuestEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _QuestConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestConnection_pageInfo, + ec.fieldContext_Query_users, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Users(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) }, - nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.UserConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.UserConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, true, true, ) } -func (ec *executionContext) fieldContext_QuestConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) + case "edges": + return ec.fieldContext_UserConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_UserConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_UserConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _QuestConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_portals(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestConnection_totalCount, + ec.fieldContext_Query_portals, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Portals(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.PortalOrder), fc.Args["where"].(*ent.PortalWhereInput)) }, - nil, - ec.marshalNInt2int, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.PortalConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.PortalConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNPortalConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalConnection, true, true, ) } -func (ec *executionContext) fieldContext_QuestConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_portals(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_PortalConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_PortalConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_PortalConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PortalConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_portals_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _QuestEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_shells(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestEdge_node, + ec.fieldContext_Query_shells, func(ctx context.Context) (any, error) { - return obj.Node, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Shells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) }, - nil, - ec.marshalOQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.ShellConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.ShellConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_QuestEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestEdge", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Quest_id(ctx, field) - case "createdAt": - return ec.fieldContext_Quest_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Quest_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Quest_name(ctx, field) - case "parameters": - return ec.fieldContext_Quest_parameters(ctx, field) - case "paramDefsAtCreation": - return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) - case "eldritchAtCreation": - return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) - case "tome": - return ec.fieldContext_Quest_tome(ctx, field) - case "bundle": - return ec.fieldContext_Quest_bundle(ctx, field) - case "tasks": - return ec.fieldContext_Quest_tasks(ctx, field) - case "creator": - return ec.fieldContext_Quest_creator(ctx, field) + case "edges": + return ec.fieldContext_ShellConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ShellConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ShellConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) + return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _QuestEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestEdge_cursor, + ec.fieldContext_Query_me, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return ec.resolvers.Query().Me(ctx) }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, true, ) } -func (ec *executionContext) fieldContext_QuestEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestEdge", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Repository_id(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Repository_id, + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query___type, func(ctx context.Context) (any, error) { - return obj.ID, nil + fc := graphql.GetFieldContext(ctx) + return ec.introspectType(fc.Args["name"].(string)) }, nil, - ec.marshalNID2int, - true, + ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType, true, + false, ) } -func (ec *executionContext) fieldContext_Repository_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Repository_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_createdAt, + ec.fieldContext_Query___schema, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return ec.introspectSchema() }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema, true, + false, ) } -func (ec *executionContext) fieldContext_Repository_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } -func (ec *executionContext) _Repository_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_id(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_lastModifiedAt, + ec.fieldContext_Quest_id, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.ID, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Repository_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Repository_url(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_url, + ec.fieldContext_Quest_createdAt, func(ctx context.Context) (any, error) { - return obj.URL, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNString2string, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Repository_url(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Repository_publicKey(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_publicKey, + ec.fieldContext_Quest_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.PublicKey, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalNString2string, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Repository_publicKey(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Repository_lastImportedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_name(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_lastImportedAt, + ec.fieldContext_Quest_name, func(ctx context.Context) (any, error) { - return obj.LastImportedAt, nil + return obj.Name, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Repository_lastImportedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Repository_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_parameters(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_tomes, + ec.fieldContext_Quest_parameters, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) + return obj.Parameters, nil }, nil, - ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Repository_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_parameters(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TomeConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TomeConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TomeConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Repository_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Repository_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_paramDefsAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_owner, + ec.fieldContext_Quest_paramDefsAtCreation, func(ctx context.Context) (any, error) { - return obj.Owner(ctx) + return obj.ParamDefsAtCreation, nil }, nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_Repository_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_paramDefsAtCreation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _RepositoryConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_eldritchAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryConnection_edges, + ec.fieldContext_Quest_eldritchAtCreation, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.EldritchAtCreation, nil }, nil, - ec.marshalORepositoryEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryEdge, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_RepositoryConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_eldritchAtCreation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryConnection", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_RepositoryEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_RepositoryEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type RepositoryEdge", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _RepositoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_tome(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryConnection_pageInfo, + ec.fieldContext_Quest_tome, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.Tome(ctx) }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, true, true, ) } -func (ec *executionContext) fieldContext_RepositoryConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_tome(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryConnection", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) + case "id": + return ec.fieldContext_Tome_id(ctx, field) + case "createdAt": + return ec.fieldContext_Tome_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Tome_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Tome_name(ctx, field) + case "description": + return ec.fieldContext_Tome_description(ctx, field) + case "author": + return ec.fieldContext_Tome_author(ctx, field) + case "supportModel": + return ec.fieldContext_Tome_supportModel(ctx, field) + case "tactic": + return ec.fieldContext_Tome_tactic(ctx, field) + case "runOnNewBeaconCallback": + return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) + case "runOnFirstHostCallback": + return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) + case "runOnSchedule": + return ec.fieldContext_Tome_runOnSchedule(ctx, field) + case "paramDefs": + return ec.fieldContext_Tome_paramDefs(ctx, field) + case "eldritch": + return ec.fieldContext_Tome_eldritch(ctx, field) + case "assets": + return ec.fieldContext_Tome_assets(ctx, field) + case "uploader": + return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) + case "scheduledHosts": + return ec.fieldContext_Tome_scheduledHosts(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, } return fc, nil } -func (ec *executionContext) _RepositoryConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_bundle(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryConnection_totalCount, + ec.fieldContext_Quest_bundle, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.Bundle(ctx) }, nil, - ec.marshalNInt2int, - true, + ec.marshalOAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, true, + false, ) } -func (ec *executionContext) fieldContext_RepositoryConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_bundle(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryConnection", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Asset_id(ctx, field) + case "createdAt": + return ec.fieldContext_Asset_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Asset_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Asset_name(ctx, field) + case "size": + return ec.fieldContext_Asset_size(ctx, field) + case "hash": + return ec.fieldContext_Asset_hash(ctx, field) + case "tomes": + return ec.fieldContext_Asset_tomes(ctx, field) + case "links": + return ec.fieldContext_Asset_links(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) }, } return fc, nil } -func (ec *executionContext) _RepositoryEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_tasks(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryEdge_node, + ec.fieldContext_Quest_tasks, func(ctx context.Context) (any, error) { - return obj.Node, nil + fc := graphql.GetFieldContext(ctx) + return obj.Tasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) }, nil, - ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, + ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_RepositoryEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryEdge", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Repository_id(ctx, field) - case "createdAt": - return ec.fieldContext_Repository_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Repository_lastModifiedAt(ctx, field) - case "url": - return ec.fieldContext_Repository_url(ctx, field) - case "publicKey": - return ec.fieldContext_Repository_publicKey(ctx, field) - case "lastImportedAt": - return ec.fieldContext_Repository_lastImportedAt(ctx, field) - case "tomes": - return ec.fieldContext_Repository_tomes(ctx, field) - case "owner": - return ec.fieldContext_Repository_owner(ctx, field) + case "edges": + return ec.fieldContext_TaskConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TaskConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TaskConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Quest_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _RepositoryEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryEdge_cursor, + ec.fieldContext_Quest_creator, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Creator(ctx) }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, - true, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, + false, ) } -func (ec *executionContext) fieldContext_RepositoryEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_creator(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryEdge", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shell_id(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_id, + ec.fieldContext_QuestConnection_edges, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Edges, nil }, nil, - ec.marshalNID2int, - true, + ec.marshalOQuestEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestEdge, true, + false, ) } -func (ec *executionContext) fieldContext_Shell_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_QuestEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_QuestEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type QuestEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shell_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_createdAt, + ec.fieldContext_QuestConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.PageInfo, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Shell_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shell_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_lastModifiedAt, + ec.fieldContext_QuestConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.TotalCount, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Shell_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Shell_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_closedAt, + ec.fieldContext_QuestEdge_node, func(ctx context.Context) (any, error) { - return obj.ClosedAt, nil + return obj.Node, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalOQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, true, false, ) } -func (ec *executionContext) fieldContext_Shell_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") - }, + switch field.Name { + case "id": + return ec.fieldContext_Quest_id(ctx, field) + case "createdAt": + return ec.fieldContext_Quest_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Quest_name(ctx, field) + case "parameters": + return ec.fieldContext_Quest_parameters(ctx, field) + case "paramDefsAtCreation": + return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) + case "eldritchAtCreation": + return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) + case "tome": + return ec.fieldContext_Quest_tome(ctx, field) + case "bundle": + return ec.fieldContext_Quest_bundle(ctx, field) + case "tasks": + return ec.fieldContext_Quest_tasks(ctx, field) + case "creator": + return ec.fieldContext_Quest_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) + }, } return fc, nil } -func (ec *executionContext) _Shell_task(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_task, + ec.fieldContext_QuestEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + return obj.Cursor, nil }, nil, - ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Shell_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Shell_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_id(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_beacon, + ec.fieldContext_Repository_id, func(ctx context.Context) (any, error) { - return obj.Beacon(ctx) + return obj.ID, nil }, nil, - ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Shell_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Repository", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Beacon_id(ctx, field) - case "createdAt": - return ec.fieldContext_Beacon_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Beacon_name(ctx, field) - case "principal": - return ec.fieldContext_Beacon_principal(ctx, field) - case "identifier": - return ec.fieldContext_Beacon_identifier(ctx, field) - case "agentIdentifier": - return ec.fieldContext_Beacon_agentIdentifier(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Beacon_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Beacon_nextSeenAt(ctx, field) - case "interval": - return ec.fieldContext_Beacon_interval(ctx, field) - case "transport": - return ec.fieldContext_Beacon_transport(ctx, field) - case "host": - return ec.fieldContext_Beacon_host(ctx, field) - case "tasks": - return ec.fieldContext_Beacon_tasks(ctx, field) - case "shells": - return ec.fieldContext_Beacon_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Shell_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_owner, + ec.fieldContext_Repository_createdAt, func(ctx context.Context) (any, error) { - return obj.Owner(ctx) + return obj.CreatedAt, nil }, nil, - ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Shell_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Repository", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Shell_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_activeUsers, + ec.fieldContext_Repository_lastModifiedAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ActiveUsers(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) + return obj.LastModifiedAt, nil }, nil, - ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Shell_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Repository", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_UserConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_UserConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_UserConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Shell_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _ShellConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_url(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_edges, + ec.fieldContext_Repository_url, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.URL, nil }, nil, - ec.marshalOShellEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellEdge, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_ShellConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_url(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellConnection", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_ShellEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_ShellEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ShellEdge", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _ShellConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_publicKey(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_pageInfo, + ec.fieldContext_Repository_publicKey, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.PublicKey, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_ShellConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_publicKey(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellConnection", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _ShellConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_lastImportedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_totalCount, + ec.fieldContext_Repository_lastImportedAt, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.LastImportedAt, nil }, nil, - ec.marshalNInt2int, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_ShellConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_lastImportedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellConnection", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _ShellEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellEdge_node, + ec.fieldContext_Repository_tomes, func(ctx context.Context) (any, error) { - return obj.Node, nil - }, + fc := graphql.GetFieldContext(ctx) + return obj.Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) + }, nil, - ec.marshalOShell2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShell, + ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_ShellEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellEdge", + Object: "Repository", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Shell_id(ctx, field) - case "createdAt": - return ec.fieldContext_Shell_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Shell_lastModifiedAt(ctx, field) - case "closedAt": - return ec.fieldContext_Shell_closedAt(ctx, field) - case "task": - return ec.fieldContext_Shell_task(ctx, field) - case "beacon": - return ec.fieldContext_Shell_beacon(ctx, field) - case "owner": - return ec.fieldContext_Shell_owner(ctx, field) - case "activeUsers": - return ec.fieldContext_Shell_activeUsers(ctx, field) + case "edges": + return ec.fieldContext_TomeConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TomeConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TomeConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Shell", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Repository_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _ShellEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellEdge_cursor, + ec.fieldContext_Repository_owner, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Owner(ctx) }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, - true, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, + false, ) } -func (ec *executionContext) fieldContext_ShellEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellEdge", + Object: "Repository", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_id, + ec.fieldContext_RepositoryConnection_edges, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Edges, nil }, nil, - ec.marshalNID2int, - true, + ec.marshalORepositoryEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryEdge, true, + false, ) } -func (ec *executionContext) fieldContext_Tag_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_RepositoryEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_RepositoryEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RepositoryEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_name, + ec.fieldContext_RepositoryConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.PageInfo, nil }, nil, - ec.marshalNString2string, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Tag_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tag_kind(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_kind, + ec.fieldContext_RepositoryConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Kind, nil + return obj.TotalCount, nil }, nil, - ec.marshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Tag_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TagKind does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tag_hosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_hosts, + ec.fieldContext_RepositoryEdge_node, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Hosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) + return obj.Node, nil }, nil, - ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, - true, + ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, true, + false, ) } -func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "RepositoryEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_HostConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_Repository_id(ctx, field) + case "createdAt": + return ec.fieldContext_Repository_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Repository_lastModifiedAt(ctx, field) + case "url": + return ec.fieldContext_Repository_url(ctx, field) + case "publicKey": + return ec.fieldContext_Repository_publicKey(ctx, field) + case "lastImportedAt": + return ec.fieldContext_Repository_lastImportedAt(ctx, field) + case "tomes": + return ec.fieldContext_Repository_tomes(ctx, field) + case "owner": + return ec.fieldContext_Repository_owner(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Tag_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _TagConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagConnection_edges, + ec.fieldContext_RepositoryEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Cursor, nil }, nil, - ec.marshalOTagEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagEdge, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, true, - false, ) } -func (ec *executionContext) fieldContext_TagConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "RepositoryEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_TagEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_TagEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TagEdge", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TagConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_id(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagConnection_pageInfo, + ec.fieldContext_Shell_id, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.ID, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_TagConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TagConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagConnection_totalCount, + ec.fieldContext_Shell_createdAt, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNInt2int, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_TagConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TagEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagEdge_node, + ec.fieldContext_Shell_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalOTag2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTag, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_TagEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagEdge", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "kind": - return ec.fieldContext_Tag_kind(ctx, field) - case "hosts": - return ec.fieldContext_Tag_hosts(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TagEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagEdge_cursor, + ec.fieldContext_Shell_closedAt, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.ClosedAt, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_TagEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagEdge", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_task(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_id, + ec.fieldContext_Shell_task, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Task(ctx) }, nil, - ec.marshalNID2int, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, true, ) } -func (ec *executionContext) fieldContext_Task_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_createdAt, + ec.fieldContext_Shell_beacon, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Beacon(ctx) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, true, true, ) } -func (ec *executionContext) fieldContext_Task_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Beacon_name(ctx, field) + case "principal": + return ec.fieldContext_Beacon_principal(ctx, field) + case "identifier": + return ec.fieldContext_Beacon_identifier(ctx, field) + case "agentIdentifier": + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Beacon_nextSeenAt(ctx, field) + case "interval": + return ec.fieldContext_Beacon_interval(ctx, field) + case "transport": + return ec.fieldContext_Beacon_transport(ctx, field) + case "host": + return ec.fieldContext_Beacon_host(ctx, field) + case "tasks": + return ec.fieldContext_Beacon_tasks(ctx, field) + case "shells": + return ec.fieldContext_Beacon_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_lastModifiedAt, + ec.fieldContext_Shell_owner, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Owner(ctx) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, true, ) } -func (ec *executionContext) fieldContext_Task_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_claimedAt, + ec.fieldContext_Shell_activeUsers, func(ctx context.Context) (any, error) { - return obj.ClaimedAt, nil + fc := graphql.GetFieldContext(ctx) + return obj.ActiveUsers(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Task_claimedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_UserConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_UserConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_UserConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Shell_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_execStartedAt, + ec.fieldContext_ShellConnection_edges, func(ctx context.Context) (any, error) { - return obj.ExecStartedAt, nil + return obj.Edges, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalOShellEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellEdge, true, false, ) } -func (ec *executionContext) fieldContext_Task_execStartedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_ShellEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_ShellEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ShellEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_execFinishedAt, + ec.fieldContext_ShellConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.ExecFinishedAt, nil + return obj.PageInfo, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Task_execFinishedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_output(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_output, + ec.fieldContext_ShellConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Output, nil + return obj.TotalCount, nil }, nil, - ec.marshalOString2string, + ec.marshalNInt2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Task_output(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_outputSize, + ec.fieldContext_ShellEdge_node, func(ctx context.Context) (any, error) { - return obj.OutputSize, nil + return obj.Node, nil }, nil, - ec.marshalNInt2int, - true, + ec.marshalOShell2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShell, true, + false, ) } -func (ec *executionContext) fieldContext_Task_outputSize(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Shell_id(ctx, field) + case "createdAt": + return ec.fieldContext_Shell_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Shell_lastModifiedAt(ctx, field) + case "closedAt": + return ec.fieldContext_Shell_closedAt(ctx, field) + case "task": + return ec.fieldContext_Shell_task(ctx, field) + case "beacon": + return ec.fieldContext_Shell_beacon(ctx, field) + case "owner": + return ec.fieldContext_Shell_owner(ctx, field) + case "activeUsers": + return ec.fieldContext_Shell_activeUsers(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Shell", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_error, + ec.fieldContext_ShellEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Error, nil + return obj.Cursor, nil }, nil, - ec.marshalOString2string, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Task_error(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_quest, + ec.fieldContext_Tag_id, func(ctx context.Context) (any, error) { - return obj.Quest(ctx) + return obj.ID, nil }, nil, - ec.marshalNQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Task_quest(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Quest_id(ctx, field) - case "createdAt": - return ec.fieldContext_Quest_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Quest_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Quest_name(ctx, field) - case "parameters": - return ec.fieldContext_Quest_parameters(ctx, field) - case "paramDefsAtCreation": - return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) - case "eldritchAtCreation": - return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) - case "tome": - return ec.fieldContext_Quest_tome(ctx, field) - case "bundle": - return ec.fieldContext_Quest_bundle(ctx, field) - case "tasks": - return ec.fieldContext_Quest_tasks(ctx, field) - case "creator": - return ec.fieldContext_Quest_creator(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_beacon, + ec.fieldContext_Tag_name, func(ctx context.Context) (any, error) { - return obj.Beacon(ctx) + return obj.Name, nil }, nil, - ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Task_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Beacon_id(ctx, field) - case "createdAt": - return ec.fieldContext_Beacon_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Beacon_name(ctx, field) - case "principal": - return ec.fieldContext_Beacon_principal(ctx, field) - case "identifier": - return ec.fieldContext_Beacon_identifier(ctx, field) - case "agentIdentifier": - return ec.fieldContext_Beacon_agentIdentifier(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Beacon_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Beacon_nextSeenAt(ctx, field) - case "interval": - return ec.fieldContext_Beacon_interval(ctx, field) - case "transport": - return ec.fieldContext_Beacon_transport(ctx, field) - case "host": - return ec.fieldContext_Beacon_host(ctx, field) - case "tasks": - return ec.fieldContext_Beacon_tasks(ctx, field) - case "shells": - return ec.fieldContext_Beacon_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_reportedFiles(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Tag_kind(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_reportedFiles, + ec.fieldContext_Tag_kind, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ReportedFiles(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostFileOrder), fc.Args["where"].(*ent.HostFileWhereInput)) + return obj.Kind, nil }, nil, - ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, + ec.marshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind, true, true, ) } -func (ec *executionContext) fieldContext_Task_reportedFiles(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostFileConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostFileConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostFileConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostFileConnection", field.Name) + return nil, errors.New("field of type TagKind does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Task_reportedFiles_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Tag_hosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_reportedProcesses, + ec.fieldContext_Tag_hosts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return obj.ReportedProcesses(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostProcessOrder), fc.Args["where"].(*ent.HostProcessWhereInput)) + return obj.Hosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) }, nil, - ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, + ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, true, true, ) } -func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_HostProcessConnection_edges(ctx, field) + return ec.fieldContext_HostConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_HostProcessConnection_pageInfo(ctx, field) + return ec.fieldContext_HostConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_HostProcessConnection_totalCount(ctx, field) + return ec.fieldContext_HostConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostProcessConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) }, } defer func() { @@ -9140,165 +8816,67 @@ func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Task_reportedProcesses_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Tag_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Task_reportedCredentials(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _TagConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_reportedCredentials, + ec.fieldContext_TagConnection_edges, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ReportedCredentials(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostCredentialOrder), fc.Args["where"].(*ent.HostCredentialWhereInput)) + return obj.Edges, nil }, nil, - ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, - true, + ec.marshalOTagEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagEdge, true, + false, ) } -func (ec *executionContext) fieldContext_Task_reportedCredentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "TagConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_HostCredentialConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostCredentialConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostCredentialConnection_totalCount(ctx, field) + case "node": + return ec.fieldContext_TagEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_TagEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TagEdge", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Task_reportedCredentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Task_shells(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _TagConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_shells, + ec.fieldContext_TagConnection_pageInfo, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Shells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) + return obj.PageInfo, nil }, nil, - ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Task_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_ShellConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_ShellConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_ShellConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Task_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_TaskConnection_edges, - func(ctx context.Context) (any, error) { - return obj.Edges, nil - }, - nil, - ec.marshalOTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskEdge, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_TaskConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_TaskEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_TaskEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_TaskConnection_pageInfo, - func(ctx context.Context) (any, error) { - return obj.PageInfo, nil - }, - nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_TaskConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "TagConnection", Field: field, IsMethod: false, IsResolver: false, @@ -9319,12 +8897,12 @@ func (ec *executionContext) fieldContext_TaskConnection_pageInfo(_ context.Conte return fc, nil } -func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _TagConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TaskConnection_totalCount, + ec.fieldContext_TagConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -9335,9 +8913,9 @@ func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, fiel ) } -func (ec *executionContext) fieldContext_TaskConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "TagConnection", Field: field, IsMethod: false, IsResolver: false, @@ -9348,73 +8926,51 @@ func (ec *executionContext) fieldContext_TaskConnection_totalCount(_ context.Con return fc, nil } -func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TagEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TaskEdge_node, + ec.fieldContext_TagEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalOTag2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTag, true, false, ) } -func (ec *executionContext) fieldContext_TaskEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "TagEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "kind": + return ec.fieldContext_Tag_kind(ctx, field) + case "hosts": + return ec.fieldContext_Tag_hosts(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } return fc, nil } -func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TagEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TaskEdge_cursor, + ec.fieldContext_TagEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -9425,9 +8981,9 @@ func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_TaskEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "TagEdge", Field: field, IsMethod: false, IsResolver: false, @@ -9438,12 +8994,12 @@ func (ec *executionContext) fieldContext_TaskEdge_cursor(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_id, + ec.fieldContext_Task_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -9454,9 +9010,9 @@ func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_Tome_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -9467,12 +9023,12 @@ func (ec *executionContext) fieldContext_Tome_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_createdAt, + ec.fieldContext_Task_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -9483,9 +9039,9 @@ func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.C ) } -func (ec *executionContext) fieldContext_Tome_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -9496,12 +9052,12 @@ func (ec *executionContext) fieldContext_Tome_createdAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_lastModifiedAt, + ec.fieldContext_Task_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -9512,9 +9068,9 @@ func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Tome_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -9525,329 +9081,423 @@ func (ec *executionContext) fieldContext_Tome_lastModifiedAt(_ context.Context, return fc, nil } -func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_name, + ec.fieldContext_Task_claimedAt, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.ClaimedAt, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_claimedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_description(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_description, + ec.fieldContext_Task_execStartedAt, func(ctx context.Context) (any, error) { - return obj.Description, nil + return obj.ExecStartedAt, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_execStartedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_author, + ec.fieldContext_Task_execFinishedAt, func(ctx context.Context) (any, error) { - return obj.Author, nil + return obj.ExecFinishedAt, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_author(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_execFinishedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_output(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_supportModel, + ec.fieldContext_Task_output, func(ctx context.Context) (any, error) { - return obj.SupportModel, nil + return obj.Output, nil }, nil, - ec.marshalNTomeSupportModel2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_supportModel(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_output(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TomeSupportModel does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_tactic, + ec.fieldContext_Task_outputSize, func(ctx context.Context) (any, error) { - return obj.Tactic, nil + return obj.OutputSize, nil }, nil, - ec.marshalNTomeTactic2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Tome_tactic(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_outputSize(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TomeTactic does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_runOnNewBeaconCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_runOnNewBeaconCallback, + ec.fieldContext_Task_error, func(ctx context.Context) (any, error) { - return obj.RunOnNewBeaconCallback, nil + return obj.Error, nil }, nil, - ec.marshalNBoolean2bool, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_runOnNewBeaconCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_error(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_runOnFirstHostCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_runOnFirstHostCallback, + ec.fieldContext_Task_quest, func(ctx context.Context) (any, error) { - return obj.RunOnFirstHostCallback, nil + return obj.Quest(ctx) }, nil, - ec.marshalNBoolean2bool, + ec.marshalNQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, true, true, ) } -func (ec *executionContext) fieldContext_Tome_runOnFirstHostCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_quest(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Quest_id(ctx, field) + case "createdAt": + return ec.fieldContext_Quest_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Quest_name(ctx, field) + case "parameters": + return ec.fieldContext_Quest_parameters(ctx, field) + case "paramDefsAtCreation": + return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) + case "eldritchAtCreation": + return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) + case "tome": + return ec.fieldContext_Quest_tome(ctx, field) + case "bundle": + return ec.fieldContext_Quest_bundle(ctx, field) + case "tasks": + return ec.fieldContext_Quest_tasks(ctx, field) + case "creator": + return ec.fieldContext_Quest_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_runOnSchedule(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_runOnSchedule, + ec.fieldContext_Task_beacon, func(ctx context.Context) (any, error) { - return obj.RunOnSchedule, nil + return obj.Beacon(ctx) }, nil, - ec.marshalNString2string, + ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, true, true, ) } -func (ec *executionContext) fieldContext_Tome_runOnSchedule(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Beacon_name(ctx, field) + case "principal": + return ec.fieldContext_Beacon_principal(ctx, field) + case "identifier": + return ec.fieldContext_Beacon_identifier(ctx, field) + case "agentIdentifier": + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Beacon_nextSeenAt(ctx, field) + case "interval": + return ec.fieldContext_Beacon_interval(ctx, field) + case "transport": + return ec.fieldContext_Beacon_transport(ctx, field) + case "host": + return ec.fieldContext_Beacon_host(ctx, field) + case "tasks": + return ec.fieldContext_Beacon_tasks(ctx, field) + case "shells": + return ec.fieldContext_Beacon_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_reportedFiles(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_paramDefs, + ec.fieldContext_Task_reportedFiles, func(ctx context.Context) (any, error) { - return obj.ParamDefs, nil + fc := graphql.GetFieldContext(ctx) + return obj.ReportedFiles(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostFileOrder), fc.Args["where"].(*ent.HostFileWhereInput)) }, nil, - ec.marshalOString2string, + ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Tome_paramDefs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedFiles(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_HostFileConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostFileConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostFileConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostFileConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Task_reportedFiles_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_eldritch, + ec.fieldContext_Task_reportedProcesses, func(ctx context.Context) (any, error) { - return obj.Eldritch, nil + fc := graphql.GetFieldContext(ctx) + return obj.ReportedProcesses(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostProcessOrder), fc.Args["where"].(*ent.HostProcessWhereInput)) }, nil, - ec.marshalNString2string, + ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, true, true, ) } -func (ec *executionContext) fieldContext_Tome_eldritch(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_HostProcessConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostProcessConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostProcessConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostProcessConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Task_reportedProcesses_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tome_assets(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_reportedCredentials(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_assets, + ec.fieldContext_Task_reportedCredentials, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return obj.Assets(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AssetOrder), fc.Args["where"].(*ent.AssetWhereInput)) + return obj.ReportedCredentials(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostCredentialOrder), fc.Args["where"].(*ent.HostCredentialWhereInput)) }, nil, - ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, + ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, true, true, ) } -func (ec *executionContext) fieldContext_Tome_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedCredentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_AssetConnection_edges(ctx, field) + return ec.fieldContext_HostCredentialConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_AssetConnection_pageInfo(ctx, field) + return ec.fieldContext_HostCredentialConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_AssetConnection_totalCount(ctx, field) + return ec.fieldContext_HostCredentialConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AssetConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", field.Name) }, } defer func() { @@ -9857,195 +9507,103 @@ func (ec *executionContext) fieldContext_Tome_assets(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Tome_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Task_reportedCredentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_shells(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_uploader, + ec.fieldContext_Task_shells, func(ctx context.Context) (any, error) { - return obj.Uploader(ctx) + fc := graphql.GetFieldContext(ctx) + return obj.Shells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) }, nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Tome_uploader(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) + case "edges": + return ec.fieldContext_ShellConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ShellConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ShellConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Task_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tome_repository(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_repository, + ec.fieldContext_TaskConnection_edges, func(ctx context.Context) (any, error) { - return obj.Repository(ctx) + return obj.Edges, nil }, nil, - ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, + ec.marshalOTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskEdge, true, false, ) } -func (ec *executionContext) fieldContext_Tome_repository(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "TaskConnection", Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Repository_id(ctx, field) - case "createdAt": - return ec.fieldContext_Repository_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Repository_lastModifiedAt(ctx, field) - case "url": - return ec.fieldContext_Repository_url(ctx, field) - case "publicKey": - return ec.fieldContext_Repository_publicKey(ctx, field) - case "lastImportedAt": - return ec.fieldContext_Repository_lastImportedAt(ctx, field) - case "tomes": - return ec.fieldContext_Repository_tomes(ctx, field) - case "owner": - return ec.fieldContext_Repository_owner(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Tome_scheduledHosts, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ScheduledHosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) - }, - nil, - ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Tome", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Tome_scheduledHosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _TomeConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_TomeConnection_edges, - func(ctx context.Context) (any, error) { - return obj.Edges, nil - }, - nil, - ec.marshalOTomeEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeEdge, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_TomeConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TomeConnection", - Field: field, - IsMethod: false, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "node": - return ec.fieldContext_TomeEdge_node(ctx, field) + return ec.fieldContext_TaskEdge_node(ctx, field) case "cursor": - return ec.fieldContext_TomeEdge_cursor(ctx, field) + return ec.fieldContext_TaskEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TomeEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _TomeConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeConnection_pageInfo, + ec.fieldContext_TaskConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -10056,9 +9614,9 @@ func (ec *executionContext) _TomeConnection_pageInfo(ctx context.Context, field ) } -func (ec *executionContext) fieldContext_TomeConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeConnection", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, @@ -10079,12 +9637,12 @@ func (ec *executionContext) fieldContext_TomeConnection_pageInfo(_ context.Conte return fc, nil } -func (ec *executionContext) _TomeConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeConnection_totalCount, + ec.fieldContext_TaskConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -10095,9 +9653,9 @@ func (ec *executionContext) _TomeConnection_totalCount(ctx context.Context, fiel ) } -func (ec *executionContext) fieldContext_TomeConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeConnection", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, @@ -10108,77 +9666,73 @@ func (ec *executionContext) fieldContext_TomeConnection_totalCount(_ context.Con return fc, nil } -func (ec *executionContext) _TomeEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeEdge_node, + ec.fieldContext_TaskEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, + ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, false, ) } -func (ec *executionContext) fieldContext_TomeEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeEdge", + Object: "TaskEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Tome_id(ctx, field) + return ec.fieldContext_Task_id(ctx, field) case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) + return ec.fieldContext_Task_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Tome_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Tome_name(ctx, field) - case "description": - return ec.fieldContext_Tome_description(ctx, field) - case "author": - return ec.fieldContext_Tome_author(ctx, field) - case "supportModel": - return ec.fieldContext_Tome_supportModel(ctx, field) - case "tactic": - return ec.fieldContext_Tome_tactic(ctx, field) - case "runOnNewBeaconCallback": - return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) - case "runOnFirstHostCallback": - return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) - case "runOnSchedule": - return ec.fieldContext_Tome_runOnSchedule(ctx, field) - case "paramDefs": - return ec.fieldContext_Tome_paramDefs(ctx, field) - case "eldritch": - return ec.fieldContext_Tome_eldritch(ctx, field) - case "assets": - return ec.fieldContext_Tome_assets(ctx, field) - case "uploader": - return ec.fieldContext_Tome_uploader(ctx, field) - case "repository": - return ec.fieldContext_Tome_repository(ctx, field) - case "scheduledHosts": - return ec.fieldContext_Tome_scheduledHosts(ctx, field) + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _TomeEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeEdge_cursor, + ec.fieldContext_TaskEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -10189,9 +9743,9 @@ func (ec *executionContext) _TomeEdge_cursor(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_TomeEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeEdge", + Object: "TaskEdge", Field: field, IsMethod: false, IsResolver: false, @@ -10202,12 +9756,12 @@ func (ec *executionContext) fieldContext_TomeEdge_cursor(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_id, + ec.fieldContext_Tome_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -10218,9 +9772,9 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, @@ -10231,403 +9785,1680 @@ func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_name, + ec.fieldContext_Tome_createdAt, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNString2string, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_User_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_photoURL, + ec.fieldContext_Tome_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.PhotoURL, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalNString2string, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_User_photoURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_isActivated(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_isActivated, + ec.fieldContext_Tome_name, func(ctx context.Context) (any, error) { - return obj.IsActivated, nil + return obj.Name, nil }, nil, - ec.marshalNBoolean2bool, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_User_isActivated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_description(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_isAdmin, + ec.fieldContext_Tome_description, func(ctx context.Context) (any, error) { - return obj.IsAdmin, nil + return obj.Description, nil }, nil, - ec.marshalNBoolean2bool, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_User_isAdmin(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_tomes, + ec.fieldContext_Tome_author, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) + return obj.Author, nil }, nil, - ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_author(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TomeConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TomeConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TomeConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_User_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _User_activeShells(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_activeShells, + ec.fieldContext_Tome_supportModel, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ActiveShells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) + return obj.SupportModel, nil }, nil, - ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + ec.marshalNTomeSupportModel2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel, true, true, ) } -func (ec *executionContext) fieldContext_User_activeShells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_supportModel(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_ShellConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_ShellConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_ShellConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) + return nil, errors.New("field of type TomeSupportModel does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_User_activeShells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err + return fc, nil +} + +func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_tactic, + func(ctx context.Context) (any, error) { + return obj.Tactic, nil + }, + nil, + ec.marshalNTomeTactic2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Tome_tactic(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type TomeTactic does not have child fields") + }, } return fc, nil } -func (ec *executionContext) _UserConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_runOnNewBeaconCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserConnection_edges, + ec.fieldContext_Tome_runOnNewBeaconCallback, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.RunOnNewBeaconCallback, nil }, nil, - ec.marshalOUserEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserEdge, + ec.marshalNBoolean2bool, + true, true, - false, ) } -func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_runOnNewBeaconCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserConnection", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_UserEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_UserEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_runOnFirstHostCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserConnection_pageInfo, + ec.fieldContext_Tome_runOnFirstHostCallback, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.RunOnFirstHostCallback, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNBoolean2bool, true, true, ) } -func (ec *executionContext) fieldContext_UserConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_runOnFirstHostCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserConnection", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_runOnSchedule(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserConnection_totalCount, + ec.fieldContext_Tome_runOnSchedule, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.RunOnSchedule, nil }, nil, - ec.marshalNInt2int, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_UserConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_runOnSchedule(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserConnection", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserEdge_node, + ec.fieldContext_Tome_paramDefs, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.ParamDefs, nil }, nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_UserEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_paramDefs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserEdge", + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_eldritch, + func(ctx context.Context) (any, error) { + return obj.Eldritch, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Tome_eldritch(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_assets(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_assets, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.Assets(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AssetOrder), fc.Args["where"].(*ent.AssetWhereInput)) + }, + nil, + ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Tome_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) + case "edges": + return ec.fieldContext_AssetConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_AssetConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_AssetConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type AssetConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Tome_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_uploader, + func(ctx context.Context) (any, error) { + return obj.Uploader(ctx) + }, + nil, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Tome_uploader(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_repository(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_repository, + func(ctx context.Context) (any, error) { + return obj.Repository(ctx) + }, + nil, + ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Tome_repository(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Repository_id(ctx, field) + case "createdAt": + return ec.fieldContext_Repository_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Repository_lastModifiedAt(ctx, field) + case "url": + return ec.fieldContext_Repository_url(ctx, field) + case "publicKey": + return ec.fieldContext_Repository_publicKey(ctx, field) + case "lastImportedAt": + return ec.fieldContext_Repository_lastImportedAt(ctx, field) + case "tomes": + return ec.fieldContext_Repository_tomes(ctx, field) + case "owner": + return ec.fieldContext_Repository_owner(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_scheduledHosts, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.ScheduledHosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) + }, + nil, + ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_HostConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Tome_scheduledHosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _TomeConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeConnection_edges, + func(ctx context.Context) (any, error) { + return obj.Edges, nil + }, + nil, + ec.marshalOTomeEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeEdge, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_TomeConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "node": + return ec.fieldContext_TomeEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_TomeEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TomeEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _TomeConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeConnection_pageInfo, + func(ctx context.Context) (any, error) { + return obj.PageInfo, nil + }, + nil, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_TomeConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _TomeConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeConnection_totalCount, + func(ctx context.Context) (any, error) { + return obj.TotalCount, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_TomeConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _TomeEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeEdge_node, + func(ctx context.Context) (any, error) { + return obj.Node, nil + }, + nil, + ec.marshalOTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_TomeEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Tome_id(ctx, field) + case "createdAt": + return ec.fieldContext_Tome_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Tome_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Tome_name(ctx, field) + case "description": + return ec.fieldContext_Tome_description(ctx, field) + case "author": + return ec.fieldContext_Tome_author(ctx, field) + case "supportModel": + return ec.fieldContext_Tome_supportModel(ctx, field) + case "tactic": + return ec.fieldContext_Tome_tactic(ctx, field) + case "runOnNewBeaconCallback": + return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) + case "runOnFirstHostCallback": + return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) + case "runOnSchedule": + return ec.fieldContext_Tome_runOnSchedule(ctx, field) + case "paramDefs": + return ec.fieldContext_Tome_paramDefs(ctx, field) + case "eldritch": + return ec.fieldContext_Tome_eldritch(ctx, field) + case "assets": + return ec.fieldContext_Tome_assets(ctx, field) + case "uploader": + return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) + case "scheduledHosts": + return ec.fieldContext_Tome_scheduledHosts(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _TomeEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeEdge_cursor, + func(ctx context.Context) (any, error) { + return obj.Cursor, nil + }, + nil, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_TomeEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Cursor does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_id, + func(ctx context.Context) (any, error) { + return obj.ID, nil + }, + nil, + ec.marshalNID2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_name, + func(ctx context.Context) (any, error) { + return obj.Name, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_photoURL, + func(ctx context.Context) (any, error) { + return obj.PhotoURL, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_photoURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_isActivated(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_isActivated, + func(ctx context.Context) (any, error) { + return obj.IsActivated, nil + }, + nil, + ec.marshalNBoolean2bool, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_isActivated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_isAdmin, + func(ctx context.Context) (any, error) { + return obj.IsAdmin, nil + }, + nil, + ec.marshalNBoolean2bool, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_isAdmin(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_tomes, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) + }, + nil, + ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_TomeConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TomeConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TomeConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_User_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _User_activeShells(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_activeShells, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.ActiveShells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) + }, + nil, + ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_activeShells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_ShellConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ShellConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ShellConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_User_activeShells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserConnection_edges, + func(ctx context.Context) (any, error) { + return obj.Edges, nil + }, + nil, + ec.marshalOUserEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserEdge, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "node": + return ec.fieldContext_UserEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_UserEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserConnection_pageInfo, + func(ctx context.Context) (any, error) { + return obj.PageInfo, nil + }, + nil, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_UserConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserConnection_totalCount, + func(ctx context.Context) (any, error) { + return obj.TotalCount, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_UserConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _UserEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserEdge_node, + func(ctx context.Context) (any, error) { + return obj.Node, nil + }, + nil, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_UserEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _UserEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserEdge_cursor, + func(ctx context.Context) (any, error) { + return obj.Cursor, nil + }, + nil, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_UserEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Cursor does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputAssetOrder(ctx context.Context, obj any) (ent.AssetOrder, error) { + var it ent.AssetOrder + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + if err != nil { + return it, err + } + it.Direction = data + case "field": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNAssetOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputAssetWhereInput(ctx context.Context, obj any) (ent.AssetWhereInput, error) { + var it ent.AssetWhereInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashEqualFold", "hashContainsFold", "hasTomes", "hasTomesWith", "hasLinks", "hasLinksWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOAssetWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createdAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNotIn = data + case "createdAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGT = data + case "createdAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGTE = data + case "createdAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLT = data + case "createdAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLTE = data + case "lastModifiedAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAt = data + case "lastModifiedAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLTE = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameNEQ = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data + case "size": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.Size = data + case "sizeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeNEQ = data + case "sizeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.SizeIn = data + case "sizeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.SizeNotIn = data + case "sizeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeGT = data + case "sizeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeGTE = data + case "sizeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeLT = data + case "sizeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeLTE = data + case "hash": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Hash = data + case "hashNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashNEQ = data + case "hashIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.HashIn = data + case "hashNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.HashNotIn = data + case "hashGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashGT = data + case "hashGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashGTE = data + case "hashLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashLT = data + case "hashLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashLTE = data + case "hashContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashContains = data + case "hashHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashHasPrefix = data + case "hashHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashHasSuffix = data + case "hashEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashEqualFold = data + case "hashContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashContainsFold = data + case "hasTomes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasTomes = data + case "hasTomesWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomesWith")) + data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) + if err != nil { + return it, err } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) - }, + it.HasTomesWith = data + case "hasLinks": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinks")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasLinks = data + case "hasLinksWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinksWith")) + data, err := ec.unmarshalOLinkWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasLinksWith = data + } } - return fc, nil -} - -func (ec *executionContext) _UserEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_UserEdge_cursor, - func(ctx context.Context) (any, error) { - return obj.Cursor, nil - }, - nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, - true, - true, - ) -} -func (ec *executionContext) fieldContext_UserEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "UserEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil + return it, nil } -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputAssetOrder(ctx context.Context, obj any) (ent.AssetOrder, error) { - var it ent.AssetOrder +func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj any) (ent.BeaconOrder, error) { + var it ent.BeaconOrder asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -10653,7 +11484,7 @@ func (ec *executionContext) unmarshalInputAssetOrder(ctx context.Context, obj an it.Direction = data case "field": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNAssetOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetOrderField(ctx, v) + data, err := ec.unmarshalNBeaconOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconOrderField(ctx, v) if err != nil { return it, err } @@ -10664,14 +11495,14 @@ func (ec *executionContext) unmarshalInputAssetOrder(ctx context.Context, obj an return it, nil } -func (ec *executionContext) unmarshalInputAssetWhereInput(ctx context.Context, obj any) (ent.AssetWhereInput, error) { - var it ent.AssetWhereInput +func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, obj any) (ent.BeaconWhereInput, error) { + var it ent.BeaconWhereInput asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashEqualFold", "hashContainsFold", "hasTomes", "hasTomesWith", "hasLinks", "hasLinksWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "nextSeenAt", "nextSeenAtNEQ", "nextSeenAtIn", "nextSeenAtNotIn", "nextSeenAtGT", "nextSeenAtGTE", "nextSeenAtLT", "nextSeenAtLTE", "nextSeenAtIsNil", "nextSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "transport", "transportNEQ", "transportIn", "transportNotIn", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith", "hasShells", "hasShellsWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -10680,21 +11511,21 @@ func (ec *executionContext) unmarshalInputAssetWhereInput(ctx context.Context, o switch k { case "not": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOAssetWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInput(ctx, v) + data, err := ec.unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInput(ctx, v) if err != nil { return it, err } it.Not = data case "and": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) if err != nil { return it, err } it.And = data case "or": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -10852,1206 +11683,1065 @@ func (ec *executionContext) unmarshalInputAssetWhereInput(ctx context.Context, o if err != nil { return it, err } - it.LastModifiedAtGTE = data - case "lastModifiedAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtLT = data - case "lastModifiedAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtLTE = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Name = data - case "nameNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameNEQ = data - case "nameIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameIn = data - case "nameNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameNotIn = data - case "nameGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGT = data - case "nameGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGTE = data - case "nameLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameLT = data - case "nameLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameLTE = data - case "nameContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameContains = data - case "nameHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameHasPrefix = data - case "nameHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameHasSuffix = data - case "nameEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameEqualFold = data - case "nameContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameContainsFold = data - case "size": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.Size = data - case "sizeNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SizeNEQ = data - case "sizeIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.SizeIn = data - case "sizeNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.SizeNotIn = data - case "sizeGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SizeGT = data - case "sizeGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SizeGTE = data - case "sizeLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SizeLT = data - case "sizeLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SizeLTE = data - case "hash": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Hash = data - case "hashNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.HashNEQ = data - case "hashIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.HashIn = data - case "hashNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.HashNotIn = data - case "hashGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.HashGT = data - case "hashGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) + it.LastModifiedAtLTE = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashGTE = data - case "hashLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashLT = data - case "hashLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NameNEQ = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.HashLTE = data - case "hashContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.HashContains = data - case "hashHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashHasPrefix = data - case "hashHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) + it.NameGT = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashHasSuffix = data - case "hashEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) + it.NameGTE = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashEqualFold = data - case "hashContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) + it.NameLT = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashContainsFold = data - case "hasTomes": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.NameLTE = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTomes = data - case "hasTomesWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomesWith")) - data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTomesWith = data - case "hasLinks": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinks")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasLinks = data - case "hasLinksWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinksWith")) - data, err := ec.unmarshalOLinkWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkWhereInputᚄ(ctx, v) + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasLinksWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj any) (ent.BeaconOrder, error) { - var it ent.BeaconOrder - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNBeaconOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconOrderField(ctx, v) + it.NameContainsFold = data + case "principal": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, obj any) (ent.BeaconWhereInput, error) { - var it ent.BeaconWhereInput - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "nextSeenAt", "nextSeenAtNEQ", "nextSeenAtIn", "nextSeenAtNotIn", "nextSeenAtGT", "nextSeenAtGTE", "nextSeenAtLT", "nextSeenAtLTE", "nextSeenAtIsNil", "nextSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "transport", "transportNEQ", "transportIn", "transportNotIn", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith", "hasShells", "hasShellsWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInput(ctx, v) + it.Principal = data + case "principalNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + it.PrincipalNEQ = data + case "principalIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + it.PrincipalIn = data + case "principalNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.PrincipalNotIn = data + case "principalGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.PrincipalGT = data + case "principalGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.PrincipalGTE = data + case "principalLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.PrincipalLT = data + case "principalLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.PrincipalLTE = data + case "principalContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.PrincipalContains = data + case "principalHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.PrincipalHasPrefix = data + case "principalHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.PrincipalHasSuffix = data + case "principalIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.IDLTE = data - case "createdAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.PrincipalIsNil = data + case "principalNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.CreatedAt = data - case "createdAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.PrincipalNotNil = data + case "principalEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNEQ = data - case "createdAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.PrincipalEqualFold = data + case "principalContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtIn = data - case "createdAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.PrincipalContainsFold = data + case "identifier": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNotIn = data - case "createdAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.Identifier = data + case "identifierNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtGT = data - case "createdAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierNEQ = data + case "identifierIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.CreatedAtGTE = data - case "createdAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierIn = data + case "identifierNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.CreatedAtLT = data - case "createdAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierNotIn = data + case "identifierGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtLTE = data - case "lastModifiedAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierGT = data + case "identifierGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAt = data - case "lastModifiedAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierGTE = data + case "identifierLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtNEQ = data - case "lastModifiedAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.IdentifierLT = data + case "identifierLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtIn = data - case "lastModifiedAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.IdentifierLTE = data + case "identifierContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtNotIn = data - case "lastModifiedAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierContains = data + case "identifierHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtGT = data - case "lastModifiedAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierHasPrefix = data + case "identifierHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtGTE = data - case "lastModifiedAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierHasSuffix = data + case "identifierEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtLT = data - case "lastModifiedAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierEqualFold = data + case "identifierContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtLTE = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.IdentifierContainsFold = data + case "agentIdentifier": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifier")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "nameNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + it.AgentIdentifier = data + case "agentIdentifierNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameNEQ = data - case "nameIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + it.AgentIdentifierNEQ = data + case "agentIdentifierIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameIn = data - case "nameNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + it.AgentIdentifierIn = data + case "agentIdentifierNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameNotIn = data - case "nameGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + it.AgentIdentifierNotIn = data + case "agentIdentifierGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGT = data - case "nameGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + it.AgentIdentifierGT = data + case "agentIdentifierGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGTE = data - case "nameLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + it.AgentIdentifierGTE = data + case "agentIdentifierLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLT = data - case "nameLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + it.AgentIdentifierLT = data + case "agentIdentifierLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLTE = data - case "nameContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + it.AgentIdentifierLTE = data + case "agentIdentifierContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContains = data - case "nameHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + it.AgentIdentifierContains = data + case "agentIdentifierHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasPrefix = data - case "nameHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + it.AgentIdentifierHasPrefix = data + case "agentIdentifierHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.AgentIdentifierHasSuffix = data + case "agentIdentifierIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.AgentIdentifierIsNil = data + case "agentIdentifierNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "principal": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + it.AgentIdentifierNotNil = data + case "agentIdentifierEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Principal = data - case "principalNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + it.AgentIdentifierEqualFold = data + case "agentIdentifierContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalNEQ = data - case "principalIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.AgentIdentifierContainsFold = data + case "lastSeenAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalIn = data - case "principalNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.LastSeenAt = data + case "lastSeenAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalNotIn = data - case "principalGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtNEQ = data + case "lastSeenAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalGT = data - case "principalGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtIn = data + case "lastSeenAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtNotIn = data + case "lastSeenAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtGT = data + case "lastSeenAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalGTE = data - case "principalLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtGTE = data + case "lastSeenAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalLT = data - case "principalLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtLT = data + case "lastSeenAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalLTE = data - case "principalContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtLTE = data + case "lastSeenAtIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PrincipalContains = data - case "principalHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtIsNil = data + case "lastSeenAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PrincipalHasPrefix = data - case "principalHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtNotNil = data + case "nextSeenAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalHasSuffix = data - case "principalIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.NextSeenAt = data + case "nextSeenAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalIsNil = data - case "principalNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.NextSeenAtNEQ = data + case "nextSeenAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalNotNil = data - case "principalEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NextSeenAtIn = data + case "nextSeenAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalEqualFold = data - case "principalContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NextSeenAtNotIn = data + case "nextSeenAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalContainsFold = data - case "identifier": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NextSeenAtGT = data + case "nextSeenAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.Identifier = data - case "identifierNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NextSeenAtGTE = data + case "nextSeenAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IdentifierNEQ = data - case "identifierIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.NextSeenAtLT = data + case "nextSeenAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IdentifierIn = data - case "identifierNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.NextSeenAtLTE = data + case "nextSeenAtIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.IdentifierNotIn = data - case "identifierGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NextSeenAtIsNil = data + case "nextSeenAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.IdentifierGT = data - case "identifierGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NextSeenAtNotNil = data + case "interval": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.IdentifierGTE = data - case "identifierLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.Interval = data + case "intervalNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNEQ")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.IdentifierLT = data - case "identifierLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalNEQ = data + case "intervalIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierLTE = data - case "identifierContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalIn = data + case "intervalNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierContains = data - case "identifierHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalNotIn = data + case "intervalGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.IdentifierHasPrefix = data - case "identifierHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalGT = data + case "intervalGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.IdentifierHasSuffix = data - case "identifierEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalGTE = data + case "intervalLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.IdentifierEqualFold = data - case "identifierContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalLT = data + case "intervalLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.IdentifierContainsFold = data - case "agentIdentifier": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifier")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalLTE = data + case "intervalIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.AgentIdentifier = data - case "agentIdentifierNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalIsNil = data + case "intervalNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNEQ = data - case "agentIdentifierIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.IntervalNotNil = data + case "transport": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transport")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) if err != nil { return it, err } - it.AgentIdentifierIn = data - case "agentIdentifierNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.Transport = data + case "transportNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNEQ")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNotIn = data - case "agentIdentifierGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.TransportNEQ = data + case "transportIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportIn")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierGT = data - case "agentIdentifierGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.TransportIn = data + case "transportNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNotIn")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierGTE = data - case "agentIdentifierLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.TransportNotIn = data + case "hasHost": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.AgentIdentifierLT = data - case "agentIdentifierLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.HasHost = data + case "hasHostWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierLTE = data - case "agentIdentifierContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.HasHostWith = data + case "hasTasks": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.AgentIdentifierContains = data - case "agentIdentifierHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.HasTasks = data + case "hasTasksWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierHasPrefix = data - case "agentIdentifierHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.HasTasksWith = data + case "hasShells": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShells")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.AgentIdentifierHasSuffix = data - case "agentIdentifierIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.HasShells = data + case "hasShellsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellsWith")) + data, err := ec.unmarshalOShellWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierIsNil = data - case "agentIdentifierNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.HasShellsWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputBuilderOrder(ctx context.Context, obj any) (ent.BuilderOrder, error) { + var it ent.BuilderOrder + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNotNil = data - case "agentIdentifierEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.Direction = data + case "field": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNBuilderOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderOrderField(ctx, v) if err != nil { return it, err } - it.AgentIdentifierEqualFold = data - case "agentIdentifierContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputBuilderWhereInput(ctx context.Context, obj any) (ent.BuilderWhereInput, error) { + var it ent.BuilderWhereInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "upstream", "upstreamNEQ", "upstreamIn", "upstreamNotIn", "upstreamGT", "upstreamGTE", "upstreamLT", "upstreamLTE", "upstreamContains", "upstreamHasPrefix", "upstreamHasSuffix", "upstreamEqualFold", "upstreamContainsFold"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOBuilderWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInput(ctx, v) if err != nil { return it, err } - it.AgentIdentifierContainsFold = data - case "lastSeenAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOBuilderWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.LastSeenAt = data - case "lastSeenAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOBuilderWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.LastSeenAtNEQ = data - case "lastSeenAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.LastSeenAtIn = data - case "lastSeenAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotIn = data - case "lastSeenAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.LastSeenAtGT = data - case "lastSeenAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.LastSeenAtGTE = data - case "lastSeenAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.LastSeenAtLT = data - case "lastSeenAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.LastSeenAtLTE = data - case "lastSeenAtIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.LastSeenAtIsNil = data - case "lastSeenAtNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotNil = data - case "nextSeenAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAt")) + it.IDLTE = data + case "createdAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NextSeenAt = data - case "nextSeenAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNEQ")) + it.CreatedAt = data + case "createdAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NextSeenAtNEQ = data - case "nextSeenAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIn")) + it.CreatedAtNEQ = data + case "createdAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.NextSeenAtIn = data - case "nextSeenAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotIn")) + it.CreatedAtIn = data + case "createdAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.NextSeenAtNotIn = data - case "nextSeenAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGT")) + it.CreatedAtNotIn = data + case "createdAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NextSeenAtGT = data - case "nextSeenAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGTE")) + it.CreatedAtGT = data + case "createdAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NextSeenAtGTE = data - case "nextSeenAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLT")) + it.CreatedAtGTE = data + case "createdAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NextSeenAtLT = data - case "nextSeenAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLTE")) + it.CreatedAtLT = data + case "createdAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NextSeenAtLTE = data - case "nextSeenAtIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.CreatedAtLTE = data + case "lastModifiedAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NextSeenAtIsNil = data - case "nextSeenAtNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.LastModifiedAt = data + case "lastModifiedAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NextSeenAtNotNil = data - case "interval": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.Interval = data - case "intervalNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNEQ")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.IntervalNEQ = data - case "intervalIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IntervalIn = data - case "intervalNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IntervalNotIn = data - case "intervalGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IntervalGT = data - case "intervalGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.LastModifiedAtLTE = data + case "upstream": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstream")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalGTE = data - case "intervalLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.Upstream = data + case "upstreamNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalLT = data - case "intervalLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.UpstreamNEQ = data + case "upstreamIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IntervalLTE = data - case "intervalIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.UpstreamIn = data + case "upstreamNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IntervalIsNil = data - case "intervalNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.UpstreamNotIn = data + case "upstreamGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalNotNil = data - case "transport": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transport")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) + it.UpstreamGT = data + case "upstreamGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Transport = data - case "transportNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNEQ")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) + it.UpstreamGTE = data + case "upstreamLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TransportNEQ = data - case "transportIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportIn")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) + it.UpstreamLT = data + case "upstreamLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TransportIn = data - case "transportNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNotIn")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) + it.UpstreamLTE = data + case "upstreamContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TransportNotIn = data - case "hasHost": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.UpstreamContains = data + case "upstreamHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasHost = data - case "hasHostWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + it.UpstreamHasPrefix = data + case "upstreamHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasHostWith = data - case "hasTasks": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.UpstreamHasSuffix = data + case "upstreamEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTasks = data - case "hasTasksWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + it.UpstreamEqualFold = data + case "upstreamContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTasksWith = data - case "hasShells": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShells")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.UpstreamContainsFold = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCreateBuilderInput(ctx context.Context, obj any) (ent.CreateBuilderInput, error) { + var it ent.CreateBuilderInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"supportedTargets", "upstream"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "supportedTargets": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("supportedTargets")) + data, err := ec.unmarshalNHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx, v) if err != nil { return it, err } - it.HasShells = data - case "hasShellsWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellsWith")) - data, err := ec.unmarshalOShellWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellWhereInputᚄ(ctx, v) + it.SupportedTargets = data + case "upstream": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstream")) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - it.HasShellsWith = data + it.Upstream = data } } @@ -21042,6 +21732,11 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Host(ctx, sel, obj) + case *ent.Builder: + if obj == nil { + return graphql.Null + } + return ec._Builder(ctx, sel, obj) case *ent.Beacon: if obj == nil { return graphql.Null @@ -21391,62 +22086,208 @@ func (ec *executionContext) _Beacon(ctx context.Context, sel ast.SelectionSet, o return res } - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "shells": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Beacon_shells(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var beaconConnectionImplementors = []string{"BeaconConnection"} + +func (ec *executionContext) _BeaconConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, beaconConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BeaconConnection") + case "edges": + out.Values[i] = ec._BeaconConnection_edges(ctx, field, obj) + case "pageInfo": + out.Values[i] = ec._BeaconConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "totalCount": + out.Values[i] = ec._BeaconConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var beaconEdgeImplementors = []string{"BeaconEdge"} + +func (ec *executionContext) _BeaconEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, beaconEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BeaconEdge") + case "node": + out.Values[i] = ec._BeaconEdge_node(ctx, field, obj) + case "cursor": + out.Values[i] = ec._BeaconEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "shells": - field := field + return out +} - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Beacon_shells(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } +var builderImplementors = []string{"Builder", "Node"} - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) +func (ec *executionContext) _Builder(ctx context.Context, sel ast.SelectionSet, obj *ent.Builder) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, builderImplementors) - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Builder") + case "id": + out.Values[i] = ec._Builder_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createdAt": + out.Values[i] = ec._Builder_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "lastModifiedAt": + out.Values[i] = ec._Builder_lastModifiedAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "supportedTargets": + out.Values[i] = ec._Builder_supportedTargets(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "upstream": + out.Values[i] = ec._Builder_upstream(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -21470,26 +22311,26 @@ func (ec *executionContext) _Beacon(ctx context.Context, sel ast.SelectionSet, o return out } -var beaconConnectionImplementors = []string{"BeaconConnection"} +var builderConnectionImplementors = []string{"BuilderConnection"} -func (ec *executionContext) _BeaconConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, beaconConnectionImplementors) +func (ec *executionContext) _BuilderConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.BuilderConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, builderConnectionImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("BeaconConnection") + out.Values[i] = graphql.MarshalString("BuilderConnection") case "edges": - out.Values[i] = ec._BeaconConnection_edges(ctx, field, obj) + out.Values[i] = ec._BuilderConnection_edges(ctx, field, obj) case "pageInfo": - out.Values[i] = ec._BeaconConnection_pageInfo(ctx, field, obj) + out.Values[i] = ec._BuilderConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "totalCount": - out.Values[i] = ec._BeaconConnection_totalCount(ctx, field, obj) + out.Values[i] = ec._BuilderConnection_totalCount(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -21516,21 +22357,21 @@ func (ec *executionContext) _BeaconConnection(ctx context.Context, sel ast.Selec return out } -var beaconEdgeImplementors = []string{"BeaconEdge"} +var builderEdgeImplementors = []string{"BuilderEdge"} -func (ec *executionContext) _BeaconEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, beaconEdgeImplementors) +func (ec *executionContext) _BuilderEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.BuilderEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, builderEdgeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("BeaconEdge") + out.Values[i] = graphql.MarshalString("BuilderEdge") case "node": - out.Values[i] = ec._BeaconEdge_node(ctx, field, obj) + out.Values[i] = ec._BuilderEdge_node(ctx, field, obj) case "cursor": - out.Values[i] = ec._BeaconEdge_cursor(ctx, field, obj) + out.Values[i] = ec._BuilderEdge_cursor(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -25432,6 +26273,42 @@ func (ec *executionContext) unmarshalNBeaconWhereInput2ᚖrealmᚗpubᚋtavern return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder(ctx context.Context, sel ast.SelectionSet, v *ent.Builder) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Builder(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNBuilderOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderOrderField(ctx context.Context, v any) (*ent.BuilderOrderField, error) { + var res = new(ent.BuilderOrderField) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNBuilderOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.BuilderOrderField) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalNBuilderWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInput(ctx context.Context, v any) (*ent.BuilderWhereInput, error) { + res, err := ec.unmarshalInputBuilderWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNCreateBuilderInput2realmᚗpubᚋtavernᚋinternalᚋentᚐCreateBuilderInput(ctx context.Context, v any) (ent.CreateBuilderInput, error) { + res, err := ec.unmarshalInputCreateBuilderInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNCreateHostCredentialInput2realmᚗpubᚋtavernᚋinternalᚋentᚐCreateHostCredentialInput(ctx context.Context, v any) (ent.CreateHostCredentialInput, error) { res, err := ec.unmarshalInputCreateHostCredentialInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -25627,6 +26504,65 @@ func (ec *executionContext) marshalNHostPlatform2realmᚗpubᚋtavernᚋinternal return v } +func (ec *executionContext) unmarshalNHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx context.Context, v any) ([]c2pb.Host_Platform, error) { + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]c2pb.Host_Platform, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx context.Context, sel ast.SelectionSet, v []c2pb.Host_Platform) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + func (ec *executionContext) marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection(ctx context.Context, sel ast.SelectionSet, v *ent.HostProcessConnection) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -26515,6 +27451,87 @@ func (ec *executionContext) unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavern return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder(ctx context.Context, sel ast.SelectionSet, v *ent.Builder) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Builder(ctx, sel, v) +} + +func (ec *executionContext) marshalOBuilderEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.BuilderEdge) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOBuilderEdge2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOBuilderEdge2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderEdge(ctx context.Context, sel ast.SelectionSet, v *ent.BuilderEdge) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._BuilderEdge(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOBuilderWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInputᚄ(ctx context.Context, v any) ([]*ent.BuilderWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]*ent.BuilderWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNBuilderWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOBuilderWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInput(ctx context.Context, v any) (*ent.BuilderWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputBuilderWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, v any) (*entgql.Cursor[int], error) { if v == nil { return nil, nil diff --git a/tavern/internal/graphql/generated/inputs.generated.go b/tavern/internal/graphql/generated/inputs.generated.go index 96524e087..fc4665f32 100644 --- a/tavern/internal/graphql/generated/inputs.generated.go +++ b/tavern/internal/graphql/generated/inputs.generated.go @@ -4,8 +4,13 @@ package generated import ( "context" + "errors" + "fmt" + "strconv" + "sync/atomic" "github.com/99designs/gqlgen/graphql" + "github.com/vektah/gqlparser/v2/ast" "realm.pub/tavern/internal/graphql/models" ) @@ -23,6 +28,105 @@ import ( // region **************************** field.gotpl ***************************** +func (ec *executionContext) _RegisterBuilderOutput_builder(ctx context.Context, field graphql.CollectedField, obj *models.RegisterBuilderOutput) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_RegisterBuilderOutput_builder, + func(ctx context.Context) (any, error) { + return obj.Builder, nil + }, + nil, + ec.marshalNBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_RegisterBuilderOutput_builder(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RegisterBuilderOutput", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Builder_id(ctx, field) + case "createdAt": + return ec.fieldContext_Builder_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Builder_lastModifiedAt(ctx, field) + case "supportedTargets": + return ec.fieldContext_Builder_supportedTargets(ctx, field) + case "upstream": + return ec.fieldContext_Builder_upstream(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Builder", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _RegisterBuilderOutput_mtlsCert(ctx context.Context, field graphql.CollectedField, obj *models.RegisterBuilderOutput) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_RegisterBuilderOutput_mtlsCert, + func(ctx context.Context) (any, error) { + return obj.MtlsCert, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_RegisterBuilderOutput_mtlsCert(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RegisterBuilderOutput", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _RegisterBuilderOutput_config(ctx context.Context, field graphql.CollectedField, obj *models.RegisterBuilderOutput) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_RegisterBuilderOutput_config, + func(ctx context.Context) (any, error) { + return obj.Config, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_RegisterBuilderOutput_config(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RegisterBuilderOutput", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -186,10 +290,73 @@ func (ec *executionContext) unmarshalInputSubmitTaskResultInput(ctx context.Cont // region **************************** object.gotpl **************************** +var registerBuilderOutputImplementors = []string{"RegisterBuilderOutput"} + +func (ec *executionContext) _RegisterBuilderOutput(ctx context.Context, sel ast.SelectionSet, obj *models.RegisterBuilderOutput) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, registerBuilderOutputImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("RegisterBuilderOutput") + case "builder": + out.Values[i] = ec._RegisterBuilderOutput_builder(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mtlsCert": + out.Values[i] = ec._RegisterBuilderOutput_mtlsCert(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "config": + out.Values[i] = ec._RegisterBuilderOutput_config(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** +func (ec *executionContext) marshalNRegisterBuilderOutput2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRegisterBuilderOutput(ctx context.Context, sel ast.SelectionSet, v models.RegisterBuilderOutput) graphql.Marshaler { + return ec._RegisterBuilderOutput(ctx, sel, &v) +} + +func (ec *executionContext) marshalNRegisterBuilderOutput2ᚖrealmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRegisterBuilderOutput(ctx context.Context, sel ast.SelectionSet, v *models.RegisterBuilderOutput) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._RegisterBuilderOutput(ctx, sel, v) +} + func (ec *executionContext) unmarshalOImportRepositoryInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐImportRepositoryInput(ctx context.Context, v any) (*models.ImportRepositoryInput, error) { if v == nil { return nil, nil diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index b22b79b6b..8e01c2aa7 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -34,6 +34,7 @@ type MutationResolver interface { CreateLink(ctx context.Context, input ent.CreateLinkInput) (*ent.Link, error) UpdateLink(ctx context.Context, linkID int, input ent.UpdateLinkInput) (*ent.Link, error) DisableLink(ctx context.Context, linkID int) (*ent.Link, error) + RegisterBuilder(ctx context.Context, input ent.CreateBuilderInput) (*models.RegisterBuilderOutput, error) } // endregion ************************** generated!.gotpl ************************** @@ -149,6 +150,17 @@ func (ec *executionContext) field_Mutation_importRepository_args(ctx context.Con return args, nil } +func (ec *executionContext) field_Mutation_registerBuilder_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNCreateBuilderInput2realmᚗpubᚋtavernᚋinternalᚋentᚐCreateBuilderInput) + if err != nil { + return nil, err + } + args["input"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation_updateBeacon_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -1481,6 +1493,73 @@ func (ec *executionContext) fieldContext_Mutation_disableLink(ctx context.Contex return fc, nil } +func (ec *executionContext) _Mutation_registerBuilder(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Mutation_registerBuilder, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Mutation().RegisterBuilder(ctx, fc.Args["input"].(ent.CreateBuilderInput)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "ADMIN") + if err != nil { + var zeroVal *models.RegisterBuilderOutput + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *models.RegisterBuilderOutput + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNRegisterBuilderOutput2ᚖrealmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRegisterBuilderOutput, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Mutation_registerBuilder(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "builder": + return ec.fieldContext_RegisterBuilderOutput_builder(ctx, field) + case "mtlsCert": + return ec.fieldContext_RegisterBuilderOutput_mtlsCert(ctx, field) + case "config": + return ec.fieldContext_RegisterBuilderOutput_config(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RegisterBuilderOutput", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_registerBuilder_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -1618,6 +1697,13 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "registerBuilder": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_registerBuilder(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 87c914b73..54b2a86d5 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -94,6 +94,25 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + Builder struct { + CreatedAt func(childComplexity int) int + ID func(childComplexity int) int + LastModifiedAt func(childComplexity int) int + SupportedTargets func(childComplexity int) int + Upstream func(childComplexity int) int + } + + BuilderConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + BuilderEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Host struct { Beacons func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BeaconOrder, where *ent.BeaconWhereInput) int CreatedAt func(childComplexity int) int @@ -230,6 +249,7 @@ type ComplexityRoot struct { DisableLink func(childComplexity int, linkID int) int DropAllData func(childComplexity int) int ImportRepository func(childComplexity int, repoID int, input *models.ImportRepositoryInput) int + RegisterBuilder func(childComplexity int, input ent.CreateBuilderInput) int UpdateBeacon func(childComplexity int, beaconID int, input ent.UpdateBeaconInput) int UpdateHost func(childComplexity int, hostID int, input ent.UpdateHostInput) int UpdateLink func(childComplexity int, linkID int, input ent.UpdateLinkInput) int @@ -309,6 +329,12 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + RegisterBuilderOutput struct { + Builder func(childComplexity int) int + Config func(childComplexity int) int + MtlsCert func(childComplexity int) int + } + Repository struct { CreatedAt func(childComplexity int) int ID func(childComplexity int) int @@ -716,6 +742,76 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.BeaconEdge.Node(childComplexity), true + case "Builder.createdAt": + if e.complexity.Builder.CreatedAt == nil { + break + } + + return e.complexity.Builder.CreatedAt(childComplexity), true + + case "Builder.id": + if e.complexity.Builder.ID == nil { + break + } + + return e.complexity.Builder.ID(childComplexity), true + + case "Builder.lastModifiedAt": + if e.complexity.Builder.LastModifiedAt == nil { + break + } + + return e.complexity.Builder.LastModifiedAt(childComplexity), true + + case "Builder.supportedTargets": + if e.complexity.Builder.SupportedTargets == nil { + break + } + + return e.complexity.Builder.SupportedTargets(childComplexity), true + + case "Builder.upstream": + if e.complexity.Builder.Upstream == nil { + break + } + + return e.complexity.Builder.Upstream(childComplexity), true + + case "BuilderConnection.edges": + if e.complexity.BuilderConnection.Edges == nil { + break + } + + return e.complexity.BuilderConnection.Edges(childComplexity), true + + case "BuilderConnection.pageInfo": + if e.complexity.BuilderConnection.PageInfo == nil { + break + } + + return e.complexity.BuilderConnection.PageInfo(childComplexity), true + + case "BuilderConnection.totalCount": + if e.complexity.BuilderConnection.TotalCount == nil { + break + } + + return e.complexity.BuilderConnection.TotalCount(childComplexity), true + + case "BuilderEdge.cursor": + if e.complexity.BuilderEdge.Cursor == nil { + break + } + + return e.complexity.BuilderEdge.Cursor(childComplexity), true + + case "BuilderEdge.node": + if e.complexity.BuilderEdge.Node == nil { + break + } + + return e.complexity.BuilderEdge.Node(childComplexity), true + case "Host.beacons": if e.complexity.Host.Beacons == nil { break @@ -1416,6 +1512,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Mutation.ImportRepository(childComplexity, args["repoID"].(int), args["input"].(*models.ImportRepositoryInput)), true + case "Mutation.registerBuilder": + if e.complexity.Mutation.RegisterBuilder == nil { + break + } + + args, err := ec.field_Mutation_registerBuilder_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.RegisterBuilder(childComplexity, args["input"].(ent.CreateBuilderInput)), true + case "Mutation.updateBeacon": if e.complexity.Mutation.UpdateBeacon == nil { break @@ -1892,6 +2000,27 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.QuestEdge.Node(childComplexity), true + case "RegisterBuilderOutput.builder": + if e.complexity.RegisterBuilderOutput.Builder == nil { + break + } + + return e.complexity.RegisterBuilderOutput.Builder(childComplexity), true + + case "RegisterBuilderOutput.config": + if e.complexity.RegisterBuilderOutput.Config == nil { + break + } + + return e.complexity.RegisterBuilderOutput.Config(childComplexity), true + + case "RegisterBuilderOutput.mtlsCert": + if e.complexity.RegisterBuilderOutput.MtlsCert == nil { + break + } + + return e.complexity.RegisterBuilderOutput.MtlsCert(childComplexity), true + case "Repository.createdAt": if e.complexity.Repository.CreatedAt == nil { break @@ -2582,7 +2711,10 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputAssetWhereInput, ec.unmarshalInputBeaconOrder, ec.unmarshalInputBeaconWhereInput, + ec.unmarshalInputBuilderOrder, + ec.unmarshalInputBuilderWhereInput, ec.unmarshalInputClaimTasksInput, + ec.unmarshalInputCreateBuilderInput, ec.unmarshalInputCreateHostCredentialInput, ec.unmarshalInputCreateLinkInput, ec.unmarshalInputCreateQuestInput, @@ -3302,6 +3434,147 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type Builder implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} +""" +A connection to a list of items. +""" +type BuilderConnection { + """ + A list of edges. + """ + edges: [BuilderEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuilderEdge { + """ + The item at the end of the edge. + """ + node: Builder + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Builder connections +""" +input BuilderOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Builders. + """ + field: BuilderOrderField! +} +""" +Properties by which Builder connections can be ordered. +""" +enum BuilderOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +BuilderWhereInput is used for filtering Builder objects. +Input was generated by ent. +""" +input BuilderWhereInput { + not: BuilderWhereInput + and: [BuilderWhereInput!] + or: [BuilderWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + created_at field predicates + """ + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """ + last_modified_at field predicates + """ + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """ + upstream field predicates + """ + upstream: String + upstreamNEQ: String + upstreamIn: [String!] + upstreamNotIn: [String!] + upstreamGT: String + upstreamGTE: String + upstreamLT: String + upstreamLTE: String + upstreamContains: String + upstreamHasPrefix: String + upstreamHasSuffix: String + upstreamEqualFold: String + upstreamContainsFold: String +} +""" +CreateBuilderInput is used for create Builder object. +Input was generated by ent. +""" +input CreateBuilderInput { + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} """ CreateHostCredentialInput is used for create HostCredential object. Input was generated by ent. @@ -7200,6 +7473,11 @@ scalar Uint64 createLink(input: CreateLinkInput!): Link! @requireRole(role: USER) updateLink(linkID: ID!, input: UpdateLinkInput!): Link! @requireRole(role: USER) disableLink(linkID: ID!): Link! @requireRole(role: USER) + + ### + # Builder + ### + registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) } `, BuiltIn: false}, {Name: "../schema/inputs.graphql", Input: `input ClaimTasksInput { @@ -7251,6 +7529,18 @@ input ImportRepositoryInput { """ includeDirs: [String!] } + +"""Output returned when registering a new builder.""" +type RegisterBuilderOutput { + """The created builder entity.""" + builder: Builder! + + """mTLS certificate in base64 encoding for the builder to authenticate.""" + mtlsCert: String! + + """YAML-formatted configuration for the builder.""" + config: String! +} `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) diff --git a/tavern/internal/graphql/models/gqlgen_models.go b/tavern/internal/graphql/models/gqlgen_models.go index 6ac3402e4..b8bffa6ce 100644 --- a/tavern/internal/graphql/models/gqlgen_models.go +++ b/tavern/internal/graphql/models/gqlgen_models.go @@ -10,6 +10,7 @@ import ( "time" "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent" ) type ClaimTasksInput struct { @@ -35,6 +36,16 @@ type ImportRepositoryInput struct { IncludeDirs []string `json:"includeDirs,omitempty"` } +// Output returned when registering a new builder. +type RegisterBuilderOutput struct { + // The created builder entity. + Builder *ent.Builder `json:"builder"` + // mTLS certificate in base64 encoding for the builder to authenticate. + MtlsCert string `json:"mtlsCert"` + // YAML-formatted configuration for the builder. + Config string `json:"config"` +} + type SubmitTaskResultInput struct { // ID of the task to submit results for. TaskID int `json:"taskID"` diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index 0d3534cf2..b37416a4c 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -7,10 +7,19 @@ package graphql import ( "context" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/x509" + "crypto/x509/pkix" + "encoding/base64" + "encoding/pem" "fmt" + "math/big" "strings" "time" + yaml "gopkg.in/yaml.v3" "realm.pub/tavern/internal/auth" "realm.pub/tavern/internal/ent" "realm.pub/tavern/internal/ent/asset" @@ -56,6 +65,9 @@ func (r *mutationResolver) DropAllData(ctx context.Context) (bool, error) { if _, err := client.Tag.Delete().Exec(ctx); err != nil { return false, rollback(tx, fmt.Errorf("failed to delete tags: %w", err)) } + if _, err := client.Builder.Delete().Exec(ctx); err != nil { + return false, rollback(tx, fmt.Errorf("failed to delete builders: %w", err)) + } // Commit if err := tx.Commit(); err != nil { @@ -276,6 +288,82 @@ func (r *mutationResolver) DisableLink(ctx context.Context, linkID int) (*ent.Li Save(ctx) } +// RegisterBuilder is the resolver for the registerBuilder field. +func (r *mutationResolver) RegisterBuilder(ctx context.Context, input ent.CreateBuilderInput) (*models.RegisterBuilderOutput, error) { + // 1. Create builder ent + builder, err := r.client.Builder.Create().SetInput(input).Save(ctx) + if err != nil { + return nil, fmt.Errorf("failed to create builder: %w", err) + } + + // 2. Generate self-signed X.509 certificate for mTLS + privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + return nil, fmt.Errorf("failed to generate private key: %w", err) + } + + serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) + if err != nil { + return nil, fmt.Errorf("failed to generate serial number: %w", err) + } + + template := x509.Certificate{ + SerialNumber: serialNumber, + Subject: pkix.Name{ + CommonName: fmt.Sprintf("builder-%d", builder.ID), + Organization: []string{"Realm"}, + }, + NotBefore: time.Now(), + NotAfter: time.Now().Add(365 * 24 * time.Hour), + KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, + BasicConstraintsValid: true, + } + + certDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &privKey.PublicKey, privKey) + if err != nil { + return nil, fmt.Errorf("failed to create certificate: %w", err) + } + + certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER}) + keyDER, err := x509.MarshalECPrivateKey(privKey) + if err != nil { + return nil, fmt.Errorf("failed to marshal private key: %w", err) + } + keyPEM := pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER}) + + // Combine cert and key into a single PEM bundle, base64-encode it + combinedPEM := append(certPEM, keyPEM...) + mtlsCert := base64.StdEncoding.EncodeToString(combinedPEM) + + // 3. Build YAML config + targetNames := make([]string, len(builder.SupportedTargets)) + for i, t := range builder.SupportedTargets { + targetNames[i] = strings.ToLower(strings.TrimPrefix(t.String(), "PLATFORM_")) + } + + configData := struct { + SupportedTargets []string `yaml:"supported_targets"` + MTLS string `yaml:"mtls"` + Upstream string `yaml:"upstream"` + }{ + SupportedTargets: targetNames, + MTLS: mtlsCert, + Upstream: builder.Upstream, + } + + configBytes, err := yaml.Marshal(configData) + if err != nil { + return nil, fmt.Errorf("failed to marshal builder config: %w", err) + } + + return &models.RegisterBuilderOutput{ + Builder: builder, + MtlsCert: mtlsCert, + Config: string(configBytes), + }, nil +} + // Mutation returns generated.MutationResolver implementation. func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index b3f9ccea1..4c3dbc9d7 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -579,6 +579,147 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type Builder implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} +""" +A connection to a list of items. +""" +type BuilderConnection { + """ + A list of edges. + """ + edges: [BuilderEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuilderEdge { + """ + The item at the end of the edge. + """ + node: Builder + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Builder connections +""" +input BuilderOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Builders. + """ + field: BuilderOrderField! +} +""" +Properties by which Builder connections can be ordered. +""" +enum BuilderOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +BuilderWhereInput is used for filtering Builder objects. +Input was generated by ent. +""" +input BuilderWhereInput { + not: BuilderWhereInput + and: [BuilderWhereInput!] + or: [BuilderWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + created_at field predicates + """ + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """ + last_modified_at field predicates + """ + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """ + upstream field predicates + """ + upstream: String + upstreamNEQ: String + upstreamIn: [String!] + upstreamNotIn: [String!] + upstreamGT: String + upstreamGTE: String + upstreamLT: String + upstreamLTE: String + upstreamContains: String + upstreamHasPrefix: String + upstreamHasSuffix: String + upstreamEqualFold: String + upstreamContainsFold: String +} +""" +CreateBuilderInput is used for create Builder object. +Input was generated by ent. +""" +input CreateBuilderInput { + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} """ CreateHostCredentialInput is used for create HostCredential object. Input was generated by ent. @@ -4253,6 +4394,18 @@ input ImportRepositoryInput { """ includeDirs: [String!] } + +"""Output returned when registering a new builder.""" +type RegisterBuilderOutput { + """The created builder entity.""" + builder: Builder! + + """mTLS certificate in base64 encoding for the builder to authenticate.""" + mtlsCert: String! + + """YAML-formatted configuration for the builder.""" + config: String! +} type Mutation { #### # Admin @@ -4309,6 +4462,11 @@ type Mutation { createLink(input: CreateLinkInput!): Link! @requireRole(role: USER) updateLink(linkID: ID!, input: UpdateLinkInput!): Link! @requireRole(role: USER) disableLink(linkID: ID!): Link! @requireRole(role: USER) + + ### + # Builder + ### + registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) } extend type Query { assets( diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index 7f2d7f666..635caf269 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -574,6 +574,147 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type Builder implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} +""" +A connection to a list of items. +""" +type BuilderConnection { + """ + A list of edges. + """ + edges: [BuilderEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuilderEdge { + """ + The item at the end of the edge. + """ + node: Builder + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Builder connections +""" +input BuilderOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Builders. + """ + field: BuilderOrderField! +} +""" +Properties by which Builder connections can be ordered. +""" +enum BuilderOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +BuilderWhereInput is used for filtering Builder objects. +Input was generated by ent. +""" +input BuilderWhereInput { + not: BuilderWhereInput + and: [BuilderWhereInput!] + or: [BuilderWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + created_at field predicates + """ + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """ + last_modified_at field predicates + """ + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """ + upstream field predicates + """ + upstream: String + upstreamNEQ: String + upstreamIn: [String!] + upstreamNotIn: [String!] + upstreamGT: String + upstreamGTE: String + upstreamLT: String + upstreamLTE: String + upstreamContains: String + upstreamHasPrefix: String + upstreamHasSuffix: String + upstreamEqualFold: String + upstreamContainsFold: String +} +""" +CreateBuilderInput is used for create Builder object. +Input was generated by ent. +""" +input CreateBuilderInput { + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} """ CreateHostCredentialInput is used for create HostCredential object. Input was generated by ent. diff --git a/tavern/internal/graphql/schema/inputs.graphql b/tavern/internal/graphql/schema/inputs.graphql index 80dac9eb5..460afcc30 100644 --- a/tavern/internal/graphql/schema/inputs.graphql +++ b/tavern/internal/graphql/schema/inputs.graphql @@ -47,3 +47,15 @@ input ImportRepositoryInput { """ includeDirs: [String!] } + +"""Output returned when registering a new builder.""" +type RegisterBuilderOutput { + """The created builder entity.""" + builder: Builder! + + """mTLS certificate in base64 encoding for the builder to authenticate.""" + mtlsCert: String! + + """YAML-formatted configuration for the builder.""" + config: String! +} diff --git a/tavern/internal/graphql/schema/mutation.graphql b/tavern/internal/graphql/schema/mutation.graphql index 743d223d9..e2de39ca3 100644 --- a/tavern/internal/graphql/schema/mutation.graphql +++ b/tavern/internal/graphql/schema/mutation.graphql @@ -54,4 +54,9 @@ type Mutation { createLink(input: CreateLinkInput!): Link! @requireRole(role: USER) updateLink(linkID: ID!, input: UpdateLinkInput!): Link! @requireRole(role: USER) disableLink(linkID: ID!): Link! @requireRole(role: USER) + + ### + # Builder + ### + registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) } diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index b3f9ccea1..4c3dbc9d7 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -579,6 +579,147 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type Builder implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} +""" +A connection to a list of items. +""" +type BuilderConnection { + """ + A list of edges. + """ + edges: [BuilderEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuilderEdge { + """ + The item at the end of the edge. + """ + node: Builder + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Builder connections +""" +input BuilderOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Builders. + """ + field: BuilderOrderField! +} +""" +Properties by which Builder connections can be ordered. +""" +enum BuilderOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +BuilderWhereInput is used for filtering Builder objects. +Input was generated by ent. +""" +input BuilderWhereInput { + not: BuilderWhereInput + and: [BuilderWhereInput!] + or: [BuilderWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + created_at field predicates + """ + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """ + last_modified_at field predicates + """ + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """ + upstream field predicates + """ + upstream: String + upstreamNEQ: String + upstreamIn: [String!] + upstreamNotIn: [String!] + upstreamGT: String + upstreamGTE: String + upstreamLT: String + upstreamLTE: String + upstreamContains: String + upstreamHasPrefix: String + upstreamHasSuffix: String + upstreamEqualFold: String + upstreamContainsFold: String +} +""" +CreateBuilderInput is used for create Builder object. +Input was generated by ent. +""" +input CreateBuilderInput { + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} """ CreateHostCredentialInput is used for create HostCredential object. Input was generated by ent. @@ -4253,6 +4394,18 @@ input ImportRepositoryInput { """ includeDirs: [String!] } + +"""Output returned when registering a new builder.""" +type RegisterBuilderOutput { + """The created builder entity.""" + builder: Builder! + + """mTLS certificate in base64 encoding for the builder to authenticate.""" + mtlsCert: String! + + """YAML-formatted configuration for the builder.""" + config: String! +} type Mutation { #### # Admin @@ -4309,6 +4462,11 @@ type Mutation { createLink(input: CreateLinkInput!): Link! @requireRole(role: USER) updateLink(linkID: ID!, input: UpdateLinkInput!): Link! @requireRole(role: USER) disableLink(linkID: ID!): Link! @requireRole(role: USER) + + ### + # Builder + ### + registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) } extend type Query { assets( From b29e77de3af9581e1f2b2271c921cbe61e09aed6 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Mon, 9 Feb 2026 23:18:09 +0000 Subject: [PATCH 02/19] encrypted ping --- tavern/app.go | 34 ++++- tavern/internal/builder/README.md | 31 +++- tavern/internal/builder/auth.go | 139 +++++++++++++++++ tavern/internal/builder/ca.go | 144 ++++++++++++++++++ tavern/internal/builder/client.go | 93 ++++++++++- tavern/internal/builder/config.go | 4 + tavern/internal/builder/integration_test.go | 84 +++++++--- tavern/internal/ent/builder.go | 13 +- tavern/internal/ent/builder/builder.go | 12 ++ tavern/internal/ent/builder/where.go | 70 +++++++++ tavern/internal/ent/builder_create.go | 36 +++++ tavern/internal/ent/gql_collection.go | 5 + tavern/internal/ent/gql_where_input.go | 54 +++++++ tavern/internal/ent/migrate/schema.go | 1 + tavern/internal/ent/mutation.go | 56 ++++++- tavern/internal/ent/runtime/runtime.go | 6 + tavern/internal/ent/schema/builder.go | 9 ++ tavern/internal/graphql/api_test.go | 2 +- .../graphql/generated/ent.generated.go | 129 +++++++++++++++- .../graphql/generated/inputs.generated.go | 2 + .../graphql/generated/root_.generated.go | 28 ++++ tavern/internal/graphql/mutation.resolvers.go | 58 ++----- tavern/internal/graphql/quest_test.go | 2 +- tavern/internal/graphql/resolver.go | 17 ++- tavern/internal/graphql/schema.graphql | 20 +++ tavern/internal/graphql/schema/ent.graphql | 20 +++ tavern/internal/graphql/tome_test.go | 2 +- tavern/internal/graphql/user_test.go | 2 +- tavern/internal/www/schema.graphql | 20 +++ 29 files changed, 1003 insertions(+), 90 deletions(-) create mode 100644 tavern/internal/builder/auth.go create mode 100644 tavern/internal/builder/ca.go diff --git a/tavern/app.go b/tavern/app.go index 7027ba2df..4a7227598 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -3,6 +3,8 @@ package main import ( "context" "crypto/ecdh" + "crypto/ecdsa" + "crypto/x509" "encoding/base64" "fmt" "log" @@ -240,6 +242,13 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { // Initialize Git Tome Importer git := cfg.NewGitImporter(client) + // Initialize Builder CA + builderCACert, builderCAKey, err := getBuilderCA() + if err != nil { + client.Close() + return nil, fmt.Errorf("failed to initialize builder CA: %w", err) + } + // Initialize Test Data if cfg.IsTestDataEnabled() { createTestData(ctx, client) @@ -299,7 +308,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { AllowUnactivated: true, }, "/graphql": tavernhttp.Endpoint{ - Handler: newGraphQLHandler(client, git), + Handler: newGraphQLHandler(client, git, builderCACert, builderCAKey), AllowUnactivated: true, }, "/c2.C2/": tavernhttp.Endpoint{ @@ -311,7 +320,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { Handler: newPortalGRPCHandler(client, portalMux), }, "/builder.Builder/": tavernhttp.Endpoint{ - Handler: newBuilderGRPCHandler(client), + Handler: newBuilderGRPCHandler(client, builderCACert), AllowUnauthenticated: true, AllowUnactivated: true, }, @@ -395,8 +404,8 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { return tSrv, nil } -func newGraphQLHandler(client *ent.Client, repoImporter graphql.RepoImporter) http.Handler { - srv := handler.NewDefaultServer(graphql.NewSchema(client, repoImporter)) +func newGraphQLHandler(client *ent.Client, repoImporter graphql.RepoImporter, builderCACert *x509.Certificate, builderCAKey *ecdsa.PrivateKey) http.Handler { + srv := handler.NewDefaultServer(graphql.NewSchema(client, repoImporter, builderCACert, builderCAKey)) srv.Use(entgql.Transactioner{TxOpener: client}) // Configure Raw Query Logging @@ -512,6 +521,16 @@ func getKeyPairEd25519() (pubKey []byte, privKey []byte, err error) { return pubKey, privKey, nil } +// getBuilderCA returns the Builder CA certificate and private key for signing builder certificates. +func getBuilderCA() (caCert *x509.Certificate, caKey *ecdsa.PrivateKey, err error) { + secretsManager, err := newSecretsManager() + if err != nil { + return nil, nil, err + } + + return builder.GetOrCreateCA(secretsManager) +} + func newPortalGRPCHandler(graph *ent.Client, portalMux *mux.Mux) http.Handler { portalSrv := portals.New(graph, portalMux) grpcSrv := grpc.NewServer( @@ -534,10 +553,13 @@ func newPortalGRPCHandler(graph *ent.Client, portalMux *mux.Mux) http.Handler { }) } -func newBuilderGRPCHandler(client *ent.Client) http.Handler { +func newBuilderGRPCHandler(client *ent.Client, caCert *x509.Certificate) http.Handler { builderSrv := builder.New(client) grpcSrv := grpc.NewServer( - grpc.UnaryInterceptor(grpcWithUnaryMetrics), + grpc.ChainUnaryInterceptor( + builder.NewAuthInterceptor(caCert, client), + grpcWithUnaryMetrics, + ), grpc.StreamInterceptor(grpcWithStreamMetrics), ) builderpb.RegisterBuilderServer(grpcSrv, builderSrv) diff --git a/tavern/internal/builder/README.md b/tavern/internal/builder/README.md index 50d238fb7..00558fa7b 100644 --- a/tavern/internal/builder/README.md +++ b/tavern/internal/builder/README.md @@ -4,7 +4,8 @@ The builder package orchestrates agent compilation for target platforms. It conn ## Overview -- **Registration**: Builders register with Tavern via the `registerBuilder` GraphQL mutation, which returns an mTLS certificate and a YAML configuration file. +- **Registration**: Builders register with Tavern via the `registerBuilder` GraphQL mutation, which returns an mTLS certificate signed by the Tavern Builder CA and a YAML configuration file. +- **mTLS Authentication**: All gRPC requests are authenticated using application-level mTLS. The builder presents its CA-signed certificate and a signed timestamp in gRPC metadata on each request. The server verifies the certificate chain, proof of private key possession, and looks up the builder by the identifier embedded in the certificate CN. - **gRPC API**: Builders communicate with Tavern over gRPC at the `/builder.Builder/` route. Currently supports a `Ping` health check endpoint. - **CLI**: Run a builder using the `builder` subcommand with a `--config` flag pointing to a YAML configuration file. @@ -13,17 +14,37 @@ The builder package orchestrates agent compilation for target platforms. It conn Builders are configured via a YAML file with the following schema: ```yaml +id: supported_targets: - linux - macos - windows mtls: +upstream: ``` | Field | Description | |-------|-------------| +| `id` | Unique identifier for this builder, assigned during registration. Embedded in the mTLS certificate CN as `builder-{id}`. | | `supported_targets` | List of platforms this builder can compile agents for. Valid values: `linux`, `macos`, `windows`. | -| `mtls` | Base64-encoded PEM bundle containing the mTLS certificate and private key for authenticating with Tavern. | +| `mtls` | Base64-encoded PEM bundle containing the CA-signed mTLS certificate and private key for authenticating with Tavern. | +| `upstream` | The Tavern server address to connect to. | + +## Authentication Flow + +1. An admin registers a builder via the `registerBuilder` GraphQL mutation. +2. Tavern generates a unique identifier and an ECDSA P-256 client certificate signed by the Tavern Builder CA, with CN=`builder-{identifier}`. +3. The builder config YAML is returned containing the certificate, private key, identifier, and upstream address. +4. On each gRPC call, the builder client sends three metadata fields: + - `builder-cert`: Base64-encoded DER certificate + - `builder-signature`: Base64-encoded ECDSA signature over the timestamp + - `builder-timestamp`: RFC3339Nano timestamp +5. The server interceptor verifies: + - Certificate was signed by the Tavern Builder CA + - Signature proves private key possession + - Timestamp is within 5 minutes (replay prevention) + - Certificate has not expired + - Builder identifier from CN exists in the database ## Usage @@ -37,9 +58,11 @@ go run ./tavern builder --config /path/to/builder-config.yaml | File | Purpose | |------|---------| +| `auth.go` | gRPC unary interceptor for mTLS authentication | +| `ca.go` | Builder CA generation, persistence, and certificate signing | +| `client.go` | Builder client with `PerRPCCredentials` for mTLS auth | | `config.go` | YAML configuration parsing and validation | | `server.go` | gRPC server implementation (Ping) | -| `run.go` | Builder run loop (connects to Tavern and awaits work) | | `proto/builder.proto` | Protobuf service definition | | `builderpb/` | Generated protobuf Go code | -| `integration_test.go` | End-to-end test covering registration and gRPC communication | +| `integration_test.go` | End-to-end test covering registration, mTLS auth, and unauthenticated rejection | diff --git a/tavern/internal/builder/auth.go b/tavern/internal/builder/auth.go new file mode 100644 index 000000000..be479da6e --- /dev/null +++ b/tavern/internal/builder/auth.go @@ -0,0 +1,139 @@ +package builder + +import ( + "context" + "crypto/ecdsa" + "crypto/sha256" + "crypto/x509" + "encoding/base64" + "log/slog" + "strings" + "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + + "realm.pub/tavern/internal/ent" + entbuilder "realm.pub/tavern/internal/ent/builder" +) + +const ( + // Metadata keys for mTLS authentication. + mdKeyBuilderCert = "builder-cert" + mdKeyBuilderSignature = "builder-signature" + mdKeyBuilderTimestamp = "builder-timestamp" + + // Maximum age for a timestamp to be considered valid. + maxTimestampAge = 5 * time.Minute + + // CN prefix used in builder certificates. + builderCNPrefix = "builder-" +) + +type builderContextKey struct{} + +// BuilderFromContext extracts the authenticated builder entity from the context. +func BuilderFromContext(ctx context.Context) (*ent.Builder, bool) { + b, ok := ctx.Value(builderContextKey{}).(*ent.Builder) + return b, ok +} + +// NewAuthInterceptor creates a gRPC unary server interceptor that validates +// builder mTLS credentials. It verifies: +// 1. The certificate was signed by the provided CA +// 2. The signature proves possession of the corresponding private key +// 3. The timestamp is recent (prevents replay) +// 4. The builder identifier from the CN exists in the database +func NewAuthInterceptor(caCert *x509.Certificate, graph *ent.Client) grpc.UnaryServerInterceptor { + return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return nil, status.Error(codes.Unauthenticated, "missing metadata") + } + + // Extract metadata values + certB64 := getMetadataValue(md, mdKeyBuilderCert) + sigB64 := getMetadataValue(md, mdKeyBuilderSignature) + timestamp := getMetadataValue(md, mdKeyBuilderTimestamp) + + if certB64 == "" || sigB64 == "" || timestamp == "" { + return nil, status.Error(codes.Unauthenticated, "missing builder credentials") + } + + // Parse the certificate + certDER, err := base64.StdEncoding.DecodeString(certB64) + if err != nil { + return nil, status.Error(codes.Unauthenticated, "invalid certificate encoding") + } + + cert, err := x509.ParseCertificate(certDER) + if err != nil { + return nil, status.Error(codes.Unauthenticated, "invalid certificate") + } + + // Verify certificate was signed by our CA + if err := cert.CheckSignatureFrom(caCert); err != nil { + return nil, status.Error(codes.Unauthenticated, "certificate not signed by trusted CA") + } + + // Verify certificate validity period + now := time.Now() + if now.Before(cert.NotBefore) || now.After(cert.NotAfter) { + return nil, status.Error(codes.Unauthenticated, "certificate expired or not yet valid") + } + + // Verify timestamp freshness + ts, err := time.Parse(time.RFC3339Nano, timestamp) + if err != nil { + return nil, status.Error(codes.Unauthenticated, "invalid timestamp format") + } + if now.Sub(ts).Abs() > maxTimestampAge { + return nil, status.Error(codes.Unauthenticated, "timestamp too old or too far in the future") + } + + // Verify signature (proof of private key possession) + sigBytes, err := base64.StdEncoding.DecodeString(sigB64) + if err != nil { + return nil, status.Error(codes.Unauthenticated, "invalid signature encoding") + } + + hash := sha256.Sum256([]byte(timestamp)) + pubKey, ok := cert.PublicKey.(*ecdsa.PublicKey) + if !ok { + return nil, status.Error(codes.Unauthenticated, "certificate does not contain ECDSA public key") + } + if !ecdsa.VerifyASN1(pubKey, hash[:], sigBytes) { + return nil, status.Error(codes.Unauthenticated, "invalid signature") + } + + // Extract builder identifier from CN + cn := cert.Subject.CommonName + if !strings.HasPrefix(cn, builderCNPrefix) { + return nil, status.Error(codes.Unauthenticated, "invalid certificate CN format") + } + identifier := strings.TrimPrefix(cn, builderCNPrefix) + + // Look up builder in database + b, err := graph.Builder.Query().Where(entbuilder.IdentifierEQ(identifier)).Only(ctx) + if err != nil { + slog.WarnContext(ctx, "builder authentication failed: builder not found", "identifier", identifier, "error", err) + return nil, status.Error(codes.Unauthenticated, "builder not found") + } + + slog.InfoContext(ctx, "builder authenticated", "builder_id", b.ID, "identifier", identifier) + + // Store builder in context for downstream handlers + ctx = context.WithValue(ctx, builderContextKey{}, b) + return handler(ctx, req) + } +} + +func getMetadataValue(md metadata.MD, key string) string { + values := md.Get(key) + if len(values) == 0 { + return "" + } + return values[0] +} diff --git a/tavern/internal/builder/ca.go b/tavern/internal/builder/ca.go new file mode 100644 index 000000000..6764ab6bd --- /dev/null +++ b/tavern/internal/builder/ca.go @@ -0,0 +1,144 @@ +package builder + +import ( + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "fmt" + "math/big" + "time" + + "realm.pub/tavern/internal/secrets" +) + +// GetOrCreateCA retrieves or generates the Builder CA certificate and private key. +// The CA is persisted via the secrets manager so it survives restarts. +// Data is stored as PEM (text-safe) to avoid binary corruption in YAML-based secrets managers. +func GetOrCreateCA(secretsManager secrets.SecretsManager) (*x509.Certificate, *ecdsa.PrivateKey, error) { + if secretsManager == nil { + return nil, nil, fmt.Errorf("secrets manager is nil") + } + + // Try to load existing CA (stored as PEM for text-safety) + certPEMBytes, certErr := secretsManager.GetValue("builder_ca_certificate") + keyPEMBytes, keyErr := secretsManager.GetValue("builder_ca_private_key") + + if certErr == nil && keyErr == nil && len(certPEMBytes) > 0 && len(keyPEMBytes) > 0 { + certBlock, _ := pem.Decode(certPEMBytes) + if certBlock == nil { + return nil, nil, fmt.Errorf("failed to decode stored CA certificate PEM") + } + cert, err := x509.ParseCertificate(certBlock.Bytes) + if err != nil { + return nil, nil, fmt.Errorf("failed to parse stored CA certificate: %w", err) + } + + keyBlock, _ := pem.Decode(keyPEMBytes) + if keyBlock == nil { + return nil, nil, fmt.Errorf("failed to decode stored CA private key PEM") + } + key, err := x509.ParseECPrivateKey(keyBlock.Bytes) + if err != nil { + return nil, nil, fmt.Errorf("failed to parse stored CA private key: %w", err) + } + return cert, key, nil + } + + // Generate new CA + privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + return nil, nil, fmt.Errorf("failed to generate CA private key: %w", err) + } + + serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) + if err != nil { + return nil, nil, fmt.Errorf("failed to generate serial number: %w", err) + } + + template := x509.Certificate{ + SerialNumber: serialNumber, + Subject: pkix.Name{ + CommonName: "Realm Builder CA", + Organization: []string{"Realm"}, + }, + NotBefore: time.Now(), + NotAfter: time.Now().Add(10 * 365 * 24 * time.Hour), + KeyUsage: x509.KeyUsageCertSign | x509.KeyUsageCRLSign, + BasicConstraintsValid: true, + IsCA: true, + MaxPathLen: 0, + } + + caDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &privKey.PublicKey, privKey) + if err != nil { + return nil, nil, fmt.Errorf("failed to create CA certificate: %w", err) + } + + keyDER, err := x509.MarshalECPrivateKey(privKey) + if err != nil { + return nil, nil, fmt.Errorf("failed to marshal CA private key: %w", err) + } + + // Store as PEM to avoid binary corruption in text-based secrets managers + certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: caDER}) + keyPEM := pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER}) + + if _, err := secretsManager.SetValue("builder_ca_certificate", certPEM); err != nil { + return nil, nil, fmt.Errorf("failed to store CA certificate: %w", err) + } + if _, err := secretsManager.SetValue("builder_ca_private_key", keyPEM); err != nil { + return nil, nil, fmt.Errorf("failed to store CA private key: %w", err) + } + + cert, err := x509.ParseCertificate(caDER) + if err != nil { + return nil, nil, fmt.Errorf("failed to parse generated CA certificate: %w", err) + } + + return cert, privKey, nil +} + +// SignBuilderCertificate generates a client certificate for a builder, signed by the CA. +// The certificate CN is set to "builder-{identifier}" for identity attribution. +func SignBuilderCertificate(ca *x509.Certificate, caKey *ecdsa.PrivateKey, builderIdentifier string) (certPEM []byte, keyPEM []byte, err error) { + privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + return nil, nil, fmt.Errorf("failed to generate builder private key: %w", err) + } + + serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) + if err != nil { + return nil, nil, fmt.Errorf("failed to generate serial number: %w", err) + } + + template := x509.Certificate{ + SerialNumber: serialNumber, + Subject: pkix.Name{ + CommonName: fmt.Sprintf("builder-%s", builderIdentifier), + Organization: []string{"Realm"}, + }, + NotBefore: time.Now(), + NotAfter: time.Now().Add(365 * 24 * time.Hour), + KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, + BasicConstraintsValid: true, + } + + certDER, err := x509.CreateCertificate(rand.Reader, &template, ca, &privKey.PublicKey, caKey) + if err != nil { + return nil, nil, fmt.Errorf("failed to create builder certificate: %w", err) + } + + certPEM = pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER}) + + keyDER, err := x509.MarshalECPrivateKey(privKey) + if err != nil { + return nil, nil, fmt.Errorf("failed to marshal builder private key: %w", err) + } + keyPEM = pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER}) + + return certPEM, keyPEM, nil +} diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index 33674348b..aebdcc2b0 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -2,25 +2,116 @@ package builder import ( "context" + "crypto/ecdsa" + "crypto/rand" + "crypto/sha256" + "crypto/x509" + "encoding/base64" + "encoding/pem" "fmt" "log/slog" + "time" "google.golang.org/grpc" + "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" "realm.pub/tavern/internal/builder/builderpb" ) +// builderCredentials implements grpc.PerRPCCredentials for mTLS authentication. +type builderCredentials struct { + certDERBase64 string + privKey *ecdsa.PrivateKey +} + +// GetRequestMetadata generates fresh authentication metadata for each RPC call. +// It signs the current timestamp with the builder's private key to prove possession. +func (c *builderCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { + timestamp := time.Now().UTC().Format(time.RFC3339Nano) + + hash := sha256.Sum256([]byte(timestamp)) + sig, err := ecdsa.SignASN1(rand.Reader, c.privKey, hash[:]) + if err != nil { + return nil, fmt.Errorf("failed to sign timestamp: %w", err) + } + + return map[string]string{ + mdKeyBuilderCert: c.certDERBase64, + mdKeyBuilderSignature: base64.StdEncoding.EncodeToString(sig), + mdKeyBuilderTimestamp: timestamp, + }, nil +} + +// RequireTransportSecurity returns false since Tavern uses h2c (HTTP/2 cleartext) +// with TLS terminated at the reverse proxy level. +func (c *builderCredentials) RequireTransportSecurity() bool { + return false +} + +// NewCredentialsFromConfig creates gRPC per-RPC credentials from a builder config. +func NewCredentialsFromConfig(cfg *Config) (credentials.PerRPCCredentials, error) { + return parseMTLSCredentials(cfg.MTLS) +} + +// parseMTLSCredentials loads the certificate and private key from the config's +// base64-encoded PEM bundle. +func parseMTLSCredentials(mtlsBase64 string) (*builderCredentials, error) { + pemBundle, err := base64.StdEncoding.DecodeString(mtlsBase64) + if err != nil { + return nil, fmt.Errorf("failed to decode mTLS base64: %w", err) + } + + var certDER []byte + var privKey *ecdsa.PrivateKey + + for { + block, rest := pem.Decode(pemBundle) + if block == nil { + break + } + switch block.Type { + case "CERTIFICATE": + certDER = block.Bytes + case "EC PRIVATE KEY": + privKey, err = x509.ParseECPrivateKey(block.Bytes) + if err != nil { + return nil, fmt.Errorf("failed to parse EC private key: %w", err) + } + } + pemBundle = rest + } + + if certDER == nil { + return nil, fmt.Errorf("no certificate found in mTLS bundle") + } + if privKey == nil { + return nil, fmt.Errorf("no private key found in mTLS bundle") + } + + return &builderCredentials{ + certDERBase64: base64.StdEncoding.EncodeToString(certDER), + privKey: privKey, + }, nil +} + // Run starts the builder process using the provided configuration. -// It connects to the configured upstream server and sends a ping request. +// It connects to the configured upstream server with mTLS credentials and sends a ping request. func Run(ctx context.Context, cfg *Config) error { slog.InfoContext(ctx, "builder started", + "id", cfg.ID, "supported_targets", cfg.SupportedTargets, "upstream", cfg.Upstream, ) + creds, err := parseMTLSCredentials(cfg.MTLS) + if err != nil { + return fmt.Errorf("failed to parse mTLS credentials: %w", err) + } + conn, err := grpc.NewClient(cfg.Upstream, grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), ) if err != nil { return fmt.Errorf("failed to connect to upstream %q: %w", cfg.Upstream, err) diff --git a/tavern/internal/builder/config.go b/tavern/internal/builder/config.go index ba618463c..ffbe7776e 100644 --- a/tavern/internal/builder/config.go +++ b/tavern/internal/builder/config.go @@ -9,6 +9,7 @@ import ( // Config represents the YAML configuration for a builder. type Config struct { + ID string `yaml:"id"` SupportedTargets []string `yaml:"supported_targets"` MTLS string `yaml:"mtls"` Upstream string `yaml:"upstream"` @@ -38,6 +39,9 @@ func ParseConfigBytes(data []byte) (*Config, error) { } func (cfg *Config) validate() error { + if cfg.ID == "" { + return fmt.Errorf("config must specify a builder id") + } if len(cfg.SupportedTargets) == 0 { return fmt.Errorf("config must specify at least one supported_target") } diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go index ab3e2f993..673c73721 100644 --- a/tavern/internal/builder/integration_test.go +++ b/tavern/internal/builder/integration_test.go @@ -11,7 +11,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc" + "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/status" "google.golang.org/grpc/test/bufconn" "realm.pub/tavern/internal/builder" @@ -19,6 +21,7 @@ import ( "realm.pub/tavern/internal/ent/enttest" "realm.pub/tavern/internal/graphql" tavernhttp "realm.pub/tavern/internal/http" + "realm.pub/tavern/internal/secrets" "realm.pub/tavern/tomes" ) @@ -29,17 +32,26 @@ func TestBuilderE2E(t *testing.T) { graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") defer graph.Close() - // 2. Setup GraphQL server with authentication bypass + // 2. Initialize Builder CA + secretsDir := t.TempDir() + secretsManager, err := secrets.NewDebugFileSecrets(secretsDir + "/secrets.yaml") + require.NoError(t, err) + caCert, caKey, err := builder.GetOrCreateCA(secretsManager) + require.NoError(t, err) + require.NotNil(t, caCert) + require.NotNil(t, caKey) + + // 3. Setup GraphQL server with authentication bypass and Builder CA git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caKey)), }, tavernhttp.WithAuthenticationBypass(graph), ) gqlClient := client.New(srv, client.Path("/graphql")) - // 3. Register a builder via GraphQL mutation + // 4. Register a builder via GraphQL mutation var registerResp struct { RegisterBuilder struct { Builder struct { @@ -50,7 +62,7 @@ func TestBuilderE2E(t *testing.T) { } } - err := gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { + err = gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { registerBuilder(input: $input) { builder { id } mtlsCert @@ -65,22 +77,28 @@ func TestBuilderE2E(t *testing.T) { require.NotEmpty(t, registerResp.RegisterBuilder.MtlsCert) require.NotEmpty(t, registerResp.RegisterBuilder.Config) - // 4. Parse the returned YAML config + // 5. Parse the returned YAML config cfg, err := builder.ParseConfigBytes([]byte(registerResp.RegisterBuilder.Config)) require.NoError(t, err) assert.Contains(t, cfg.SupportedTargets, "linux") assert.Contains(t, cfg.SupportedTargets, "macos") assert.NotEmpty(t, cfg.MTLS) + assert.NotEmpty(t, cfg.ID) assert.Equal(t, "https://tavern.example.com:443", cfg.Upstream) - // 5. Verify builder exists in DB + // 6. Verify builder exists in DB builders, err := graph.Builder.Query().All(ctx) require.NoError(t, err) require.Len(t, builders, 1) + assert.Equal(t, cfg.ID, builders[0].Identifier) - // 6. Setup builder gRPC server via bufconn + // 7. Setup builder gRPC server via bufconn with mTLS auth interceptor lis := bufconn.Listen(1024 * 1024) - grpcSrv := grpc.NewServer() + grpcSrv := grpc.NewServer( + grpc.ChainUnaryInterceptor( + builder.NewAuthInterceptor(caCert, graph), + ), + ) builderSrv := builder.New(graph) builderpb.RegisterBuilderServer(grpcSrv, builderSrv) @@ -91,19 +109,41 @@ func TestBuilderE2E(t *testing.T) { }() defer grpcSrv.Stop() - // 7. Connect gRPC client via bufconn - conn, err := grpc.DialContext(ctx, "bufnet", - grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { - return lis.Dial() - }), - grpc.WithTransportCredentials(insecure.NewCredentials()), - ) - require.NoError(t, err) - defer conn.Close() + bufDialer := func(context.Context, string) (net.Conn, error) { + return lis.Dial() + } - // 8. Call Ping on the builder gRPC service - builderClient := builderpb.NewBuilderClient(conn) - pingResp, err := builderClient.Ping(ctx, &builderpb.PingRequest{}) - require.NoError(t, err) - require.NotNil(t, pingResp) + // 8. Test: Unauthenticated request should be rejected + t.Run("unauthenticated request rejected", func(t *testing.T) { + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + require.NoError(t, err) + defer conn.Close() + + unauthClient := builderpb.NewBuilderClient(conn) + _, err = unauthClient.Ping(ctx, &builderpb.PingRequest{}) + require.Error(t, err) + assert.Equal(t, codes.Unauthenticated, status.Code(err)) + }) + + // 9. Test: Authenticated request should succeed + t.Run("authenticated request succeeds", func(t *testing.T) { + creds, err := builder.NewCredentialsFromConfig(cfg) + require.NoError(t, err) + + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + require.NoError(t, err) + defer conn.Close() + + authClient := builderpb.NewBuilderClient(conn) + pingResp, err := authClient.Ping(ctx, &builderpb.PingRequest{}) + require.NoError(t, err) + require.NotNil(t, pingResp) + }) } diff --git a/tavern/internal/ent/builder.go b/tavern/internal/ent/builder.go index dd2ea785a..527ec31a2 100644 --- a/tavern/internal/ent/builder.go +++ b/tavern/internal/ent/builder.go @@ -23,6 +23,8 @@ type Builder struct { CreatedAt time.Time `json:"created_at,omitempty"` // Timestamp of when this ent was last updated LastModifiedAt time.Time `json:"last_modified_at,omitempty"` + // Unique identifier for the builder, embedded in its mTLS certificate CN. + Identifier string `json:"identifier,omitempty"` // The platforms this builder can build agents for. SupportedTargets []c2pb.Host_Platform `json:"supported_targets,omitempty"` // The server address that the builder should connect to. @@ -39,7 +41,7 @@ func (*Builder) scanValues(columns []string) ([]any, error) { values[i] = new([]byte) case builder.FieldID: values[i] = new(sql.NullInt64) - case builder.FieldUpstream: + case builder.FieldIdentifier, builder.FieldUpstream: values[i] = new(sql.NullString) case builder.FieldCreatedAt, builder.FieldLastModifiedAt: values[i] = new(sql.NullTime) @@ -76,6 +78,12 @@ func (b *Builder) assignValues(columns []string, values []any) error { } else if value.Valid { b.LastModifiedAt = value.Time } + case builder.FieldIdentifier: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field identifier", values[i]) + } else if value.Valid { + b.Identifier = value.String + } case builder.FieldSupportedTargets: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field supported_targets", values[i]) @@ -132,6 +140,9 @@ func (b *Builder) String() string { builder.WriteString("last_modified_at=") builder.WriteString(b.LastModifiedAt.Format(time.ANSIC)) builder.WriteString(", ") + builder.WriteString("identifier=") + builder.WriteString(b.Identifier) + builder.WriteString(", ") builder.WriteString("supported_targets=") builder.WriteString(fmt.Sprintf("%v", b.SupportedTargets)) builder.WriteString(", ") diff --git a/tavern/internal/ent/builder/builder.go b/tavern/internal/ent/builder/builder.go index 00716d2dd..19caff758 100644 --- a/tavern/internal/ent/builder/builder.go +++ b/tavern/internal/ent/builder/builder.go @@ -17,6 +17,8 @@ const ( FieldCreatedAt = "created_at" // FieldLastModifiedAt holds the string denoting the last_modified_at field in the database. FieldLastModifiedAt = "last_modified_at" + // FieldIdentifier holds the string denoting the identifier field in the database. + FieldIdentifier = "identifier" // FieldSupportedTargets holds the string denoting the supported_targets field in the database. FieldSupportedTargets = "supported_targets" // FieldUpstream holds the string denoting the upstream field in the database. @@ -30,6 +32,7 @@ var Columns = []string{ FieldID, FieldCreatedAt, FieldLastModifiedAt, + FieldIdentifier, FieldSupportedTargets, FieldUpstream, } @@ -51,6 +54,10 @@ var ( DefaultLastModifiedAt func() time.Time // UpdateDefaultLastModifiedAt holds the default value on update for the "last_modified_at" field. UpdateDefaultLastModifiedAt func() time.Time + // DefaultIdentifier holds the default value on creation for the "identifier" field. + DefaultIdentifier func() string + // IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. + IdentifierValidator func(string) error ) // OrderOption defines the ordering options for the Builder queries. @@ -71,6 +78,11 @@ func ByLastModifiedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldLastModifiedAt, opts...).ToFunc() } +// ByIdentifier orders the results by the identifier field. +func ByIdentifier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIdentifier, opts...).ToFunc() +} + // ByUpstream orders the results by the upstream field. func ByUpstream(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUpstream, opts...).ToFunc() diff --git a/tavern/internal/ent/builder/where.go b/tavern/internal/ent/builder/where.go index d23885e58..fcf05be32 100644 --- a/tavern/internal/ent/builder/where.go +++ b/tavern/internal/ent/builder/where.go @@ -64,6 +64,11 @@ func LastModifiedAt(v time.Time) predicate.Builder { return predicate.Builder(sql.FieldEQ(FieldLastModifiedAt, v)) } +// Identifier applies equality check predicate on the "identifier" field. It's identical to IdentifierEQ. +func Identifier(v string) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldIdentifier, v)) +} + // Upstream applies equality check predicate on the "upstream" field. It's identical to UpstreamEQ. func Upstream(v string) predicate.Builder { return predicate.Builder(sql.FieldEQ(FieldUpstream, v)) @@ -149,6 +154,71 @@ func LastModifiedAtLTE(v time.Time) predicate.Builder { return predicate.Builder(sql.FieldLTE(FieldLastModifiedAt, v)) } +// IdentifierEQ applies the EQ predicate on the "identifier" field. +func IdentifierEQ(v string) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldIdentifier, v)) +} + +// IdentifierNEQ applies the NEQ predicate on the "identifier" field. +func IdentifierNEQ(v string) predicate.Builder { + return predicate.Builder(sql.FieldNEQ(FieldIdentifier, v)) +} + +// IdentifierIn applies the In predicate on the "identifier" field. +func IdentifierIn(vs ...string) predicate.Builder { + return predicate.Builder(sql.FieldIn(FieldIdentifier, vs...)) +} + +// IdentifierNotIn applies the NotIn predicate on the "identifier" field. +func IdentifierNotIn(vs ...string) predicate.Builder { + return predicate.Builder(sql.FieldNotIn(FieldIdentifier, vs...)) +} + +// IdentifierGT applies the GT predicate on the "identifier" field. +func IdentifierGT(v string) predicate.Builder { + return predicate.Builder(sql.FieldGT(FieldIdentifier, v)) +} + +// IdentifierGTE applies the GTE predicate on the "identifier" field. +func IdentifierGTE(v string) predicate.Builder { + return predicate.Builder(sql.FieldGTE(FieldIdentifier, v)) +} + +// IdentifierLT applies the LT predicate on the "identifier" field. +func IdentifierLT(v string) predicate.Builder { + return predicate.Builder(sql.FieldLT(FieldIdentifier, v)) +} + +// IdentifierLTE applies the LTE predicate on the "identifier" field. +func IdentifierLTE(v string) predicate.Builder { + return predicate.Builder(sql.FieldLTE(FieldIdentifier, v)) +} + +// IdentifierContains applies the Contains predicate on the "identifier" field. +func IdentifierContains(v string) predicate.Builder { + return predicate.Builder(sql.FieldContains(FieldIdentifier, v)) +} + +// IdentifierHasPrefix applies the HasPrefix predicate on the "identifier" field. +func IdentifierHasPrefix(v string) predicate.Builder { + return predicate.Builder(sql.FieldHasPrefix(FieldIdentifier, v)) +} + +// IdentifierHasSuffix applies the HasSuffix predicate on the "identifier" field. +func IdentifierHasSuffix(v string) predicate.Builder { + return predicate.Builder(sql.FieldHasSuffix(FieldIdentifier, v)) +} + +// IdentifierEqualFold applies the EqualFold predicate on the "identifier" field. +func IdentifierEqualFold(v string) predicate.Builder { + return predicate.Builder(sql.FieldEqualFold(FieldIdentifier, v)) +} + +// IdentifierContainsFold applies the ContainsFold predicate on the "identifier" field. +func IdentifierContainsFold(v string) predicate.Builder { + return predicate.Builder(sql.FieldContainsFold(FieldIdentifier, v)) +} + // UpstreamEQ applies the EQ predicate on the "upstream" field. func UpstreamEQ(v string) predicate.Builder { return predicate.Builder(sql.FieldEQ(FieldUpstream, v)) diff --git a/tavern/internal/ent/builder_create.go b/tavern/internal/ent/builder_create.go index c0fc84575..371beb2c0 100644 --- a/tavern/internal/ent/builder_create.go +++ b/tavern/internal/ent/builder_create.go @@ -51,6 +51,20 @@ func (bc *BuilderCreate) SetNillableLastModifiedAt(t *time.Time) *BuilderCreate return bc } +// SetIdentifier sets the "identifier" field. +func (bc *BuilderCreate) SetIdentifier(s string) *BuilderCreate { + bc.mutation.SetIdentifier(s) + return bc +} + +// SetNillableIdentifier sets the "identifier" field if the given value is not nil. +func (bc *BuilderCreate) SetNillableIdentifier(s *string) *BuilderCreate { + if s != nil { + bc.SetIdentifier(*s) + } + return bc +} + // SetSupportedTargets sets the "supported_targets" field. func (bc *BuilderCreate) SetSupportedTargets(cp []c2pb.Host_Platform) *BuilderCreate { bc.mutation.SetSupportedTargets(cp) @@ -106,6 +120,10 @@ func (bc *BuilderCreate) defaults() { v := builder.DefaultLastModifiedAt() bc.mutation.SetLastModifiedAt(v) } + if _, ok := bc.mutation.Identifier(); !ok { + v := builder.DefaultIdentifier() + bc.mutation.SetIdentifier(v) + } } // check runs all checks and user-defined validators on the builder. @@ -116,6 +134,14 @@ func (bc *BuilderCreate) check() error { if _, ok := bc.mutation.LastModifiedAt(); !ok { return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "Builder.last_modified_at"`)} } + if _, ok := bc.mutation.Identifier(); !ok { + return &ValidationError{Name: "identifier", err: errors.New(`ent: missing required field "Builder.identifier"`)} + } + if v, ok := bc.mutation.Identifier(); ok { + if err := builder.IdentifierValidator(v); err != nil { + return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "Builder.identifier": %w`, err)} + } + } if _, ok := bc.mutation.SupportedTargets(); !ok { return &ValidationError{Name: "supported_targets", err: errors.New(`ent: missing required field "Builder.supported_targets"`)} } @@ -157,6 +183,10 @@ func (bc *BuilderCreate) createSpec() (*Builder, *sqlgraph.CreateSpec) { _spec.SetField(builder.FieldLastModifiedAt, field.TypeTime, value) _node.LastModifiedAt = value } + if value, ok := bc.mutation.Identifier(); ok { + _spec.SetField(builder.FieldIdentifier, field.TypeString, value) + _node.Identifier = value + } if value, ok := bc.mutation.SupportedTargets(); ok { _spec.SetField(builder.FieldSupportedTargets, field.TypeJSON, value) _node.SupportedTargets = value @@ -267,6 +297,9 @@ func (u *BuilderUpsertOne) UpdateNewValues() *BuilderUpsertOne { if _, exists := u.create.mutation.CreatedAt(); exists { s.SetIgnore(builder.FieldCreatedAt) } + if _, exists := u.create.mutation.Identifier(); exists { + s.SetIgnore(builder.FieldIdentifier) + } })) return u } @@ -519,6 +552,9 @@ func (u *BuilderUpsertBulk) UpdateNewValues() *BuilderUpsertBulk { if _, exists := b.mutation.CreatedAt(); exists { s.SetIgnore(builder.FieldCreatedAt) } + if _, exists := b.mutation.Identifier(); exists { + s.SetIgnore(builder.FieldIdentifier) + } } })) return u diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index 2bc7ba9a9..948088580 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -685,6 +685,11 @@ func (b *BuilderQuery) collectField(ctx context.Context, oneNode bool, opCtx *gr selectedFields = append(selectedFields, builder.FieldLastModifiedAt) fieldSeen[builder.FieldLastModifiedAt] = struct{}{} } + case "identifier": + if _, ok := fieldSeen[builder.FieldIdentifier]; !ok { + selectedFields = append(selectedFields, builder.FieldIdentifier) + fieldSeen[builder.FieldIdentifier] = struct{}{} + } case "supportedTargets": if _, ok := fieldSeen[builder.FieldSupportedTargets]; !ok { selectedFields = append(selectedFields, builder.FieldSupportedTargets) diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index 6fa734934..982b0efb0 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -1077,6 +1077,21 @@ type BuilderWhereInput struct { LastModifiedAtLT *time.Time `json:"lastModifiedAtLT,omitempty"` LastModifiedAtLTE *time.Time `json:"lastModifiedAtLTE,omitempty"` + // "identifier" field predicates. + Identifier *string `json:"identifier,omitempty"` + IdentifierNEQ *string `json:"identifierNEQ,omitempty"` + IdentifierIn []string `json:"identifierIn,omitempty"` + IdentifierNotIn []string `json:"identifierNotIn,omitempty"` + IdentifierGT *string `json:"identifierGT,omitempty"` + IdentifierGTE *string `json:"identifierGTE,omitempty"` + IdentifierLT *string `json:"identifierLT,omitempty"` + IdentifierLTE *string `json:"identifierLTE,omitempty"` + IdentifierContains *string `json:"identifierContains,omitempty"` + IdentifierHasPrefix *string `json:"identifierHasPrefix,omitempty"` + IdentifierHasSuffix *string `json:"identifierHasSuffix,omitempty"` + IdentifierEqualFold *string `json:"identifierEqualFold,omitempty"` + IdentifierContainsFold *string `json:"identifierContainsFold,omitempty"` + // "upstream" field predicates. Upstream *string `json:"upstream,omitempty"` UpstreamNEQ *string `json:"upstreamNEQ,omitempty"` @@ -1236,6 +1251,45 @@ func (i *BuilderWhereInput) P() (predicate.Builder, error) { if i.LastModifiedAtLTE != nil { predicates = append(predicates, builder.LastModifiedAtLTE(*i.LastModifiedAtLTE)) } + if i.Identifier != nil { + predicates = append(predicates, builder.IdentifierEQ(*i.Identifier)) + } + if i.IdentifierNEQ != nil { + predicates = append(predicates, builder.IdentifierNEQ(*i.IdentifierNEQ)) + } + if len(i.IdentifierIn) > 0 { + predicates = append(predicates, builder.IdentifierIn(i.IdentifierIn...)) + } + if len(i.IdentifierNotIn) > 0 { + predicates = append(predicates, builder.IdentifierNotIn(i.IdentifierNotIn...)) + } + if i.IdentifierGT != nil { + predicates = append(predicates, builder.IdentifierGT(*i.IdentifierGT)) + } + if i.IdentifierGTE != nil { + predicates = append(predicates, builder.IdentifierGTE(*i.IdentifierGTE)) + } + if i.IdentifierLT != nil { + predicates = append(predicates, builder.IdentifierLT(*i.IdentifierLT)) + } + if i.IdentifierLTE != nil { + predicates = append(predicates, builder.IdentifierLTE(*i.IdentifierLTE)) + } + if i.IdentifierContains != nil { + predicates = append(predicates, builder.IdentifierContains(*i.IdentifierContains)) + } + if i.IdentifierHasPrefix != nil { + predicates = append(predicates, builder.IdentifierHasPrefix(*i.IdentifierHasPrefix)) + } + if i.IdentifierHasSuffix != nil { + predicates = append(predicates, builder.IdentifierHasSuffix(*i.IdentifierHasSuffix)) + } + if i.IdentifierEqualFold != nil { + predicates = append(predicates, builder.IdentifierEqualFold(*i.IdentifierEqualFold)) + } + if i.IdentifierContainsFold != nil { + predicates = append(predicates, builder.IdentifierContainsFold(*i.IdentifierContainsFold)) + } if i.Upstream != nil { predicates = append(predicates, builder.UpstreamEQ(*i.Upstream)) } diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index 0822396a8..ca0e810bc 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -59,6 +59,7 @@ var ( {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "last_modified_at", Type: field.TypeTime}, + {Name: "identifier", Type: field.TypeString, Unique: true}, {Name: "supported_targets", Type: field.TypeJSON}, {Name: "upstream", Type: field.TypeString}, } diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index 08b2e6411..16365537a 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -2057,6 +2057,7 @@ type BuilderMutation struct { id *int created_at *time.Time last_modified_at *time.Time + identifier *string supported_targets *[]c2pb.Host_Platform appendsupported_targets []c2pb.Host_Platform upstream *string @@ -2236,6 +2237,42 @@ func (m *BuilderMutation) ResetLastModifiedAt() { m.last_modified_at = nil } +// SetIdentifier sets the "identifier" field. +func (m *BuilderMutation) SetIdentifier(s string) { + m.identifier = &s +} + +// Identifier returns the value of the "identifier" field in the mutation. +func (m *BuilderMutation) Identifier() (r string, exists bool) { + v := m.identifier + if v == nil { + return + } + return *v, true +} + +// OldIdentifier returns the old "identifier" field's value of the Builder entity. +// If the Builder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuilderMutation) OldIdentifier(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIdentifier is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIdentifier requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIdentifier: %w", err) + } + return oldValue.Identifier, nil +} + +// ResetIdentifier resets all changes to the "identifier" field. +func (m *BuilderMutation) ResetIdentifier() { + m.identifier = nil +} + // SetSupportedTargets sets the "supported_targets" field. func (m *BuilderMutation) SetSupportedTargets(cp []c2pb.Host_Platform) { m.supported_targets = &cp @@ -2357,13 +2394,16 @@ func (m *BuilderMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BuilderMutation) Fields() []string { - fields := make([]string, 0, 4) + fields := make([]string, 0, 5) if m.created_at != nil { fields = append(fields, builder.FieldCreatedAt) } if m.last_modified_at != nil { fields = append(fields, builder.FieldLastModifiedAt) } + if m.identifier != nil { + fields = append(fields, builder.FieldIdentifier) + } if m.supported_targets != nil { fields = append(fields, builder.FieldSupportedTargets) } @@ -2382,6 +2422,8 @@ func (m *BuilderMutation) Field(name string) (ent.Value, bool) { return m.CreatedAt() case builder.FieldLastModifiedAt: return m.LastModifiedAt() + case builder.FieldIdentifier: + return m.Identifier() case builder.FieldSupportedTargets: return m.SupportedTargets() case builder.FieldUpstream: @@ -2399,6 +2441,8 @@ func (m *BuilderMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldCreatedAt(ctx) case builder.FieldLastModifiedAt: return m.OldLastModifiedAt(ctx) + case builder.FieldIdentifier: + return m.OldIdentifier(ctx) case builder.FieldSupportedTargets: return m.OldSupportedTargets(ctx) case builder.FieldUpstream: @@ -2426,6 +2470,13 @@ func (m *BuilderMutation) SetField(name string, value ent.Value) error { } m.SetLastModifiedAt(v) return nil + case builder.FieldIdentifier: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIdentifier(v) + return nil case builder.FieldSupportedTargets: v, ok := value.([]c2pb.Host_Platform) if !ok { @@ -2495,6 +2546,9 @@ func (m *BuilderMutation) ResetField(name string) error { case builder.FieldLastModifiedAt: m.ResetLastModifiedAt() return nil + case builder.FieldIdentifier: + m.ResetIdentifier() + return nil case builder.FieldSupportedTargets: m.ResetSupportedTargets() return nil diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index 6c0d5633d..2f34f548b 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -109,6 +109,12 @@ func init() { builder.DefaultLastModifiedAt = builderDescLastModifiedAt.Default.(func() time.Time) // builder.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. builder.UpdateDefaultLastModifiedAt = builderDescLastModifiedAt.UpdateDefault.(func() time.Time) + // builderDescIdentifier is the schema descriptor for identifier field. + builderDescIdentifier := builderFields[0].Descriptor() + // builder.DefaultIdentifier holds the default value on creation for the identifier field. + builder.DefaultIdentifier = builderDescIdentifier.Default.(func() string) + // builder.IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. + builder.IdentifierValidator = builderDescIdentifier.Validators[0].(func(string) error) hostMixin := schema.Host{}.Mixin() hostMixinFields0 := hostMixin[0].Fields() _ = hostMixinFields0 diff --git a/tavern/internal/ent/schema/builder.go b/tavern/internal/ent/schema/builder.go index 484c5be3d..8613d5f26 100644 --- a/tavern/internal/ent/schema/builder.go +++ b/tavern/internal/ent/schema/builder.go @@ -17,6 +17,15 @@ type Builder struct { // Fields of the Builder. func (Builder) Fields() []ent.Field { return []ent.Field{ + field.String("identifier"). + DefaultFunc(newRandomIdentifier). + NotEmpty(). + Unique(). + Immutable(). + Annotations( + entgql.Skip(entgql.SkipMutationCreateInput), + ). + Comment("Unique identifier for the builder, embedded in its mTLS certificate CN."), field.JSON("supported_targets", []c2pb.Host_Platform{}). Annotations( entgql.Type("[HostPlatform!]"), diff --git a/tavern/internal/graphql/api_test.go b/tavern/internal/graphql/api_test.go index 75046c9e1..b8ad58a76 100644 --- a/tavern/internal/graphql/api_test.go +++ b/tavern/internal/graphql/api_test.go @@ -94,7 +94,7 @@ func runTestCase(t *testing.T, path string) { // Server srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importerFake{graph})), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importerFake{graph}, nil, nil)), }, tavernhttp.WithAuthentication(graph), ) diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index 18ee7e36f..f8c914387 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -2479,6 +2479,35 @@ func (ec *executionContext) fieldContext_Builder_lastModifiedAt(_ context.Contex return fc, nil } +func (ec *executionContext) _Builder_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Builder_identifier, + func(ctx context.Context) (any, error) { + return obj.Identifier, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Builder_identifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Builder", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Builder_supportedTargets(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -2670,6 +2699,8 @@ func (ec *executionContext) fieldContext_BuilderEdge_node(_ context.Context, fie return ec.fieldContext_Builder_createdAt(ctx, field) case "lastModifiedAt": return ec.fieldContext_Builder_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Builder_identifier(ctx, field) case "supportedTargets": return ec.fieldContext_Builder_supportedTargets(ctx, field) case "upstream": @@ -12421,7 +12452,7 @@ func (ec *executionContext) unmarshalInputBuilderWhereInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "upstream", "upstreamNEQ", "upstreamIn", "upstreamNotIn", "upstreamGT", "upstreamGTE", "upstreamLT", "upstreamLTE", "upstreamContains", "upstreamHasPrefix", "upstreamHasSuffix", "upstreamEqualFold", "upstreamContainsFold"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "upstream", "upstreamNEQ", "upstreamIn", "upstreamNotIn", "upstreamGT", "upstreamGTE", "upstreamLT", "upstreamLTE", "upstreamContains", "upstreamHasPrefix", "upstreamHasSuffix", "upstreamEqualFold", "upstreamContainsFold"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -12617,6 +12648,97 @@ func (ec *executionContext) unmarshalInputBuilderWhereInput(ctx context.Context, return it, err } it.LastModifiedAtLTE = data + case "identifier": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Identifier = data + case "identifierNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierNEQ = data + case "identifierIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.IdentifierIn = data + case "identifierNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.IdentifierNotIn = data + case "identifierGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierGT = data + case "identifierGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierGTE = data + case "identifierLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierLT = data + case "identifierLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierLTE = data + case "identifierContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierContains = data + case "identifierHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierHasPrefix = data + case "identifierHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierHasSuffix = data + case "identifierEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierEqualFold = data + case "identifierContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierContainsFold = data case "upstream": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstream")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) @@ -22278,6 +22400,11 @@ func (ec *executionContext) _Builder(ctx context.Context, sel ast.SelectionSet, if out.Values[i] == graphql.Null { out.Invalids++ } + case "identifier": + out.Values[i] = ec._Builder_identifier(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "supportedTargets": out.Values[i] = ec._Builder_supportedTargets(ctx, field, obj) if out.Values[i] == graphql.Null { diff --git a/tavern/internal/graphql/generated/inputs.generated.go b/tavern/internal/graphql/generated/inputs.generated.go index fc4665f32..0fbd94e21 100644 --- a/tavern/internal/graphql/generated/inputs.generated.go +++ b/tavern/internal/graphql/generated/inputs.generated.go @@ -58,6 +58,8 @@ func (ec *executionContext) fieldContext_RegisterBuilderOutput_builder(_ context return ec.fieldContext_Builder_createdAt(ctx, field) case "lastModifiedAt": return ec.fieldContext_Builder_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Builder_identifier(ctx, field) case "supportedTargets": return ec.fieldContext_Builder_supportedTargets(ctx, field) case "upstream": diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 54b2a86d5..8e7bf9ecf 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -97,6 +97,7 @@ type ComplexityRoot struct { Builder struct { CreatedAt func(childComplexity int) int ID func(childComplexity int) int + Identifier func(childComplexity int) int LastModifiedAt func(childComplexity int) int SupportedTargets func(childComplexity int) int Upstream func(childComplexity int) int @@ -756,6 +757,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Builder.ID(childComplexity), true + case "Builder.identifier": + if e.complexity.Builder.Identifier == nil { + break + } + + return e.complexity.Builder.Identifier(childComplexity), true + case "Builder.lastModifiedAt": if e.complexity.Builder.LastModifiedAt == nil { break @@ -3445,6 +3453,10 @@ type Builder implements Node { """ lastModifiedAt: Time! """ + Unique identifier for the builder, embedded in its mTLS certificate CN. + """ + identifier: String! + """ The platforms this builder can build agents for. """ supportedTargets: [HostPlatform!]! @@ -3545,6 +3557,22 @@ input BuilderWhereInput { lastModifiedAtLT: Time lastModifiedAtLTE: Time """ + identifier field predicates + """ + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """ upstream field predicates """ upstream: String diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index b37416a4c..2b397c363 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -7,20 +7,14 @@ package graphql import ( "context" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "crypto/x509" - "crypto/x509/pkix" "encoding/base64" - "encoding/pem" "fmt" - "math/big" "strings" "time" yaml "gopkg.in/yaml.v3" "realm.pub/tavern/internal/auth" + "realm.pub/tavern/internal/builder" "realm.pub/tavern/internal/ent" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/graphql/generated" @@ -290,66 +284,38 @@ func (r *mutationResolver) DisableLink(ctx context.Context, linkID int) (*ent.Li // RegisterBuilder is the resolver for the registerBuilder field. func (r *mutationResolver) RegisterBuilder(ctx context.Context, input ent.CreateBuilderInput) (*models.RegisterBuilderOutput, error) { - // 1. Create builder ent - builder, err := r.client.Builder.Create().SetInput(input).Save(ctx) + // 1. Create builder ent (identifier is auto-generated) + b, err := r.client.Builder.Create().SetInput(input).Save(ctx) if err != nil { return nil, fmt.Errorf("failed to create builder: %w", err) } - // 2. Generate self-signed X.509 certificate for mTLS - privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + // 2. Generate CA-signed X.509 certificate for mTLS + certPEM, keyPEM, err := builder.SignBuilderCertificate(r.builderCA, r.builderCAKey, b.Identifier) if err != nil { - return nil, fmt.Errorf("failed to generate private key: %w", err) + return nil, fmt.Errorf("failed to sign builder certificate: %w", err) } - serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) - if err != nil { - return nil, fmt.Errorf("failed to generate serial number: %w", err) - } - - template := x509.Certificate{ - SerialNumber: serialNumber, - Subject: pkix.Name{ - CommonName: fmt.Sprintf("builder-%d", builder.ID), - Organization: []string{"Realm"}, - }, - NotBefore: time.Now(), - NotAfter: time.Now().Add(365 * 24 * time.Hour), - KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment, - ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, - BasicConstraintsValid: true, - } - - certDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &privKey.PublicKey, privKey) - if err != nil { - return nil, fmt.Errorf("failed to create certificate: %w", err) - } - - certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER}) - keyDER, err := x509.MarshalECPrivateKey(privKey) - if err != nil { - return nil, fmt.Errorf("failed to marshal private key: %w", err) - } - keyPEM := pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER}) - // Combine cert and key into a single PEM bundle, base64-encode it combinedPEM := append(certPEM, keyPEM...) mtlsCert := base64.StdEncoding.EncodeToString(combinedPEM) // 3. Build YAML config - targetNames := make([]string, len(builder.SupportedTargets)) - for i, t := range builder.SupportedTargets { + targetNames := make([]string, len(b.SupportedTargets)) + for i, t := range b.SupportedTargets { targetNames[i] = strings.ToLower(strings.TrimPrefix(t.String(), "PLATFORM_")) } configData := struct { + ID string `yaml:"id"` SupportedTargets []string `yaml:"supported_targets"` MTLS string `yaml:"mtls"` Upstream string `yaml:"upstream"` }{ + ID: b.Identifier, SupportedTargets: targetNames, MTLS: mtlsCert, - Upstream: builder.Upstream, + Upstream: b.Upstream, } configBytes, err := yaml.Marshal(configData) @@ -358,7 +324,7 @@ func (r *mutationResolver) RegisterBuilder(ctx context.Context, input ent.Create } return &models.RegisterBuilderOutput{ - Builder: builder, + Builder: b, MtlsCert: mtlsCert, Config: string(configBytes), }, nil diff --git a/tavern/internal/graphql/quest_test.go b/tavern/internal/graphql/quest_test.go index b02df15b1..0734bae8d 100644 --- a/tavern/internal/graphql/quest_test.go +++ b/tavern/internal/graphql/quest_test.go @@ -33,7 +33,7 @@ func TestCreateQuest(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/resolver.go b/tavern/internal/graphql/resolver.go index b2ae9ae21..c7175c07f 100644 --- a/tavern/internal/graphql/resolver.go +++ b/tavern/internal/graphql/resolver.go @@ -2,6 +2,8 @@ package graphql import ( "context" + "crypto/ecdsa" + "crypto/x509" "fmt" "realm.pub/tavern/internal/auth" @@ -19,14 +21,21 @@ type RepoImporter interface { // Resolver is the resolver root. type Resolver struct { - client *ent.Client - importer RepoImporter + client *ent.Client + importer RepoImporter + builderCA *x509.Certificate + builderCAKey *ecdsa.PrivateKey } // NewSchema creates a graphql executable schema. -func NewSchema(client *ent.Client, importer RepoImporter) graphql.ExecutableSchema { +func NewSchema(client *ent.Client, importer RepoImporter, builderCA *x509.Certificate, builderCAKey *ecdsa.PrivateKey) graphql.ExecutableSchema { cfg := generated.Config{ - Resolvers: &Resolver{client, importer}, + Resolvers: &Resolver{ + client: client, + importer: importer, + builderCA: builderCA, + builderCAKey: builderCAKey, + }, } cfg.Directives.RequireRole = func(ctx context.Context, obj interface{}, next graphql.Resolver, requiredRole models.Role) (interface{}, error) { // Allow unauthenticated contexts to continue for open endpoints diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index 4c3dbc9d7..7748635f4 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -590,6 +590,10 @@ type Builder implements Node { """ lastModifiedAt: Time! """ + Unique identifier for the builder, embedded in its mTLS certificate CN. + """ + identifier: String! + """ The platforms this builder can build agents for. """ supportedTargets: [HostPlatform!]! @@ -690,6 +694,22 @@ input BuilderWhereInput { lastModifiedAtLT: Time lastModifiedAtLTE: Time """ + identifier field predicates + """ + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """ upstream field predicates """ upstream: String diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index 635caf269..6bc1b41c6 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -585,6 +585,10 @@ type Builder implements Node { """ lastModifiedAt: Time! """ + Unique identifier for the builder, embedded in its mTLS certificate CN. + """ + identifier: String! + """ The platforms this builder can build agents for. """ supportedTargets: [HostPlatform!]! @@ -685,6 +689,22 @@ input BuilderWhereInput { lastModifiedAtLT: Time lastModifiedAtLTE: Time """ + identifier field predicates + """ + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """ upstream field predicates """ upstream: String diff --git a/tavern/internal/graphql/tome_test.go b/tavern/internal/graphql/tome_test.go index 2d342b7cf..1278bea24 100644 --- a/tavern/internal/graphql/tome_test.go +++ b/tavern/internal/graphql/tome_test.go @@ -26,7 +26,7 @@ func TestTomeMutations(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/user_test.go b/tavern/internal/graphql/user_test.go index d97f9e71d..e6cedeb54 100644 --- a/tavern/internal/graphql/user_test.go +++ b/tavern/internal/graphql/user_test.go @@ -29,7 +29,7 @@ func TestUserMutations(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index 4c3dbc9d7..7748635f4 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -590,6 +590,10 @@ type Builder implements Node { """ lastModifiedAt: Time! """ + Unique identifier for the builder, embedded in its mTLS certificate CN. + """ + identifier: String! + """ The platforms this builder can build agents for. """ supportedTargets: [HostPlatform!]! @@ -690,6 +694,22 @@ input BuilderWhereInput { lastModifiedAtLT: Time lastModifiedAtLTE: Time """ + identifier field predicates + """ + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """ upstream field predicates """ upstream: String From 19a647a4b9cf57f496ce817acf0e7e1ac3276987 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Mon, 9 Feb 2026 23:43:41 +0000 Subject: [PATCH 03/19] Replace b64 ID with uuid --- tavern/internal/builder/client.go | 10 ++++------ tavern/internal/ent/schema/beacon.go | 12 ++---------- tavern/internal/graphql/mutation.resolvers.go | 5 ++--- tavern/internal/graphql/schema/inputs.graphql | 2 +- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index aebdcc2b0..b5507497d 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -55,12 +55,9 @@ func NewCredentialsFromConfig(cfg *Config) (credentials.PerRPCCredentials, error } // parseMTLSCredentials loads the certificate and private key from the config's -// base64-encoded PEM bundle. -func parseMTLSCredentials(mtlsBase64 string) (*builderCredentials, error) { - pemBundle, err := base64.StdEncoding.DecodeString(mtlsBase64) - if err != nil { - return nil, fmt.Errorf("failed to decode mTLS base64: %w", err) - } +// PEM bundle string. +func parseMTLSCredentials(mtlsPEM string) (*builderCredentials, error) { + pemBundle := []byte(mtlsPEM) var certDER []byte var privKey *ecdsa.PrivateKey @@ -74,6 +71,7 @@ func parseMTLSCredentials(mtlsBase64 string) (*builderCredentials, error) { case "CERTIFICATE": certDER = block.Bytes case "EC PRIVATE KEY": + var err error privKey, err = x509.ParseECPrivateKey(block.Bytes) if err != nil { return nil, fmt.Errorf("failed to parse EC private key: %w", err) diff --git a/tavern/internal/ent/schema/beacon.go b/tavern/internal/ent/schema/beacon.go index 1f36fe8c9..660f4f123 100644 --- a/tavern/internal/ent/schema/beacon.go +++ b/tavern/internal/ent/schema/beacon.go @@ -1,10 +1,7 @@ package schema import ( - "crypto/rand" - "encoding/base64" - "fmt" - "io" + "github.com/google/uuid" "entgo.io/contrib/entgql" "entgo.io/ent" @@ -134,10 +131,5 @@ func (Beacon) Mixin() []ent.Mixin { } func newRandomIdentifier() string { - buf := make([]byte, 64) - _, err := io.ReadFull(rand.Reader, buf) - if err != nil { - panic(fmt.Errorf("failed to generate random identifier: %w", err)) - } - return base64.StdEncoding.EncodeToString(buf) + return uuid.New().String() } diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index 2b397c363..187fe3aa6 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -7,7 +7,6 @@ package graphql import ( "context" - "encoding/base64" "fmt" "strings" "time" @@ -296,9 +295,9 @@ func (r *mutationResolver) RegisterBuilder(ctx context.Context, input ent.Create return nil, fmt.Errorf("failed to sign builder certificate: %w", err) } - // Combine cert and key into a single PEM bundle, base64-encode it + // Combine cert and key into a single PEM bundle combinedPEM := append(certPEM, keyPEM...) - mtlsCert := base64.StdEncoding.EncodeToString(combinedPEM) + mtlsCert := string(combinedPEM) // 3. Build YAML config targetNames := make([]string, len(b.SupportedTargets)) diff --git a/tavern/internal/graphql/schema/inputs.graphql b/tavern/internal/graphql/schema/inputs.graphql index 460afcc30..b8f8234b9 100644 --- a/tavern/internal/graphql/schema/inputs.graphql +++ b/tavern/internal/graphql/schema/inputs.graphql @@ -53,7 +53,7 @@ type RegisterBuilderOutput { """The created builder entity.""" builder: Builder! - """mTLS certificate in base64 encoding for the builder to authenticate.""" + """mTLS certificate PEM bundle for the builder to authenticate.""" mtlsCert: String! """YAML-formatted configuration for the builder.""" From 26ea646257f2a5c475a2d77a082d5be39451827f Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Tue, 10 Feb 2026 00:02:55 +0000 Subject: [PATCH 04/19] Update to use ed25519 key --- tavern/app.go | 19 ++++- tavern/internal/builder/auth.go | 10 +-- tavern/internal/builder/ca.go | 87 ++++----------------- tavern/internal/builder/client.go | 26 +++--- tavern/internal/builder/integration_test.go | 13 ++- tavern/internal/graphql/resolver.go | 18 ++--- 6 files changed, 63 insertions(+), 110 deletions(-) diff --git a/tavern/app.go b/tavern/app.go index 4a7227598..75b00f688 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -3,7 +3,7 @@ package main import ( "context" "crypto/ecdh" - "crypto/ecdsa" + "crypto/ed25519" "crypto/x509" "encoding/base64" "fmt" @@ -404,7 +404,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { return tSrv, nil } -func newGraphQLHandler(client *ent.Client, repoImporter graphql.RepoImporter, builderCACert *x509.Certificate, builderCAKey *ecdsa.PrivateKey) http.Handler { +func newGraphQLHandler(client *ent.Client, repoImporter graphql.RepoImporter, builderCACert *x509.Certificate, builderCAKey ed25519.PrivateKey) http.Handler { srv := handler.NewDefaultServer(graphql.NewSchema(client, repoImporter, builderCACert, builderCAKey)) srv.Use(entgql.Transactioner{TxOpener: client}) @@ -522,13 +522,24 @@ func getKeyPairEd25519() (pubKey []byte, privKey []byte, err error) { } // getBuilderCA returns the Builder CA certificate and private key for signing builder certificates. -func getBuilderCA() (caCert *x509.Certificate, caKey *ecdsa.PrivateKey, err error) { +// It uses the existing ED25519 key from the secrets manager. +func getBuilderCA() (caCert *x509.Certificate, caKey ed25519.PrivateKey, err error) { secretsManager, err := newSecretsManager() if err != nil { return nil, nil, err } - return builder.GetOrCreateCA(secretsManager) + caKey, err = crypto.GetPrivKeyED25519(secretsManager) + if err != nil { + return nil, nil, fmt.Errorf("failed to get ED25519 private key: %w", err) + } + + caCert, err = builder.CreateCA(caKey) + if err != nil { + return nil, nil, fmt.Errorf("failed to create builder CA: %w", err) + } + + return caCert, caKey, nil } func newPortalGRPCHandler(graph *ent.Client, portalMux *mux.Mux) http.Handler { diff --git a/tavern/internal/builder/auth.go b/tavern/internal/builder/auth.go index be479da6e..2d2517cde 100644 --- a/tavern/internal/builder/auth.go +++ b/tavern/internal/builder/auth.go @@ -2,8 +2,7 @@ package builder import ( "context" - "crypto/ecdsa" - "crypto/sha256" + "crypto/ed25519" "crypto/x509" "encoding/base64" "log/slog" @@ -99,12 +98,11 @@ func NewAuthInterceptor(caCert *x509.Certificate, graph *ent.Client) grpc.UnaryS return nil, status.Error(codes.Unauthenticated, "invalid signature encoding") } - hash := sha256.Sum256([]byte(timestamp)) - pubKey, ok := cert.PublicKey.(*ecdsa.PublicKey) + pubKey, ok := cert.PublicKey.(ed25519.PublicKey) if !ok { - return nil, status.Error(codes.Unauthenticated, "certificate does not contain ECDSA public key") + return nil, status.Error(codes.Unauthenticated, "certificate does not contain ED25519 public key") } - if !ecdsa.VerifyASN1(pubKey, hash[:], sigBytes) { + if !ed25519.Verify(pubKey, []byte(timestamp), sigBytes) { return nil, status.Error(codes.Unauthenticated, "invalid signature") } diff --git a/tavern/internal/builder/ca.go b/tavern/internal/builder/ca.go index 6764ab6bd..b482d76bf 100644 --- a/tavern/internal/builder/ca.go +++ b/tavern/internal/builder/ca.go @@ -1,8 +1,7 @@ package builder import ( - "crypto/ecdsa" - "crypto/elliptic" + "crypto/ed25519" "crypto/rand" "crypto/x509" "crypto/x509/pkix" @@ -10,52 +9,16 @@ import ( "fmt" "math/big" "time" - - "realm.pub/tavern/internal/secrets" ) -// GetOrCreateCA retrieves or generates the Builder CA certificate and private key. -// The CA is persisted via the secrets manager so it survives restarts. -// Data is stored as PEM (text-safe) to avoid binary corruption in YAML-based secrets managers. -func GetOrCreateCA(secretsManager secrets.SecretsManager) (*x509.Certificate, *ecdsa.PrivateKey, error) { - if secretsManager == nil { - return nil, nil, fmt.Errorf("secrets manager is nil") - } - - // Try to load existing CA (stored as PEM for text-safety) - certPEMBytes, certErr := secretsManager.GetValue("builder_ca_certificate") - keyPEMBytes, keyErr := secretsManager.GetValue("builder_ca_private_key") - - if certErr == nil && keyErr == nil && len(certPEMBytes) > 0 && len(keyPEMBytes) > 0 { - certBlock, _ := pem.Decode(certPEMBytes) - if certBlock == nil { - return nil, nil, fmt.Errorf("failed to decode stored CA certificate PEM") - } - cert, err := x509.ParseCertificate(certBlock.Bytes) - if err != nil { - return nil, nil, fmt.Errorf("failed to parse stored CA certificate: %w", err) - } - - keyBlock, _ := pem.Decode(keyPEMBytes) - if keyBlock == nil { - return nil, nil, fmt.Errorf("failed to decode stored CA private key PEM") - } - key, err := x509.ParseECPrivateKey(keyBlock.Bytes) - if err != nil { - return nil, nil, fmt.Errorf("failed to parse stored CA private key: %w", err) - } - return cert, key, nil - } - - // Generate new CA - privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) - if err != nil { - return nil, nil, fmt.Errorf("failed to generate CA private key: %w", err) - } +// CreateCA creates a self-signed CA certificate from the provided ED25519 private key. +// The certificate is generated in-memory each time — only the private key needs to be persisted. +func CreateCA(privKey ed25519.PrivateKey) (*x509.Certificate, error) { + pubKey := privKey.Public().(ed25519.PublicKey) serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) if err != nil { - return nil, nil, fmt.Errorf("failed to generate serial number: %w", err) + return nil, fmt.Errorf("failed to generate serial number: %w", err) } template := x509.Certificate{ @@ -72,41 +35,25 @@ func GetOrCreateCA(secretsManager secrets.SecretsManager) (*x509.Certificate, *e MaxPathLen: 0, } - caDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &privKey.PublicKey, privKey) - if err != nil { - return nil, nil, fmt.Errorf("failed to create CA certificate: %w", err) - } - - keyDER, err := x509.MarshalECPrivateKey(privKey) + caDER, err := x509.CreateCertificate(rand.Reader, &template, &template, pubKey, privKey) if err != nil { - return nil, nil, fmt.Errorf("failed to marshal CA private key: %w", err) - } - - // Store as PEM to avoid binary corruption in text-based secrets managers - certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: caDER}) - keyPEM := pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER}) - - if _, err := secretsManager.SetValue("builder_ca_certificate", certPEM); err != nil { - return nil, nil, fmt.Errorf("failed to store CA certificate: %w", err) - } - if _, err := secretsManager.SetValue("builder_ca_private_key", keyPEM); err != nil { - return nil, nil, fmt.Errorf("failed to store CA private key: %w", err) + return nil, fmt.Errorf("failed to create CA certificate: %w", err) } cert, err := x509.ParseCertificate(caDER) if err != nil { - return nil, nil, fmt.Errorf("failed to parse generated CA certificate: %w", err) + return nil, fmt.Errorf("failed to parse generated CA certificate: %w", err) } - return cert, privKey, nil + return cert, nil } // SignBuilderCertificate generates a client certificate for a builder, signed by the CA. // The certificate CN is set to "builder-{identifier}" for identity attribution. -func SignBuilderCertificate(ca *x509.Certificate, caKey *ecdsa.PrivateKey, builderIdentifier string) (certPEM []byte, keyPEM []byte, err error) { - privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) +func SignBuilderCertificate(ca *x509.Certificate, caKey ed25519.PrivateKey, builderIdentifier string) (certPEM []byte, keyPEM []byte, err error) { + builderPub, builderPriv, err := ed25519.GenerateKey(rand.Reader) if err != nil { - return nil, nil, fmt.Errorf("failed to generate builder private key: %w", err) + return nil, nil, fmt.Errorf("failed to generate builder key pair: %w", err) } serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) @@ -122,23 +69,23 @@ func SignBuilderCertificate(ca *x509.Certificate, caKey *ecdsa.PrivateKey, build }, NotBefore: time.Now(), NotAfter: time.Now().Add(365 * 24 * time.Hour), - KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment, + KeyUsage: x509.KeyUsageDigitalSignature, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, BasicConstraintsValid: true, } - certDER, err := x509.CreateCertificate(rand.Reader, &template, ca, &privKey.PublicKey, caKey) + certDER, err := x509.CreateCertificate(rand.Reader, &template, ca, builderPub, caKey) if err != nil { return nil, nil, fmt.Errorf("failed to create builder certificate: %w", err) } certPEM = pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER}) - keyDER, err := x509.MarshalECPrivateKey(privKey) + keyDER, err := x509.MarshalPKCS8PrivateKey(builderPriv) if err != nil { return nil, nil, fmt.Errorf("failed to marshal builder private key: %w", err) } - keyPEM = pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER}) + keyPEM = pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: keyDER}) return certPEM, keyPEM, nil } diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index b5507497d..4596133fb 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -2,9 +2,7 @@ package builder import ( "context" - "crypto/ecdsa" - "crypto/rand" - "crypto/sha256" + "crypto/ed25519" "crypto/x509" "encoding/base64" "encoding/pem" @@ -22,7 +20,7 @@ import ( // builderCredentials implements grpc.PerRPCCredentials for mTLS authentication. type builderCredentials struct { certDERBase64 string - privKey *ecdsa.PrivateKey + privKey ed25519.PrivateKey } // GetRequestMetadata generates fresh authentication metadata for each RPC call. @@ -30,11 +28,7 @@ type builderCredentials struct { func (c *builderCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { timestamp := time.Now().UTC().Format(time.RFC3339Nano) - hash := sha256.Sum256([]byte(timestamp)) - sig, err := ecdsa.SignASN1(rand.Reader, c.privKey, hash[:]) - if err != nil { - return nil, fmt.Errorf("failed to sign timestamp: %w", err) - } + sig := ed25519.Sign(c.privKey, []byte(timestamp)) return map[string]string{ mdKeyBuilderCert: c.certDERBase64, @@ -60,7 +54,7 @@ func parseMTLSCredentials(mtlsPEM string) (*builderCredentials, error) { pemBundle := []byte(mtlsPEM) var certDER []byte - var privKey *ecdsa.PrivateKey + var privKey ed25519.PrivateKey for { block, rest := pem.Decode(pemBundle) @@ -70,12 +64,16 @@ func parseMTLSCredentials(mtlsPEM string) (*builderCredentials, error) { switch block.Type { case "CERTIFICATE": certDER = block.Bytes - case "EC PRIVATE KEY": - var err error - privKey, err = x509.ParseECPrivateKey(block.Bytes) + case "PRIVATE KEY": + key, err := x509.ParsePKCS8PrivateKey(block.Bytes) if err != nil { - return nil, fmt.Errorf("failed to parse EC private key: %w", err) + return nil, fmt.Errorf("failed to parse private key: %w", err) + } + edKey, ok := key.(ed25519.PrivateKey) + if !ok { + return nil, fmt.Errorf("private key is not ED25519") } + privKey = edKey } pemBundle = rest } diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go index 673c73721..072b143a2 100644 --- a/tavern/internal/builder/integration_test.go +++ b/tavern/internal/builder/integration_test.go @@ -2,6 +2,8 @@ package builder_test import ( "context" + "crypto/ed25519" + "crypto/rand" "net" "testing" @@ -21,7 +23,6 @@ import ( "realm.pub/tavern/internal/ent/enttest" "realm.pub/tavern/internal/graphql" tavernhttp "realm.pub/tavern/internal/http" - "realm.pub/tavern/internal/secrets" "realm.pub/tavern/tomes" ) @@ -32,20 +33,18 @@ func TestBuilderE2E(t *testing.T) { graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") defer graph.Close() - // 2. Initialize Builder CA - secretsDir := t.TempDir() - secretsManager, err := secrets.NewDebugFileSecrets(secretsDir + "/secrets.yaml") + // 2. Generate ED25519 key pair and create Builder CA + _, caPrivKey, err := ed25519.GenerateKey(rand.Reader) require.NoError(t, err) - caCert, caKey, err := builder.GetOrCreateCA(secretsManager) + caCert, err := builder.CreateCA(caPrivKey) require.NoError(t, err) require.NotNil(t, caCert) - require.NotNil(t, caKey) // 3. Setup GraphQL server with authentication bypass and Builder CA git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caKey)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/resolver.go b/tavern/internal/graphql/resolver.go index c7175c07f..0d60c3f8e 100644 --- a/tavern/internal/graphql/resolver.go +++ b/tavern/internal/graphql/resolver.go @@ -2,7 +2,7 @@ package graphql import ( "context" - "crypto/ecdsa" + "crypto/ed25519" "crypto/x509" "fmt" @@ -21,19 +21,19 @@ type RepoImporter interface { // Resolver is the resolver root. type Resolver struct { - client *ent.Client - importer RepoImporter - builderCA *x509.Certificate - builderCAKey *ecdsa.PrivateKey + client *ent.Client + importer RepoImporter + builderCA *x509.Certificate + builderCAKey ed25519.PrivateKey } // NewSchema creates a graphql executable schema. -func NewSchema(client *ent.Client, importer RepoImporter, builderCA *x509.Certificate, builderCAKey *ecdsa.PrivateKey) graphql.ExecutableSchema { +func NewSchema(client *ent.Client, importer RepoImporter, builderCA *x509.Certificate, builderCAKey ed25519.PrivateKey) graphql.ExecutableSchema { cfg := generated.Config{ Resolvers: &Resolver{ - client: client, - importer: importer, - builderCA: builderCA, + client: client, + importer: importer, + builderCA: builderCA, builderCAKey: builderCAKey, }, } From e9561bf8e51eb6f8adef5dae3655d2c0faa932cc Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Tue, 10 Feb 2026 01:45:27 +0000 Subject: [PATCH 05/19] Address feedback --- tavern/app.go | 2 +- tavern/internal/builder/README.md | 10 +++---- tavern/internal/builder/auth.go | 33 ++++++++------------- tavern/internal/builder/client.go | 14 ++++----- tavern/internal/builder/integration_test.go | 2 +- tavern/internal/ent/schema/beacon.go | 12 ++++++-- tavern/internal/ent/schema/builder.go | 4 ++- 7 files changed, 39 insertions(+), 38 deletions(-) diff --git a/tavern/app.go b/tavern/app.go index 75b00f688..040d2161e 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -568,7 +568,7 @@ func newBuilderGRPCHandler(client *ent.Client, caCert *x509.Certificate) http.Ha builderSrv := builder.New(client) grpcSrv := grpc.NewServer( grpc.ChainUnaryInterceptor( - builder.NewAuthInterceptor(caCert, client), + builder.NewMTLSAuthInterceptor(caCert, client), grpcWithUnaryMetrics, ), grpc.StreamInterceptor(grpcWithStreamMetrics), diff --git a/tavern/internal/builder/README.md b/tavern/internal/builder/README.md index 00558fa7b..1d914a279 100644 --- a/tavern/internal/builder/README.md +++ b/tavern/internal/builder/README.md @@ -19,7 +19,7 @@ supported_targets: - linux - macos - windows -mtls: +mtls: upstream: ``` @@ -27,17 +27,17 @@ upstream: |-------|-------------| | `id` | Unique identifier for this builder, assigned during registration. Embedded in the mTLS certificate CN as `builder-{id}`. | | `supported_targets` | List of platforms this builder can compile agents for. Valid values: `linux`, `macos`, `windows`. | -| `mtls` | Base64-encoded PEM bundle containing the CA-signed mTLS certificate and private key for authenticating with Tavern. | +| `mtls` | PEM bundle containing the CA-signed mTLS certificate and private key for authenticating with Tavern. | | `upstream` | The Tavern server address to connect to. | ## Authentication Flow 1. An admin registers a builder via the `registerBuilder` GraphQL mutation. -2. Tavern generates a unique identifier and an ECDSA P-256 client certificate signed by the Tavern Builder CA, with CN=`builder-{identifier}`. +2. Tavern generates a unique identifier and an Ed25519 client certificate signed by the Tavern Builder CA, with CN=`builder-{identifier}`. 3. The builder config YAML is returned containing the certificate, private key, identifier, and upstream address. 4. On each gRPC call, the builder client sends three metadata fields: - - `builder-cert`: Base64-encoded DER certificate - - `builder-signature`: Base64-encoded ECDSA signature over the timestamp + - `builder-cert-bin`: DER-encoded certificate (binary metadata) + - `builder-signature-bin`: Ed25519 signature over the timestamp (binary metadata) - `builder-timestamp`: RFC3339Nano timestamp 5. The server interceptor verifies: - Certificate was signed by the Tavern Builder CA diff --git a/tavern/internal/builder/auth.go b/tavern/internal/builder/auth.go index 2d2517cde..eb85a6a6a 100644 --- a/tavern/internal/builder/auth.go +++ b/tavern/internal/builder/auth.go @@ -4,7 +4,6 @@ import ( "context" "crypto/ed25519" "crypto/x509" - "encoding/base64" "log/slog" "strings" "time" @@ -20,8 +19,9 @@ import ( const ( // Metadata keys for mTLS authentication. - mdKeyBuilderCert = "builder-cert" - mdKeyBuilderSignature = "builder-signature" + // Keys ending in "-bin" use gRPC binary metadata encoding. + mdKeyBuilderCert = "builder-cert-bin" + mdKeyBuilderSignature = "builder-signature-bin" mdKeyBuilderTimestamp = "builder-timestamp" // Maximum age for a timestamp to be considered valid. @@ -39,35 +39,31 @@ func BuilderFromContext(ctx context.Context) (*ent.Builder, bool) { return b, ok } -// NewAuthInterceptor creates a gRPC unary server interceptor that validates +// NewMTLSAuthInterceptor creates a gRPC unary server interceptor that validates // builder mTLS credentials. It verifies: // 1. The certificate was signed by the provided CA // 2. The signature proves possession of the corresponding private key // 3. The timestamp is recent (prevents replay) // 4. The builder identifier from the CN exists in the database -func NewAuthInterceptor(caCert *x509.Certificate, graph *ent.Client) grpc.UnaryServerInterceptor { +func NewMTLSAuthInterceptor(caCert *x509.Certificate, graph *ent.Client) grpc.UnaryServerInterceptor { return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { md, ok := metadata.FromIncomingContext(ctx) if !ok { return nil, status.Error(codes.Unauthenticated, "missing metadata") } - // Extract metadata values - certB64 := getMetadataValue(md, mdKeyBuilderCert) - sigB64 := getMetadataValue(md, mdKeyBuilderSignature) + // Extract metadata values. + // Binary metadata (keys ending in "-bin") is automatically base64 decoded by gRPC. + certDER := getMetadataValue(md, mdKeyBuilderCert) + signature := getMetadataValue(md, mdKeyBuilderSignature) timestamp := getMetadataValue(md, mdKeyBuilderTimestamp) - if certB64 == "" || sigB64 == "" || timestamp == "" { + if certDER == "" || signature == "" || timestamp == "" { return nil, status.Error(codes.Unauthenticated, "missing builder credentials") } // Parse the certificate - certDER, err := base64.StdEncoding.DecodeString(certB64) - if err != nil { - return nil, status.Error(codes.Unauthenticated, "invalid certificate encoding") - } - - cert, err := x509.ParseCertificate(certDER) + cert, err := x509.ParseCertificate([]byte(certDER)) if err != nil { return nil, status.Error(codes.Unauthenticated, "invalid certificate") } @@ -93,16 +89,11 @@ func NewAuthInterceptor(caCert *x509.Certificate, graph *ent.Client) grpc.UnaryS } // Verify signature (proof of private key possession) - sigBytes, err := base64.StdEncoding.DecodeString(sigB64) - if err != nil { - return nil, status.Error(codes.Unauthenticated, "invalid signature encoding") - } - pubKey, ok := cert.PublicKey.(ed25519.PublicKey) if !ok { return nil, status.Error(codes.Unauthenticated, "certificate does not contain ED25519 public key") } - if !ed25519.Verify(pubKey, []byte(timestamp), sigBytes) { + if !ed25519.Verify(pubKey, []byte(timestamp), []byte(signature)) { return nil, status.Error(codes.Unauthenticated, "invalid signature") } diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index 4596133fb..3d310d63d 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -4,7 +4,6 @@ import ( "context" "crypto/ed25519" "crypto/x509" - "encoding/base64" "encoding/pem" "fmt" "log/slog" @@ -19,20 +18,21 @@ import ( // builderCredentials implements grpc.PerRPCCredentials for mTLS authentication. type builderCredentials struct { - certDERBase64 string - privKey ed25519.PrivateKey + certDER []byte + privKey ed25519.PrivateKey } // GetRequestMetadata generates fresh authentication metadata for each RPC call. // It signs the current timestamp with the builder's private key to prove possession. +// Binary metadata (keys ending in "-bin") is automatically base64 encoded by gRPC. func (c *builderCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { timestamp := time.Now().UTC().Format(time.RFC3339Nano) sig := ed25519.Sign(c.privKey, []byte(timestamp)) return map[string]string{ - mdKeyBuilderCert: c.certDERBase64, - mdKeyBuilderSignature: base64.StdEncoding.EncodeToString(sig), + mdKeyBuilderCert: string(c.certDER), + mdKeyBuilderSignature: string(sig), mdKeyBuilderTimestamp: timestamp, }, nil } @@ -86,8 +86,8 @@ func parseMTLSCredentials(mtlsPEM string) (*builderCredentials, error) { } return &builderCredentials{ - certDERBase64: base64.StdEncoding.EncodeToString(certDER), - privKey: privKey, + certDER: certDER, + privKey: privKey, }, nil } diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go index 072b143a2..4e0cbc7af 100644 --- a/tavern/internal/builder/integration_test.go +++ b/tavern/internal/builder/integration_test.go @@ -95,7 +95,7 @@ func TestBuilderE2E(t *testing.T) { lis := bufconn.Listen(1024 * 1024) grpcSrv := grpc.NewServer( grpc.ChainUnaryInterceptor( - builder.NewAuthInterceptor(caCert, graph), + builder.NewMTLSAuthInterceptor(caCert, graph), ), ) builderSrv := builder.New(graph) diff --git a/tavern/internal/ent/schema/beacon.go b/tavern/internal/ent/schema/beacon.go index 660f4f123..1f36fe8c9 100644 --- a/tavern/internal/ent/schema/beacon.go +++ b/tavern/internal/ent/schema/beacon.go @@ -1,7 +1,10 @@ package schema import ( - "github.com/google/uuid" + "crypto/rand" + "encoding/base64" + "fmt" + "io" "entgo.io/contrib/entgql" "entgo.io/ent" @@ -131,5 +134,10 @@ func (Beacon) Mixin() []ent.Mixin { } func newRandomIdentifier() string { - return uuid.New().String() + buf := make([]byte, 64) + _, err := io.ReadFull(rand.Reader, buf) + if err != nil { + panic(fmt.Errorf("failed to generate random identifier: %w", err)) + } + return base64.StdEncoding.EncodeToString(buf) } diff --git a/tavern/internal/ent/schema/builder.go b/tavern/internal/ent/schema/builder.go index 8613d5f26..d29e5269d 100644 --- a/tavern/internal/ent/schema/builder.go +++ b/tavern/internal/ent/schema/builder.go @@ -1,6 +1,8 @@ package schema import ( + "github.com/google/uuid" + "entgo.io/contrib/entgql" "entgo.io/ent" "entgo.io/ent/dialect/entsql" @@ -18,7 +20,7 @@ type Builder struct { func (Builder) Fields() []ent.Field { return []ent.Field{ field.String("identifier"). - DefaultFunc(newRandomIdentifier). + DefaultFunc(func() string { return uuid.New().String() }). NotEmpty(). Unique(). Immutable(). From 50c5355a103261cccaca1bbda38d94aafd1276e0 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Tue, 10 Feb 2026 01:55:51 +0000 Subject: [PATCH 06/19] fix --- tavern/app.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tavern/app.go b/tavern/app.go index 3fd555144..658c347a4 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -4,6 +4,7 @@ import ( "context" "crypto/ecdh" "crypto/ed25519" + "crypto/tls" "crypto/x509" "encoding/base64" "fmt" From b85c95de0eda476cca1f2ba8677c642b3f9d86e0 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Tue, 10 Feb 2026 04:24:34 +0000 Subject: [PATCH 07/19] Callback and claim tasks. TODO: fix tasking dead clients. --- .../internal/builder/builderpb/builder.pb.go | 328 +- .../builder/builderpb/builder_grpc.pb.go | 78 +- tavern/internal/builder/client.go | 58 +- tavern/internal/builder/generate.go | 3 + tavern/internal/builder/integration_test.go | 194 + tavern/internal/builder/proto/builder.proto | 23 + tavern/internal/builder/server.go | 133 + tavern/internal/ent/builder.go | 56 +- tavern/internal/ent/builder/builder.go | 31 + tavern/internal/ent/builder/where.go | 24 + tavern/internal/ent/builder_create.go | 32 + tavern/internal/ent/builder_query.go | 128 +- tavern/internal/ent/builder_update.go | 163 + tavern/internal/ent/buildtask.go | 249 + tavern/internal/ent/buildtask/buildtask.go | 189 + tavern/internal/ent/buildtask/where.go | 670 + tavern/internal/ent/buildtask_create.go | 1107 ++ tavern/internal/ent/buildtask_delete.go | 88 + tavern/internal/ent/buildtask_query.go | 627 + tavern/internal/ent/buildtask_update.go | 720 ++ tavern/internal/ent/client.go | 185 +- tavern/internal/ent/ent.go | 2 + tavern/internal/ent/gql_collection.go | 241 + tavern/internal/ent/gql_edge.go | 29 + tavern/internal/ent/gql_mutation_input.go | 4 + tavern/internal/ent/gql_node.go | 31 + tavern/internal/ent/gql_pagination.go | 423 + tavern/internal/ent/gql_where_input.go | 613 + tavern/internal/ent/hook/hook.go | 12 + tavern/internal/ent/migrate/schema.go | 34 + tavern/internal/ent/mutation.go | 1078 +- tavern/internal/ent/predicate/predicate.go | 3 + tavern/internal/ent/privacy/privacy.go | 24 + tavern/internal/ent/runtime/runtime.go | 24 + tavern/internal/ent/schema/build_task.go | 100 + tavern/internal/ent/schema/builder.go | 11 +- tavern/internal/ent/tx.go | 3 + tavern/internal/graphql/build_task_test.go | 161 + .../graphql/generated/ent.generated.go | 10329 ++++++++++------ .../graphql/generated/inputs.generated.go | 48 + .../graphql/generated/mutation.generated.go | 104 + .../graphql/generated/root_.generated.go | 526 +- .../internal/graphql/models/gqlgen_models.go | 12 +- tavern/internal/graphql/mutation.resolvers.go | 44 + tavern/internal/graphql/query.resolvers.go | 16 + tavern/internal/graphql/schema.graphql | 339 +- tavern/internal/graphql/schema/ent.graphql | 301 +- tavern/internal/graphql/schema/inputs.graphql | 12 + .../internal/graphql/schema/mutation.graphql | 5 + tavern/internal/graphql/schema/query.graphql | 19 + tavern/internal/www/schema.graphql | 339 +- 51 files changed, 15786 insertions(+), 4187 deletions(-) create mode 100644 tavern/internal/builder/generate.go create mode 100644 tavern/internal/ent/buildtask.go create mode 100644 tavern/internal/ent/buildtask/buildtask.go create mode 100644 tavern/internal/ent/buildtask/where.go create mode 100644 tavern/internal/ent/buildtask_create.go create mode 100644 tavern/internal/ent/buildtask_delete.go create mode 100644 tavern/internal/ent/buildtask_query.go create mode 100644 tavern/internal/ent/buildtask_update.go create mode 100644 tavern/internal/ent/schema/build_task.go create mode 100644 tavern/internal/graphql/build_task_test.go diff --git a/tavern/internal/builder/builderpb/builder.pb.go b/tavern/internal/builder/builderpb/builder.pb.go index 40d023ccc..25b650204 100644 --- a/tavern/internal/builder/builderpb/builder.pb.go +++ b/tavern/internal/builder/builderpb/builder.pb.go @@ -93,20 +93,300 @@ func (*PingResponse) Descriptor() ([]byte, []int) { return file_builder_proto_rawDescGZIP(), []int{1} } +type ClaimBuildTasksRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ClaimBuildTasksRequest) Reset() { + *x = ClaimBuildTasksRequest{} + mi := &file_builder_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ClaimBuildTasksRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClaimBuildTasksRequest) ProtoMessage() {} + +func (x *ClaimBuildTasksRequest) ProtoReflect() protoreflect.Message { + mi := &file_builder_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClaimBuildTasksRequest.ProtoReflect.Descriptor instead. +func (*ClaimBuildTasksRequest) Descriptor() ([]byte, []int) { + return file_builder_proto_rawDescGZIP(), []int{2} +} + +type BuildTaskSpec struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + TargetOs string `protobuf:"bytes,2,opt,name=target_os,json=targetOs,proto3" json:"target_os,omitempty"` + BuildImage string `protobuf:"bytes,3,opt,name=build_image,json=buildImage,proto3" json:"build_image,omitempty"` + BuildScript string `protobuf:"bytes,4,opt,name=build_script,json=buildScript,proto3" json:"build_script,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BuildTaskSpec) Reset() { + *x = BuildTaskSpec{} + mi := &file_builder_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BuildTaskSpec) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BuildTaskSpec) ProtoMessage() {} + +func (x *BuildTaskSpec) ProtoReflect() protoreflect.Message { + mi := &file_builder_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BuildTaskSpec.ProtoReflect.Descriptor instead. +func (*BuildTaskSpec) Descriptor() ([]byte, []int) { + return file_builder_proto_rawDescGZIP(), []int{3} +} + +func (x *BuildTaskSpec) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *BuildTaskSpec) GetTargetOs() string { + if x != nil { + return x.TargetOs + } + return "" +} + +func (x *BuildTaskSpec) GetBuildImage() string { + if x != nil { + return x.BuildImage + } + return "" +} + +func (x *BuildTaskSpec) GetBuildScript() string { + if x != nil { + return x.BuildScript + } + return "" +} + +type ClaimBuildTasksResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Tasks []*BuildTaskSpec `protobuf:"bytes,1,rep,name=tasks,proto3" json:"tasks,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ClaimBuildTasksResponse) Reset() { + *x = ClaimBuildTasksResponse{} + mi := &file_builder_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ClaimBuildTasksResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClaimBuildTasksResponse) ProtoMessage() {} + +func (x *ClaimBuildTasksResponse) ProtoReflect() protoreflect.Message { + mi := &file_builder_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClaimBuildTasksResponse.ProtoReflect.Descriptor instead. +func (*ClaimBuildTasksResponse) Descriptor() ([]byte, []int) { + return file_builder_proto_rawDescGZIP(), []int{4} +} + +func (x *ClaimBuildTasksResponse) GetTasks() []*BuildTaskSpec { + if x != nil { + return x.Tasks + } + return nil +} + +type SubmitBuildTaskOutputRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` + Output string `protobuf:"bytes,2,opt,name=output,proto3" json:"output,omitempty"` + Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SubmitBuildTaskOutputRequest) Reset() { + *x = SubmitBuildTaskOutputRequest{} + mi := &file_builder_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SubmitBuildTaskOutputRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubmitBuildTaskOutputRequest) ProtoMessage() {} + +func (x *SubmitBuildTaskOutputRequest) ProtoReflect() protoreflect.Message { + mi := &file_builder_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubmitBuildTaskOutputRequest.ProtoReflect.Descriptor instead. +func (*SubmitBuildTaskOutputRequest) Descriptor() ([]byte, []int) { + return file_builder_proto_rawDescGZIP(), []int{5} +} + +func (x *SubmitBuildTaskOutputRequest) GetTaskId() int64 { + if x != nil { + return x.TaskId + } + return 0 +} + +func (x *SubmitBuildTaskOutputRequest) GetOutput() string { + if x != nil { + return x.Output + } + return "" +} + +func (x *SubmitBuildTaskOutputRequest) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +type SubmitBuildTaskOutputResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SubmitBuildTaskOutputResponse) Reset() { + *x = SubmitBuildTaskOutputResponse{} + mi := &file_builder_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SubmitBuildTaskOutputResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubmitBuildTaskOutputResponse) ProtoMessage() {} + +func (x *SubmitBuildTaskOutputResponse) ProtoReflect() protoreflect.Message { + mi := &file_builder_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubmitBuildTaskOutputResponse.ProtoReflect.Descriptor instead. +func (*SubmitBuildTaskOutputResponse) Descriptor() ([]byte, []int) { + return file_builder_proto_rawDescGZIP(), []int{6} +} + var File_builder_proto protoreflect.FileDescriptor var file_builder_proto_rawDesc = string([]byte{ 0x0a, 0x0d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x22, 0x0d, 0x0a, 0x0b, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x69, 0x6e, 0x67, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x40, 0x0a, 0x07, 0x42, 0x75, 0x69, 0x6c, 0x64, - 0x65, 0x72, 0x12, 0x35, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x2e, 0x62, 0x75, 0x69, - 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x15, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2d, 0x5a, 0x2b, 0x72, 0x65, 0x61, - 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, 0x6e, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2f, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x0a, 0x16, 0x43, 0x6c, 0x61, 0x69, 0x6d, + 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x22, 0x80, 0x01, 0x0a, 0x0d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x53, + 0x70, 0x65, 0x63, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x6f, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4f, 0x73, + 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6d, 0x61, 0x67, + 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x53, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x22, 0x47, 0x0a, 0x17, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, + 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x2c, 0x0a, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, + 0x73, 0x6b, 0x53, 0x70, 0x65, 0x63, 0x52, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x22, 0x65, 0x0a, + 0x1c, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, + 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, + 0x07, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, + 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x14, + 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x22, 0x1f, 0x0a, 0x1d, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x42, 0x75, + 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x82, 0x02, 0x0a, 0x07, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65, + 0x72, 0x12, 0x35, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x2e, 0x62, 0x75, 0x69, 0x6c, + 0x64, 0x65, 0x72, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x15, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x56, 0x0a, 0x0f, 0x43, 0x6c, 0x61, 0x69, + 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x1f, 0x2e, 0x62, 0x75, + 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x62, + 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, + 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x68, 0x0a, 0x15, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, + 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x25, 0x2e, 0x62, 0x75, 0x69, 0x6c, + 0x64, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, + 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x26, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, + 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2d, 0x5a, 0x2b, 0x72, 0x65, + 0x61, 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, 0x6e, 0x2f, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2f, + 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, }) var ( @@ -121,19 +401,29 @@ func file_builder_proto_rawDescGZIP() []byte { return file_builder_proto_rawDescData } -var file_builder_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_builder_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_builder_proto_goTypes = []any{ - (*PingRequest)(nil), // 0: builder.PingRequest - (*PingResponse)(nil), // 1: builder.PingResponse + (*PingRequest)(nil), // 0: builder.PingRequest + (*PingResponse)(nil), // 1: builder.PingResponse + (*ClaimBuildTasksRequest)(nil), // 2: builder.ClaimBuildTasksRequest + (*BuildTaskSpec)(nil), // 3: builder.BuildTaskSpec + (*ClaimBuildTasksResponse)(nil), // 4: builder.ClaimBuildTasksResponse + (*SubmitBuildTaskOutputRequest)(nil), // 5: builder.SubmitBuildTaskOutputRequest + (*SubmitBuildTaskOutputResponse)(nil), // 6: builder.SubmitBuildTaskOutputResponse } var file_builder_proto_depIdxs = []int32{ - 0, // 0: builder.Builder.Ping:input_type -> builder.PingRequest - 1, // 1: builder.Builder.Ping:output_type -> builder.PingResponse - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 3, // 0: builder.ClaimBuildTasksResponse.tasks:type_name -> builder.BuildTaskSpec + 0, // 1: builder.Builder.Ping:input_type -> builder.PingRequest + 2, // 2: builder.Builder.ClaimBuildTasks:input_type -> builder.ClaimBuildTasksRequest + 5, // 3: builder.Builder.SubmitBuildTaskOutput:input_type -> builder.SubmitBuildTaskOutputRequest + 1, // 4: builder.Builder.Ping:output_type -> builder.PingResponse + 4, // 5: builder.Builder.ClaimBuildTasks:output_type -> builder.ClaimBuildTasksResponse + 6, // 6: builder.Builder.SubmitBuildTaskOutput:output_type -> builder.SubmitBuildTaskOutputResponse + 4, // [4:7] is the sub-list for method output_type + 1, // [1:4] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_builder_proto_init() } @@ -147,7 +437,7 @@ func file_builder_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_builder_proto_rawDesc), len(file_builder_proto_rawDesc)), NumEnums: 0, - NumMessages: 2, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/tavern/internal/builder/builderpb/builder_grpc.pb.go b/tavern/internal/builder/builderpb/builder_grpc.pb.go index febce446b..242846d9e 100644 --- a/tavern/internal/builder/builderpb/builder_grpc.pb.go +++ b/tavern/internal/builder/builderpb/builder_grpc.pb.go @@ -19,7 +19,9 @@ import ( const _ = grpc.SupportPackageIsVersion8 const ( - Builder_Ping_FullMethodName = "/builder.Builder/Ping" + Builder_Ping_FullMethodName = "/builder.Builder/Ping" + Builder_ClaimBuildTasks_FullMethodName = "/builder.Builder/ClaimBuildTasks" + Builder_SubmitBuildTaskOutput_FullMethodName = "/builder.Builder/SubmitBuildTaskOutput" ) // BuilderClient is the client API for Builder service. @@ -27,6 +29,8 @@ const ( // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type BuilderClient interface { Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) + ClaimBuildTasks(ctx context.Context, in *ClaimBuildTasksRequest, opts ...grpc.CallOption) (*ClaimBuildTasksResponse, error) + SubmitBuildTaskOutput(ctx context.Context, in *SubmitBuildTaskOutputRequest, opts ...grpc.CallOption) (*SubmitBuildTaskOutputResponse, error) } type builderClient struct { @@ -47,11 +51,33 @@ func (c *builderClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc. return out, nil } +func (c *builderClient) ClaimBuildTasks(ctx context.Context, in *ClaimBuildTasksRequest, opts ...grpc.CallOption) (*ClaimBuildTasksResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ClaimBuildTasksResponse) + err := c.cc.Invoke(ctx, Builder_ClaimBuildTasks_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *builderClient) SubmitBuildTaskOutput(ctx context.Context, in *SubmitBuildTaskOutputRequest, opts ...grpc.CallOption) (*SubmitBuildTaskOutputResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SubmitBuildTaskOutputResponse) + err := c.cc.Invoke(ctx, Builder_SubmitBuildTaskOutput_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // BuilderServer is the server API for Builder service. // All implementations must embed UnimplementedBuilderServer // for forward compatibility type BuilderServer interface { Ping(context.Context, *PingRequest) (*PingResponse, error) + ClaimBuildTasks(context.Context, *ClaimBuildTasksRequest) (*ClaimBuildTasksResponse, error) + SubmitBuildTaskOutput(context.Context, *SubmitBuildTaskOutputRequest) (*SubmitBuildTaskOutputResponse, error) mustEmbedUnimplementedBuilderServer() } @@ -62,6 +88,12 @@ type UnimplementedBuilderServer struct { func (UnimplementedBuilderServer) Ping(context.Context, *PingRequest) (*PingResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") } +func (UnimplementedBuilderServer) ClaimBuildTasks(context.Context, *ClaimBuildTasksRequest) (*ClaimBuildTasksResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClaimBuildTasks not implemented") +} +func (UnimplementedBuilderServer) SubmitBuildTaskOutput(context.Context, *SubmitBuildTaskOutputRequest) (*SubmitBuildTaskOutputResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitBuildTaskOutput not implemented") +} func (UnimplementedBuilderServer) mustEmbedUnimplementedBuilderServer() {} // UnsafeBuilderServer may be embedded to opt out of forward compatibility for this service. @@ -93,6 +125,42 @@ func _Builder_Ping_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Builder_ClaimBuildTasks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ClaimBuildTasksRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BuilderServer).ClaimBuildTasks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Builder_ClaimBuildTasks_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BuilderServer).ClaimBuildTasks(ctx, req.(*ClaimBuildTasksRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Builder_SubmitBuildTaskOutput_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SubmitBuildTaskOutputRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BuilderServer).SubmitBuildTaskOutput(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Builder_SubmitBuildTaskOutput_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BuilderServer).SubmitBuildTaskOutput(ctx, req.(*SubmitBuildTaskOutputRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Builder_ServiceDesc is the grpc.ServiceDesc for Builder service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -104,6 +172,14 @@ var Builder_ServiceDesc = grpc.ServiceDesc{ MethodName: "Ping", Handler: _Builder_Ping_Handler, }, + { + MethodName: "ClaimBuildTasks", + Handler: _Builder_ClaimBuildTasks_Handler, + }, + { + MethodName: "SubmitBuildTaskOutput", + Handler: _Builder_SubmitBuildTaskOutput_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "builder.proto", diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index 3d310d63d..ef2e92f59 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -92,7 +92,8 @@ func parseMTLSCredentials(mtlsPEM string) (*builderCredentials, error) { } // Run starts the builder process using the provided configuration. -// It connects to the configured upstream server with mTLS credentials and sends a ping request. +// It connects to the configured upstream server with mTLS credentials, +// then enters a polling loop to claim and execute build tasks. func Run(ctx context.Context, cfg *Config) error { slog.InfoContext(ctx, "builder started", "id", cfg.ID, @@ -115,6 +116,8 @@ func Run(ctx context.Context, cfg *Config) error { defer conn.Close() client := builderpb.NewBuilderClient(conn) + + // Initial ping to verify connectivity _, err = client.Ping(ctx, &builderpb.PingRequest{}) if err != nil { return fmt.Errorf("failed to ping upstream: %w", err) @@ -122,7 +125,54 @@ func Run(ctx context.Context, cfg *Config) error { slog.InfoContext(ctx, "successfully pinged upstream", "upstream", cfg.Upstream) - // Wait for context cancellation - <-ctx.Done() - return ctx.Err() + // Main polling loop + ticker := time.NewTicker(5 * time.Second) + defer ticker.Stop() + + for { + select { + case <-ctx.Done(): + return ctx.Err() + case <-ticker.C: + if err := claimAndExecuteTasks(ctx, client); err != nil { + slog.ErrorContext(ctx, "error processing build tasks", "error", err) + } + } + } +} + +func claimAndExecuteTasks(ctx context.Context, client builderpb.BuilderClient) error { + resp, err := client.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) + if err != nil { + return fmt.Errorf("failed to claim build tasks: %w", err) + } + + for _, task := range resp.Tasks { + slog.InfoContext(ctx, "claimed build task", + "task_id", task.Id, + "target_os", task.TargetOs, + "build_image", task.BuildImage, + ) + + // Print the build script + fmt.Printf("=== Build Task %d ===\n", task.Id) + fmt.Printf("Target OS: %s\n", task.TargetOs) + fmt.Printf("Build Image: %s\n", task.BuildImage) + fmt.Printf("Build Script:\n%s\n", task.BuildScript) + fmt.Println("====================") + + // Report completion + _, err := client.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ + TaskId: task.Id, + Output: fmt.Sprintf("Build script printed successfully for target %s", task.TargetOs), + }) + if err != nil { + slog.ErrorContext(ctx, "failed to submit build task output", + "task_id", task.Id, + "error", err, + ) + } + } + + return nil } diff --git a/tavern/internal/builder/generate.go b/tavern/internal/builder/generate.go new file mode 100644 index 000000000..68087e2e6 --- /dev/null +++ b/tavern/internal/builder/generate.go @@ -0,0 +1,3 @@ +package builder + +//go:generate protoc -I=./proto --go_out=./builderpb --go_opt=paths=source_relative --go-grpc_out=./builderpb --go-grpc_opt=paths=source_relative builder.proto diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go index 4e0cbc7af..346d554ce 100644 --- a/tavern/internal/builder/integration_test.go +++ b/tavern/internal/builder/integration_test.go @@ -20,6 +20,7 @@ import ( "realm.pub/tavern/internal/builder" "realm.pub/tavern/internal/builder/builderpb" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent/enttest" "realm.pub/tavern/internal/graphql" tavernhttp "realm.pub/tavern/internal/http" @@ -145,4 +146,197 @@ func TestBuilderE2E(t *testing.T) { require.NoError(t, err) require.NotNil(t, pingResp) }) + + // 10. Test: ClaimBuildTasks returns unclaimed tasks and marks them as claimed + t.Run("ClaimBuildTasks", func(t *testing.T) { + // Create an authenticated client + creds, err := builder.NewCredentialsFromConfig(cfg) + require.NoError(t, err) + + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + require.NoError(t, err) + defer conn.Close() + + authClient := builderpb.NewBuilderClient(conn) + + // Create a build task assigned to this builder + bt := graph.BuildTask.Create(). + SetTargetOs(c2pb.Host_PLATFORM_LINUX). + SetBuildImage("golang:1.21"). + SetBuildScript("echo hello && go build ./..."). + SetBuilderID(builders[0].ID). + SaveX(ctx) + + // Claim tasks + resp, err := authClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) + require.NoError(t, err) + require.Len(t, resp.Tasks, 1) + assert.Equal(t, int64(bt.ID), resp.Tasks[0].Id) + assert.Equal(t, "golang:1.21", resp.Tasks[0].BuildImage) + assert.Equal(t, "echo hello && go build ./...", resp.Tasks[0].BuildScript) + + // Verify claimed_at is set + reloaded := graph.BuildTask.GetX(ctx, bt.ID) + assert.False(t, reloaded.ClaimedAt.IsZero()) + + // Claim again -> should return empty (already claimed) + resp2, err := authClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) + require.NoError(t, err) + assert.Empty(t, resp2.Tasks) + }) + + // 11. Test: SubmitBuildTaskOutput sets output and finished_at + t.Run("SubmitBuildTaskOutput", func(t *testing.T) { + creds, err := builder.NewCredentialsFromConfig(cfg) + require.NoError(t, err) + + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + require.NoError(t, err) + defer conn.Close() + + authClient := builderpb.NewBuilderClient(conn) + + // Create and claim a build task + bt := graph.BuildTask.Create(). + SetTargetOs(c2pb.Host_PLATFORM_MACOS). + SetBuildImage("rust:1.75"). + SetBuildScript("cargo build --release"). + SetBuilderID(builders[0].ID). + SaveX(ctx) + + // Claim the task + claimResp, err := authClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) + require.NoError(t, err) + require.Len(t, claimResp.Tasks, 1) + + // Submit output + _, err = authClient.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ + TaskId: int64(bt.ID), + Output: "build succeeded", + }) + require.NoError(t, err) + + // Verify the build task was updated + reloaded := graph.BuildTask.GetX(ctx, bt.ID) + assert.Equal(t, "build succeeded", reloaded.Output) + assert.False(t, reloaded.FinishedAt.IsZero()) + assert.Empty(t, reloaded.Error) + }) + + // 12. Test: SubmitBuildTaskOutput with error + t.Run("SubmitBuildTaskOutputWithError", func(t *testing.T) { + creds, err := builder.NewCredentialsFromConfig(cfg) + require.NoError(t, err) + + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + require.NoError(t, err) + defer conn.Close() + + authClient := builderpb.NewBuilderClient(conn) + + // Create and claim a build task + bt := graph.BuildTask.Create(). + SetTargetOs(c2pb.Host_PLATFORM_LINUX). + SetBuildImage("golang:1.21"). + SetBuildScript("go build ./..."). + SetBuilderID(builders[0].ID). + SaveX(ctx) + + claimResp, err := authClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) + require.NoError(t, err) + require.Len(t, claimResp.Tasks, 1) + + // Submit output with error + _, err = authClient.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ + TaskId: int64(bt.ID), + Output: "partial output before failure", + Error: "compilation failed: missing dependency", + }) + require.NoError(t, err) + + // Verify the build task has both output and error + reloaded := graph.BuildTask.GetX(ctx, bt.ID) + assert.Equal(t, "partial output before failure", reloaded.Output) + assert.Equal(t, "compilation failed: missing dependency", reloaded.Error) + assert.False(t, reloaded.FinishedAt.IsZero()) + }) + + // 13. Test: SubmitBuildTaskOutput for another builder's task is rejected + t.Run("SubmitBuildTaskOutputWrongBuilder", func(t *testing.T) { + // Register a second builder + var registerResp2 struct { + RegisterBuilder struct { + Builder struct { + ID string + } + Config string + } + } + err := gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { + registerBuilder(input: $input) { + builder { id } + config + } + }`, ®isterResp2, client.Var("input", map[string]any{ + "supportedTargets": []string{"PLATFORM_WINDOWS"}, + "upstream": "https://tavern.example.com:443", + })) + require.NoError(t, err) + + cfg2, err := builder.ParseConfigBytes([]byte(registerResp2.RegisterBuilder.Config)) + require.NoError(t, err) + + // Get the second builder's DB entity + allBuilders, err := graph.Builder.Query().All(ctx) + require.NoError(t, err) + require.Len(t, allBuilders, 2) + + var secondBuilder int + for _, b := range allBuilders { + if b.Identifier == cfg2.ID { + secondBuilder = b.ID + } + } + + // Create a build task assigned to the second builder + bt := graph.BuildTask.Create(). + SetTargetOs(c2pb.Host_PLATFORM_WINDOWS). + SetBuildImage("mcr.microsoft.com/windows:ltsc2022"). + SetBuildScript("msbuild /t:Build"). + SetBuilderID(secondBuilder). + SaveX(ctx) + + // Try to submit output using the FIRST builder's credentials + creds, err := builder.NewCredentialsFromConfig(cfg) + require.NoError(t, err) + + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + require.NoError(t, err) + defer conn.Close() + + authClient := builderpb.NewBuilderClient(conn) + + _, err = authClient.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ + TaskId: int64(bt.ID), + Output: "should not be allowed", + }) + require.Error(t, err) + assert.Equal(t, codes.PermissionDenied, status.Code(err)) + }) } diff --git a/tavern/internal/builder/proto/builder.proto b/tavern/internal/builder/proto/builder.proto index 138641bc3..176ae1b93 100644 --- a/tavern/internal/builder/proto/builder.proto +++ b/tavern/internal/builder/proto/builder.proto @@ -7,6 +7,29 @@ option go_package = "realm.pub/tavern/internal/builder/builderpb"; message PingRequest {} message PingResponse {} +message ClaimBuildTasksRequest {} + +message BuildTaskSpec { + int64 id = 1; + string target_os = 2; + string build_image = 3; + string build_script = 4; +} + +message ClaimBuildTasksResponse { + repeated BuildTaskSpec tasks = 1; +} + +message SubmitBuildTaskOutputRequest { + int64 task_id = 1; + string output = 2; + string error = 3; +} + +message SubmitBuildTaskOutputResponse {} + service Builder { rpc Ping(PingRequest) returns (PingResponse) {} + rpc ClaimBuildTasks(ClaimBuildTasksRequest) returns (ClaimBuildTasksResponse) {} + rpc SubmitBuildTaskOutput(SubmitBuildTaskOutputRequest) returns (SubmitBuildTaskOutputResponse) {} } diff --git a/tavern/internal/builder/server.go b/tavern/internal/builder/server.go index c7f2d4c2c..a033fe8cd 100644 --- a/tavern/internal/builder/server.go +++ b/tavern/internal/builder/server.go @@ -3,9 +3,15 @@ package builder import ( "context" "log/slog" + "time" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/ent" + entbuilder "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" ) // Server implements the Builder gRPC service. @@ -26,3 +32,130 @@ func (s *Server) Ping(ctx context.Context, req *builderpb.PingRequest) (*builder slog.Info("ping!") return &builderpb.PingResponse{}, nil } + +// ClaimBuildTasks returns unclaimed build tasks assigned to the authenticated builder and marks them as claimed. +func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildTasksRequest) (*builderpb.ClaimBuildTasksResponse, error) { + now := time.Now() + + // 1. Extract authenticated builder from context + b, ok := BuilderFromContext(ctx) + if !ok { + return nil, status.Error(codes.Unauthenticated, "builder not authenticated") + } + + // 2. Query unclaimed build tasks assigned to this builder + tasks, err := s.graph.BuildTask.Query(). + Where( + buildtask.HasBuilderWith(entbuilder.ID(b.ID)), + buildtask.ClaimedAtIsNil(), + ). + All(ctx) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to query build tasks: %v", err) + } + + if len(tasks) == 0 { + // Log for debugging: count total tasks (including claimed) for this builder + total, _ := s.graph.BuildTask.Query(). + Where(buildtask.HasBuilderWith(entbuilder.ID(b.ID))). + Count(ctx) + slog.InfoContext(ctx, "no unclaimed build tasks found", + "builder_id", b.ID, + "total_tasks_for_builder", total, + ) + return &builderpb.ClaimBuildTasksResponse{}, nil + } + + // 3. Begin transaction to claim tasks atomically + tx, err := s.graph.Tx(ctx) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to start transaction: %v", err) + } + defer func() { + if v := recover(); v != nil { + tx.Rollback() + panic(v) + } + }() + + client := tx.Client() + taskIDs := make([]int, 0, len(tasks)) + for _, t := range tasks { + _, err := client.BuildTask.UpdateOne(t). + SetClaimedAt(now). + SetStartedAt(now). + Save(ctx) + if err != nil { + tx.Rollback() + return nil, status.Errorf(codes.Internal, "failed to claim build task %d: %v", t.ID, err) + } + taskIDs = append(taskIDs, t.ID) + } + + if err := tx.Commit(); err != nil { + return nil, status.Errorf(codes.Internal, "failed to commit transaction: %v", err) + } + + // 4. Build response from claimed tasks + resp := &builderpb.ClaimBuildTasksResponse{} + for _, t := range tasks { + resp.Tasks = append(resp.Tasks, &builderpb.BuildTaskSpec{ + Id: int64(t.ID), + TargetOs: t.TargetOs.String(), + BuildImage: t.BuildImage, + BuildScript: t.BuildScript, + }) + } + + slog.InfoContext(ctx, "builder claimed build tasks", + "builder_id", b.ID, + "task_count", len(resp.Tasks), + ) + + return resp, nil +} + +// SubmitBuildTaskOutput records the output of a completed build task. +func (s *Server) SubmitBuildTaskOutput(ctx context.Context, req *builderpb.SubmitBuildTaskOutputRequest) (*builderpb.SubmitBuildTaskOutputResponse, error) { + now := time.Now() + + // 1. Validate the builder is authenticated + b, ok := BuilderFromContext(ctx) + if !ok { + return nil, status.Error(codes.Unauthenticated, "builder not authenticated") + } + + // 2. Load the build task and verify it belongs to this builder + bt, err := s.graph.BuildTask.Get(ctx, int(req.TaskId)) + if err != nil { + return nil, status.Errorf(codes.NotFound, "build task %d not found: %v", req.TaskId, err) + } + + btBuilder, err := bt.QueryBuilder().Only(ctx) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to query builder for task %d: %v", req.TaskId, err) + } + if btBuilder.ID != b.ID { + return nil, status.Errorf(codes.PermissionDenied, "build task %d is not assigned to this builder", req.TaskId) + } + + // 3. Update the build task with output and mark as finished + update := s.graph.BuildTask.UpdateOne(bt). + SetFinishedAt(now). + SetOutput(req.Output) + if req.Error != "" { + update = update.SetError(req.Error) + } + + if _, err := update.Save(ctx); err != nil { + return nil, status.Errorf(codes.Internal, "failed to update build task %d: %v", req.TaskId, err) + } + + slog.InfoContext(ctx, "build task output submitted", + "task_id", req.TaskId, + "builder_id", b.ID, + "has_error", req.Error != "", + ) + + return &builderpb.SubmitBuildTaskOutputResponse{}, nil +} diff --git a/tavern/internal/ent/builder.go b/tavern/internal/ent/builder.go index 527ec31a2..d116f7de3 100644 --- a/tavern/internal/ent/builder.go +++ b/tavern/internal/ent/builder.go @@ -28,10 +28,35 @@ type Builder struct { // The platforms this builder can build agents for. SupportedTargets []c2pb.Host_Platform `json:"supported_targets,omitempty"` // The server address that the builder should connect to. - Upstream string `json:"upstream,omitempty"` + Upstream string `json:"upstream,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the BuilderQuery when eager-loading is set. + Edges BuilderEdges `json:"edges"` selectValues sql.SelectValues } +// BuilderEdges holds the relations/edges for other nodes in the graph. +type BuilderEdges struct { + // Build tasks assigned to this builder. + BuildTasks []*BuildTask `json:"build_tasks,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool + // totalCount holds the count of the edges above. + totalCount [1]map[string]int + + namedBuildTasks map[string][]*BuildTask +} + +// BuildTasksOrErr returns the BuildTasks value or an error if the edge +// was not loaded in eager-loading. +func (e BuilderEdges) BuildTasksOrErr() ([]*BuildTask, error) { + if e.loadedTypes[0] { + return e.BuildTasks, nil + } + return nil, &NotLoadedError{edge: "build_tasks"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Builder) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -111,6 +136,11 @@ func (b *Builder) Value(name string) (ent.Value, error) { return b.selectValues.Get(name) } +// QueryBuildTasks queries the "build_tasks" edge of the Builder entity. +func (b *Builder) QueryBuildTasks() *BuildTaskQuery { + return NewBuilderClient(b.config).QueryBuildTasks(b) +} + // Update returns a builder for updating this Builder. // Note that you need to call Builder.Unwrap() before calling this method if this Builder // was returned from a transaction, and the transaction was committed or rolled back. @@ -152,5 +182,29 @@ func (b *Builder) String() string { return builder.String() } +// NamedBuildTasks returns the BuildTasks named value or an error if the edge was not +// loaded in eager-loading with this name. +func (b *Builder) NamedBuildTasks(name string) ([]*BuildTask, error) { + if b.Edges.namedBuildTasks == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := b.Edges.namedBuildTasks[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (b *Builder) appendNamedBuildTasks(name string, edges ...*BuildTask) { + if b.Edges.namedBuildTasks == nil { + b.Edges.namedBuildTasks = make(map[string][]*BuildTask) + } + if len(edges) == 0 { + b.Edges.namedBuildTasks[name] = []*BuildTask{} + } else { + b.Edges.namedBuildTasks[name] = append(b.Edges.namedBuildTasks[name], edges...) + } +} + // Builders is a parsable slice of Builder. type Builders []*Builder diff --git a/tavern/internal/ent/builder/builder.go b/tavern/internal/ent/builder/builder.go index 19caff758..86c6268c1 100644 --- a/tavern/internal/ent/builder/builder.go +++ b/tavern/internal/ent/builder/builder.go @@ -6,6 +6,7 @@ import ( "time" "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" ) const ( @@ -23,8 +24,17 @@ const ( FieldSupportedTargets = "supported_targets" // FieldUpstream holds the string denoting the upstream field in the database. FieldUpstream = "upstream" + // EdgeBuildTasks holds the string denoting the build_tasks edge name in mutations. + EdgeBuildTasks = "build_tasks" // Table holds the table name of the builder in the database. Table = "builders" + // BuildTasksTable is the table that holds the build_tasks relation/edge. + BuildTasksTable = "build_tasks" + // BuildTasksInverseTable is the table name for the BuildTask entity. + // It exists in this package in order to avoid circular dependency with the "buildtask" package. + BuildTasksInverseTable = "build_tasks" + // BuildTasksColumn is the table column denoting the build_tasks relation/edge. + BuildTasksColumn = "build_task_builder" ) // Columns holds all SQL columns for builder fields. @@ -87,3 +97,24 @@ func ByIdentifier(opts ...sql.OrderTermOption) OrderOption { func ByUpstream(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUpstream, opts...).ToFunc() } + +// ByBuildTasksCount orders the results by build_tasks count. +func ByBuildTasksCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newBuildTasksStep(), opts...) + } +} + +// ByBuildTasks orders the results by build_tasks terms. +func ByBuildTasks(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newBuildTasksStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newBuildTasksStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(BuildTasksInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, BuildTasksTable, BuildTasksColumn), + ) +} diff --git a/tavern/internal/ent/builder/where.go b/tavern/internal/ent/builder/where.go index fcf05be32..a2f85e99c 100644 --- a/tavern/internal/ent/builder/where.go +++ b/tavern/internal/ent/builder/where.go @@ -6,6 +6,7 @@ import ( "time" "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" "realm.pub/tavern/internal/ent/predicate" ) @@ -284,6 +285,29 @@ func UpstreamContainsFold(v string) predicate.Builder { return predicate.Builder(sql.FieldContainsFold(FieldUpstream, v)) } +// HasBuildTasks applies the HasEdge predicate on the "build_tasks" edge. +func HasBuildTasks() predicate.Builder { + return predicate.Builder(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, BuildTasksTable, BuildTasksColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasBuildTasksWith applies the HasEdge predicate on the "build_tasks" edge with a given conditions (other predicates). +func HasBuildTasksWith(preds ...predicate.BuildTask) predicate.Builder { + return predicate.Builder(func(s *sql.Selector) { + step := newBuildTasksStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Builder) predicate.Builder { return predicate.Builder(sql.AndPredicates(predicates...)) diff --git a/tavern/internal/ent/builder_create.go b/tavern/internal/ent/builder_create.go index 371beb2c0..9a85f8ba9 100644 --- a/tavern/internal/ent/builder_create.go +++ b/tavern/internal/ent/builder_create.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/schema/field" "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" ) // BuilderCreate is the builder for creating a Builder entity. @@ -77,6 +78,21 @@ func (bc *BuilderCreate) SetUpstream(s string) *BuilderCreate { return bc } +// AddBuildTaskIDs adds the "build_tasks" edge to the BuildTask entity by IDs. +func (bc *BuilderCreate) AddBuildTaskIDs(ids ...int) *BuilderCreate { + bc.mutation.AddBuildTaskIDs(ids...) + return bc +} + +// AddBuildTasks adds the "build_tasks" edges to the BuildTask entity. +func (bc *BuilderCreate) AddBuildTasks(b ...*BuildTask) *BuilderCreate { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return bc.AddBuildTaskIDs(ids...) +} + // Mutation returns the BuilderMutation object of the builder. func (bc *BuilderCreate) Mutation() *BuilderMutation { return bc.mutation @@ -195,6 +211,22 @@ func (bc *BuilderCreate) createSpec() (*Builder, *sqlgraph.CreateSpec) { _spec.SetField(builder.FieldUpstream, field.TypeString, value) _node.Upstream = value } + if nodes := bc.mutation.BuildTasksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: builder.BuildTasksTable, + Columns: []string{builder.BuildTasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/tavern/internal/ent/builder_query.go b/tavern/internal/ent/builder_query.go index 71412c4b0..c206e4e13 100644 --- a/tavern/internal/ent/builder_query.go +++ b/tavern/internal/ent/builder_query.go @@ -4,6 +4,7 @@ package ent import ( "context" + "database/sql/driver" "fmt" "math" @@ -12,18 +13,21 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/predicate" ) // BuilderQuery is the builder for querying Builder entities. type BuilderQuery struct { config - ctx *QueryContext - order []builder.OrderOption - inters []Interceptor - predicates []predicate.Builder - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*Builder) error + ctx *QueryContext + order []builder.OrderOption + inters []Interceptor + predicates []predicate.Builder + withBuildTasks *BuildTaskQuery + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Builder) error + withNamedBuildTasks map[string]*BuildTaskQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -60,6 +64,28 @@ func (bq *BuilderQuery) Order(o ...builder.OrderOption) *BuilderQuery { return bq } +// QueryBuildTasks chains the current query on the "build_tasks" edge. +func (bq *BuilderQuery) QueryBuildTasks() *BuildTaskQuery { + query := (&BuildTaskClient{config: bq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := bq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := bq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(builder.Table, builder.FieldID, selector), + sqlgraph.To(buildtask.Table, buildtask.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, builder.BuildTasksTable, builder.BuildTasksColumn), + ) + fromU = sqlgraph.SetNeighbors(bq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Builder entity from the query. // Returns a *NotFoundError when no Builder was found. func (bq *BuilderQuery) First(ctx context.Context) (*Builder, error) { @@ -247,17 +273,29 @@ func (bq *BuilderQuery) Clone() *BuilderQuery { return nil } return &BuilderQuery{ - config: bq.config, - ctx: bq.ctx.Clone(), - order: append([]builder.OrderOption{}, bq.order...), - inters: append([]Interceptor{}, bq.inters...), - predicates: append([]predicate.Builder{}, bq.predicates...), + config: bq.config, + ctx: bq.ctx.Clone(), + order: append([]builder.OrderOption{}, bq.order...), + inters: append([]Interceptor{}, bq.inters...), + predicates: append([]predicate.Builder{}, bq.predicates...), + withBuildTasks: bq.withBuildTasks.Clone(), // clone intermediate query. sql: bq.sql.Clone(), path: bq.path, } } +// WithBuildTasks tells the query-builder to eager-load the nodes that are connected to +// the "build_tasks" edge. The optional arguments are used to configure the query builder of the edge. +func (bq *BuilderQuery) WithBuildTasks(opts ...func(*BuildTaskQuery)) *BuilderQuery { + query := (&BuildTaskClient{config: bq.config}).Query() + for _, opt := range opts { + opt(query) + } + bq.withBuildTasks = query + return bq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -334,8 +372,11 @@ func (bq *BuilderQuery) prepareQuery(ctx context.Context) error { func (bq *BuilderQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Builder, error) { var ( - nodes = []*Builder{} - _spec = bq.querySpec() + nodes = []*Builder{} + _spec = bq.querySpec() + loadedTypes = [1]bool{ + bq.withBuildTasks != nil, + } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Builder).scanValues(nil, columns) @@ -343,6 +384,7 @@ func (bq *BuilderQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Buil _spec.Assign = func(columns []string, values []any) error { node := &Builder{config: bq.config} nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } if len(bq.modifiers) > 0 { @@ -357,6 +399,20 @@ func (bq *BuilderQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Buil if len(nodes) == 0 { return nodes, nil } + if query := bq.withBuildTasks; query != nil { + if err := bq.loadBuildTasks(ctx, query, nodes, + func(n *Builder) { n.Edges.BuildTasks = []*BuildTask{} }, + func(n *Builder, e *BuildTask) { n.Edges.BuildTasks = append(n.Edges.BuildTasks, e) }); err != nil { + return nil, err + } + } + for name, query := range bq.withNamedBuildTasks { + if err := bq.loadBuildTasks(ctx, query, nodes, + func(n *Builder) { n.appendNamedBuildTasks(name) }, + func(n *Builder, e *BuildTask) { n.appendNamedBuildTasks(name, e) }); err != nil { + return nil, err + } + } for i := range bq.loadTotal { if err := bq.loadTotal[i](ctx, nodes); err != nil { return nil, err @@ -365,6 +421,38 @@ func (bq *BuilderQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Buil return nodes, nil } +func (bq *BuilderQuery) loadBuildTasks(ctx context.Context, query *BuildTaskQuery, nodes []*Builder, init func(*Builder), assign func(*Builder, *BuildTask)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Builder) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.BuildTask(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(builder.BuildTasksColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.build_task_builder + if fk == nil { + return fmt.Errorf(`foreign-key "build_task_builder" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "build_task_builder" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} + func (bq *BuilderQuery) sqlCount(ctx context.Context) (int, error) { _spec := bq.querySpec() if len(bq.modifiers) > 0 { @@ -449,6 +537,20 @@ func (bq *BuilderQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// WithNamedBuildTasks tells the query-builder to eager-load the nodes that are connected to the "build_tasks" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (bq *BuilderQuery) WithNamedBuildTasks(name string, opts ...func(*BuildTaskQuery)) *BuilderQuery { + query := (&BuildTaskClient{config: bq.config}).Query() + for _, opt := range opts { + opt(query) + } + if bq.withNamedBuildTasks == nil { + bq.withNamedBuildTasks = make(map[string]*BuildTaskQuery) + } + bq.withNamedBuildTasks[name] = query + return bq +} + // BuilderGroupBy is the group-by builder for Builder entities. type BuilderGroupBy struct { selector diff --git a/tavern/internal/ent/builder_update.go b/tavern/internal/ent/builder_update.go index bb70a9a18..fd4fefe9a 100644 --- a/tavern/internal/ent/builder_update.go +++ b/tavern/internal/ent/builder_update.go @@ -14,6 +14,7 @@ import ( "entgo.io/ent/schema/field" "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/predicate" ) @@ -62,11 +63,47 @@ func (bu *BuilderUpdate) SetNillableUpstream(s *string) *BuilderUpdate { return bu } +// AddBuildTaskIDs adds the "build_tasks" edge to the BuildTask entity by IDs. +func (bu *BuilderUpdate) AddBuildTaskIDs(ids ...int) *BuilderUpdate { + bu.mutation.AddBuildTaskIDs(ids...) + return bu +} + +// AddBuildTasks adds the "build_tasks" edges to the BuildTask entity. +func (bu *BuilderUpdate) AddBuildTasks(b ...*BuildTask) *BuilderUpdate { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return bu.AddBuildTaskIDs(ids...) +} + // Mutation returns the BuilderMutation object of the builder. func (bu *BuilderUpdate) Mutation() *BuilderMutation { return bu.mutation } +// ClearBuildTasks clears all "build_tasks" edges to the BuildTask entity. +func (bu *BuilderUpdate) ClearBuildTasks() *BuilderUpdate { + bu.mutation.ClearBuildTasks() + return bu +} + +// RemoveBuildTaskIDs removes the "build_tasks" edge to BuildTask entities by IDs. +func (bu *BuilderUpdate) RemoveBuildTaskIDs(ids ...int) *BuilderUpdate { + bu.mutation.RemoveBuildTaskIDs(ids...) + return bu +} + +// RemoveBuildTasks removes "build_tasks" edges to BuildTask entities. +func (bu *BuilderUpdate) RemoveBuildTasks(b ...*BuildTask) *BuilderUpdate { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return bu.RemoveBuildTaskIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (bu *BuilderUpdate) Save(ctx context.Context) (int, error) { bu.defaults() @@ -126,6 +163,51 @@ func (bu *BuilderUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := bu.mutation.Upstream(); ok { _spec.SetField(builder.FieldUpstream, field.TypeString, value) } + if bu.mutation.BuildTasksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: builder.BuildTasksTable, + Columns: []string{builder.BuildTasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.RemovedBuildTasksIDs(); len(nodes) > 0 && !bu.mutation.BuildTasksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: builder.BuildTasksTable, + Columns: []string{builder.BuildTasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.BuildTasksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: builder.BuildTasksTable, + Columns: []string{builder.BuildTasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, bu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{builder.Label} @@ -178,11 +260,47 @@ func (buo *BuilderUpdateOne) SetNillableUpstream(s *string) *BuilderUpdateOne { return buo } +// AddBuildTaskIDs adds the "build_tasks" edge to the BuildTask entity by IDs. +func (buo *BuilderUpdateOne) AddBuildTaskIDs(ids ...int) *BuilderUpdateOne { + buo.mutation.AddBuildTaskIDs(ids...) + return buo +} + +// AddBuildTasks adds the "build_tasks" edges to the BuildTask entity. +func (buo *BuilderUpdateOne) AddBuildTasks(b ...*BuildTask) *BuilderUpdateOne { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return buo.AddBuildTaskIDs(ids...) +} + // Mutation returns the BuilderMutation object of the builder. func (buo *BuilderUpdateOne) Mutation() *BuilderMutation { return buo.mutation } +// ClearBuildTasks clears all "build_tasks" edges to the BuildTask entity. +func (buo *BuilderUpdateOne) ClearBuildTasks() *BuilderUpdateOne { + buo.mutation.ClearBuildTasks() + return buo +} + +// RemoveBuildTaskIDs removes the "build_tasks" edge to BuildTask entities by IDs. +func (buo *BuilderUpdateOne) RemoveBuildTaskIDs(ids ...int) *BuilderUpdateOne { + buo.mutation.RemoveBuildTaskIDs(ids...) + return buo +} + +// RemoveBuildTasks removes "build_tasks" edges to BuildTask entities. +func (buo *BuilderUpdateOne) RemoveBuildTasks(b ...*BuildTask) *BuilderUpdateOne { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return buo.RemoveBuildTaskIDs(ids...) +} + // Where appends a list predicates to the BuilderUpdate builder. func (buo *BuilderUpdateOne) Where(ps ...predicate.Builder) *BuilderUpdateOne { buo.mutation.Where(ps...) @@ -272,6 +390,51 @@ func (buo *BuilderUpdateOne) sqlSave(ctx context.Context) (_node *Builder, err e if value, ok := buo.mutation.Upstream(); ok { _spec.SetField(builder.FieldUpstream, field.TypeString, value) } + if buo.mutation.BuildTasksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: builder.BuildTasksTable, + Columns: []string{builder.BuildTasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.RemovedBuildTasksIDs(); len(nodes) > 0 && !buo.mutation.BuildTasksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: builder.BuildTasksTable, + Columns: []string{builder.BuildTasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.BuildTasksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: builder.BuildTasksTable, + Columns: []string{builder.BuildTasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &Builder{config: buo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/tavern/internal/ent/buildtask.go b/tavern/internal/ent/buildtask.go new file mode 100644 index 000000000..870132d81 --- /dev/null +++ b/tavern/internal/ent/buildtask.go @@ -0,0 +1,249 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" +) + +// BuildTask is the model entity for the BuildTask schema. +type BuildTask struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Timestamp of when this ent was created + CreatedAt time.Time `json:"created_at,omitempty"` + // Timestamp of when this ent was last updated + LastModifiedAt time.Time `json:"last_modified_at,omitempty"` + // The target operating system platform for this build. + TargetOs c2pb.Host_Platform `json:"target_os,omitempty"` + // Docker container image name to use for the build. + BuildImage string `json:"build_image,omitempty"` + // The script to execute inside the build container. + BuildScript string `json:"build_script,omitempty"` + // Timestamp of when a builder claimed this task, null if unclaimed. + ClaimedAt time.Time `json:"claimed_at,omitempty"` + // Timestamp of when the build execution started, null if not yet started. + StartedAt time.Time `json:"started_at,omitempty"` + // Timestamp of when the build finished, null if not yet finished. + FinishedAt time.Time `json:"finished_at,omitempty"` + // Output from the build execution. + Output string `json:"output,omitempty"` + // Error message if the build failed. + Error string `json:"error,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the BuildTaskQuery when eager-loading is set. + Edges BuildTaskEdges `json:"edges"` + build_task_builder *int + selectValues sql.SelectValues +} + +// BuildTaskEdges holds the relations/edges for other nodes in the graph. +type BuildTaskEdges struct { + // The builder assigned to execute this build task. + Builder *Builder `json:"builder,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool + // totalCount holds the count of the edges above. + totalCount [1]map[string]int +} + +// BuilderOrErr returns the Builder value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e BuildTaskEdges) BuilderOrErr() (*Builder, error) { + if e.Builder != nil { + return e.Builder, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: builder.Label} + } + return nil, &NotLoadedError{edge: "builder"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*BuildTask) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case buildtask.FieldTargetOs: + values[i] = new(c2pb.Host_Platform) + case buildtask.FieldID: + values[i] = new(sql.NullInt64) + case buildtask.FieldBuildImage, buildtask.FieldBuildScript, buildtask.FieldOutput, buildtask.FieldError: + values[i] = new(sql.NullString) + case buildtask.FieldCreatedAt, buildtask.FieldLastModifiedAt, buildtask.FieldClaimedAt, buildtask.FieldStartedAt, buildtask.FieldFinishedAt: + values[i] = new(sql.NullTime) + case buildtask.ForeignKeys[0]: // build_task_builder + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the BuildTask fields. +func (bt *BuildTask) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case buildtask.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + bt.ID = int(value.Int64) + case buildtask.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + bt.CreatedAt = value.Time + } + case buildtask.FieldLastModifiedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_modified_at", values[i]) + } else if value.Valid { + bt.LastModifiedAt = value.Time + } + case buildtask.FieldTargetOs: + if value, ok := values[i].(*c2pb.Host_Platform); !ok { + return fmt.Errorf("unexpected type %T for field target_os", values[i]) + } else if value != nil { + bt.TargetOs = *value + } + case buildtask.FieldBuildImage: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field build_image", values[i]) + } else if value.Valid { + bt.BuildImage = value.String + } + case buildtask.FieldBuildScript: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field build_script", values[i]) + } else if value.Valid { + bt.BuildScript = value.String + } + case buildtask.FieldClaimedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field claimed_at", values[i]) + } else if value.Valid { + bt.ClaimedAt = value.Time + } + case buildtask.FieldStartedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field started_at", values[i]) + } else if value.Valid { + bt.StartedAt = value.Time + } + case buildtask.FieldFinishedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field finished_at", values[i]) + } else if value.Valid { + bt.FinishedAt = value.Time + } + case buildtask.FieldOutput: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field output", values[i]) + } else if value.Valid { + bt.Output = value.String + } + case buildtask.FieldError: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field error", values[i]) + } else if value.Valid { + bt.Error = value.String + } + case buildtask.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field build_task_builder", value) + } else if value.Valid { + bt.build_task_builder = new(int) + *bt.build_task_builder = int(value.Int64) + } + default: + bt.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the BuildTask. +// This includes values selected through modifiers, order, etc. +func (bt *BuildTask) Value(name string) (ent.Value, error) { + return bt.selectValues.Get(name) +} + +// QueryBuilder queries the "builder" edge of the BuildTask entity. +func (bt *BuildTask) QueryBuilder() *BuilderQuery { + return NewBuildTaskClient(bt.config).QueryBuilder(bt) +} + +// Update returns a builder for updating this BuildTask. +// Note that you need to call BuildTask.Unwrap() before calling this method if this BuildTask +// was returned from a transaction, and the transaction was committed or rolled back. +func (bt *BuildTask) Update() *BuildTaskUpdateOne { + return NewBuildTaskClient(bt.config).UpdateOne(bt) +} + +// Unwrap unwraps the BuildTask entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (bt *BuildTask) Unwrap() *BuildTask { + _tx, ok := bt.config.driver.(*txDriver) + if !ok { + panic("ent: BuildTask is not a transactional entity") + } + bt.config.driver = _tx.drv + return bt +} + +// String implements the fmt.Stringer. +func (bt *BuildTask) String() string { + var builder strings.Builder + builder.WriteString("BuildTask(") + builder.WriteString(fmt.Sprintf("id=%v, ", bt.ID)) + builder.WriteString("created_at=") + builder.WriteString(bt.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("last_modified_at=") + builder.WriteString(bt.LastModifiedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("target_os=") + builder.WriteString(fmt.Sprintf("%v", bt.TargetOs)) + builder.WriteString(", ") + builder.WriteString("build_image=") + builder.WriteString(bt.BuildImage) + builder.WriteString(", ") + builder.WriteString("build_script=") + builder.WriteString(bt.BuildScript) + builder.WriteString(", ") + builder.WriteString("claimed_at=") + builder.WriteString(bt.ClaimedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("started_at=") + builder.WriteString(bt.StartedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("finished_at=") + builder.WriteString(bt.FinishedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("output=") + builder.WriteString(bt.Output) + builder.WriteString(", ") + builder.WriteString("error=") + builder.WriteString(bt.Error) + builder.WriteByte(')') + return builder.String() +} + +// BuildTasks is a parsable slice of BuildTask. +type BuildTasks []*BuildTask diff --git a/tavern/internal/ent/buildtask/buildtask.go b/tavern/internal/ent/buildtask/buildtask.go new file mode 100644 index 000000000..c1f064b77 --- /dev/null +++ b/tavern/internal/ent/buildtask/buildtask.go @@ -0,0 +1,189 @@ +// Code generated by ent, DO NOT EDIT. + +package buildtask + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/99designs/gqlgen/graphql" + "realm.pub/tavern/internal/c2/c2pb" +) + +const ( + // Label holds the string label denoting the buildtask type in the database. + Label = "build_task" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldLastModifiedAt holds the string denoting the last_modified_at field in the database. + FieldLastModifiedAt = "last_modified_at" + // FieldTargetOs holds the string denoting the target_os field in the database. + FieldTargetOs = "target_os" + // FieldBuildImage holds the string denoting the build_image field in the database. + FieldBuildImage = "build_image" + // FieldBuildScript holds the string denoting the build_script field in the database. + FieldBuildScript = "build_script" + // FieldClaimedAt holds the string denoting the claimed_at field in the database. + FieldClaimedAt = "claimed_at" + // FieldStartedAt holds the string denoting the started_at field in the database. + FieldStartedAt = "started_at" + // FieldFinishedAt holds the string denoting the finished_at field in the database. + FieldFinishedAt = "finished_at" + // FieldOutput holds the string denoting the output field in the database. + FieldOutput = "output" + // FieldError holds the string denoting the error field in the database. + FieldError = "error" + // EdgeBuilder holds the string denoting the builder edge name in mutations. + EdgeBuilder = "builder" + // Table holds the table name of the buildtask in the database. + Table = "build_tasks" + // BuilderTable is the table that holds the builder relation/edge. + BuilderTable = "build_tasks" + // BuilderInverseTable is the table name for the Builder entity. + // It exists in this package in order to avoid circular dependency with the "builder" package. + BuilderInverseTable = "builders" + // BuilderColumn is the table column denoting the builder relation/edge. + BuilderColumn = "build_task_builder" +) + +// Columns holds all SQL columns for buildtask fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldLastModifiedAt, + FieldTargetOs, + FieldBuildImage, + FieldBuildScript, + FieldClaimedAt, + FieldStartedAt, + FieldFinishedAt, + FieldOutput, + FieldError, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "build_tasks" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "build_task_builder", +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultLastModifiedAt holds the default value on creation for the "last_modified_at" field. + DefaultLastModifiedAt func() time.Time + // UpdateDefaultLastModifiedAt holds the default value on update for the "last_modified_at" field. + UpdateDefaultLastModifiedAt func() time.Time + // BuildImageValidator is a validator for the "build_image" field. It is called by the builders before save. + BuildImageValidator func(string) error + // BuildScriptValidator is a validator for the "build_script" field. It is called by the builders before save. + BuildScriptValidator func(string) error +) + +// TargetOsValidator is a validator for the "target_os" field enum values. It is called by the builders before save. +func TargetOsValidator(to c2pb.Host_Platform) error { + switch to.String() { + case "PLATFORM_BSD", "PLATFORM_LINUX", "PLATFORM_MACOS", "PLATFORM_UNSPECIFIED", "PLATFORM_WINDOWS": + return nil + default: + return fmt.Errorf("buildtask: invalid enum value for target_os field: %q", to) + } +} + +// OrderOption defines the ordering options for the BuildTask queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByLastModifiedAt orders the results by the last_modified_at field. +func ByLastModifiedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastModifiedAt, opts...).ToFunc() +} + +// ByTargetOs orders the results by the target_os field. +func ByTargetOs(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTargetOs, opts...).ToFunc() +} + +// ByBuildImage orders the results by the build_image field. +func ByBuildImage(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBuildImage, opts...).ToFunc() +} + +// ByBuildScript orders the results by the build_script field. +func ByBuildScript(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBuildScript, opts...).ToFunc() +} + +// ByClaimedAt orders the results by the claimed_at field. +func ByClaimedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldClaimedAt, opts...).ToFunc() +} + +// ByStartedAt orders the results by the started_at field. +func ByStartedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStartedAt, opts...).ToFunc() +} + +// ByFinishedAt orders the results by the finished_at field. +func ByFinishedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFinishedAt, opts...).ToFunc() +} + +// ByOutput orders the results by the output field. +func ByOutput(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOutput, opts...).ToFunc() +} + +// ByError orders the results by the error field. +func ByError(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldError, opts...).ToFunc() +} + +// ByBuilderField orders the results by builder field. +func ByBuilderField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newBuilderStep(), sql.OrderByField(field, opts...)) + } +} +func newBuilderStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(BuilderInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, BuilderTable, BuilderColumn), + ) +} + +var ( + // c2pb.Host_Platform must implement graphql.Marshaler. + _ graphql.Marshaler = (*c2pb.Host_Platform)(nil) + // c2pb.Host_Platform must implement graphql.Unmarshaler. + _ graphql.Unmarshaler = (*c2pb.Host_Platform)(nil) +) diff --git a/tavern/internal/ent/buildtask/where.go b/tavern/internal/ent/buildtask/where.go new file mode 100644 index 000000000..597121c12 --- /dev/null +++ b/tavern/internal/ent/buildtask/where.go @@ -0,0 +1,670 @@ +// Code generated by ent, DO NOT EDIT. + +package buildtask + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldCreatedAt, v)) +} + +// LastModifiedAt applies equality check predicate on the "last_modified_at" field. It's identical to LastModifiedAtEQ. +func LastModifiedAt(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// BuildImage applies equality check predicate on the "build_image" field. It's identical to BuildImageEQ. +func BuildImage(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldBuildImage, v)) +} + +// BuildScript applies equality check predicate on the "build_script" field. It's identical to BuildScriptEQ. +func BuildScript(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldBuildScript, v)) +} + +// ClaimedAt applies equality check predicate on the "claimed_at" field. It's identical to ClaimedAtEQ. +func ClaimedAt(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldClaimedAt, v)) +} + +// StartedAt applies equality check predicate on the "started_at" field. It's identical to StartedAtEQ. +func StartedAt(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldStartedAt, v)) +} + +// FinishedAt applies equality check predicate on the "finished_at" field. It's identical to FinishedAtEQ. +func FinishedAt(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldFinishedAt, v)) +} + +// Output applies equality check predicate on the "output" field. It's identical to OutputEQ. +func Output(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldOutput, v)) +} + +// Error applies equality check predicate on the "error" field. It's identical to ErrorEQ. +func Error(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldError, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldCreatedAt, v)) +} + +// LastModifiedAtEQ applies the EQ predicate on the "last_modified_at" field. +func LastModifiedAtEQ(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtNEQ applies the NEQ predicate on the "last_modified_at" field. +func LastModifiedAtNEQ(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtIn applies the In predicate on the "last_modified_at" field. +func LastModifiedAtIn(vs ...time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtNotIn applies the NotIn predicate on the "last_modified_at" field. +func LastModifiedAtNotIn(vs ...time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtGT applies the GT predicate on the "last_modified_at" field. +func LastModifiedAtGT(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtGTE applies the GTE predicate on the "last_modified_at" field. +func LastModifiedAtGTE(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLT applies the LT predicate on the "last_modified_at" field. +func LastModifiedAtLT(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLTE applies the LTE predicate on the "last_modified_at" field. +func LastModifiedAtLTE(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldLastModifiedAt, v)) +} + +// TargetOsEQ applies the EQ predicate on the "target_os" field. +func TargetOsEQ(v c2pb.Host_Platform) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldTargetOs, v)) +} + +// TargetOsNEQ applies the NEQ predicate on the "target_os" field. +func TargetOsNEQ(v c2pb.Host_Platform) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldTargetOs, v)) +} + +// TargetOsIn applies the In predicate on the "target_os" field. +func TargetOsIn(vs ...c2pb.Host_Platform) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldTargetOs, vs...)) +} + +// TargetOsNotIn applies the NotIn predicate on the "target_os" field. +func TargetOsNotIn(vs ...c2pb.Host_Platform) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldTargetOs, vs...)) +} + +// BuildImageEQ applies the EQ predicate on the "build_image" field. +func BuildImageEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldBuildImage, v)) +} + +// BuildImageNEQ applies the NEQ predicate on the "build_image" field. +func BuildImageNEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldBuildImage, v)) +} + +// BuildImageIn applies the In predicate on the "build_image" field. +func BuildImageIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldBuildImage, vs...)) +} + +// BuildImageNotIn applies the NotIn predicate on the "build_image" field. +func BuildImageNotIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldBuildImage, vs...)) +} + +// BuildImageGT applies the GT predicate on the "build_image" field. +func BuildImageGT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldBuildImage, v)) +} + +// BuildImageGTE applies the GTE predicate on the "build_image" field. +func BuildImageGTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldBuildImage, v)) +} + +// BuildImageLT applies the LT predicate on the "build_image" field. +func BuildImageLT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldBuildImage, v)) +} + +// BuildImageLTE applies the LTE predicate on the "build_image" field. +func BuildImageLTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldBuildImage, v)) +} + +// BuildImageContains applies the Contains predicate on the "build_image" field. +func BuildImageContains(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContains(FieldBuildImage, v)) +} + +// BuildImageHasPrefix applies the HasPrefix predicate on the "build_image" field. +func BuildImageHasPrefix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasPrefix(FieldBuildImage, v)) +} + +// BuildImageHasSuffix applies the HasSuffix predicate on the "build_image" field. +func BuildImageHasSuffix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasSuffix(FieldBuildImage, v)) +} + +// BuildImageEqualFold applies the EqualFold predicate on the "build_image" field. +func BuildImageEqualFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEqualFold(FieldBuildImage, v)) +} + +// BuildImageContainsFold applies the ContainsFold predicate on the "build_image" field. +func BuildImageContainsFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContainsFold(FieldBuildImage, v)) +} + +// BuildScriptEQ applies the EQ predicate on the "build_script" field. +func BuildScriptEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldBuildScript, v)) +} + +// BuildScriptNEQ applies the NEQ predicate on the "build_script" field. +func BuildScriptNEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldBuildScript, v)) +} + +// BuildScriptIn applies the In predicate on the "build_script" field. +func BuildScriptIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldBuildScript, vs...)) +} + +// BuildScriptNotIn applies the NotIn predicate on the "build_script" field. +func BuildScriptNotIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldBuildScript, vs...)) +} + +// BuildScriptGT applies the GT predicate on the "build_script" field. +func BuildScriptGT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldBuildScript, v)) +} + +// BuildScriptGTE applies the GTE predicate on the "build_script" field. +func BuildScriptGTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldBuildScript, v)) +} + +// BuildScriptLT applies the LT predicate on the "build_script" field. +func BuildScriptLT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldBuildScript, v)) +} + +// BuildScriptLTE applies the LTE predicate on the "build_script" field. +func BuildScriptLTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldBuildScript, v)) +} + +// BuildScriptContains applies the Contains predicate on the "build_script" field. +func BuildScriptContains(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContains(FieldBuildScript, v)) +} + +// BuildScriptHasPrefix applies the HasPrefix predicate on the "build_script" field. +func BuildScriptHasPrefix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasPrefix(FieldBuildScript, v)) +} + +// BuildScriptHasSuffix applies the HasSuffix predicate on the "build_script" field. +func BuildScriptHasSuffix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasSuffix(FieldBuildScript, v)) +} + +// BuildScriptEqualFold applies the EqualFold predicate on the "build_script" field. +func BuildScriptEqualFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEqualFold(FieldBuildScript, v)) +} + +// BuildScriptContainsFold applies the ContainsFold predicate on the "build_script" field. +func BuildScriptContainsFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContainsFold(FieldBuildScript, v)) +} + +// ClaimedAtEQ applies the EQ predicate on the "claimed_at" field. +func ClaimedAtEQ(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldClaimedAt, v)) +} + +// ClaimedAtNEQ applies the NEQ predicate on the "claimed_at" field. +func ClaimedAtNEQ(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldClaimedAt, v)) +} + +// ClaimedAtIn applies the In predicate on the "claimed_at" field. +func ClaimedAtIn(vs ...time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldClaimedAt, vs...)) +} + +// ClaimedAtNotIn applies the NotIn predicate on the "claimed_at" field. +func ClaimedAtNotIn(vs ...time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldClaimedAt, vs...)) +} + +// ClaimedAtGT applies the GT predicate on the "claimed_at" field. +func ClaimedAtGT(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldClaimedAt, v)) +} + +// ClaimedAtGTE applies the GTE predicate on the "claimed_at" field. +func ClaimedAtGTE(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldClaimedAt, v)) +} + +// ClaimedAtLT applies the LT predicate on the "claimed_at" field. +func ClaimedAtLT(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldClaimedAt, v)) +} + +// ClaimedAtLTE applies the LTE predicate on the "claimed_at" field. +func ClaimedAtLTE(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldClaimedAt, v)) +} + +// ClaimedAtIsNil applies the IsNil predicate on the "claimed_at" field. +func ClaimedAtIsNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldIsNull(FieldClaimedAt)) +} + +// ClaimedAtNotNil applies the NotNil predicate on the "claimed_at" field. +func ClaimedAtNotNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotNull(FieldClaimedAt)) +} + +// StartedAtEQ applies the EQ predicate on the "started_at" field. +func StartedAtEQ(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldStartedAt, v)) +} + +// StartedAtNEQ applies the NEQ predicate on the "started_at" field. +func StartedAtNEQ(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldStartedAt, v)) +} + +// StartedAtIn applies the In predicate on the "started_at" field. +func StartedAtIn(vs ...time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldStartedAt, vs...)) +} + +// StartedAtNotIn applies the NotIn predicate on the "started_at" field. +func StartedAtNotIn(vs ...time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldStartedAt, vs...)) +} + +// StartedAtGT applies the GT predicate on the "started_at" field. +func StartedAtGT(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldStartedAt, v)) +} + +// StartedAtGTE applies the GTE predicate on the "started_at" field. +func StartedAtGTE(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldStartedAt, v)) +} + +// StartedAtLT applies the LT predicate on the "started_at" field. +func StartedAtLT(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldStartedAt, v)) +} + +// StartedAtLTE applies the LTE predicate on the "started_at" field. +func StartedAtLTE(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldStartedAt, v)) +} + +// StartedAtIsNil applies the IsNil predicate on the "started_at" field. +func StartedAtIsNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldIsNull(FieldStartedAt)) +} + +// StartedAtNotNil applies the NotNil predicate on the "started_at" field. +func StartedAtNotNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotNull(FieldStartedAt)) +} + +// FinishedAtEQ applies the EQ predicate on the "finished_at" field. +func FinishedAtEQ(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldFinishedAt, v)) +} + +// FinishedAtNEQ applies the NEQ predicate on the "finished_at" field. +func FinishedAtNEQ(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldFinishedAt, v)) +} + +// FinishedAtIn applies the In predicate on the "finished_at" field. +func FinishedAtIn(vs ...time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldFinishedAt, vs...)) +} + +// FinishedAtNotIn applies the NotIn predicate on the "finished_at" field. +func FinishedAtNotIn(vs ...time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldFinishedAt, vs...)) +} + +// FinishedAtGT applies the GT predicate on the "finished_at" field. +func FinishedAtGT(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldFinishedAt, v)) +} + +// FinishedAtGTE applies the GTE predicate on the "finished_at" field. +func FinishedAtGTE(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldFinishedAt, v)) +} + +// FinishedAtLT applies the LT predicate on the "finished_at" field. +func FinishedAtLT(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldFinishedAt, v)) +} + +// FinishedAtLTE applies the LTE predicate on the "finished_at" field. +func FinishedAtLTE(v time.Time) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldFinishedAt, v)) +} + +// FinishedAtIsNil applies the IsNil predicate on the "finished_at" field. +func FinishedAtIsNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldIsNull(FieldFinishedAt)) +} + +// FinishedAtNotNil applies the NotNil predicate on the "finished_at" field. +func FinishedAtNotNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotNull(FieldFinishedAt)) +} + +// OutputEQ applies the EQ predicate on the "output" field. +func OutputEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldOutput, v)) +} + +// OutputNEQ applies the NEQ predicate on the "output" field. +func OutputNEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldOutput, v)) +} + +// OutputIn applies the In predicate on the "output" field. +func OutputIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldOutput, vs...)) +} + +// OutputNotIn applies the NotIn predicate on the "output" field. +func OutputNotIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldOutput, vs...)) +} + +// OutputGT applies the GT predicate on the "output" field. +func OutputGT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldOutput, v)) +} + +// OutputGTE applies the GTE predicate on the "output" field. +func OutputGTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldOutput, v)) +} + +// OutputLT applies the LT predicate on the "output" field. +func OutputLT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldOutput, v)) +} + +// OutputLTE applies the LTE predicate on the "output" field. +func OutputLTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldOutput, v)) +} + +// OutputContains applies the Contains predicate on the "output" field. +func OutputContains(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContains(FieldOutput, v)) +} + +// OutputHasPrefix applies the HasPrefix predicate on the "output" field. +func OutputHasPrefix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasPrefix(FieldOutput, v)) +} + +// OutputHasSuffix applies the HasSuffix predicate on the "output" field. +func OutputHasSuffix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasSuffix(FieldOutput, v)) +} + +// OutputIsNil applies the IsNil predicate on the "output" field. +func OutputIsNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldIsNull(FieldOutput)) +} + +// OutputNotNil applies the NotNil predicate on the "output" field. +func OutputNotNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotNull(FieldOutput)) +} + +// OutputEqualFold applies the EqualFold predicate on the "output" field. +func OutputEqualFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEqualFold(FieldOutput, v)) +} + +// OutputContainsFold applies the ContainsFold predicate on the "output" field. +func OutputContainsFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContainsFold(FieldOutput, v)) +} + +// ErrorEQ applies the EQ predicate on the "error" field. +func ErrorEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldError, v)) +} + +// ErrorNEQ applies the NEQ predicate on the "error" field. +func ErrorNEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldError, v)) +} + +// ErrorIn applies the In predicate on the "error" field. +func ErrorIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldError, vs...)) +} + +// ErrorNotIn applies the NotIn predicate on the "error" field. +func ErrorNotIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldError, vs...)) +} + +// ErrorGT applies the GT predicate on the "error" field. +func ErrorGT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldError, v)) +} + +// ErrorGTE applies the GTE predicate on the "error" field. +func ErrorGTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldError, v)) +} + +// ErrorLT applies the LT predicate on the "error" field. +func ErrorLT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldError, v)) +} + +// ErrorLTE applies the LTE predicate on the "error" field. +func ErrorLTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldError, v)) +} + +// ErrorContains applies the Contains predicate on the "error" field. +func ErrorContains(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContains(FieldError, v)) +} + +// ErrorHasPrefix applies the HasPrefix predicate on the "error" field. +func ErrorHasPrefix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasPrefix(FieldError, v)) +} + +// ErrorHasSuffix applies the HasSuffix predicate on the "error" field. +func ErrorHasSuffix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasSuffix(FieldError, v)) +} + +// ErrorIsNil applies the IsNil predicate on the "error" field. +func ErrorIsNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldIsNull(FieldError)) +} + +// ErrorNotNil applies the NotNil predicate on the "error" field. +func ErrorNotNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotNull(FieldError)) +} + +// ErrorEqualFold applies the EqualFold predicate on the "error" field. +func ErrorEqualFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEqualFold(FieldError, v)) +} + +// ErrorContainsFold applies the ContainsFold predicate on the "error" field. +func ErrorContainsFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContainsFold(FieldError, v)) +} + +// HasBuilder applies the HasEdge predicate on the "builder" edge. +func HasBuilder() predicate.BuildTask { + return predicate.BuildTask(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, BuilderTable, BuilderColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasBuilderWith applies the HasEdge predicate on the "builder" edge with a given conditions (other predicates). +func HasBuilderWith(preds ...predicate.Builder) predicate.BuildTask { + return predicate.BuildTask(func(s *sql.Selector) { + step := newBuilderStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.BuildTask) predicate.BuildTask { + return predicate.BuildTask(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.BuildTask) predicate.BuildTask { + return predicate.BuildTask(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.BuildTask) predicate.BuildTask { + return predicate.BuildTask(sql.NotPredicates(p)) +} diff --git a/tavern/internal/ent/buildtask_create.go b/tavern/internal/ent/buildtask_create.go new file mode 100644 index 000000000..e2660cc1e --- /dev/null +++ b/tavern/internal/ent/buildtask_create.go @@ -0,0 +1,1107 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" +) + +// BuildTaskCreate is the builder for creating a BuildTask entity. +type BuildTaskCreate struct { + config + mutation *BuildTaskMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreatedAt sets the "created_at" field. +func (btc *BuildTaskCreate) SetCreatedAt(t time.Time) *BuildTaskCreate { + btc.mutation.SetCreatedAt(t) + return btc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableCreatedAt(t *time.Time) *BuildTaskCreate { + if t != nil { + btc.SetCreatedAt(*t) + } + return btc +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (btc *BuildTaskCreate) SetLastModifiedAt(t time.Time) *BuildTaskCreate { + btc.mutation.SetLastModifiedAt(t) + return btc +} + +// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableLastModifiedAt(t *time.Time) *BuildTaskCreate { + if t != nil { + btc.SetLastModifiedAt(*t) + } + return btc +} + +// SetTargetOs sets the "target_os" field. +func (btc *BuildTaskCreate) SetTargetOs(cp c2pb.Host_Platform) *BuildTaskCreate { + btc.mutation.SetTargetOs(cp) + return btc +} + +// SetBuildImage sets the "build_image" field. +func (btc *BuildTaskCreate) SetBuildImage(s string) *BuildTaskCreate { + btc.mutation.SetBuildImage(s) + return btc +} + +// SetBuildScript sets the "build_script" field. +func (btc *BuildTaskCreate) SetBuildScript(s string) *BuildTaskCreate { + btc.mutation.SetBuildScript(s) + return btc +} + +// SetClaimedAt sets the "claimed_at" field. +func (btc *BuildTaskCreate) SetClaimedAt(t time.Time) *BuildTaskCreate { + btc.mutation.SetClaimedAt(t) + return btc +} + +// SetNillableClaimedAt sets the "claimed_at" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableClaimedAt(t *time.Time) *BuildTaskCreate { + if t != nil { + btc.SetClaimedAt(*t) + } + return btc +} + +// SetStartedAt sets the "started_at" field. +func (btc *BuildTaskCreate) SetStartedAt(t time.Time) *BuildTaskCreate { + btc.mutation.SetStartedAt(t) + return btc +} + +// SetNillableStartedAt sets the "started_at" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableStartedAt(t *time.Time) *BuildTaskCreate { + if t != nil { + btc.SetStartedAt(*t) + } + return btc +} + +// SetFinishedAt sets the "finished_at" field. +func (btc *BuildTaskCreate) SetFinishedAt(t time.Time) *BuildTaskCreate { + btc.mutation.SetFinishedAt(t) + return btc +} + +// SetNillableFinishedAt sets the "finished_at" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableFinishedAt(t *time.Time) *BuildTaskCreate { + if t != nil { + btc.SetFinishedAt(*t) + } + return btc +} + +// SetOutput sets the "output" field. +func (btc *BuildTaskCreate) SetOutput(s string) *BuildTaskCreate { + btc.mutation.SetOutput(s) + return btc +} + +// SetNillableOutput sets the "output" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableOutput(s *string) *BuildTaskCreate { + if s != nil { + btc.SetOutput(*s) + } + return btc +} + +// SetError sets the "error" field. +func (btc *BuildTaskCreate) SetError(s string) *BuildTaskCreate { + btc.mutation.SetError(s) + return btc +} + +// SetNillableError sets the "error" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableError(s *string) *BuildTaskCreate { + if s != nil { + btc.SetError(*s) + } + return btc +} + +// SetBuilderID sets the "builder" edge to the Builder entity by ID. +func (btc *BuildTaskCreate) SetBuilderID(id int) *BuildTaskCreate { + btc.mutation.SetBuilderID(id) + return btc +} + +// SetBuilder sets the "builder" edge to the Builder entity. +func (btc *BuildTaskCreate) SetBuilder(b *Builder) *BuildTaskCreate { + return btc.SetBuilderID(b.ID) +} + +// Mutation returns the BuildTaskMutation object of the builder. +func (btc *BuildTaskCreate) Mutation() *BuildTaskMutation { + return btc.mutation +} + +// Save creates the BuildTask in the database. +func (btc *BuildTaskCreate) Save(ctx context.Context) (*BuildTask, error) { + btc.defaults() + return withHooks(ctx, btc.sqlSave, btc.mutation, btc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (btc *BuildTaskCreate) SaveX(ctx context.Context) *BuildTask { + v, err := btc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (btc *BuildTaskCreate) Exec(ctx context.Context) error { + _, err := btc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (btc *BuildTaskCreate) ExecX(ctx context.Context) { + if err := btc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (btc *BuildTaskCreate) defaults() { + if _, ok := btc.mutation.CreatedAt(); !ok { + v := buildtask.DefaultCreatedAt() + btc.mutation.SetCreatedAt(v) + } + if _, ok := btc.mutation.LastModifiedAt(); !ok { + v := buildtask.DefaultLastModifiedAt() + btc.mutation.SetLastModifiedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (btc *BuildTaskCreate) check() error { + if _, ok := btc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "BuildTask.created_at"`)} + } + if _, ok := btc.mutation.LastModifiedAt(); !ok { + return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "BuildTask.last_modified_at"`)} + } + if _, ok := btc.mutation.TargetOs(); !ok { + return &ValidationError{Name: "target_os", err: errors.New(`ent: missing required field "BuildTask.target_os"`)} + } + if v, ok := btc.mutation.TargetOs(); ok { + if err := buildtask.TargetOsValidator(v); err != nil { + return &ValidationError{Name: "target_os", err: fmt.Errorf(`ent: validator failed for field "BuildTask.target_os": %w`, err)} + } + } + if _, ok := btc.mutation.BuildImage(); !ok { + return &ValidationError{Name: "build_image", err: errors.New(`ent: missing required field "BuildTask.build_image"`)} + } + if v, ok := btc.mutation.BuildImage(); ok { + if err := buildtask.BuildImageValidator(v); err != nil { + return &ValidationError{Name: "build_image", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_image": %w`, err)} + } + } + if _, ok := btc.mutation.BuildScript(); !ok { + return &ValidationError{Name: "build_script", err: errors.New(`ent: missing required field "BuildTask.build_script"`)} + } + if v, ok := btc.mutation.BuildScript(); ok { + if err := buildtask.BuildScriptValidator(v); err != nil { + return &ValidationError{Name: "build_script", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_script": %w`, err)} + } + } + if len(btc.mutation.BuilderIDs()) == 0 { + return &ValidationError{Name: "builder", err: errors.New(`ent: missing required edge "BuildTask.builder"`)} + } + return nil +} + +func (btc *BuildTaskCreate) sqlSave(ctx context.Context) (*BuildTask, error) { + if err := btc.check(); err != nil { + return nil, err + } + _node, _spec := btc.createSpec() + if err := sqlgraph.CreateNode(ctx, btc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + btc.mutation.id = &_node.ID + btc.mutation.done = true + return _node, nil +} + +func (btc *BuildTaskCreate) createSpec() (*BuildTask, *sqlgraph.CreateSpec) { + var ( + _node = &BuildTask{config: btc.config} + _spec = sqlgraph.NewCreateSpec(buildtask.Table, sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt)) + ) + _spec.OnConflict = btc.conflict + if value, ok := btc.mutation.CreatedAt(); ok { + _spec.SetField(buildtask.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := btc.mutation.LastModifiedAt(); ok { + _spec.SetField(buildtask.FieldLastModifiedAt, field.TypeTime, value) + _node.LastModifiedAt = value + } + if value, ok := btc.mutation.TargetOs(); ok { + _spec.SetField(buildtask.FieldTargetOs, field.TypeEnum, value) + _node.TargetOs = value + } + if value, ok := btc.mutation.BuildImage(); ok { + _spec.SetField(buildtask.FieldBuildImage, field.TypeString, value) + _node.BuildImage = value + } + if value, ok := btc.mutation.BuildScript(); ok { + _spec.SetField(buildtask.FieldBuildScript, field.TypeString, value) + _node.BuildScript = value + } + if value, ok := btc.mutation.ClaimedAt(); ok { + _spec.SetField(buildtask.FieldClaimedAt, field.TypeTime, value) + _node.ClaimedAt = value + } + if value, ok := btc.mutation.StartedAt(); ok { + _spec.SetField(buildtask.FieldStartedAt, field.TypeTime, value) + _node.StartedAt = value + } + if value, ok := btc.mutation.FinishedAt(); ok { + _spec.SetField(buildtask.FieldFinishedAt, field.TypeTime, value) + _node.FinishedAt = value + } + if value, ok := btc.mutation.Output(); ok { + _spec.SetField(buildtask.FieldOutput, field.TypeString, value) + _node.Output = value + } + if value, ok := btc.mutation.Error(); ok { + _spec.SetField(buildtask.FieldError, field.TypeString, value) + _node.Error = value + } + if nodes := btc.mutation.BuilderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: buildtask.BuilderTable, + Columns: []string{buildtask.BuilderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.build_task_builder = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.BuildTask.Create(). +// SetCreatedAt(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.BuildTaskUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (btc *BuildTaskCreate) OnConflict(opts ...sql.ConflictOption) *BuildTaskUpsertOne { + btc.conflict = opts + return &BuildTaskUpsertOne{ + create: btc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.BuildTask.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (btc *BuildTaskCreate) OnConflictColumns(columns ...string) *BuildTaskUpsertOne { + btc.conflict = append(btc.conflict, sql.ConflictColumns(columns...)) + return &BuildTaskUpsertOne{ + create: btc, + } +} + +type ( + // BuildTaskUpsertOne is the builder for "upsert"-ing + // one BuildTask node. + BuildTaskUpsertOne struct { + create *BuildTaskCreate + } + + // BuildTaskUpsert is the "OnConflict" setter. + BuildTaskUpsert struct { + *sql.UpdateSet + } +) + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BuildTaskUpsert) SetLastModifiedAt(v time.Time) *BuildTaskUpsert { + u.Set(buildtask.FieldLastModifiedAt, v) + return u +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateLastModifiedAt() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldLastModifiedAt) + return u +} + +// SetTargetOs sets the "target_os" field. +func (u *BuildTaskUpsert) SetTargetOs(v c2pb.Host_Platform) *BuildTaskUpsert { + u.Set(buildtask.FieldTargetOs, v) + return u +} + +// UpdateTargetOs sets the "target_os" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateTargetOs() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldTargetOs) + return u +} + +// SetBuildImage sets the "build_image" field. +func (u *BuildTaskUpsert) SetBuildImage(v string) *BuildTaskUpsert { + u.Set(buildtask.FieldBuildImage, v) + return u +} + +// UpdateBuildImage sets the "build_image" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateBuildImage() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldBuildImage) + return u +} + +// SetBuildScript sets the "build_script" field. +func (u *BuildTaskUpsert) SetBuildScript(v string) *BuildTaskUpsert { + u.Set(buildtask.FieldBuildScript, v) + return u +} + +// UpdateBuildScript sets the "build_script" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateBuildScript() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldBuildScript) + return u +} + +// SetClaimedAt sets the "claimed_at" field. +func (u *BuildTaskUpsert) SetClaimedAt(v time.Time) *BuildTaskUpsert { + u.Set(buildtask.FieldClaimedAt, v) + return u +} + +// UpdateClaimedAt sets the "claimed_at" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateClaimedAt() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldClaimedAt) + return u +} + +// ClearClaimedAt clears the value of the "claimed_at" field. +func (u *BuildTaskUpsert) ClearClaimedAt() *BuildTaskUpsert { + u.SetNull(buildtask.FieldClaimedAt) + return u +} + +// SetStartedAt sets the "started_at" field. +func (u *BuildTaskUpsert) SetStartedAt(v time.Time) *BuildTaskUpsert { + u.Set(buildtask.FieldStartedAt, v) + return u +} + +// UpdateStartedAt sets the "started_at" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateStartedAt() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldStartedAt) + return u +} + +// ClearStartedAt clears the value of the "started_at" field. +func (u *BuildTaskUpsert) ClearStartedAt() *BuildTaskUpsert { + u.SetNull(buildtask.FieldStartedAt) + return u +} + +// SetFinishedAt sets the "finished_at" field. +func (u *BuildTaskUpsert) SetFinishedAt(v time.Time) *BuildTaskUpsert { + u.Set(buildtask.FieldFinishedAt, v) + return u +} + +// UpdateFinishedAt sets the "finished_at" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateFinishedAt() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldFinishedAt) + return u +} + +// ClearFinishedAt clears the value of the "finished_at" field. +func (u *BuildTaskUpsert) ClearFinishedAt() *BuildTaskUpsert { + u.SetNull(buildtask.FieldFinishedAt) + return u +} + +// SetOutput sets the "output" field. +func (u *BuildTaskUpsert) SetOutput(v string) *BuildTaskUpsert { + u.Set(buildtask.FieldOutput, v) + return u +} + +// UpdateOutput sets the "output" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateOutput() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldOutput) + return u +} + +// ClearOutput clears the value of the "output" field. +func (u *BuildTaskUpsert) ClearOutput() *BuildTaskUpsert { + u.SetNull(buildtask.FieldOutput) + return u +} + +// SetError sets the "error" field. +func (u *BuildTaskUpsert) SetError(v string) *BuildTaskUpsert { + u.Set(buildtask.FieldError, v) + return u +} + +// UpdateError sets the "error" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateError() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldError) + return u +} + +// ClearError clears the value of the "error" field. +func (u *BuildTaskUpsert) ClearError() *BuildTaskUpsert { + u.SetNull(buildtask.FieldError) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.BuildTask.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *BuildTaskUpsertOne) UpdateNewValues() *BuildTaskUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(buildtask.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.BuildTask.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *BuildTaskUpsertOne) Ignore() *BuildTaskUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *BuildTaskUpsertOne) DoNothing() *BuildTaskUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the BuildTaskCreate.OnConflict +// documentation for more info. +func (u *BuildTaskUpsertOne) Update(set func(*BuildTaskUpsert)) *BuildTaskUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&BuildTaskUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BuildTaskUpsertOne) SetLastModifiedAt(v time.Time) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateLastModifiedAt() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetTargetOs sets the "target_os" field. +func (u *BuildTaskUpsertOne) SetTargetOs(v c2pb.Host_Platform) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetTargetOs(v) + }) +} + +// UpdateTargetOs sets the "target_os" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateTargetOs() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateTargetOs() + }) +} + +// SetBuildImage sets the "build_image" field. +func (u *BuildTaskUpsertOne) SetBuildImage(v string) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetBuildImage(v) + }) +} + +// UpdateBuildImage sets the "build_image" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateBuildImage() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateBuildImage() + }) +} + +// SetBuildScript sets the "build_script" field. +func (u *BuildTaskUpsertOne) SetBuildScript(v string) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetBuildScript(v) + }) +} + +// UpdateBuildScript sets the "build_script" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateBuildScript() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateBuildScript() + }) +} + +// SetClaimedAt sets the "claimed_at" field. +func (u *BuildTaskUpsertOne) SetClaimedAt(v time.Time) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetClaimedAt(v) + }) +} + +// UpdateClaimedAt sets the "claimed_at" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateClaimedAt() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateClaimedAt() + }) +} + +// ClearClaimedAt clears the value of the "claimed_at" field. +func (u *BuildTaskUpsertOne) ClearClaimedAt() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearClaimedAt() + }) +} + +// SetStartedAt sets the "started_at" field. +func (u *BuildTaskUpsertOne) SetStartedAt(v time.Time) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetStartedAt(v) + }) +} + +// UpdateStartedAt sets the "started_at" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateStartedAt() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateStartedAt() + }) +} + +// ClearStartedAt clears the value of the "started_at" field. +func (u *BuildTaskUpsertOne) ClearStartedAt() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearStartedAt() + }) +} + +// SetFinishedAt sets the "finished_at" field. +func (u *BuildTaskUpsertOne) SetFinishedAt(v time.Time) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetFinishedAt(v) + }) +} + +// UpdateFinishedAt sets the "finished_at" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateFinishedAt() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateFinishedAt() + }) +} + +// ClearFinishedAt clears the value of the "finished_at" field. +func (u *BuildTaskUpsertOne) ClearFinishedAt() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearFinishedAt() + }) +} + +// SetOutput sets the "output" field. +func (u *BuildTaskUpsertOne) SetOutput(v string) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetOutput(v) + }) +} + +// UpdateOutput sets the "output" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateOutput() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateOutput() + }) +} + +// ClearOutput clears the value of the "output" field. +func (u *BuildTaskUpsertOne) ClearOutput() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearOutput() + }) +} + +// SetError sets the "error" field. +func (u *BuildTaskUpsertOne) SetError(v string) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetError(v) + }) +} + +// UpdateError sets the "error" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateError() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateError() + }) +} + +// ClearError clears the value of the "error" field. +func (u *BuildTaskUpsertOne) ClearError() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearError() + }) +} + +// Exec executes the query. +func (u *BuildTaskUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for BuildTaskCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *BuildTaskUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *BuildTaskUpsertOne) ID(ctx context.Context) (id int, err error) { + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *BuildTaskUpsertOne) IDX(ctx context.Context) int { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// BuildTaskCreateBulk is the builder for creating many BuildTask entities in bulk. +type BuildTaskCreateBulk struct { + config + err error + builders []*BuildTaskCreate + conflict []sql.ConflictOption +} + +// Save creates the BuildTask entities in the database. +func (btcb *BuildTaskCreateBulk) Save(ctx context.Context) ([]*BuildTask, error) { + if btcb.err != nil { + return nil, btcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(btcb.builders)) + nodes := make([]*BuildTask, len(btcb.builders)) + mutators := make([]Mutator, len(btcb.builders)) + for i := range btcb.builders { + func(i int, root context.Context) { + builder := btcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*BuildTaskMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, btcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = btcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, btcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, btcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (btcb *BuildTaskCreateBulk) SaveX(ctx context.Context) []*BuildTask { + v, err := btcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (btcb *BuildTaskCreateBulk) Exec(ctx context.Context) error { + _, err := btcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (btcb *BuildTaskCreateBulk) ExecX(ctx context.Context) { + if err := btcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.BuildTask.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.BuildTaskUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (btcb *BuildTaskCreateBulk) OnConflict(opts ...sql.ConflictOption) *BuildTaskUpsertBulk { + btcb.conflict = opts + return &BuildTaskUpsertBulk{ + create: btcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.BuildTask.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (btcb *BuildTaskCreateBulk) OnConflictColumns(columns ...string) *BuildTaskUpsertBulk { + btcb.conflict = append(btcb.conflict, sql.ConflictColumns(columns...)) + return &BuildTaskUpsertBulk{ + create: btcb, + } +} + +// BuildTaskUpsertBulk is the builder for "upsert"-ing +// a bulk of BuildTask nodes. +type BuildTaskUpsertBulk struct { + create *BuildTaskCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.BuildTask.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *BuildTaskUpsertBulk) UpdateNewValues() *BuildTaskUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(buildtask.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.BuildTask.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *BuildTaskUpsertBulk) Ignore() *BuildTaskUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *BuildTaskUpsertBulk) DoNothing() *BuildTaskUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the BuildTaskCreateBulk.OnConflict +// documentation for more info. +func (u *BuildTaskUpsertBulk) Update(set func(*BuildTaskUpsert)) *BuildTaskUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&BuildTaskUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BuildTaskUpsertBulk) SetLastModifiedAt(v time.Time) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateLastModifiedAt() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetTargetOs sets the "target_os" field. +func (u *BuildTaskUpsertBulk) SetTargetOs(v c2pb.Host_Platform) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetTargetOs(v) + }) +} + +// UpdateTargetOs sets the "target_os" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateTargetOs() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateTargetOs() + }) +} + +// SetBuildImage sets the "build_image" field. +func (u *BuildTaskUpsertBulk) SetBuildImage(v string) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetBuildImage(v) + }) +} + +// UpdateBuildImage sets the "build_image" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateBuildImage() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateBuildImage() + }) +} + +// SetBuildScript sets the "build_script" field. +func (u *BuildTaskUpsertBulk) SetBuildScript(v string) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetBuildScript(v) + }) +} + +// UpdateBuildScript sets the "build_script" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateBuildScript() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateBuildScript() + }) +} + +// SetClaimedAt sets the "claimed_at" field. +func (u *BuildTaskUpsertBulk) SetClaimedAt(v time.Time) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetClaimedAt(v) + }) +} + +// UpdateClaimedAt sets the "claimed_at" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateClaimedAt() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateClaimedAt() + }) +} + +// ClearClaimedAt clears the value of the "claimed_at" field. +func (u *BuildTaskUpsertBulk) ClearClaimedAt() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearClaimedAt() + }) +} + +// SetStartedAt sets the "started_at" field. +func (u *BuildTaskUpsertBulk) SetStartedAt(v time.Time) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetStartedAt(v) + }) +} + +// UpdateStartedAt sets the "started_at" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateStartedAt() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateStartedAt() + }) +} + +// ClearStartedAt clears the value of the "started_at" field. +func (u *BuildTaskUpsertBulk) ClearStartedAt() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearStartedAt() + }) +} + +// SetFinishedAt sets the "finished_at" field. +func (u *BuildTaskUpsertBulk) SetFinishedAt(v time.Time) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetFinishedAt(v) + }) +} + +// UpdateFinishedAt sets the "finished_at" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateFinishedAt() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateFinishedAt() + }) +} + +// ClearFinishedAt clears the value of the "finished_at" field. +func (u *BuildTaskUpsertBulk) ClearFinishedAt() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearFinishedAt() + }) +} + +// SetOutput sets the "output" field. +func (u *BuildTaskUpsertBulk) SetOutput(v string) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetOutput(v) + }) +} + +// UpdateOutput sets the "output" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateOutput() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateOutput() + }) +} + +// ClearOutput clears the value of the "output" field. +func (u *BuildTaskUpsertBulk) ClearOutput() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearOutput() + }) +} + +// SetError sets the "error" field. +func (u *BuildTaskUpsertBulk) SetError(v string) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetError(v) + }) +} + +// UpdateError sets the "error" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateError() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateError() + }) +} + +// ClearError clears the value of the "error" field. +func (u *BuildTaskUpsertBulk) ClearError() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearError() + }) +} + +// Exec executes the query. +func (u *BuildTaskUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the BuildTaskCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for BuildTaskCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *BuildTaskUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/buildtask_delete.go b/tavern/internal/ent/buildtask_delete.go new file mode 100644 index 000000000..efbc1b352 --- /dev/null +++ b/tavern/internal/ent/buildtask_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/buildtask" + "realm.pub/tavern/internal/ent/predicate" +) + +// BuildTaskDelete is the builder for deleting a BuildTask entity. +type BuildTaskDelete struct { + config + hooks []Hook + mutation *BuildTaskMutation +} + +// Where appends a list predicates to the BuildTaskDelete builder. +func (btd *BuildTaskDelete) Where(ps ...predicate.BuildTask) *BuildTaskDelete { + btd.mutation.Where(ps...) + return btd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (btd *BuildTaskDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, btd.sqlExec, btd.mutation, btd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (btd *BuildTaskDelete) ExecX(ctx context.Context) int { + n, err := btd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (btd *BuildTaskDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(buildtask.Table, sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt)) + if ps := btd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, btd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + btd.mutation.done = true + return affected, err +} + +// BuildTaskDeleteOne is the builder for deleting a single BuildTask entity. +type BuildTaskDeleteOne struct { + btd *BuildTaskDelete +} + +// Where appends a list predicates to the BuildTaskDelete builder. +func (btdo *BuildTaskDeleteOne) Where(ps ...predicate.BuildTask) *BuildTaskDeleteOne { + btdo.btd.mutation.Where(ps...) + return btdo +} + +// Exec executes the deletion query. +func (btdo *BuildTaskDeleteOne) Exec(ctx context.Context) error { + n, err := btdo.btd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{buildtask.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (btdo *BuildTaskDeleteOne) ExecX(ctx context.Context) { + if err := btdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/buildtask_query.go b/tavern/internal/ent/buildtask_query.go new file mode 100644 index 000000000..071eb3eb6 --- /dev/null +++ b/tavern/internal/ent/buildtask_query.go @@ -0,0 +1,627 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" + "realm.pub/tavern/internal/ent/predicate" +) + +// BuildTaskQuery is the builder for querying BuildTask entities. +type BuildTaskQuery struct { + config + ctx *QueryContext + order []buildtask.OrderOption + inters []Interceptor + predicates []predicate.BuildTask + withBuilder *BuilderQuery + withFKs bool + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*BuildTask) error + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the BuildTaskQuery builder. +func (btq *BuildTaskQuery) Where(ps ...predicate.BuildTask) *BuildTaskQuery { + btq.predicates = append(btq.predicates, ps...) + return btq +} + +// Limit the number of records to be returned by this query. +func (btq *BuildTaskQuery) Limit(limit int) *BuildTaskQuery { + btq.ctx.Limit = &limit + return btq +} + +// Offset to start from. +func (btq *BuildTaskQuery) Offset(offset int) *BuildTaskQuery { + btq.ctx.Offset = &offset + return btq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (btq *BuildTaskQuery) Unique(unique bool) *BuildTaskQuery { + btq.ctx.Unique = &unique + return btq +} + +// Order specifies how the records should be ordered. +func (btq *BuildTaskQuery) Order(o ...buildtask.OrderOption) *BuildTaskQuery { + btq.order = append(btq.order, o...) + return btq +} + +// QueryBuilder chains the current query on the "builder" edge. +func (btq *BuildTaskQuery) QueryBuilder() *BuilderQuery { + query := (&BuilderClient{config: btq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := btq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := btq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(buildtask.Table, buildtask.FieldID, selector), + sqlgraph.To(builder.Table, builder.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, buildtask.BuilderTable, buildtask.BuilderColumn), + ) + fromU = sqlgraph.SetNeighbors(btq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first BuildTask entity from the query. +// Returns a *NotFoundError when no BuildTask was found. +func (btq *BuildTaskQuery) First(ctx context.Context) (*BuildTask, error) { + nodes, err := btq.Limit(1).All(setContextOp(ctx, btq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{buildtask.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (btq *BuildTaskQuery) FirstX(ctx context.Context) *BuildTask { + node, err := btq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first BuildTask ID from the query. +// Returns a *NotFoundError when no BuildTask ID was found. +func (btq *BuildTaskQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = btq.Limit(1).IDs(setContextOp(ctx, btq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{buildtask.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (btq *BuildTaskQuery) FirstIDX(ctx context.Context) int { + id, err := btq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single BuildTask entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one BuildTask entity is found. +// Returns a *NotFoundError when no BuildTask entities are found. +func (btq *BuildTaskQuery) Only(ctx context.Context) (*BuildTask, error) { + nodes, err := btq.Limit(2).All(setContextOp(ctx, btq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{buildtask.Label} + default: + return nil, &NotSingularError{buildtask.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (btq *BuildTaskQuery) OnlyX(ctx context.Context) *BuildTask { + node, err := btq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only BuildTask ID in the query. +// Returns a *NotSingularError when more than one BuildTask ID is found. +// Returns a *NotFoundError when no entities are found. +func (btq *BuildTaskQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = btq.Limit(2).IDs(setContextOp(ctx, btq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{buildtask.Label} + default: + err = &NotSingularError{buildtask.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (btq *BuildTaskQuery) OnlyIDX(ctx context.Context) int { + id, err := btq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of BuildTasks. +func (btq *BuildTaskQuery) All(ctx context.Context) ([]*BuildTask, error) { + ctx = setContextOp(ctx, btq.ctx, ent.OpQueryAll) + if err := btq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*BuildTask, *BuildTaskQuery]() + return withInterceptors[[]*BuildTask](ctx, btq, qr, btq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (btq *BuildTaskQuery) AllX(ctx context.Context) []*BuildTask { + nodes, err := btq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of BuildTask IDs. +func (btq *BuildTaskQuery) IDs(ctx context.Context) (ids []int, err error) { + if btq.ctx.Unique == nil && btq.path != nil { + btq.Unique(true) + } + ctx = setContextOp(ctx, btq.ctx, ent.OpQueryIDs) + if err = btq.Select(buildtask.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (btq *BuildTaskQuery) IDsX(ctx context.Context) []int { + ids, err := btq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (btq *BuildTaskQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, btq.ctx, ent.OpQueryCount) + if err := btq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, btq, querierCount[*BuildTaskQuery](), btq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (btq *BuildTaskQuery) CountX(ctx context.Context) int { + count, err := btq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (btq *BuildTaskQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, btq.ctx, ent.OpQueryExist) + switch _, err := btq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (btq *BuildTaskQuery) ExistX(ctx context.Context) bool { + exist, err := btq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the BuildTaskQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (btq *BuildTaskQuery) Clone() *BuildTaskQuery { + if btq == nil { + return nil + } + return &BuildTaskQuery{ + config: btq.config, + ctx: btq.ctx.Clone(), + order: append([]buildtask.OrderOption{}, btq.order...), + inters: append([]Interceptor{}, btq.inters...), + predicates: append([]predicate.BuildTask{}, btq.predicates...), + withBuilder: btq.withBuilder.Clone(), + // clone intermediate query. + sql: btq.sql.Clone(), + path: btq.path, + } +} + +// WithBuilder tells the query-builder to eager-load the nodes that are connected to +// the "builder" edge. The optional arguments are used to configure the query builder of the edge. +func (btq *BuildTaskQuery) WithBuilder(opts ...func(*BuilderQuery)) *BuildTaskQuery { + query := (&BuilderClient{config: btq.config}).Query() + for _, opt := range opts { + opt(query) + } + btq.withBuilder = query + return btq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.BuildTask.Query(). +// GroupBy(buildtask.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (btq *BuildTaskQuery) GroupBy(field string, fields ...string) *BuildTaskGroupBy { + btq.ctx.Fields = append([]string{field}, fields...) + grbuild := &BuildTaskGroupBy{build: btq} + grbuild.flds = &btq.ctx.Fields + grbuild.label = buildtask.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.BuildTask.Query(). +// Select(buildtask.FieldCreatedAt). +// Scan(ctx, &v) +func (btq *BuildTaskQuery) Select(fields ...string) *BuildTaskSelect { + btq.ctx.Fields = append(btq.ctx.Fields, fields...) + sbuild := &BuildTaskSelect{BuildTaskQuery: btq} + sbuild.label = buildtask.Label + sbuild.flds, sbuild.scan = &btq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a BuildTaskSelect configured with the given aggregations. +func (btq *BuildTaskQuery) Aggregate(fns ...AggregateFunc) *BuildTaskSelect { + return btq.Select().Aggregate(fns...) +} + +func (btq *BuildTaskQuery) prepareQuery(ctx context.Context) error { + for _, inter := range btq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, btq); err != nil { + return err + } + } + } + for _, f := range btq.ctx.Fields { + if !buildtask.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if btq.path != nil { + prev, err := btq.path(ctx) + if err != nil { + return err + } + btq.sql = prev + } + return nil +} + +func (btq *BuildTaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*BuildTask, error) { + var ( + nodes = []*BuildTask{} + withFKs = btq.withFKs + _spec = btq.querySpec() + loadedTypes = [1]bool{ + btq.withBuilder != nil, + } + ) + if btq.withBuilder != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, buildtask.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*BuildTask).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &BuildTask{config: btq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(btq.modifiers) > 0 { + _spec.Modifiers = btq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, btq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := btq.withBuilder; query != nil { + if err := btq.loadBuilder(ctx, query, nodes, nil, + func(n *BuildTask, e *Builder) { n.Edges.Builder = e }); err != nil { + return nil, err + } + } + for i := range btq.loadTotal { + if err := btq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (btq *BuildTaskQuery) loadBuilder(ctx context.Context, query *BuilderQuery, nodes []*BuildTask, init func(*BuildTask), assign func(*BuildTask, *Builder)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*BuildTask) + for i := range nodes { + if nodes[i].build_task_builder == nil { + continue + } + fk := *nodes[i].build_task_builder + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(builder.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "build_task_builder" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (btq *BuildTaskQuery) sqlCount(ctx context.Context) (int, error) { + _spec := btq.querySpec() + if len(btq.modifiers) > 0 { + _spec.Modifiers = btq.modifiers + } + _spec.Node.Columns = btq.ctx.Fields + if len(btq.ctx.Fields) > 0 { + _spec.Unique = btq.ctx.Unique != nil && *btq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, btq.driver, _spec) +} + +func (btq *BuildTaskQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(buildtask.Table, buildtask.Columns, sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt)) + _spec.From = btq.sql + if unique := btq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if btq.path != nil { + _spec.Unique = true + } + if fields := btq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, buildtask.FieldID) + for i := range fields { + if fields[i] != buildtask.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := btq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := btq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := btq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := btq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (btq *BuildTaskQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(btq.driver.Dialect()) + t1 := builder.Table(buildtask.Table) + columns := btq.ctx.Fields + if len(columns) == 0 { + columns = buildtask.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if btq.sql != nil { + selector = btq.sql + selector.Select(selector.Columns(columns...)...) + } + if btq.ctx.Unique != nil && *btq.ctx.Unique { + selector.Distinct() + } + for _, p := range btq.predicates { + p(selector) + } + for _, p := range btq.order { + p(selector) + } + if offset := btq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := btq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// BuildTaskGroupBy is the group-by builder for BuildTask entities. +type BuildTaskGroupBy struct { + selector + build *BuildTaskQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (btgb *BuildTaskGroupBy) Aggregate(fns ...AggregateFunc) *BuildTaskGroupBy { + btgb.fns = append(btgb.fns, fns...) + return btgb +} + +// Scan applies the selector query and scans the result into the given value. +func (btgb *BuildTaskGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, btgb.build.ctx, ent.OpQueryGroupBy) + if err := btgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BuildTaskQuery, *BuildTaskGroupBy](ctx, btgb.build, btgb, btgb.build.inters, v) +} + +func (btgb *BuildTaskGroupBy) sqlScan(ctx context.Context, root *BuildTaskQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(btgb.fns)) + for _, fn := range btgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*btgb.flds)+len(btgb.fns)) + for _, f := range *btgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*btgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := btgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// BuildTaskSelect is the builder for selecting fields of BuildTask entities. +type BuildTaskSelect struct { + *BuildTaskQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (bts *BuildTaskSelect) Aggregate(fns ...AggregateFunc) *BuildTaskSelect { + bts.fns = append(bts.fns, fns...) + return bts +} + +// Scan applies the selector query and scans the result into the given value. +func (bts *BuildTaskSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bts.ctx, ent.OpQuerySelect) + if err := bts.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BuildTaskQuery, *BuildTaskSelect](ctx, bts.BuildTaskQuery, bts, bts.inters, v) +} + +func (bts *BuildTaskSelect) sqlScan(ctx context.Context, root *BuildTaskQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(bts.fns)) + for _, fn := range bts.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*bts.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := bts.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/tavern/internal/ent/buildtask_update.go b/tavern/internal/ent/buildtask_update.go new file mode 100644 index 000000000..7e466dffa --- /dev/null +++ b/tavern/internal/ent/buildtask_update.go @@ -0,0 +1,720 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" + "realm.pub/tavern/internal/ent/predicate" +) + +// BuildTaskUpdate is the builder for updating BuildTask entities. +type BuildTaskUpdate struct { + config + hooks []Hook + mutation *BuildTaskMutation +} + +// Where appends a list predicates to the BuildTaskUpdate builder. +func (btu *BuildTaskUpdate) Where(ps ...predicate.BuildTask) *BuildTaskUpdate { + btu.mutation.Where(ps...) + return btu +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (btu *BuildTaskUpdate) SetLastModifiedAt(t time.Time) *BuildTaskUpdate { + btu.mutation.SetLastModifiedAt(t) + return btu +} + +// SetTargetOs sets the "target_os" field. +func (btu *BuildTaskUpdate) SetTargetOs(cp c2pb.Host_Platform) *BuildTaskUpdate { + btu.mutation.SetTargetOs(cp) + return btu +} + +// SetNillableTargetOs sets the "target_os" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableTargetOs(cp *c2pb.Host_Platform) *BuildTaskUpdate { + if cp != nil { + btu.SetTargetOs(*cp) + } + return btu +} + +// SetBuildImage sets the "build_image" field. +func (btu *BuildTaskUpdate) SetBuildImage(s string) *BuildTaskUpdate { + btu.mutation.SetBuildImage(s) + return btu +} + +// SetNillableBuildImage sets the "build_image" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableBuildImage(s *string) *BuildTaskUpdate { + if s != nil { + btu.SetBuildImage(*s) + } + return btu +} + +// SetBuildScript sets the "build_script" field. +func (btu *BuildTaskUpdate) SetBuildScript(s string) *BuildTaskUpdate { + btu.mutation.SetBuildScript(s) + return btu +} + +// SetNillableBuildScript sets the "build_script" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableBuildScript(s *string) *BuildTaskUpdate { + if s != nil { + btu.SetBuildScript(*s) + } + return btu +} + +// SetClaimedAt sets the "claimed_at" field. +func (btu *BuildTaskUpdate) SetClaimedAt(t time.Time) *BuildTaskUpdate { + btu.mutation.SetClaimedAt(t) + return btu +} + +// SetNillableClaimedAt sets the "claimed_at" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableClaimedAt(t *time.Time) *BuildTaskUpdate { + if t != nil { + btu.SetClaimedAt(*t) + } + return btu +} + +// ClearClaimedAt clears the value of the "claimed_at" field. +func (btu *BuildTaskUpdate) ClearClaimedAt() *BuildTaskUpdate { + btu.mutation.ClearClaimedAt() + return btu +} + +// SetStartedAt sets the "started_at" field. +func (btu *BuildTaskUpdate) SetStartedAt(t time.Time) *BuildTaskUpdate { + btu.mutation.SetStartedAt(t) + return btu +} + +// SetNillableStartedAt sets the "started_at" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableStartedAt(t *time.Time) *BuildTaskUpdate { + if t != nil { + btu.SetStartedAt(*t) + } + return btu +} + +// ClearStartedAt clears the value of the "started_at" field. +func (btu *BuildTaskUpdate) ClearStartedAt() *BuildTaskUpdate { + btu.mutation.ClearStartedAt() + return btu +} + +// SetFinishedAt sets the "finished_at" field. +func (btu *BuildTaskUpdate) SetFinishedAt(t time.Time) *BuildTaskUpdate { + btu.mutation.SetFinishedAt(t) + return btu +} + +// SetNillableFinishedAt sets the "finished_at" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableFinishedAt(t *time.Time) *BuildTaskUpdate { + if t != nil { + btu.SetFinishedAt(*t) + } + return btu +} + +// ClearFinishedAt clears the value of the "finished_at" field. +func (btu *BuildTaskUpdate) ClearFinishedAt() *BuildTaskUpdate { + btu.mutation.ClearFinishedAt() + return btu +} + +// SetOutput sets the "output" field. +func (btu *BuildTaskUpdate) SetOutput(s string) *BuildTaskUpdate { + btu.mutation.SetOutput(s) + return btu +} + +// SetNillableOutput sets the "output" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableOutput(s *string) *BuildTaskUpdate { + if s != nil { + btu.SetOutput(*s) + } + return btu +} + +// ClearOutput clears the value of the "output" field. +func (btu *BuildTaskUpdate) ClearOutput() *BuildTaskUpdate { + btu.mutation.ClearOutput() + return btu +} + +// SetError sets the "error" field. +func (btu *BuildTaskUpdate) SetError(s string) *BuildTaskUpdate { + btu.mutation.SetError(s) + return btu +} + +// SetNillableError sets the "error" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableError(s *string) *BuildTaskUpdate { + if s != nil { + btu.SetError(*s) + } + return btu +} + +// ClearError clears the value of the "error" field. +func (btu *BuildTaskUpdate) ClearError() *BuildTaskUpdate { + btu.mutation.ClearError() + return btu +} + +// SetBuilderID sets the "builder" edge to the Builder entity by ID. +func (btu *BuildTaskUpdate) SetBuilderID(id int) *BuildTaskUpdate { + btu.mutation.SetBuilderID(id) + return btu +} + +// SetBuilder sets the "builder" edge to the Builder entity. +func (btu *BuildTaskUpdate) SetBuilder(b *Builder) *BuildTaskUpdate { + return btu.SetBuilderID(b.ID) +} + +// Mutation returns the BuildTaskMutation object of the builder. +func (btu *BuildTaskUpdate) Mutation() *BuildTaskMutation { + return btu.mutation +} + +// ClearBuilder clears the "builder" edge to the Builder entity. +func (btu *BuildTaskUpdate) ClearBuilder() *BuildTaskUpdate { + btu.mutation.ClearBuilder() + return btu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (btu *BuildTaskUpdate) Save(ctx context.Context) (int, error) { + btu.defaults() + return withHooks(ctx, btu.sqlSave, btu.mutation, btu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (btu *BuildTaskUpdate) SaveX(ctx context.Context) int { + affected, err := btu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (btu *BuildTaskUpdate) Exec(ctx context.Context) error { + _, err := btu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (btu *BuildTaskUpdate) ExecX(ctx context.Context) { + if err := btu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (btu *BuildTaskUpdate) defaults() { + if _, ok := btu.mutation.LastModifiedAt(); !ok { + v := buildtask.UpdateDefaultLastModifiedAt() + btu.mutation.SetLastModifiedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (btu *BuildTaskUpdate) check() error { + if v, ok := btu.mutation.TargetOs(); ok { + if err := buildtask.TargetOsValidator(v); err != nil { + return &ValidationError{Name: "target_os", err: fmt.Errorf(`ent: validator failed for field "BuildTask.target_os": %w`, err)} + } + } + if v, ok := btu.mutation.BuildImage(); ok { + if err := buildtask.BuildImageValidator(v); err != nil { + return &ValidationError{Name: "build_image", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_image": %w`, err)} + } + } + if v, ok := btu.mutation.BuildScript(); ok { + if err := buildtask.BuildScriptValidator(v); err != nil { + return &ValidationError{Name: "build_script", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_script": %w`, err)} + } + } + if btu.mutation.BuilderCleared() && len(btu.mutation.BuilderIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "BuildTask.builder"`) + } + return nil +} + +func (btu *BuildTaskUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := btu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(buildtask.Table, buildtask.Columns, sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt)) + if ps := btu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := btu.mutation.LastModifiedAt(); ok { + _spec.SetField(buildtask.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := btu.mutation.TargetOs(); ok { + _spec.SetField(buildtask.FieldTargetOs, field.TypeEnum, value) + } + if value, ok := btu.mutation.BuildImage(); ok { + _spec.SetField(buildtask.FieldBuildImage, field.TypeString, value) + } + if value, ok := btu.mutation.BuildScript(); ok { + _spec.SetField(buildtask.FieldBuildScript, field.TypeString, value) + } + if value, ok := btu.mutation.ClaimedAt(); ok { + _spec.SetField(buildtask.FieldClaimedAt, field.TypeTime, value) + } + if btu.mutation.ClaimedAtCleared() { + _spec.ClearField(buildtask.FieldClaimedAt, field.TypeTime) + } + if value, ok := btu.mutation.StartedAt(); ok { + _spec.SetField(buildtask.FieldStartedAt, field.TypeTime, value) + } + if btu.mutation.StartedAtCleared() { + _spec.ClearField(buildtask.FieldStartedAt, field.TypeTime) + } + if value, ok := btu.mutation.FinishedAt(); ok { + _spec.SetField(buildtask.FieldFinishedAt, field.TypeTime, value) + } + if btu.mutation.FinishedAtCleared() { + _spec.ClearField(buildtask.FieldFinishedAt, field.TypeTime) + } + if value, ok := btu.mutation.Output(); ok { + _spec.SetField(buildtask.FieldOutput, field.TypeString, value) + } + if btu.mutation.OutputCleared() { + _spec.ClearField(buildtask.FieldOutput, field.TypeString) + } + if value, ok := btu.mutation.Error(); ok { + _spec.SetField(buildtask.FieldError, field.TypeString, value) + } + if btu.mutation.ErrorCleared() { + _spec.ClearField(buildtask.FieldError, field.TypeString) + } + if btu.mutation.BuilderCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: buildtask.BuilderTable, + Columns: []string{buildtask.BuilderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := btu.mutation.BuilderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: buildtask.BuilderTable, + Columns: []string{buildtask.BuilderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, btu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{buildtask.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + btu.mutation.done = true + return n, nil +} + +// BuildTaskUpdateOne is the builder for updating a single BuildTask entity. +type BuildTaskUpdateOne struct { + config + fields []string + hooks []Hook + mutation *BuildTaskMutation +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (btuo *BuildTaskUpdateOne) SetLastModifiedAt(t time.Time) *BuildTaskUpdateOne { + btuo.mutation.SetLastModifiedAt(t) + return btuo +} + +// SetTargetOs sets the "target_os" field. +func (btuo *BuildTaskUpdateOne) SetTargetOs(cp c2pb.Host_Platform) *BuildTaskUpdateOne { + btuo.mutation.SetTargetOs(cp) + return btuo +} + +// SetNillableTargetOs sets the "target_os" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableTargetOs(cp *c2pb.Host_Platform) *BuildTaskUpdateOne { + if cp != nil { + btuo.SetTargetOs(*cp) + } + return btuo +} + +// SetBuildImage sets the "build_image" field. +func (btuo *BuildTaskUpdateOne) SetBuildImage(s string) *BuildTaskUpdateOne { + btuo.mutation.SetBuildImage(s) + return btuo +} + +// SetNillableBuildImage sets the "build_image" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableBuildImage(s *string) *BuildTaskUpdateOne { + if s != nil { + btuo.SetBuildImage(*s) + } + return btuo +} + +// SetBuildScript sets the "build_script" field. +func (btuo *BuildTaskUpdateOne) SetBuildScript(s string) *BuildTaskUpdateOne { + btuo.mutation.SetBuildScript(s) + return btuo +} + +// SetNillableBuildScript sets the "build_script" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableBuildScript(s *string) *BuildTaskUpdateOne { + if s != nil { + btuo.SetBuildScript(*s) + } + return btuo +} + +// SetClaimedAt sets the "claimed_at" field. +func (btuo *BuildTaskUpdateOne) SetClaimedAt(t time.Time) *BuildTaskUpdateOne { + btuo.mutation.SetClaimedAt(t) + return btuo +} + +// SetNillableClaimedAt sets the "claimed_at" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableClaimedAt(t *time.Time) *BuildTaskUpdateOne { + if t != nil { + btuo.SetClaimedAt(*t) + } + return btuo +} + +// ClearClaimedAt clears the value of the "claimed_at" field. +func (btuo *BuildTaskUpdateOne) ClearClaimedAt() *BuildTaskUpdateOne { + btuo.mutation.ClearClaimedAt() + return btuo +} + +// SetStartedAt sets the "started_at" field. +func (btuo *BuildTaskUpdateOne) SetStartedAt(t time.Time) *BuildTaskUpdateOne { + btuo.mutation.SetStartedAt(t) + return btuo +} + +// SetNillableStartedAt sets the "started_at" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableStartedAt(t *time.Time) *BuildTaskUpdateOne { + if t != nil { + btuo.SetStartedAt(*t) + } + return btuo +} + +// ClearStartedAt clears the value of the "started_at" field. +func (btuo *BuildTaskUpdateOne) ClearStartedAt() *BuildTaskUpdateOne { + btuo.mutation.ClearStartedAt() + return btuo +} + +// SetFinishedAt sets the "finished_at" field. +func (btuo *BuildTaskUpdateOne) SetFinishedAt(t time.Time) *BuildTaskUpdateOne { + btuo.mutation.SetFinishedAt(t) + return btuo +} + +// SetNillableFinishedAt sets the "finished_at" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableFinishedAt(t *time.Time) *BuildTaskUpdateOne { + if t != nil { + btuo.SetFinishedAt(*t) + } + return btuo +} + +// ClearFinishedAt clears the value of the "finished_at" field. +func (btuo *BuildTaskUpdateOne) ClearFinishedAt() *BuildTaskUpdateOne { + btuo.mutation.ClearFinishedAt() + return btuo +} + +// SetOutput sets the "output" field. +func (btuo *BuildTaskUpdateOne) SetOutput(s string) *BuildTaskUpdateOne { + btuo.mutation.SetOutput(s) + return btuo +} + +// SetNillableOutput sets the "output" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableOutput(s *string) *BuildTaskUpdateOne { + if s != nil { + btuo.SetOutput(*s) + } + return btuo +} + +// ClearOutput clears the value of the "output" field. +func (btuo *BuildTaskUpdateOne) ClearOutput() *BuildTaskUpdateOne { + btuo.mutation.ClearOutput() + return btuo +} + +// SetError sets the "error" field. +func (btuo *BuildTaskUpdateOne) SetError(s string) *BuildTaskUpdateOne { + btuo.mutation.SetError(s) + return btuo +} + +// SetNillableError sets the "error" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableError(s *string) *BuildTaskUpdateOne { + if s != nil { + btuo.SetError(*s) + } + return btuo +} + +// ClearError clears the value of the "error" field. +func (btuo *BuildTaskUpdateOne) ClearError() *BuildTaskUpdateOne { + btuo.mutation.ClearError() + return btuo +} + +// SetBuilderID sets the "builder" edge to the Builder entity by ID. +func (btuo *BuildTaskUpdateOne) SetBuilderID(id int) *BuildTaskUpdateOne { + btuo.mutation.SetBuilderID(id) + return btuo +} + +// SetBuilder sets the "builder" edge to the Builder entity. +func (btuo *BuildTaskUpdateOne) SetBuilder(b *Builder) *BuildTaskUpdateOne { + return btuo.SetBuilderID(b.ID) +} + +// Mutation returns the BuildTaskMutation object of the builder. +func (btuo *BuildTaskUpdateOne) Mutation() *BuildTaskMutation { + return btuo.mutation +} + +// ClearBuilder clears the "builder" edge to the Builder entity. +func (btuo *BuildTaskUpdateOne) ClearBuilder() *BuildTaskUpdateOne { + btuo.mutation.ClearBuilder() + return btuo +} + +// Where appends a list predicates to the BuildTaskUpdate builder. +func (btuo *BuildTaskUpdateOne) Where(ps ...predicate.BuildTask) *BuildTaskUpdateOne { + btuo.mutation.Where(ps...) + return btuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (btuo *BuildTaskUpdateOne) Select(field string, fields ...string) *BuildTaskUpdateOne { + btuo.fields = append([]string{field}, fields...) + return btuo +} + +// Save executes the query and returns the updated BuildTask entity. +func (btuo *BuildTaskUpdateOne) Save(ctx context.Context) (*BuildTask, error) { + btuo.defaults() + return withHooks(ctx, btuo.sqlSave, btuo.mutation, btuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (btuo *BuildTaskUpdateOne) SaveX(ctx context.Context) *BuildTask { + node, err := btuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (btuo *BuildTaskUpdateOne) Exec(ctx context.Context) error { + _, err := btuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (btuo *BuildTaskUpdateOne) ExecX(ctx context.Context) { + if err := btuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (btuo *BuildTaskUpdateOne) defaults() { + if _, ok := btuo.mutation.LastModifiedAt(); !ok { + v := buildtask.UpdateDefaultLastModifiedAt() + btuo.mutation.SetLastModifiedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (btuo *BuildTaskUpdateOne) check() error { + if v, ok := btuo.mutation.TargetOs(); ok { + if err := buildtask.TargetOsValidator(v); err != nil { + return &ValidationError{Name: "target_os", err: fmt.Errorf(`ent: validator failed for field "BuildTask.target_os": %w`, err)} + } + } + if v, ok := btuo.mutation.BuildImage(); ok { + if err := buildtask.BuildImageValidator(v); err != nil { + return &ValidationError{Name: "build_image", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_image": %w`, err)} + } + } + if v, ok := btuo.mutation.BuildScript(); ok { + if err := buildtask.BuildScriptValidator(v); err != nil { + return &ValidationError{Name: "build_script", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_script": %w`, err)} + } + } + if btuo.mutation.BuilderCleared() && len(btuo.mutation.BuilderIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "BuildTask.builder"`) + } + return nil +} + +func (btuo *BuildTaskUpdateOne) sqlSave(ctx context.Context) (_node *BuildTask, err error) { + if err := btuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(buildtask.Table, buildtask.Columns, sqlgraph.NewFieldSpec(buildtask.FieldID, field.TypeInt)) + id, ok := btuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "BuildTask.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := btuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, buildtask.FieldID) + for _, f := range fields { + if !buildtask.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != buildtask.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := btuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := btuo.mutation.LastModifiedAt(); ok { + _spec.SetField(buildtask.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := btuo.mutation.TargetOs(); ok { + _spec.SetField(buildtask.FieldTargetOs, field.TypeEnum, value) + } + if value, ok := btuo.mutation.BuildImage(); ok { + _spec.SetField(buildtask.FieldBuildImage, field.TypeString, value) + } + if value, ok := btuo.mutation.BuildScript(); ok { + _spec.SetField(buildtask.FieldBuildScript, field.TypeString, value) + } + if value, ok := btuo.mutation.ClaimedAt(); ok { + _spec.SetField(buildtask.FieldClaimedAt, field.TypeTime, value) + } + if btuo.mutation.ClaimedAtCleared() { + _spec.ClearField(buildtask.FieldClaimedAt, field.TypeTime) + } + if value, ok := btuo.mutation.StartedAt(); ok { + _spec.SetField(buildtask.FieldStartedAt, field.TypeTime, value) + } + if btuo.mutation.StartedAtCleared() { + _spec.ClearField(buildtask.FieldStartedAt, field.TypeTime) + } + if value, ok := btuo.mutation.FinishedAt(); ok { + _spec.SetField(buildtask.FieldFinishedAt, field.TypeTime, value) + } + if btuo.mutation.FinishedAtCleared() { + _spec.ClearField(buildtask.FieldFinishedAt, field.TypeTime) + } + if value, ok := btuo.mutation.Output(); ok { + _spec.SetField(buildtask.FieldOutput, field.TypeString, value) + } + if btuo.mutation.OutputCleared() { + _spec.ClearField(buildtask.FieldOutput, field.TypeString) + } + if value, ok := btuo.mutation.Error(); ok { + _spec.SetField(buildtask.FieldError, field.TypeString, value) + } + if btuo.mutation.ErrorCleared() { + _spec.ClearField(buildtask.FieldError, field.TypeString) + } + if btuo.mutation.BuilderCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: buildtask.BuilderTable, + Columns: []string{buildtask.BuilderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := btuo.mutation.BuilderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: buildtask.BuilderTable, + Columns: []string{buildtask.BuilderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &BuildTask{config: btuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, btuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{buildtask.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + btuo.mutation.done = true + return _node, nil +} diff --git a/tavern/internal/ent/client.go b/tavern/internal/ent/client.go index e0db6a50b..9473dfb61 100644 --- a/tavern/internal/ent/client.go +++ b/tavern/internal/ent/client.go @@ -18,6 +18,7 @@ import ( "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -42,6 +43,8 @@ type Client struct { Asset *AssetClient // Beacon is the client for interacting with the Beacon builders. Beacon *BeaconClient + // BuildTask is the client for interacting with the BuildTask builders. + BuildTask *BuildTaskClient // Builder is the client for interacting with the Builder builders. Builder *BuilderClient // Host is the client for interacting with the Host builders. @@ -85,6 +88,7 @@ func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) c.Asset = NewAssetClient(c.config) c.Beacon = NewBeaconClient(c.config) + c.BuildTask = NewBuildTaskClient(c.config) c.Builder = NewBuilderClient(c.config) c.Host = NewHostClient(c.config) c.HostCredential = NewHostCredentialClient(c.config) @@ -193,6 +197,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { config: cfg, Asset: NewAssetClient(cfg), Beacon: NewBeaconClient(cfg), + BuildTask: NewBuildTaskClient(cfg), Builder: NewBuilderClient(cfg), Host: NewHostClient(cfg), HostCredential: NewHostCredentialClient(cfg), @@ -228,6 +233,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) config: cfg, Asset: NewAssetClient(cfg), Beacon: NewBeaconClient(cfg), + BuildTask: NewBuildTaskClient(cfg), Builder: NewBuilderClient(cfg), Host: NewHostClient(cfg), HostCredential: NewHostCredentialClient(cfg), @@ -271,7 +277,7 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Asset, c.Beacon, c.Builder, c.Host, c.HostCredential, c.HostFile, + c.Asset, c.Beacon, c.BuildTask, c.Builder, c.Host, c.HostCredential, c.HostFile, c.HostProcess, c.Link, c.Portal, c.Quest, c.Repository, c.Shell, c.Tag, c.Task, c.Tome, c.User, } { @@ -283,7 +289,7 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Asset, c.Beacon, c.Builder, c.Host, c.HostCredential, c.HostFile, + c.Asset, c.Beacon, c.BuildTask, c.Builder, c.Host, c.HostCredential, c.HostFile, c.HostProcess, c.Link, c.Portal, c.Quest, c.Repository, c.Shell, c.Tag, c.Task, c.Tome, c.User, } { @@ -298,6 +304,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Asset.mutate(ctx, m) case *BeaconMutation: return c.Beacon.mutate(ctx, m) + case *BuildTaskMutation: + return c.BuildTask.mutate(ctx, m) case *BuilderMutation: return c.Builder.mutate(ctx, m) case *HostMutation: @@ -694,6 +702,155 @@ func (c *BeaconClient) mutate(ctx context.Context, m *BeaconMutation) (Value, er } } +// BuildTaskClient is a client for the BuildTask schema. +type BuildTaskClient struct { + config +} + +// NewBuildTaskClient returns a client for the BuildTask from the given config. +func NewBuildTaskClient(c config) *BuildTaskClient { + return &BuildTaskClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `buildtask.Hooks(f(g(h())))`. +func (c *BuildTaskClient) Use(hooks ...Hook) { + c.hooks.BuildTask = append(c.hooks.BuildTask, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `buildtask.Intercept(f(g(h())))`. +func (c *BuildTaskClient) Intercept(interceptors ...Interceptor) { + c.inters.BuildTask = append(c.inters.BuildTask, interceptors...) +} + +// Create returns a builder for creating a BuildTask entity. +func (c *BuildTaskClient) Create() *BuildTaskCreate { + mutation := newBuildTaskMutation(c.config, OpCreate) + return &BuildTaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of BuildTask entities. +func (c *BuildTaskClient) CreateBulk(builders ...*BuildTaskCreate) *BuildTaskCreateBulk { + return &BuildTaskCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *BuildTaskClient) MapCreateBulk(slice any, setFunc func(*BuildTaskCreate, int)) *BuildTaskCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BuildTaskCreateBulk{err: fmt.Errorf("calling to BuildTaskClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BuildTaskCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BuildTaskCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for BuildTask. +func (c *BuildTaskClient) Update() *BuildTaskUpdate { + mutation := newBuildTaskMutation(c.config, OpUpdate) + return &BuildTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *BuildTaskClient) UpdateOne(bt *BuildTask) *BuildTaskUpdateOne { + mutation := newBuildTaskMutation(c.config, OpUpdateOne, withBuildTask(bt)) + return &BuildTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *BuildTaskClient) UpdateOneID(id int) *BuildTaskUpdateOne { + mutation := newBuildTaskMutation(c.config, OpUpdateOne, withBuildTaskID(id)) + return &BuildTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for BuildTask. +func (c *BuildTaskClient) Delete() *BuildTaskDelete { + mutation := newBuildTaskMutation(c.config, OpDelete) + return &BuildTaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *BuildTaskClient) DeleteOne(bt *BuildTask) *BuildTaskDeleteOne { + return c.DeleteOneID(bt.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *BuildTaskClient) DeleteOneID(id int) *BuildTaskDeleteOne { + builder := c.Delete().Where(buildtask.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &BuildTaskDeleteOne{builder} +} + +// Query returns a query builder for BuildTask. +func (c *BuildTaskClient) Query() *BuildTaskQuery { + return &BuildTaskQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeBuildTask}, + inters: c.Interceptors(), + } +} + +// Get returns a BuildTask entity by its id. +func (c *BuildTaskClient) Get(ctx context.Context, id int) (*BuildTask, error) { + return c.Query().Where(buildtask.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *BuildTaskClient) GetX(ctx context.Context, id int) *BuildTask { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryBuilder queries the builder edge of a BuildTask. +func (c *BuildTaskClient) QueryBuilder(bt *BuildTask) *BuilderQuery { + query := (&BuilderClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := bt.ID + step := sqlgraph.NewStep( + sqlgraph.From(buildtask.Table, buildtask.FieldID, id), + sqlgraph.To(builder.Table, builder.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, buildtask.BuilderTable, buildtask.BuilderColumn), + ) + fromV = sqlgraph.Neighbors(bt.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *BuildTaskClient) Hooks() []Hook { + return c.hooks.BuildTask +} + +// Interceptors returns the client interceptors. +func (c *BuildTaskClient) Interceptors() []Interceptor { + return c.inters.BuildTask +} + +func (c *BuildTaskClient) mutate(ctx context.Context, m *BuildTaskMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&BuildTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&BuildTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&BuildTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&BuildTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown BuildTask mutation op: %q", m.Op()) + } +} + // BuilderClient is a client for the Builder schema. type BuilderClient struct { config @@ -802,6 +959,22 @@ func (c *BuilderClient) GetX(ctx context.Context, id int) *Builder { return obj } +// QueryBuildTasks queries the build_tasks edge of a Builder. +func (c *BuilderClient) QueryBuildTasks(b *Builder) *BuildTaskQuery { + query := (&BuildTaskClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := b.ID + step := sqlgraph.NewStep( + sqlgraph.From(builder.Table, builder.FieldID, id), + sqlgraph.To(buildtask.Table, buildtask.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, builder.BuildTasksTable, builder.BuildTasksColumn), + ) + fromV = sqlgraph.Neighbors(b.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *BuilderClient) Hooks() []Hook { return c.hooks.Builder @@ -3203,11 +3376,11 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) // hooks and interceptors per client, for fast access. type ( hooks struct { - Asset, Beacon, Builder, Host, HostCredential, HostFile, HostProcess, Link, - Portal, Quest, Repository, Shell, Tag, Task, Tome, User []ent.Hook + Asset, Beacon, BuildTask, Builder, Host, HostCredential, HostFile, HostProcess, + Link, Portal, Quest, Repository, Shell, Tag, Task, Tome, User []ent.Hook } inters struct { - Asset, Beacon, Builder, Host, HostCredential, HostFile, HostProcess, Link, - Portal, Quest, Repository, Shell, Tag, Task, Tome, User []ent.Interceptor + Asset, Beacon, BuildTask, Builder, Host, HostCredential, HostFile, HostProcess, + Link, Portal, Quest, Repository, Shell, Tag, Task, Tome, User []ent.Interceptor } ) diff --git a/tavern/internal/ent/ent.go b/tavern/internal/ent/ent.go index b3c89e42e..366ea66e3 100644 --- a/tavern/internal/ent/ent.go +++ b/tavern/internal/ent/ent.go @@ -15,6 +15,7 @@ import ( "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -90,6 +91,7 @@ func checkColumn(table, column string) error { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ asset.Table: asset.ValidColumn, beacon.Table: beacon.ValidColumn, + buildtask.Table: buildtask.ValidColumn, builder.Table: builder.ValidColumn, host.Table: host.ValidColumn, hostcredential.Table: hostcredential.ValidColumn, diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index 4b54f9dc5..e976f33ff 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -13,6 +13,7 @@ import ( "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -665,6 +666,157 @@ func newBeaconPaginateArgs(rv map[string]any) *beaconPaginateArgs { return args } +// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. +func (bt *BuildTaskQuery) CollectFields(ctx context.Context, satisfies ...string) (*BuildTaskQuery, error) { + fc := graphql.GetFieldContext(ctx) + if fc == nil { + return bt, nil + } + if err := bt.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + return nil, err + } + return bt, nil +} + +func (bt *BuildTaskQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { + path = append([]string(nil), path...) + var ( + unknownSeen bool + fieldSeen = make(map[string]struct{}, len(buildtask.Columns)) + selectedFields = []string{buildtask.FieldID} + ) + for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { + switch field.Name { + + case "builder": + var ( + alias = field.Alias + path = append(path, alias) + query = (&BuilderClient{config: bt.config}).Query() + ) + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, builderImplementors)...); err != nil { + return err + } + bt.withBuilder = query + case "createdAt": + if _, ok := fieldSeen[buildtask.FieldCreatedAt]; !ok { + selectedFields = append(selectedFields, buildtask.FieldCreatedAt) + fieldSeen[buildtask.FieldCreatedAt] = struct{}{} + } + case "lastModifiedAt": + if _, ok := fieldSeen[buildtask.FieldLastModifiedAt]; !ok { + selectedFields = append(selectedFields, buildtask.FieldLastModifiedAt) + fieldSeen[buildtask.FieldLastModifiedAt] = struct{}{} + } + case "targetOs": + if _, ok := fieldSeen[buildtask.FieldTargetOs]; !ok { + selectedFields = append(selectedFields, buildtask.FieldTargetOs) + fieldSeen[buildtask.FieldTargetOs] = struct{}{} + } + case "buildImage": + if _, ok := fieldSeen[buildtask.FieldBuildImage]; !ok { + selectedFields = append(selectedFields, buildtask.FieldBuildImage) + fieldSeen[buildtask.FieldBuildImage] = struct{}{} + } + case "buildScript": + if _, ok := fieldSeen[buildtask.FieldBuildScript]; !ok { + selectedFields = append(selectedFields, buildtask.FieldBuildScript) + fieldSeen[buildtask.FieldBuildScript] = struct{}{} + } + case "claimedAt": + if _, ok := fieldSeen[buildtask.FieldClaimedAt]; !ok { + selectedFields = append(selectedFields, buildtask.FieldClaimedAt) + fieldSeen[buildtask.FieldClaimedAt] = struct{}{} + } + case "startedAt": + if _, ok := fieldSeen[buildtask.FieldStartedAt]; !ok { + selectedFields = append(selectedFields, buildtask.FieldStartedAt) + fieldSeen[buildtask.FieldStartedAt] = struct{}{} + } + case "finishedAt": + if _, ok := fieldSeen[buildtask.FieldFinishedAt]; !ok { + selectedFields = append(selectedFields, buildtask.FieldFinishedAt) + fieldSeen[buildtask.FieldFinishedAt] = struct{}{} + } + case "output": + if _, ok := fieldSeen[buildtask.FieldOutput]; !ok { + selectedFields = append(selectedFields, buildtask.FieldOutput) + fieldSeen[buildtask.FieldOutput] = struct{}{} + } + case "error": + if _, ok := fieldSeen[buildtask.FieldError]; !ok { + selectedFields = append(selectedFields, buildtask.FieldError) + fieldSeen[buildtask.FieldError] = struct{}{} + } + case "id": + case "__typename": + default: + unknownSeen = true + } + } + if !unknownSeen { + bt.Select(selectedFields...) + } + return nil +} + +type buildtaskPaginateArgs struct { + first, last *int + after, before *Cursor + opts []BuildTaskPaginateOption +} + +func newBuildTaskPaginateArgs(rv map[string]any) *buildtaskPaginateArgs { + args := &buildtaskPaginateArgs{} + if rv == nil { + return args + } + if v := rv[firstField]; v != nil { + args.first = v.(*int) + } + if v := rv[lastField]; v != nil { + args.last = v.(*int) + } + if v := rv[afterField]; v != nil { + args.after = v.(*Cursor) + } + if v := rv[beforeField]; v != nil { + args.before = v.(*Cursor) + } + if v, ok := rv[orderByField]; ok { + switch v := v.(type) { + case []*BuildTaskOrder: + args.opts = append(args.opts, WithBuildTaskOrder(v)) + case []any: + var orders []*BuildTaskOrder + for i := range v { + mv, ok := v[i].(map[string]any) + if !ok { + continue + } + var ( + err1, err2 error + order = &BuildTaskOrder{Field: &BuildTaskOrderField{}, Direction: entgql.OrderDirectionAsc} + ) + if d, ok := mv[directionField]; ok { + err1 = order.Direction.UnmarshalGQL(d) + } + if f, ok := mv[fieldField]; ok { + err2 = order.Field.UnmarshalGQL(f) + } + if err1 == nil && err2 == nil { + orders = append(orders, order) + } + } + args.opts = append(args.opts, WithBuildTaskOrder(orders)) + } + } + if v, ok := rv[whereField].(*BuildTaskWhereInput); ok { + args.opts = append(args.opts, WithBuildTaskFilter(v.Filter)) + } + return args +} + // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. func (b *BuilderQuery) CollectFields(ctx context.Context, satisfies ...string) (*BuilderQuery, error) { fc := graphql.GetFieldContext(ctx) @@ -686,6 +838,95 @@ func (b *BuilderQuery) collectField(ctx context.Context, oneNode bool, opCtx *gr ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + + case "buildTasks": + var ( + alias = field.Alias + path = append(path, alias) + query = (&BuildTaskClient{config: b.config}).Query() + ) + args := newBuildTaskPaginateArgs(fieldArgs(ctx, new(BuildTaskWhereInput), path...)) + if err := validateFirstLast(args.first, args.last); err != nil { + return fmt.Errorf("validate first and last in path %q: %w", path, err) + } + pager, err := newBuildTaskPager(args.opts, args.last != nil) + if err != nil { + return fmt.Errorf("create new pager in path %q: %w", path, err) + } + if query, err = pager.applyFilter(query); err != nil { + return err + } + ignoredEdges := !hasCollectedField(ctx, append(path, edgesField)...) + if hasCollectedField(ctx, append(path, totalCountField)...) || hasCollectedField(ctx, append(path, pageInfoField)...) { + hasPagination := args.after != nil || args.first != nil || args.before != nil || args.last != nil + if hasPagination || ignoredEdges { + query := query.Clone() + b.loadTotal = append(b.loadTotal, func(ctx context.Context, nodes []*Builder) error { + ids := make([]driver.Value, len(nodes)) + for i := range nodes { + ids[i] = nodes[i].ID + } + var v []struct { + NodeID int `sql:"build_task_builder"` + Count int `sql:"count"` + } + query.Where(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(builder.BuildTasksColumn), ids...)) + }) + if err := query.GroupBy(builder.BuildTasksColumn).Aggregate(Count()).Scan(ctx, &v); err != nil { + return err + } + m := make(map[int]int, len(v)) + for i := range v { + m[v[i].NodeID] = v[i].Count + } + for i := range nodes { + n := m[nodes[i].ID] + if nodes[i].Edges.totalCount[0] == nil { + nodes[i].Edges.totalCount[0] = make(map[string]int) + } + nodes[i].Edges.totalCount[0][alias] = n + } + return nil + }) + } else { + b.loadTotal = append(b.loadTotal, func(_ context.Context, nodes []*Builder) error { + for i := range nodes { + n := len(nodes[i].Edges.BuildTasks) + if nodes[i].Edges.totalCount[0] == nil { + nodes[i].Edges.totalCount[0] = make(map[string]int) + } + nodes[i].Edges.totalCount[0][alias] = n + } + return nil + }) + } + } + if ignoredEdges || (args.first != nil && *args.first == 0) || (args.last != nil && *args.last == 0) { + continue + } + if query, err = pager.applyCursors(query, args.after, args.before); err != nil { + return err + } + path = append(path, edgesField, nodeField) + if field := collectedField(ctx, path...); field != nil { + if err := query.collectField(ctx, false, opCtx, *field, path, mayAddCondition(satisfies, buildtaskImplementors)...); err != nil { + return err + } + } + if limit := paginateLimit(args.first, args.last); limit > 0 { + if oneNode { + pager.applyOrder(query.Limit(limit)) + } else { + modify := entgql.LimitPerRow(builder.BuildTasksColumn, limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } + } else { + query = pager.applyOrder(query) + } + b.WithNamedBuildTasks(alias, func(wq *BuildTaskQuery) { + *wq = *query + }) case "createdAt": if _, ok := fieldSeen[builder.FieldCreatedAt]; !ok { selectedFields = append(selectedFields, builder.FieldCreatedAt) diff --git a/tavern/internal/ent/gql_edge.go b/tavern/internal/ent/gql_edge.go index cd4c63083..cfd48244f 100644 --- a/tavern/internal/ent/gql_edge.go +++ b/tavern/internal/ent/gql_edge.go @@ -108,6 +108,35 @@ func (b *Beacon) Shells( return b.QueryShells().Paginate(ctx, after, first, before, last, opts...) } +func (bt *BuildTask) Builder(ctx context.Context) (*Builder, error) { + result, err := bt.Edges.BuilderOrErr() + if IsNotLoaded(err) { + result, err = bt.QueryBuilder().Only(ctx) + } + return result, err +} + +func (b *Builder) BuildTasks( + ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, orderBy []*BuildTaskOrder, where *BuildTaskWhereInput, +) (*BuildTaskConnection, error) { + opts := []BuildTaskPaginateOption{ + WithBuildTaskOrder(orderBy), + WithBuildTaskFilter(where.Filter), + } + alias := graphql.GetFieldContext(ctx).Field.Alias + totalCount, hasTotalCount := b.Edges.totalCount[0][alias] + if nodes, err := b.NamedBuildTasks(alias); err == nil || hasTotalCount { + pager, err := newBuildTaskPager(opts, last != nil) + if err != nil { + return nil, err + } + conn := &BuildTaskConnection{Edges: []*BuildTaskEdge{}, TotalCount: totalCount} + conn.build(nodes, pager, after, first, before, last) + return conn, nil + } + return b.QueryBuildTasks().Paginate(ctx, after, first, before, last, opts...) +} + func (h *Host) Tags( ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, orderBy []*TagOrder, where *TagWhereInput, ) (*TagConnection, error) { diff --git a/tavern/internal/ent/gql_mutation_input.go b/tavern/internal/ent/gql_mutation_input.go index 13b2bcf7a..5dcc8aa46 100644 --- a/tavern/internal/ent/gql_mutation_input.go +++ b/tavern/internal/ent/gql_mutation_input.go @@ -43,6 +43,7 @@ func (c *BeaconUpdateOne) SetInput(i UpdateBeaconInput) *BeaconUpdateOne { type CreateBuilderInput struct { SupportedTargets []c2pb.Host_Platform Upstream string + BuildTaskIDs []int } // Mutate applies the CreateBuilderInput on the BuilderMutation builder. @@ -51,6 +52,9 @@ func (i *CreateBuilderInput) Mutate(m *BuilderMutation) { m.SetSupportedTargets(v) } m.SetUpstream(i.Upstream) + if v := i.BuildTaskIDs; len(v) > 0 { + m.AddBuildTaskIDs(v...) + } } // SetInput applies the change-set in the CreateBuilderInput on the BuilderCreate builder. diff --git a/tavern/internal/ent/gql_node.go b/tavern/internal/ent/gql_node.go index 1e4248275..db841ccc5 100644 --- a/tavern/internal/ent/gql_node.go +++ b/tavern/internal/ent/gql_node.go @@ -18,6 +18,7 @@ import ( "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -48,6 +49,11 @@ var beaconImplementors = []string{"Beacon", "Node"} // IsNode implements the Node interface check for GQLGen. func (*Beacon) IsNode() {} +var buildtaskImplementors = []string{"BuildTask", "Node"} + +// IsNode implements the Node interface check for GQLGen. +func (*BuildTask) IsNode() {} + var builderImplementors = []string{"Builder", "Node"} // IsNode implements the Node interface check for GQLGen. @@ -194,6 +200,15 @@ func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) } } return query.Only(ctx) + case buildtask.Table: + query := c.BuildTask.Query(). + Where(buildtask.ID(id)) + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, buildtaskImplementors...); err != nil { + return nil, err + } + } + return query.Only(ctx) case builder.Table: query := c.Builder.Query(). Where(builder.ID(id)) @@ -425,6 +440,22 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, *noder = node } } + case buildtask.Table: + query := c.BuildTask.Query(). + Where(buildtask.IDIn(ids...)) + query, err := query.CollectFields(ctx, buildtaskImplementors...) + if err != nil { + return nil, err + } + nodes, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, node := range nodes { + for _, noder := range idmap[node.ID] { + *noder = node + } + } case builder.Table: query := c.Builder.Query(). Where(builder.IDIn(ids...)) diff --git a/tavern/internal/ent/gql_pagination.go b/tavern/internal/ent/gql_pagination.go index 96107fe76..7cbd0179f 100644 --- a/tavern/internal/ent/gql_pagination.go +++ b/tavern/internal/ent/gql_pagination.go @@ -18,6 +18,7 @@ import ( "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -903,6 +904,428 @@ func (b *Beacon) ToEdge(order *BeaconOrder) *BeaconEdge { } } +// BuildTaskEdge is the edge representation of BuildTask. +type BuildTaskEdge struct { + Node *BuildTask `json:"node"` + Cursor Cursor `json:"cursor"` +} + +// BuildTaskConnection is the connection containing edges to BuildTask. +type BuildTaskConnection struct { + Edges []*BuildTaskEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + +func (c *BuildTaskConnection) build(nodes []*BuildTask, pager *buildtaskPager, after *Cursor, first *int, before *Cursor, last *int) { + c.PageInfo.HasNextPage = before != nil + c.PageInfo.HasPreviousPage = after != nil + if first != nil && *first+1 == len(nodes) { + c.PageInfo.HasNextPage = true + nodes = nodes[:len(nodes)-1] + } else if last != nil && *last+1 == len(nodes) { + c.PageInfo.HasPreviousPage = true + nodes = nodes[:len(nodes)-1] + } + var nodeAt func(int) *BuildTask + if last != nil { + n := len(nodes) - 1 + nodeAt = func(i int) *BuildTask { + return nodes[n-i] + } + } else { + nodeAt = func(i int) *BuildTask { + return nodes[i] + } + } + c.Edges = make([]*BuildTaskEdge, len(nodes)) + for i := range nodes { + node := nodeAt(i) + c.Edges[i] = &BuildTaskEdge{ + Node: node, + Cursor: pager.toCursor(node), + } + } + if l := len(c.Edges); l > 0 { + c.PageInfo.StartCursor = &c.Edges[0].Cursor + c.PageInfo.EndCursor = &c.Edges[l-1].Cursor + } + if c.TotalCount == 0 { + c.TotalCount = len(nodes) + } +} + +// BuildTaskPaginateOption enables pagination customization. +type BuildTaskPaginateOption func(*buildtaskPager) error + +// WithBuildTaskOrder configures pagination ordering. +func WithBuildTaskOrder(order []*BuildTaskOrder) BuildTaskPaginateOption { + return func(pager *buildtaskPager) error { + for _, o := range order { + if err := o.Direction.Validate(); err != nil { + return err + } + } + pager.order = append(pager.order, order...) + return nil + } +} + +// WithBuildTaskFilter configures pagination filter. +func WithBuildTaskFilter(filter func(*BuildTaskQuery) (*BuildTaskQuery, error)) BuildTaskPaginateOption { + return func(pager *buildtaskPager) error { + if filter == nil { + return errors.New("BuildTaskQuery filter cannot be nil") + } + pager.filter = filter + return nil + } +} + +type buildtaskPager struct { + reverse bool + order []*BuildTaskOrder + filter func(*BuildTaskQuery) (*BuildTaskQuery, error) +} + +func newBuildTaskPager(opts []BuildTaskPaginateOption, reverse bool) (*buildtaskPager, error) { + pager := &buildtaskPager{reverse: reverse} + for _, opt := range opts { + if err := opt(pager); err != nil { + return nil, err + } + } + for i, o := range pager.order { + if i > 0 && o.Field == pager.order[i-1].Field { + return nil, fmt.Errorf("duplicate order direction %q", o.Direction) + } + } + return pager, nil +} + +func (p *buildtaskPager) applyFilter(query *BuildTaskQuery) (*BuildTaskQuery, error) { + if p.filter != nil { + return p.filter(query) + } + return query, nil +} + +func (p *buildtaskPager) toCursor(bt *BuildTask) Cursor { + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(bt).Value) + } + return Cursor{ID: bt.ID, Value: cs_} +} + +func (p *buildtaskPager) applyCursors(query *BuildTaskQuery, after, before *Cursor) (*BuildTaskQuery, error) { + idDirection := entgql.OrderDirectionAsc + if p.reverse { + idDirection = entgql.OrderDirectionDesc + } + fields, directions := make([]string, 0, len(p.order)), make([]OrderDirection, 0, len(p.order)) + for _, o := range p.order { + fields = append(fields, o.Field.column) + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + directions = append(directions, direction) + } + predicates, err := entgql.MultiCursorsPredicate(after, before, &entgql.MultiCursorsOptions{ + FieldID: DefaultBuildTaskOrder.Field.column, + DirectionID: idDirection, + Fields: fields, + Directions: directions, + }) + if err != nil { + return nil, err + } + for _, predicate := range predicates { + query = query.Where(predicate) + } + return query, nil +} + +func (p *buildtaskPager) applyOrder(query *BuildTaskQuery) *BuildTaskQuery { + var defaultOrdered bool + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + if o.Field.column == DefaultBuildTaskOrder.Field.column { + defaultOrdered = true + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } + } + if !defaultOrdered { + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(DefaultBuildTaskOrder.Field.toTerm(direction.OrderTermOption())) + } + return query +} + +func (p *buildtaskPager) orderExpr(query *BuildTaskQuery) sql.Querier { + if len(query.ctx.Fields) > 0 { + for _, o := range p.order { + query.ctx.AppendFieldOnce(o.Field.column) + } + } + return sql.ExprFunc(func(b *sql.Builder) { + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + b.Ident(o.Field.column).Pad().WriteString(string(direction)) + b.Comma() + } + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() + } + b.Ident(DefaultBuildTaskOrder.Field.column).Pad().WriteString(string(direction)) + }) +} + +// Paginate executes the query and returns a relay based cursor connection to BuildTask. +func (bt *BuildTaskQuery) Paginate( + ctx context.Context, after *Cursor, first *int, + before *Cursor, last *int, opts ...BuildTaskPaginateOption, +) (*BuildTaskConnection, error) { + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newBuildTaskPager(opts, last != nil) + if err != nil { + return nil, err + } + if bt, err = pager.applyFilter(bt); err != nil { + return nil, err + } + conn := &BuildTaskConnection{Edges: []*BuildTaskEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + hasPagination := after != nil || first != nil || before != nil || last != nil + if hasPagination || ignoredEdges { + c := bt.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { + return nil, err + } + conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 + conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 + } + } + if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { + return conn, nil + } + if bt, err = pager.applyCursors(bt, after, before); err != nil { + return nil, err + } + limit := paginateLimit(first, last) + if limit != 0 { + bt.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := bt.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + bt = pager.applyOrder(bt) + nodes, err := bt.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil +} + +var ( + // BuildTaskOrderFieldCreatedAt orders BuildTask by created_at. + BuildTaskOrderFieldCreatedAt = &BuildTaskOrderField{ + Value: func(bt *BuildTask) (ent.Value, error) { + return bt.CreatedAt, nil + }, + column: buildtask.FieldCreatedAt, + toTerm: buildtask.ByCreatedAt, + toCursor: func(bt *BuildTask) Cursor { + return Cursor{ + ID: bt.ID, + Value: bt.CreatedAt, + } + }, + } + // BuildTaskOrderFieldLastModifiedAt orders BuildTask by last_modified_at. + BuildTaskOrderFieldLastModifiedAt = &BuildTaskOrderField{ + Value: func(bt *BuildTask) (ent.Value, error) { + return bt.LastModifiedAt, nil + }, + column: buildtask.FieldLastModifiedAt, + toTerm: buildtask.ByLastModifiedAt, + toCursor: func(bt *BuildTask) Cursor { + return Cursor{ + ID: bt.ID, + Value: bt.LastModifiedAt, + } + }, + } + // BuildTaskOrderFieldTargetOs orders BuildTask by target_os. + BuildTaskOrderFieldTargetOs = &BuildTaskOrderField{ + Value: func(bt *BuildTask) (ent.Value, error) { + return bt.TargetOs, nil + }, + column: buildtask.FieldTargetOs, + toTerm: buildtask.ByTargetOs, + toCursor: func(bt *BuildTask) Cursor { + return Cursor{ + ID: bt.ID, + Value: bt.TargetOs, + } + }, + } + // BuildTaskOrderFieldClaimedAt orders BuildTask by claimed_at. + BuildTaskOrderFieldClaimedAt = &BuildTaskOrderField{ + Value: func(bt *BuildTask) (ent.Value, error) { + return bt.ClaimedAt, nil + }, + column: buildtask.FieldClaimedAt, + toTerm: buildtask.ByClaimedAt, + toCursor: func(bt *BuildTask) Cursor { + return Cursor{ + ID: bt.ID, + Value: bt.ClaimedAt, + } + }, + } + // BuildTaskOrderFieldStartedAt orders BuildTask by started_at. + BuildTaskOrderFieldStartedAt = &BuildTaskOrderField{ + Value: func(bt *BuildTask) (ent.Value, error) { + return bt.StartedAt, nil + }, + column: buildtask.FieldStartedAt, + toTerm: buildtask.ByStartedAt, + toCursor: func(bt *BuildTask) Cursor { + return Cursor{ + ID: bt.ID, + Value: bt.StartedAt, + } + }, + } + // BuildTaskOrderFieldFinishedAt orders BuildTask by finished_at. + BuildTaskOrderFieldFinishedAt = &BuildTaskOrderField{ + Value: func(bt *BuildTask) (ent.Value, error) { + return bt.FinishedAt, nil + }, + column: buildtask.FieldFinishedAt, + toTerm: buildtask.ByFinishedAt, + toCursor: func(bt *BuildTask) Cursor { + return Cursor{ + ID: bt.ID, + Value: bt.FinishedAt, + } + }, + } +) + +// String implement fmt.Stringer interface. +func (f BuildTaskOrderField) String() string { + var str string + switch f.column { + case BuildTaskOrderFieldCreatedAt.column: + str = "CREATED_AT" + case BuildTaskOrderFieldLastModifiedAt.column: + str = "LAST_MODIFIED_AT" + case BuildTaskOrderFieldTargetOs.column: + str = "TARGET_OS" + case BuildTaskOrderFieldClaimedAt.column: + str = "CLAIMED_AT" + case BuildTaskOrderFieldStartedAt.column: + str = "STARTED_AT" + case BuildTaskOrderFieldFinishedAt.column: + str = "FINISHED_AT" + } + return str +} + +// MarshalGQL implements graphql.Marshaler interface. +func (f BuildTaskOrderField) MarshalGQL(w io.Writer) { + io.WriteString(w, strconv.Quote(f.String())) +} + +// UnmarshalGQL implements graphql.Unmarshaler interface. +func (f *BuildTaskOrderField) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("BuildTaskOrderField %T must be a string", v) + } + switch str { + case "CREATED_AT": + *f = *BuildTaskOrderFieldCreatedAt + case "LAST_MODIFIED_AT": + *f = *BuildTaskOrderFieldLastModifiedAt + case "TARGET_OS": + *f = *BuildTaskOrderFieldTargetOs + case "CLAIMED_AT": + *f = *BuildTaskOrderFieldClaimedAt + case "STARTED_AT": + *f = *BuildTaskOrderFieldStartedAt + case "FINISHED_AT": + *f = *BuildTaskOrderFieldFinishedAt + default: + return fmt.Errorf("%s is not a valid BuildTaskOrderField", str) + } + return nil +} + +// BuildTaskOrderField defines the ordering field of BuildTask. +type BuildTaskOrderField struct { + // Value extracts the ordering value from the given BuildTask. + Value func(*BuildTask) (ent.Value, error) + column string // field or computed. + toTerm func(...sql.OrderTermOption) buildtask.OrderOption + toCursor func(*BuildTask) Cursor +} + +// BuildTaskOrder defines the ordering of BuildTask. +type BuildTaskOrder struct { + Direction OrderDirection `json:"direction"` + Field *BuildTaskOrderField `json:"field"` +} + +// DefaultBuildTaskOrder is the default ordering of BuildTask. +var DefaultBuildTaskOrder = &BuildTaskOrder{ + Direction: entgql.OrderDirectionAsc, + Field: &BuildTaskOrderField{ + Value: func(bt *BuildTask) (ent.Value, error) { + return bt.ID, nil + }, + column: buildtask.FieldID, + toTerm: buildtask.ByID, + toCursor: func(bt *BuildTask) Cursor { + return Cursor{ID: bt.ID} + }, + }, +} + +// ToEdge converts BuildTask into BuildTaskEdge. +func (bt *BuildTask) ToEdge(order *BuildTaskOrder) *BuildTaskEdge { + if order == nil { + order = DefaultBuildTaskOrder + } + return &BuildTaskEdge{ + Node: bt, + Cursor: order.Field.toCursor(bt), + } +} + // BuilderEdge is the edge representation of Builder. type BuilderEdge struct { Node *Builder `json:"node"` diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index dc6db4529..3b615794a 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -12,6 +12,7 @@ import ( "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -1062,6 +1063,596 @@ func (i *BeaconWhereInput) P() (predicate.Beacon, error) { } } +// BuildTaskWhereInput represents a where input for filtering BuildTask queries. +type BuildTaskWhereInput struct { + Predicates []predicate.BuildTask `json:"-"` + Not *BuildTaskWhereInput `json:"not,omitempty"` + Or []*BuildTaskWhereInput `json:"or,omitempty"` + And []*BuildTaskWhereInput `json:"and,omitempty"` + + // "id" field predicates. + ID *int `json:"id,omitempty"` + IDNEQ *int `json:"idNEQ,omitempty"` + IDIn []int `json:"idIn,omitempty"` + IDNotIn []int `json:"idNotIn,omitempty"` + IDGT *int `json:"idGT,omitempty"` + IDGTE *int `json:"idGTE,omitempty"` + IDLT *int `json:"idLT,omitempty"` + IDLTE *int `json:"idLTE,omitempty"` + + // "created_at" field predicates. + CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAtNEQ *time.Time `json:"createdAtNEQ,omitempty"` + CreatedAtIn []time.Time `json:"createdAtIn,omitempty"` + CreatedAtNotIn []time.Time `json:"createdAtNotIn,omitempty"` + CreatedAtGT *time.Time `json:"createdAtGT,omitempty"` + CreatedAtGTE *time.Time `json:"createdAtGTE,omitempty"` + CreatedAtLT *time.Time `json:"createdAtLT,omitempty"` + CreatedAtLTE *time.Time `json:"createdAtLTE,omitempty"` + + // "last_modified_at" field predicates. + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAtNEQ *time.Time `json:"lastModifiedAtNEQ,omitempty"` + LastModifiedAtIn []time.Time `json:"lastModifiedAtIn,omitempty"` + LastModifiedAtNotIn []time.Time `json:"lastModifiedAtNotIn,omitempty"` + LastModifiedAtGT *time.Time `json:"lastModifiedAtGT,omitempty"` + LastModifiedAtGTE *time.Time `json:"lastModifiedAtGTE,omitempty"` + LastModifiedAtLT *time.Time `json:"lastModifiedAtLT,omitempty"` + LastModifiedAtLTE *time.Time `json:"lastModifiedAtLTE,omitempty"` + + // "target_os" field predicates. + TargetOs *c2pb.Host_Platform `json:"targetOs,omitempty"` + TargetOsNEQ *c2pb.Host_Platform `json:"targetOsNEQ,omitempty"` + TargetOsIn []c2pb.Host_Platform `json:"targetOsIn,omitempty"` + TargetOsNotIn []c2pb.Host_Platform `json:"targetOsNotIn,omitempty"` + + // "build_image" field predicates. + BuildImage *string `json:"buildImage,omitempty"` + BuildImageNEQ *string `json:"buildImageNEQ,omitempty"` + BuildImageIn []string `json:"buildImageIn,omitempty"` + BuildImageNotIn []string `json:"buildImageNotIn,omitempty"` + BuildImageGT *string `json:"buildImageGT,omitempty"` + BuildImageGTE *string `json:"buildImageGTE,omitempty"` + BuildImageLT *string `json:"buildImageLT,omitempty"` + BuildImageLTE *string `json:"buildImageLTE,omitempty"` + BuildImageContains *string `json:"buildImageContains,omitempty"` + BuildImageHasPrefix *string `json:"buildImageHasPrefix,omitempty"` + BuildImageHasSuffix *string `json:"buildImageHasSuffix,omitempty"` + BuildImageEqualFold *string `json:"buildImageEqualFold,omitempty"` + BuildImageContainsFold *string `json:"buildImageContainsFold,omitempty"` + + // "build_script" field predicates. + BuildScript *string `json:"buildScript,omitempty"` + BuildScriptNEQ *string `json:"buildScriptNEQ,omitempty"` + BuildScriptIn []string `json:"buildScriptIn,omitempty"` + BuildScriptNotIn []string `json:"buildScriptNotIn,omitempty"` + BuildScriptGT *string `json:"buildScriptGT,omitempty"` + BuildScriptGTE *string `json:"buildScriptGTE,omitempty"` + BuildScriptLT *string `json:"buildScriptLT,omitempty"` + BuildScriptLTE *string `json:"buildScriptLTE,omitempty"` + BuildScriptContains *string `json:"buildScriptContains,omitempty"` + BuildScriptHasPrefix *string `json:"buildScriptHasPrefix,omitempty"` + BuildScriptHasSuffix *string `json:"buildScriptHasSuffix,omitempty"` + BuildScriptEqualFold *string `json:"buildScriptEqualFold,omitempty"` + BuildScriptContainsFold *string `json:"buildScriptContainsFold,omitempty"` + + // "claimed_at" field predicates. + ClaimedAt *time.Time `json:"claimedAt,omitempty"` + ClaimedAtNEQ *time.Time `json:"claimedAtNEQ,omitempty"` + ClaimedAtIn []time.Time `json:"claimedAtIn,omitempty"` + ClaimedAtNotIn []time.Time `json:"claimedAtNotIn,omitempty"` + ClaimedAtGT *time.Time `json:"claimedAtGT,omitempty"` + ClaimedAtGTE *time.Time `json:"claimedAtGTE,omitempty"` + ClaimedAtLT *time.Time `json:"claimedAtLT,omitempty"` + ClaimedAtLTE *time.Time `json:"claimedAtLTE,omitempty"` + ClaimedAtIsNil bool `json:"claimedAtIsNil,omitempty"` + ClaimedAtNotNil bool `json:"claimedAtNotNil,omitempty"` + + // "started_at" field predicates. + StartedAt *time.Time `json:"startedAt,omitempty"` + StartedAtNEQ *time.Time `json:"startedAtNEQ,omitempty"` + StartedAtIn []time.Time `json:"startedAtIn,omitempty"` + StartedAtNotIn []time.Time `json:"startedAtNotIn,omitempty"` + StartedAtGT *time.Time `json:"startedAtGT,omitempty"` + StartedAtGTE *time.Time `json:"startedAtGTE,omitempty"` + StartedAtLT *time.Time `json:"startedAtLT,omitempty"` + StartedAtLTE *time.Time `json:"startedAtLTE,omitempty"` + StartedAtIsNil bool `json:"startedAtIsNil,omitempty"` + StartedAtNotNil bool `json:"startedAtNotNil,omitempty"` + + // "finished_at" field predicates. + FinishedAt *time.Time `json:"finishedAt,omitempty"` + FinishedAtNEQ *time.Time `json:"finishedAtNEQ,omitempty"` + FinishedAtIn []time.Time `json:"finishedAtIn,omitempty"` + FinishedAtNotIn []time.Time `json:"finishedAtNotIn,omitempty"` + FinishedAtGT *time.Time `json:"finishedAtGT,omitempty"` + FinishedAtGTE *time.Time `json:"finishedAtGTE,omitempty"` + FinishedAtLT *time.Time `json:"finishedAtLT,omitempty"` + FinishedAtLTE *time.Time `json:"finishedAtLTE,omitempty"` + FinishedAtIsNil bool `json:"finishedAtIsNil,omitempty"` + FinishedAtNotNil bool `json:"finishedAtNotNil,omitempty"` + + // "output" field predicates. + Output *string `json:"output,omitempty"` + OutputNEQ *string `json:"outputNEQ,omitempty"` + OutputIn []string `json:"outputIn,omitempty"` + OutputNotIn []string `json:"outputNotIn,omitempty"` + OutputGT *string `json:"outputGT,omitempty"` + OutputGTE *string `json:"outputGTE,omitempty"` + OutputLT *string `json:"outputLT,omitempty"` + OutputLTE *string `json:"outputLTE,omitempty"` + OutputContains *string `json:"outputContains,omitempty"` + OutputHasPrefix *string `json:"outputHasPrefix,omitempty"` + OutputHasSuffix *string `json:"outputHasSuffix,omitempty"` + OutputIsNil bool `json:"outputIsNil,omitempty"` + OutputNotNil bool `json:"outputNotNil,omitempty"` + OutputEqualFold *string `json:"outputEqualFold,omitempty"` + OutputContainsFold *string `json:"outputContainsFold,omitempty"` + + // "error" field predicates. + Error *string `json:"error,omitempty"` + ErrorNEQ *string `json:"errorNEQ,omitempty"` + ErrorIn []string `json:"errorIn,omitempty"` + ErrorNotIn []string `json:"errorNotIn,omitempty"` + ErrorGT *string `json:"errorGT,omitempty"` + ErrorGTE *string `json:"errorGTE,omitempty"` + ErrorLT *string `json:"errorLT,omitempty"` + ErrorLTE *string `json:"errorLTE,omitempty"` + ErrorContains *string `json:"errorContains,omitempty"` + ErrorHasPrefix *string `json:"errorHasPrefix,omitempty"` + ErrorHasSuffix *string `json:"errorHasSuffix,omitempty"` + ErrorIsNil bool `json:"errorIsNil,omitempty"` + ErrorNotNil bool `json:"errorNotNil,omitempty"` + ErrorEqualFold *string `json:"errorEqualFold,omitempty"` + ErrorContainsFold *string `json:"errorContainsFold,omitempty"` + + // "builder" edge predicates. + HasBuilder *bool `json:"hasBuilder,omitempty"` + HasBuilderWith []*BuilderWhereInput `json:"hasBuilderWith,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *BuildTaskWhereInput) AddPredicates(predicates ...predicate.BuildTask) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the BuildTaskWhereInput filter on the BuildTaskQuery builder. +func (i *BuildTaskWhereInput) Filter(q *BuildTaskQuery) (*BuildTaskQuery, error) { + if i == nil { + return q, nil + } + p, err := i.P() + if err != nil { + if err == ErrEmptyBuildTaskWhereInput { + return q, nil + } + return nil, err + } + return q.Where(p), nil +} + +// ErrEmptyBuildTaskWhereInput is returned in case the BuildTaskWhereInput is empty. +var ErrEmptyBuildTaskWhereInput = errors.New("ent: empty predicate BuildTaskWhereInput") + +// P returns a predicate for filtering buildtasks. +// An error is returned if the input is empty or invalid. +func (i *BuildTaskWhereInput) P() (predicate.BuildTask, error) { + var predicates []predicate.BuildTask + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, buildtask.Not(p)) + } + switch n := len(i.Or); { + case n == 1: + p, err := i.Or[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + predicates = append(predicates, p) + case n > 1: + or := make([]predicate.BuildTask, 0, n) + for _, w := range i.Or { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + or = append(or, p) + } + predicates = append(predicates, buildtask.Or(or...)) + } + switch n := len(i.And); { + case n == 1: + p, err := i.And[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + predicates = append(predicates, p) + case n > 1: + and := make([]predicate.BuildTask, 0, n) + for _, w := range i.And { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + and = append(and, p) + } + predicates = append(predicates, buildtask.And(and...)) + } + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, buildtask.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, buildtask.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, buildtask.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, buildtask.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, buildtask.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, buildtask.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, buildtask.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, buildtask.IDLTE(*i.IDLTE)) + } + if i.CreatedAt != nil { + predicates = append(predicates, buildtask.CreatedAtEQ(*i.CreatedAt)) + } + if i.CreatedAtNEQ != nil { + predicates = append(predicates, buildtask.CreatedAtNEQ(*i.CreatedAtNEQ)) + } + if len(i.CreatedAtIn) > 0 { + predicates = append(predicates, buildtask.CreatedAtIn(i.CreatedAtIn...)) + } + if len(i.CreatedAtNotIn) > 0 { + predicates = append(predicates, buildtask.CreatedAtNotIn(i.CreatedAtNotIn...)) + } + if i.CreatedAtGT != nil { + predicates = append(predicates, buildtask.CreatedAtGT(*i.CreatedAtGT)) + } + if i.CreatedAtGTE != nil { + predicates = append(predicates, buildtask.CreatedAtGTE(*i.CreatedAtGTE)) + } + if i.CreatedAtLT != nil { + predicates = append(predicates, buildtask.CreatedAtLT(*i.CreatedAtLT)) + } + if i.CreatedAtLTE != nil { + predicates = append(predicates, buildtask.CreatedAtLTE(*i.CreatedAtLTE)) + } + if i.LastModifiedAt != nil { + predicates = append(predicates, buildtask.LastModifiedAtEQ(*i.LastModifiedAt)) + } + if i.LastModifiedAtNEQ != nil { + predicates = append(predicates, buildtask.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) + } + if len(i.LastModifiedAtIn) > 0 { + predicates = append(predicates, buildtask.LastModifiedAtIn(i.LastModifiedAtIn...)) + } + if len(i.LastModifiedAtNotIn) > 0 { + predicates = append(predicates, buildtask.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) + } + if i.LastModifiedAtGT != nil { + predicates = append(predicates, buildtask.LastModifiedAtGT(*i.LastModifiedAtGT)) + } + if i.LastModifiedAtGTE != nil { + predicates = append(predicates, buildtask.LastModifiedAtGTE(*i.LastModifiedAtGTE)) + } + if i.LastModifiedAtLT != nil { + predicates = append(predicates, buildtask.LastModifiedAtLT(*i.LastModifiedAtLT)) + } + if i.LastModifiedAtLTE != nil { + predicates = append(predicates, buildtask.LastModifiedAtLTE(*i.LastModifiedAtLTE)) + } + if i.TargetOs != nil { + predicates = append(predicates, buildtask.TargetOsEQ(*i.TargetOs)) + } + if i.TargetOsNEQ != nil { + predicates = append(predicates, buildtask.TargetOsNEQ(*i.TargetOsNEQ)) + } + if len(i.TargetOsIn) > 0 { + predicates = append(predicates, buildtask.TargetOsIn(i.TargetOsIn...)) + } + if len(i.TargetOsNotIn) > 0 { + predicates = append(predicates, buildtask.TargetOsNotIn(i.TargetOsNotIn...)) + } + if i.BuildImage != nil { + predicates = append(predicates, buildtask.BuildImageEQ(*i.BuildImage)) + } + if i.BuildImageNEQ != nil { + predicates = append(predicates, buildtask.BuildImageNEQ(*i.BuildImageNEQ)) + } + if len(i.BuildImageIn) > 0 { + predicates = append(predicates, buildtask.BuildImageIn(i.BuildImageIn...)) + } + if len(i.BuildImageNotIn) > 0 { + predicates = append(predicates, buildtask.BuildImageNotIn(i.BuildImageNotIn...)) + } + if i.BuildImageGT != nil { + predicates = append(predicates, buildtask.BuildImageGT(*i.BuildImageGT)) + } + if i.BuildImageGTE != nil { + predicates = append(predicates, buildtask.BuildImageGTE(*i.BuildImageGTE)) + } + if i.BuildImageLT != nil { + predicates = append(predicates, buildtask.BuildImageLT(*i.BuildImageLT)) + } + if i.BuildImageLTE != nil { + predicates = append(predicates, buildtask.BuildImageLTE(*i.BuildImageLTE)) + } + if i.BuildImageContains != nil { + predicates = append(predicates, buildtask.BuildImageContains(*i.BuildImageContains)) + } + if i.BuildImageHasPrefix != nil { + predicates = append(predicates, buildtask.BuildImageHasPrefix(*i.BuildImageHasPrefix)) + } + if i.BuildImageHasSuffix != nil { + predicates = append(predicates, buildtask.BuildImageHasSuffix(*i.BuildImageHasSuffix)) + } + if i.BuildImageEqualFold != nil { + predicates = append(predicates, buildtask.BuildImageEqualFold(*i.BuildImageEqualFold)) + } + if i.BuildImageContainsFold != nil { + predicates = append(predicates, buildtask.BuildImageContainsFold(*i.BuildImageContainsFold)) + } + if i.BuildScript != nil { + predicates = append(predicates, buildtask.BuildScriptEQ(*i.BuildScript)) + } + if i.BuildScriptNEQ != nil { + predicates = append(predicates, buildtask.BuildScriptNEQ(*i.BuildScriptNEQ)) + } + if len(i.BuildScriptIn) > 0 { + predicates = append(predicates, buildtask.BuildScriptIn(i.BuildScriptIn...)) + } + if len(i.BuildScriptNotIn) > 0 { + predicates = append(predicates, buildtask.BuildScriptNotIn(i.BuildScriptNotIn...)) + } + if i.BuildScriptGT != nil { + predicates = append(predicates, buildtask.BuildScriptGT(*i.BuildScriptGT)) + } + if i.BuildScriptGTE != nil { + predicates = append(predicates, buildtask.BuildScriptGTE(*i.BuildScriptGTE)) + } + if i.BuildScriptLT != nil { + predicates = append(predicates, buildtask.BuildScriptLT(*i.BuildScriptLT)) + } + if i.BuildScriptLTE != nil { + predicates = append(predicates, buildtask.BuildScriptLTE(*i.BuildScriptLTE)) + } + if i.BuildScriptContains != nil { + predicates = append(predicates, buildtask.BuildScriptContains(*i.BuildScriptContains)) + } + if i.BuildScriptHasPrefix != nil { + predicates = append(predicates, buildtask.BuildScriptHasPrefix(*i.BuildScriptHasPrefix)) + } + if i.BuildScriptHasSuffix != nil { + predicates = append(predicates, buildtask.BuildScriptHasSuffix(*i.BuildScriptHasSuffix)) + } + if i.BuildScriptEqualFold != nil { + predicates = append(predicates, buildtask.BuildScriptEqualFold(*i.BuildScriptEqualFold)) + } + if i.BuildScriptContainsFold != nil { + predicates = append(predicates, buildtask.BuildScriptContainsFold(*i.BuildScriptContainsFold)) + } + if i.ClaimedAt != nil { + predicates = append(predicates, buildtask.ClaimedAtEQ(*i.ClaimedAt)) + } + if i.ClaimedAtNEQ != nil { + predicates = append(predicates, buildtask.ClaimedAtNEQ(*i.ClaimedAtNEQ)) + } + if len(i.ClaimedAtIn) > 0 { + predicates = append(predicates, buildtask.ClaimedAtIn(i.ClaimedAtIn...)) + } + if len(i.ClaimedAtNotIn) > 0 { + predicates = append(predicates, buildtask.ClaimedAtNotIn(i.ClaimedAtNotIn...)) + } + if i.ClaimedAtGT != nil { + predicates = append(predicates, buildtask.ClaimedAtGT(*i.ClaimedAtGT)) + } + if i.ClaimedAtGTE != nil { + predicates = append(predicates, buildtask.ClaimedAtGTE(*i.ClaimedAtGTE)) + } + if i.ClaimedAtLT != nil { + predicates = append(predicates, buildtask.ClaimedAtLT(*i.ClaimedAtLT)) + } + if i.ClaimedAtLTE != nil { + predicates = append(predicates, buildtask.ClaimedAtLTE(*i.ClaimedAtLTE)) + } + if i.ClaimedAtIsNil { + predicates = append(predicates, buildtask.ClaimedAtIsNil()) + } + if i.ClaimedAtNotNil { + predicates = append(predicates, buildtask.ClaimedAtNotNil()) + } + if i.StartedAt != nil { + predicates = append(predicates, buildtask.StartedAtEQ(*i.StartedAt)) + } + if i.StartedAtNEQ != nil { + predicates = append(predicates, buildtask.StartedAtNEQ(*i.StartedAtNEQ)) + } + if len(i.StartedAtIn) > 0 { + predicates = append(predicates, buildtask.StartedAtIn(i.StartedAtIn...)) + } + if len(i.StartedAtNotIn) > 0 { + predicates = append(predicates, buildtask.StartedAtNotIn(i.StartedAtNotIn...)) + } + if i.StartedAtGT != nil { + predicates = append(predicates, buildtask.StartedAtGT(*i.StartedAtGT)) + } + if i.StartedAtGTE != nil { + predicates = append(predicates, buildtask.StartedAtGTE(*i.StartedAtGTE)) + } + if i.StartedAtLT != nil { + predicates = append(predicates, buildtask.StartedAtLT(*i.StartedAtLT)) + } + if i.StartedAtLTE != nil { + predicates = append(predicates, buildtask.StartedAtLTE(*i.StartedAtLTE)) + } + if i.StartedAtIsNil { + predicates = append(predicates, buildtask.StartedAtIsNil()) + } + if i.StartedAtNotNil { + predicates = append(predicates, buildtask.StartedAtNotNil()) + } + if i.FinishedAt != nil { + predicates = append(predicates, buildtask.FinishedAtEQ(*i.FinishedAt)) + } + if i.FinishedAtNEQ != nil { + predicates = append(predicates, buildtask.FinishedAtNEQ(*i.FinishedAtNEQ)) + } + if len(i.FinishedAtIn) > 0 { + predicates = append(predicates, buildtask.FinishedAtIn(i.FinishedAtIn...)) + } + if len(i.FinishedAtNotIn) > 0 { + predicates = append(predicates, buildtask.FinishedAtNotIn(i.FinishedAtNotIn...)) + } + if i.FinishedAtGT != nil { + predicates = append(predicates, buildtask.FinishedAtGT(*i.FinishedAtGT)) + } + if i.FinishedAtGTE != nil { + predicates = append(predicates, buildtask.FinishedAtGTE(*i.FinishedAtGTE)) + } + if i.FinishedAtLT != nil { + predicates = append(predicates, buildtask.FinishedAtLT(*i.FinishedAtLT)) + } + if i.FinishedAtLTE != nil { + predicates = append(predicates, buildtask.FinishedAtLTE(*i.FinishedAtLTE)) + } + if i.FinishedAtIsNil { + predicates = append(predicates, buildtask.FinishedAtIsNil()) + } + if i.FinishedAtNotNil { + predicates = append(predicates, buildtask.FinishedAtNotNil()) + } + if i.Output != nil { + predicates = append(predicates, buildtask.OutputEQ(*i.Output)) + } + if i.OutputNEQ != nil { + predicates = append(predicates, buildtask.OutputNEQ(*i.OutputNEQ)) + } + if len(i.OutputIn) > 0 { + predicates = append(predicates, buildtask.OutputIn(i.OutputIn...)) + } + if len(i.OutputNotIn) > 0 { + predicates = append(predicates, buildtask.OutputNotIn(i.OutputNotIn...)) + } + if i.OutputGT != nil { + predicates = append(predicates, buildtask.OutputGT(*i.OutputGT)) + } + if i.OutputGTE != nil { + predicates = append(predicates, buildtask.OutputGTE(*i.OutputGTE)) + } + if i.OutputLT != nil { + predicates = append(predicates, buildtask.OutputLT(*i.OutputLT)) + } + if i.OutputLTE != nil { + predicates = append(predicates, buildtask.OutputLTE(*i.OutputLTE)) + } + if i.OutputContains != nil { + predicates = append(predicates, buildtask.OutputContains(*i.OutputContains)) + } + if i.OutputHasPrefix != nil { + predicates = append(predicates, buildtask.OutputHasPrefix(*i.OutputHasPrefix)) + } + if i.OutputHasSuffix != nil { + predicates = append(predicates, buildtask.OutputHasSuffix(*i.OutputHasSuffix)) + } + if i.OutputIsNil { + predicates = append(predicates, buildtask.OutputIsNil()) + } + if i.OutputNotNil { + predicates = append(predicates, buildtask.OutputNotNil()) + } + if i.OutputEqualFold != nil { + predicates = append(predicates, buildtask.OutputEqualFold(*i.OutputEqualFold)) + } + if i.OutputContainsFold != nil { + predicates = append(predicates, buildtask.OutputContainsFold(*i.OutputContainsFold)) + } + if i.Error != nil { + predicates = append(predicates, buildtask.ErrorEQ(*i.Error)) + } + if i.ErrorNEQ != nil { + predicates = append(predicates, buildtask.ErrorNEQ(*i.ErrorNEQ)) + } + if len(i.ErrorIn) > 0 { + predicates = append(predicates, buildtask.ErrorIn(i.ErrorIn...)) + } + if len(i.ErrorNotIn) > 0 { + predicates = append(predicates, buildtask.ErrorNotIn(i.ErrorNotIn...)) + } + if i.ErrorGT != nil { + predicates = append(predicates, buildtask.ErrorGT(*i.ErrorGT)) + } + if i.ErrorGTE != nil { + predicates = append(predicates, buildtask.ErrorGTE(*i.ErrorGTE)) + } + if i.ErrorLT != nil { + predicates = append(predicates, buildtask.ErrorLT(*i.ErrorLT)) + } + if i.ErrorLTE != nil { + predicates = append(predicates, buildtask.ErrorLTE(*i.ErrorLTE)) + } + if i.ErrorContains != nil { + predicates = append(predicates, buildtask.ErrorContains(*i.ErrorContains)) + } + if i.ErrorHasPrefix != nil { + predicates = append(predicates, buildtask.ErrorHasPrefix(*i.ErrorHasPrefix)) + } + if i.ErrorHasSuffix != nil { + predicates = append(predicates, buildtask.ErrorHasSuffix(*i.ErrorHasSuffix)) + } + if i.ErrorIsNil { + predicates = append(predicates, buildtask.ErrorIsNil()) + } + if i.ErrorNotNil { + predicates = append(predicates, buildtask.ErrorNotNil()) + } + if i.ErrorEqualFold != nil { + predicates = append(predicates, buildtask.ErrorEqualFold(*i.ErrorEqualFold)) + } + if i.ErrorContainsFold != nil { + predicates = append(predicates, buildtask.ErrorContainsFold(*i.ErrorContainsFold)) + } + + if i.HasBuilder != nil { + p := buildtask.HasBuilder() + if !*i.HasBuilder { + p = buildtask.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasBuilderWith) > 0 { + with := make([]predicate.Builder, 0, len(i.HasBuilderWith)) + for _, w := range i.HasBuilderWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasBuilderWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, buildtask.HasBuilderWith(with...)) + } + switch len(predicates) { + case 0: + return nil, ErrEmptyBuildTaskWhereInput + case 1: + return predicates[0], nil + default: + return buildtask.And(predicates...), nil + } +} + // BuilderWhereInput represents a where input for filtering Builder queries. type BuilderWhereInput struct { Predicates []predicate.Builder `json:"-"` @@ -1128,6 +1719,10 @@ type BuilderWhereInput struct { UpstreamHasSuffix *string `json:"upstreamHasSuffix,omitempty"` UpstreamEqualFold *string `json:"upstreamEqualFold,omitempty"` UpstreamContainsFold *string `json:"upstreamContainsFold,omitempty"` + + // "build_tasks" edge predicates. + HasBuildTasks *bool `json:"hasBuildTasks,omitempty"` + HasBuildTasksWith []*BuildTaskWhereInput `json:"hasBuildTasksWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -1352,6 +1947,24 @@ func (i *BuilderWhereInput) P() (predicate.Builder, error) { predicates = append(predicates, builder.UpstreamContainsFold(*i.UpstreamContainsFold)) } + if i.HasBuildTasks != nil { + p := builder.HasBuildTasks() + if !*i.HasBuildTasks { + p = builder.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasBuildTasksWith) > 0 { + with := make([]predicate.BuildTask, 0, len(i.HasBuildTasksWith)) + for _, w := range i.HasBuildTasksWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasBuildTasksWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, builder.HasBuildTasksWith(with...)) + } switch len(predicates) { case 0: return nil, ErrEmptyBuilderWhereInput diff --git a/tavern/internal/ent/hook/hook.go b/tavern/internal/ent/hook/hook.go index 6c3f39320..8d5218863 100644 --- a/tavern/internal/ent/hook/hook.go +++ b/tavern/internal/ent/hook/hook.go @@ -33,6 +33,18 @@ func (f BeaconFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, erro return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BeaconMutation", m) } +// The BuildTaskFunc type is an adapter to allow the use of ordinary +// function as BuildTask mutator. +type BuildTaskFunc func(context.Context, *ent.BuildTaskMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f BuildTaskFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.BuildTaskMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BuildTaskMutation", m) +} + // The BuilderFunc type is an adapter to allow the use of ordinary // function as Builder mutator. type BuilderFunc func(context.Context, *ent.BuilderMutation) (ent.Value, error) diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index 2cc90f21b..c64806547 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -63,6 +63,35 @@ var ( }, }, } + // BuildTasksColumns holds the columns for the "build_tasks" table. + BuildTasksColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "last_modified_at", Type: field.TypeTime}, + {Name: "target_os", Type: field.TypeEnum, Enums: []string{"PLATFORM_BSD", "PLATFORM_LINUX", "PLATFORM_MACOS", "PLATFORM_UNSPECIFIED", "PLATFORM_WINDOWS"}}, + {Name: "build_image", Type: field.TypeString}, + {Name: "build_script", Type: field.TypeString, Size: 2147483647, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, + {Name: "claimed_at", Type: field.TypeTime, Nullable: true}, + {Name: "started_at", Type: field.TypeTime, Nullable: true}, + {Name: "finished_at", Type: field.TypeTime, Nullable: true}, + {Name: "output", Type: field.TypeString, Nullable: true, Size: 2147483647, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, + {Name: "error", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, + {Name: "build_task_builder", Type: field.TypeInt}, + } + // BuildTasksTable holds the schema information for the "build_tasks" table. + BuildTasksTable = &schema.Table{ + Name: "build_tasks", + Columns: BuildTasksColumns, + PrimaryKey: []*schema.Column{BuildTasksColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "build_tasks_builders_builder", + Columns: []*schema.Column{BuildTasksColumns[11]}, + RefColumns: []*schema.Column{BuildersColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } // BuildersColumns holds the columns for the "builders" table. BuildersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -582,6 +611,7 @@ var ( Tables = []*schema.Table{ AssetsTable, BeaconsTable, + BuildTasksTable, BuildersTable, HostsTable, HostCredentialsTable, @@ -611,6 +641,10 @@ func init() { BeaconsTable.Annotation = &entsql.Annotation{ Collation: "utf8mb4_general_ci", } + BuildTasksTable.ForeignKeys[0].RefTable = BuildersTable + BuildTasksTable.Annotation = &entsql.Annotation{ + Collation: "utf8mb4_general_ci", + } BuildersTable.Annotation = &entsql.Annotation{ Collation: "utf8mb4_general_ci", } diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index 0090293fe..e1c551a60 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -16,6 +16,7 @@ import ( "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -43,6 +44,7 @@ const ( // Node types. TypeAsset = "Asset" TypeBeacon = "Beacon" + TypeBuildTask = "BuildTask" TypeBuilder = "Builder" TypeHost = "Host" TypeHostCredential = "HostCredential" @@ -2108,6 +2110,983 @@ func (m *BeaconMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Beacon edge %s", name) } +// BuildTaskMutation represents an operation that mutates the BuildTask nodes in the graph. +type BuildTaskMutation struct { + config + op Op + typ string + id *int + created_at *time.Time + last_modified_at *time.Time + target_os *c2pb.Host_Platform + build_image *string + build_script *string + claimed_at *time.Time + started_at *time.Time + finished_at *time.Time + output *string + error *string + clearedFields map[string]struct{} + builder *int + clearedbuilder bool + done bool + oldValue func(context.Context) (*BuildTask, error) + predicates []predicate.BuildTask +} + +var _ ent.Mutation = (*BuildTaskMutation)(nil) + +// buildtaskOption allows management of the mutation configuration using functional options. +type buildtaskOption func(*BuildTaskMutation) + +// newBuildTaskMutation creates new mutation for the BuildTask entity. +func newBuildTaskMutation(c config, op Op, opts ...buildtaskOption) *BuildTaskMutation { + m := &BuildTaskMutation{ + config: c, + op: op, + typ: TypeBuildTask, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withBuildTaskID sets the ID field of the mutation. +func withBuildTaskID(id int) buildtaskOption { + return func(m *BuildTaskMutation) { + var ( + err error + once sync.Once + value *BuildTask + ) + m.oldValue = func(ctx context.Context) (*BuildTask, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().BuildTask.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withBuildTask sets the old BuildTask of the mutation. +func withBuildTask(node *BuildTask) buildtaskOption { + return func(m *BuildTaskMutation) { + m.oldValue = func(context.Context) (*BuildTask, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m BuildTaskMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m BuildTaskMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *BuildTaskMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *BuildTaskMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().BuildTask.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *BuildTaskMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *BuildTaskMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *BuildTaskMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (m *BuildTaskMutation) SetLastModifiedAt(t time.Time) { + m.last_modified_at = &t +} + +// LastModifiedAt returns the value of the "last_modified_at" field in the mutation. +func (m *BuildTaskMutation) LastModifiedAt() (r time.Time, exists bool) { + v := m.last_modified_at + if v == nil { + return + } + return *v, true +} + +// OldLastModifiedAt returns the old "last_modified_at" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastModifiedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastModifiedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastModifiedAt: %w", err) + } + return oldValue.LastModifiedAt, nil +} + +// ResetLastModifiedAt resets all changes to the "last_modified_at" field. +func (m *BuildTaskMutation) ResetLastModifiedAt() { + m.last_modified_at = nil +} + +// SetTargetOs sets the "target_os" field. +func (m *BuildTaskMutation) SetTargetOs(cp c2pb.Host_Platform) { + m.target_os = &cp +} + +// TargetOs returns the value of the "target_os" field in the mutation. +func (m *BuildTaskMutation) TargetOs() (r c2pb.Host_Platform, exists bool) { + v := m.target_os + if v == nil { + return + } + return *v, true +} + +// OldTargetOs returns the old "target_os" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldTargetOs(ctx context.Context) (v c2pb.Host_Platform, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTargetOs is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTargetOs requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTargetOs: %w", err) + } + return oldValue.TargetOs, nil +} + +// ResetTargetOs resets all changes to the "target_os" field. +func (m *BuildTaskMutation) ResetTargetOs() { + m.target_os = nil +} + +// SetBuildImage sets the "build_image" field. +func (m *BuildTaskMutation) SetBuildImage(s string) { + m.build_image = &s +} + +// BuildImage returns the value of the "build_image" field in the mutation. +func (m *BuildTaskMutation) BuildImage() (r string, exists bool) { + v := m.build_image + if v == nil { + return + } + return *v, true +} + +// OldBuildImage returns the old "build_image" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldBuildImage(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBuildImage is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBuildImage requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBuildImage: %w", err) + } + return oldValue.BuildImage, nil +} + +// ResetBuildImage resets all changes to the "build_image" field. +func (m *BuildTaskMutation) ResetBuildImage() { + m.build_image = nil +} + +// SetBuildScript sets the "build_script" field. +func (m *BuildTaskMutation) SetBuildScript(s string) { + m.build_script = &s +} + +// BuildScript returns the value of the "build_script" field in the mutation. +func (m *BuildTaskMutation) BuildScript() (r string, exists bool) { + v := m.build_script + if v == nil { + return + } + return *v, true +} + +// OldBuildScript returns the old "build_script" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldBuildScript(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBuildScript is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBuildScript requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBuildScript: %w", err) + } + return oldValue.BuildScript, nil +} + +// ResetBuildScript resets all changes to the "build_script" field. +func (m *BuildTaskMutation) ResetBuildScript() { + m.build_script = nil +} + +// SetClaimedAt sets the "claimed_at" field. +func (m *BuildTaskMutation) SetClaimedAt(t time.Time) { + m.claimed_at = &t +} + +// ClaimedAt returns the value of the "claimed_at" field in the mutation. +func (m *BuildTaskMutation) ClaimedAt() (r time.Time, exists bool) { + v := m.claimed_at + if v == nil { + return + } + return *v, true +} + +// OldClaimedAt returns the old "claimed_at" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldClaimedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldClaimedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldClaimedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldClaimedAt: %w", err) + } + return oldValue.ClaimedAt, nil +} + +// ClearClaimedAt clears the value of the "claimed_at" field. +func (m *BuildTaskMutation) ClearClaimedAt() { + m.claimed_at = nil + m.clearedFields[buildtask.FieldClaimedAt] = struct{}{} +} + +// ClaimedAtCleared returns if the "claimed_at" field was cleared in this mutation. +func (m *BuildTaskMutation) ClaimedAtCleared() bool { + _, ok := m.clearedFields[buildtask.FieldClaimedAt] + return ok +} + +// ResetClaimedAt resets all changes to the "claimed_at" field. +func (m *BuildTaskMutation) ResetClaimedAt() { + m.claimed_at = nil + delete(m.clearedFields, buildtask.FieldClaimedAt) +} + +// SetStartedAt sets the "started_at" field. +func (m *BuildTaskMutation) SetStartedAt(t time.Time) { + m.started_at = &t +} + +// StartedAt returns the value of the "started_at" field in the mutation. +func (m *BuildTaskMutation) StartedAt() (r time.Time, exists bool) { + v := m.started_at + if v == nil { + return + } + return *v, true +} + +// OldStartedAt returns the old "started_at" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldStartedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStartedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStartedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStartedAt: %w", err) + } + return oldValue.StartedAt, nil +} + +// ClearStartedAt clears the value of the "started_at" field. +func (m *BuildTaskMutation) ClearStartedAt() { + m.started_at = nil + m.clearedFields[buildtask.FieldStartedAt] = struct{}{} +} + +// StartedAtCleared returns if the "started_at" field was cleared in this mutation. +func (m *BuildTaskMutation) StartedAtCleared() bool { + _, ok := m.clearedFields[buildtask.FieldStartedAt] + return ok +} + +// ResetStartedAt resets all changes to the "started_at" field. +func (m *BuildTaskMutation) ResetStartedAt() { + m.started_at = nil + delete(m.clearedFields, buildtask.FieldStartedAt) +} + +// SetFinishedAt sets the "finished_at" field. +func (m *BuildTaskMutation) SetFinishedAt(t time.Time) { + m.finished_at = &t +} + +// FinishedAt returns the value of the "finished_at" field in the mutation. +func (m *BuildTaskMutation) FinishedAt() (r time.Time, exists bool) { + v := m.finished_at + if v == nil { + return + } + return *v, true +} + +// OldFinishedAt returns the old "finished_at" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldFinishedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFinishedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFinishedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFinishedAt: %w", err) + } + return oldValue.FinishedAt, nil +} + +// ClearFinishedAt clears the value of the "finished_at" field. +func (m *BuildTaskMutation) ClearFinishedAt() { + m.finished_at = nil + m.clearedFields[buildtask.FieldFinishedAt] = struct{}{} +} + +// FinishedAtCleared returns if the "finished_at" field was cleared in this mutation. +func (m *BuildTaskMutation) FinishedAtCleared() bool { + _, ok := m.clearedFields[buildtask.FieldFinishedAt] + return ok +} + +// ResetFinishedAt resets all changes to the "finished_at" field. +func (m *BuildTaskMutation) ResetFinishedAt() { + m.finished_at = nil + delete(m.clearedFields, buildtask.FieldFinishedAt) +} + +// SetOutput sets the "output" field. +func (m *BuildTaskMutation) SetOutput(s string) { + m.output = &s +} + +// Output returns the value of the "output" field in the mutation. +func (m *BuildTaskMutation) Output() (r string, exists bool) { + v := m.output + if v == nil { + return + } + return *v, true +} + +// OldOutput returns the old "output" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldOutput(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOutput is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOutput requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOutput: %w", err) + } + return oldValue.Output, nil +} + +// ClearOutput clears the value of the "output" field. +func (m *BuildTaskMutation) ClearOutput() { + m.output = nil + m.clearedFields[buildtask.FieldOutput] = struct{}{} +} + +// OutputCleared returns if the "output" field was cleared in this mutation. +func (m *BuildTaskMutation) OutputCleared() bool { + _, ok := m.clearedFields[buildtask.FieldOutput] + return ok +} + +// ResetOutput resets all changes to the "output" field. +func (m *BuildTaskMutation) ResetOutput() { + m.output = nil + delete(m.clearedFields, buildtask.FieldOutput) +} + +// SetError sets the "error" field. +func (m *BuildTaskMutation) SetError(s string) { + m.error = &s +} + +// Error returns the value of the "error" field in the mutation. +func (m *BuildTaskMutation) Error() (r string, exists bool) { + v := m.error + if v == nil { + return + } + return *v, true +} + +// OldError returns the old "error" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldError(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldError is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldError requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldError: %w", err) + } + return oldValue.Error, nil +} + +// ClearError clears the value of the "error" field. +func (m *BuildTaskMutation) ClearError() { + m.error = nil + m.clearedFields[buildtask.FieldError] = struct{}{} +} + +// ErrorCleared returns if the "error" field was cleared in this mutation. +func (m *BuildTaskMutation) ErrorCleared() bool { + _, ok := m.clearedFields[buildtask.FieldError] + return ok +} + +// ResetError resets all changes to the "error" field. +func (m *BuildTaskMutation) ResetError() { + m.error = nil + delete(m.clearedFields, buildtask.FieldError) +} + +// SetBuilderID sets the "builder" edge to the Builder entity by id. +func (m *BuildTaskMutation) SetBuilderID(id int) { + m.builder = &id +} + +// ClearBuilder clears the "builder" edge to the Builder entity. +func (m *BuildTaskMutation) ClearBuilder() { + m.clearedbuilder = true +} + +// BuilderCleared reports if the "builder" edge to the Builder entity was cleared. +func (m *BuildTaskMutation) BuilderCleared() bool { + return m.clearedbuilder +} + +// BuilderID returns the "builder" edge ID in the mutation. +func (m *BuildTaskMutation) BuilderID() (id int, exists bool) { + if m.builder != nil { + return *m.builder, true + } + return +} + +// BuilderIDs returns the "builder" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// BuilderID instead. It exists only for internal usage by the builders. +func (m *BuildTaskMutation) BuilderIDs() (ids []int) { + if id := m.builder; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetBuilder resets all changes to the "builder" edge. +func (m *BuildTaskMutation) ResetBuilder() { + m.builder = nil + m.clearedbuilder = false +} + +// Where appends a list predicates to the BuildTaskMutation builder. +func (m *BuildTaskMutation) Where(ps ...predicate.BuildTask) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the BuildTaskMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *BuildTaskMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.BuildTask, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *BuildTaskMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *BuildTaskMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (BuildTask). +func (m *BuildTaskMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *BuildTaskMutation) Fields() []string { + fields := make([]string, 0, 10) + if m.created_at != nil { + fields = append(fields, buildtask.FieldCreatedAt) + } + if m.last_modified_at != nil { + fields = append(fields, buildtask.FieldLastModifiedAt) + } + if m.target_os != nil { + fields = append(fields, buildtask.FieldTargetOs) + } + if m.build_image != nil { + fields = append(fields, buildtask.FieldBuildImage) + } + if m.build_script != nil { + fields = append(fields, buildtask.FieldBuildScript) + } + if m.claimed_at != nil { + fields = append(fields, buildtask.FieldClaimedAt) + } + if m.started_at != nil { + fields = append(fields, buildtask.FieldStartedAt) + } + if m.finished_at != nil { + fields = append(fields, buildtask.FieldFinishedAt) + } + if m.output != nil { + fields = append(fields, buildtask.FieldOutput) + } + if m.error != nil { + fields = append(fields, buildtask.FieldError) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *BuildTaskMutation) Field(name string) (ent.Value, bool) { + switch name { + case buildtask.FieldCreatedAt: + return m.CreatedAt() + case buildtask.FieldLastModifiedAt: + return m.LastModifiedAt() + case buildtask.FieldTargetOs: + return m.TargetOs() + case buildtask.FieldBuildImage: + return m.BuildImage() + case buildtask.FieldBuildScript: + return m.BuildScript() + case buildtask.FieldClaimedAt: + return m.ClaimedAt() + case buildtask.FieldStartedAt: + return m.StartedAt() + case buildtask.FieldFinishedAt: + return m.FinishedAt() + case buildtask.FieldOutput: + return m.Output() + case buildtask.FieldError: + return m.Error() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *BuildTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case buildtask.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case buildtask.FieldLastModifiedAt: + return m.OldLastModifiedAt(ctx) + case buildtask.FieldTargetOs: + return m.OldTargetOs(ctx) + case buildtask.FieldBuildImage: + return m.OldBuildImage(ctx) + case buildtask.FieldBuildScript: + return m.OldBuildScript(ctx) + case buildtask.FieldClaimedAt: + return m.OldClaimedAt(ctx) + case buildtask.FieldStartedAt: + return m.OldStartedAt(ctx) + case buildtask.FieldFinishedAt: + return m.OldFinishedAt(ctx) + case buildtask.FieldOutput: + return m.OldOutput(ctx) + case buildtask.FieldError: + return m.OldError(ctx) + } + return nil, fmt.Errorf("unknown BuildTask field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *BuildTaskMutation) SetField(name string, value ent.Value) error { + switch name { + case buildtask.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case buildtask.FieldLastModifiedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastModifiedAt(v) + return nil + case buildtask.FieldTargetOs: + v, ok := value.(c2pb.Host_Platform) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTargetOs(v) + return nil + case buildtask.FieldBuildImage: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBuildImage(v) + return nil + case buildtask.FieldBuildScript: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBuildScript(v) + return nil + case buildtask.FieldClaimedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetClaimedAt(v) + return nil + case buildtask.FieldStartedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStartedAt(v) + return nil + case buildtask.FieldFinishedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFinishedAt(v) + return nil + case buildtask.FieldOutput: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOutput(v) + return nil + case buildtask.FieldError: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetError(v) + return nil + } + return fmt.Errorf("unknown BuildTask field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *BuildTaskMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *BuildTaskMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *BuildTaskMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown BuildTask numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *BuildTaskMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(buildtask.FieldClaimedAt) { + fields = append(fields, buildtask.FieldClaimedAt) + } + if m.FieldCleared(buildtask.FieldStartedAt) { + fields = append(fields, buildtask.FieldStartedAt) + } + if m.FieldCleared(buildtask.FieldFinishedAt) { + fields = append(fields, buildtask.FieldFinishedAt) + } + if m.FieldCleared(buildtask.FieldOutput) { + fields = append(fields, buildtask.FieldOutput) + } + if m.FieldCleared(buildtask.FieldError) { + fields = append(fields, buildtask.FieldError) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *BuildTaskMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *BuildTaskMutation) ClearField(name string) error { + switch name { + case buildtask.FieldClaimedAt: + m.ClearClaimedAt() + return nil + case buildtask.FieldStartedAt: + m.ClearStartedAt() + return nil + case buildtask.FieldFinishedAt: + m.ClearFinishedAt() + return nil + case buildtask.FieldOutput: + m.ClearOutput() + return nil + case buildtask.FieldError: + m.ClearError() + return nil + } + return fmt.Errorf("unknown BuildTask nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *BuildTaskMutation) ResetField(name string) error { + switch name { + case buildtask.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case buildtask.FieldLastModifiedAt: + m.ResetLastModifiedAt() + return nil + case buildtask.FieldTargetOs: + m.ResetTargetOs() + return nil + case buildtask.FieldBuildImage: + m.ResetBuildImage() + return nil + case buildtask.FieldBuildScript: + m.ResetBuildScript() + return nil + case buildtask.FieldClaimedAt: + m.ResetClaimedAt() + return nil + case buildtask.FieldStartedAt: + m.ResetStartedAt() + return nil + case buildtask.FieldFinishedAt: + m.ResetFinishedAt() + return nil + case buildtask.FieldOutput: + m.ResetOutput() + return nil + case buildtask.FieldError: + m.ResetError() + return nil + } + return fmt.Errorf("unknown BuildTask field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *BuildTaskMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.builder != nil { + edges = append(edges, buildtask.EdgeBuilder) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *BuildTaskMutation) AddedIDs(name string) []ent.Value { + switch name { + case buildtask.EdgeBuilder: + if id := m.builder; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *BuildTaskMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *BuildTaskMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *BuildTaskMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedbuilder { + edges = append(edges, buildtask.EdgeBuilder) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *BuildTaskMutation) EdgeCleared(name string) bool { + switch name { + case buildtask.EdgeBuilder: + return m.clearedbuilder + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *BuildTaskMutation) ClearEdge(name string) error { + switch name { + case buildtask.EdgeBuilder: + m.ClearBuilder() + return nil + } + return fmt.Errorf("unknown BuildTask unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *BuildTaskMutation) ResetEdge(name string) error { + switch name { + case buildtask.EdgeBuilder: + m.ResetBuilder() + return nil + } + return fmt.Errorf("unknown BuildTask edge %s", name) +} + // BuilderMutation represents an operation that mutates the Builder nodes in the graph. type BuilderMutation struct { config @@ -2121,6 +3100,9 @@ type BuilderMutation struct { appendsupported_targets []c2pb.Host_Platform upstream *string clearedFields map[string]struct{} + build_tasks map[int]struct{} + removedbuild_tasks map[int]struct{} + clearedbuild_tasks bool done bool oldValue func(context.Context) (*Builder, error) predicates []predicate.Builder @@ -2419,6 +3401,60 @@ func (m *BuilderMutation) ResetUpstream() { m.upstream = nil } +// AddBuildTaskIDs adds the "build_tasks" edge to the BuildTask entity by ids. +func (m *BuilderMutation) AddBuildTaskIDs(ids ...int) { + if m.build_tasks == nil { + m.build_tasks = make(map[int]struct{}) + } + for i := range ids { + m.build_tasks[ids[i]] = struct{}{} + } +} + +// ClearBuildTasks clears the "build_tasks" edge to the BuildTask entity. +func (m *BuilderMutation) ClearBuildTasks() { + m.clearedbuild_tasks = true +} + +// BuildTasksCleared reports if the "build_tasks" edge to the BuildTask entity was cleared. +func (m *BuilderMutation) BuildTasksCleared() bool { + return m.clearedbuild_tasks +} + +// RemoveBuildTaskIDs removes the "build_tasks" edge to the BuildTask entity by IDs. +func (m *BuilderMutation) RemoveBuildTaskIDs(ids ...int) { + if m.removedbuild_tasks == nil { + m.removedbuild_tasks = make(map[int]struct{}) + } + for i := range ids { + delete(m.build_tasks, ids[i]) + m.removedbuild_tasks[ids[i]] = struct{}{} + } +} + +// RemovedBuildTasks returns the removed IDs of the "build_tasks" edge to the BuildTask entity. +func (m *BuilderMutation) RemovedBuildTasksIDs() (ids []int) { + for id := range m.removedbuild_tasks { + ids = append(ids, id) + } + return +} + +// BuildTasksIDs returns the "build_tasks" edge IDs in the mutation. +func (m *BuilderMutation) BuildTasksIDs() (ids []int) { + for id := range m.build_tasks { + ids = append(ids, id) + } + return +} + +// ResetBuildTasks resets all changes to the "build_tasks" edge. +func (m *BuilderMutation) ResetBuildTasks() { + m.build_tasks = nil + m.clearedbuild_tasks = false + m.removedbuild_tasks = nil +} + // Where appends a list predicates to the BuilderMutation builder. func (m *BuilderMutation) Where(ps ...predicate.Builder) { m.predicates = append(m.predicates, ps...) @@ -2620,49 +3656,85 @@ func (m *BuilderMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *BuilderMutation) AddedEdges() []string { - edges := make([]string, 0, 0) + edges := make([]string, 0, 1) + if m.build_tasks != nil { + edges = append(edges, builder.EdgeBuildTasks) + } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *BuilderMutation) AddedIDs(name string) []ent.Value { + switch name { + case builder.EdgeBuildTasks: + ids := make([]ent.Value, 0, len(m.build_tasks)) + for id := range m.build_tasks { + ids = append(ids, id) + } + return ids + } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *BuilderMutation) RemovedEdges() []string { - edges := make([]string, 0, 0) + edges := make([]string, 0, 1) + if m.removedbuild_tasks != nil { + edges = append(edges, builder.EdgeBuildTasks) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *BuilderMutation) RemovedIDs(name string) []ent.Value { + switch name { + case builder.EdgeBuildTasks: + ids := make([]ent.Value, 0, len(m.removedbuild_tasks)) + for id := range m.removedbuild_tasks { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *BuilderMutation) ClearedEdges() []string { - edges := make([]string, 0, 0) + edges := make([]string, 0, 1) + if m.clearedbuild_tasks { + edges = append(edges, builder.EdgeBuildTasks) + } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *BuilderMutation) EdgeCleared(name string) bool { + switch name { + case builder.EdgeBuildTasks: + return m.clearedbuild_tasks + } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. func (m *BuilderMutation) ClearEdge(name string) error { + switch name { + } return fmt.Errorf("unknown Builder unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. func (m *BuilderMutation) ResetEdge(name string) error { + switch name { + case builder.EdgeBuildTasks: + m.ResetBuildTasks() + return nil + } return fmt.Errorf("unknown Builder edge %s", name) } diff --git a/tavern/internal/ent/predicate/predicate.go b/tavern/internal/ent/predicate/predicate.go index 307d53f64..664394ea2 100644 --- a/tavern/internal/ent/predicate/predicate.go +++ b/tavern/internal/ent/predicate/predicate.go @@ -12,6 +12,9 @@ type Asset func(*sql.Selector) // Beacon is the predicate function for beacon builders. type Beacon func(*sql.Selector) +// BuildTask is the predicate function for buildtask builders. +type BuildTask func(*sql.Selector) + // Builder is the predicate function for builder builders. type Builder func(*sql.Selector) diff --git a/tavern/internal/ent/privacy/privacy.go b/tavern/internal/ent/privacy/privacy.go index 28cc3463a..02362ab95 100644 --- a/tavern/internal/ent/privacy/privacy.go +++ b/tavern/internal/ent/privacy/privacy.go @@ -158,6 +158,30 @@ func (f BeaconMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.BeaconMutation", m) } +// The BuildTaskQueryRuleFunc type is an adapter to allow the use of ordinary +// functions as a query rule. +type BuildTaskQueryRuleFunc func(context.Context, *ent.BuildTaskQuery) error + +// EvalQuery return f(ctx, q). +func (f BuildTaskQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.BuildTaskQuery); ok { + return f(ctx, q) + } + return Denyf("ent/privacy: unexpected query type %T, expect *ent.BuildTaskQuery", q) +} + +// The BuildTaskMutationRuleFunc type is an adapter to allow the use of ordinary +// functions as a mutation rule. +type BuildTaskMutationRuleFunc func(context.Context, *ent.BuildTaskMutation) error + +// EvalMutation calls f(ctx, m). +func (f BuildTaskMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { + if m, ok := m.(*ent.BuildTaskMutation); ok { + return f(ctx, m) + } + return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.BuildTaskMutation", m) +} + // The BuilderQueryRuleFunc type is an adapter to allow the use of ordinary // functions as a query rule. type BuilderQueryRuleFunc func(context.Context, *ent.BuilderQuery) error diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index b6a41a928..83ee281a7 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -8,6 +8,7 @@ import ( "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -94,6 +95,29 @@ func init() { beaconDescAgentIdentifier := beaconFields[3].Descriptor() // beacon.AgentIdentifierValidator is a validator for the "agent_identifier" field. It is called by the builders before save. beacon.AgentIdentifierValidator = beaconDescAgentIdentifier.Validators[0].(func(string) error) + buildtaskMixin := schema.BuildTask{}.Mixin() + buildtaskMixinFields0 := buildtaskMixin[0].Fields() + _ = buildtaskMixinFields0 + buildtaskFields := schema.BuildTask{}.Fields() + _ = buildtaskFields + // buildtaskDescCreatedAt is the schema descriptor for created_at field. + buildtaskDescCreatedAt := buildtaskMixinFields0[0].Descriptor() + // buildtask.DefaultCreatedAt holds the default value on creation for the created_at field. + buildtask.DefaultCreatedAt = buildtaskDescCreatedAt.Default.(func() time.Time) + // buildtaskDescLastModifiedAt is the schema descriptor for last_modified_at field. + buildtaskDescLastModifiedAt := buildtaskMixinFields0[1].Descriptor() + // buildtask.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. + buildtask.DefaultLastModifiedAt = buildtaskDescLastModifiedAt.Default.(func() time.Time) + // buildtask.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. + buildtask.UpdateDefaultLastModifiedAt = buildtaskDescLastModifiedAt.UpdateDefault.(func() time.Time) + // buildtaskDescBuildImage is the schema descriptor for build_image field. + buildtaskDescBuildImage := buildtaskFields[1].Descriptor() + // buildtask.BuildImageValidator is a validator for the "build_image" field. It is called by the builders before save. + buildtask.BuildImageValidator = buildtaskDescBuildImage.Validators[0].(func(string) error) + // buildtaskDescBuildScript is the schema descriptor for build_script field. + buildtaskDescBuildScript := buildtaskFields[2].Descriptor() + // buildtask.BuildScriptValidator is a validator for the "build_script" field. It is called by the builders before save. + buildtask.BuildScriptValidator = buildtaskDescBuildScript.Validators[0].(func(string) error) builderMixin := schema.Builder{}.Mixin() builderMixinFields0 := builderMixin[0].Fields() _ = builderMixinFields0 diff --git a/tavern/internal/ent/schema/build_task.go b/tavern/internal/ent/schema/build_task.go new file mode 100644 index 000000000..0b0a40529 --- /dev/null +++ b/tavern/internal/ent/schema/build_task.go @@ -0,0 +1,100 @@ +package schema + +import ( + "entgo.io/contrib/entgql" + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" +) + +// BuildTask holds the schema definition for the BuildTask entity. +type BuildTask struct { + ent.Schema +} + +// Fields of the BuildTask. +func (BuildTask) Fields() []ent.Field { + return []ent.Field{ + field.Enum("target_os"). + GoType(c2pb.Host_Platform(0)). + Annotations( + entgql.Type("HostPlatform"), + entgql.OrderField("TARGET_OS"), + ). + Comment("The target operating system platform for this build."), + field.String("build_image"). + NotEmpty(). + Comment("Docker container image name to use for the build."), + field.Text("build_script"). + NotEmpty(). + SchemaType(map[string]string{ + dialect.MySQL: "LONGTEXT", + }). + Comment("The script to execute inside the build container."), + field.Time("claimed_at"). + Optional(). + Annotations( + entgql.OrderField("CLAIMED_AT"), + ). + Comment("Timestamp of when a builder claimed this task, null if unclaimed."), + field.Time("started_at"). + Optional(). + Annotations( + entgql.OrderField("STARTED_AT"), + ). + Comment("Timestamp of when the build execution started, null if not yet started."), + field.Time("finished_at"). + Optional(). + Annotations( + entgql.OrderField("FINISHED_AT"), + ). + Comment("Timestamp of when the build finished, null if not yet finished."), + field.Text("output"). + Optional(). + SchemaType(map[string]string{ + dialect.MySQL: "LONGTEXT", + }). + Comment("Output from the build execution."), + field.String("error"). + Optional(). + SchemaType(map[string]string{ + dialect.MySQL: "LONGTEXT", + }). + Comment("Error message if the build failed."), + } +} + +// Edges of the BuildTask. +func (BuildTask) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("builder", Builder.Type). + Annotations( + entsql.OnDelete(entsql.Cascade), + ). + Required(). + Unique(). + Comment("The builder assigned to execute this build task."), + } +} + +// Annotations describes additional information for the ent. +func (BuildTask) Annotations() []schema.Annotation { + return []schema.Annotation{ + entgql.RelayConnection(), + entgql.MultiOrder(), + entsql.Annotation{ + Collation: "utf8mb4_general_ci", + }, + } +} + +// Mixin defines common shared properties for the ent. +func (BuildTask) Mixin() []ent.Mixin { + return []ent.Mixin{ + MixinHistory{}, // created_at, last_modified_at + } +} diff --git a/tavern/internal/ent/schema/builder.go b/tavern/internal/ent/schema/builder.go index d29e5269d..497a704bc 100644 --- a/tavern/internal/ent/schema/builder.go +++ b/tavern/internal/ent/schema/builder.go @@ -7,6 +7,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "realm.pub/tavern/internal/c2/c2pb" ) @@ -40,7 +41,15 @@ func (Builder) Fields() []ent.Field { // Edges of the Builder. func (Builder) Edges() []ent.Edge { - return nil + return []ent.Edge{ + edge.From("build_tasks", BuildTask.Type). + Ref("builder"). + Annotations( + entgql.RelayConnection(), + entgql.MultiOrder(), + ). + Comment("Build tasks assigned to this builder."), + } } // Annotations describes additional information for the ent. diff --git a/tavern/internal/ent/tx.go b/tavern/internal/ent/tx.go index 1fb27f5b7..7fa50213a 100644 --- a/tavern/internal/ent/tx.go +++ b/tavern/internal/ent/tx.go @@ -16,6 +16,8 @@ type Tx struct { Asset *AssetClient // Beacon is the client for interacting with the Beacon builders. Beacon *BeaconClient + // BuildTask is the client for interacting with the BuildTask builders. + BuildTask *BuildTaskClient // Builder is the client for interacting with the Builder builders. Builder *BuilderClient // Host is the client for interacting with the Host builders. @@ -177,6 +179,7 @@ func (tx *Tx) Client() *Client { func (tx *Tx) init() { tx.Asset = NewAssetClient(tx.config) tx.Beacon = NewBeaconClient(tx.config) + tx.BuildTask = NewBuildTaskClient(tx.config) tx.Builder = NewBuilderClient(tx.config) tx.Host = NewHostClient(tx.config) tx.HostCredential = NewHostCredentialClient(tx.config) diff --git a/tavern/internal/graphql/build_task_test.go b/tavern/internal/graphql/build_task_test.go new file mode 100644 index 000000000..92d2d712d --- /dev/null +++ b/tavern/internal/graphql/build_task_test.go @@ -0,0 +1,161 @@ +package graphql_test + +import ( + "context" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql/handler" + _ "github.com/mattn/go-sqlite3" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/enttest" + "realm.pub/tavern/internal/graphql" + tavernhttp "realm.pub/tavern/internal/http" + "realm.pub/tavern/tomes" +) + +func TestCreateBuildTask(t *testing.T) { + ctx := context.Background() + graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + defer graph.Close() + + git := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( + tavernhttp.RouteMap{ + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), + }, + tavernhttp.WithAuthenticationBypass(graph), + ) + gqlClient := client.New(srv, client.Path("/graphql")) + + mutFull := `mutation createBuildTask($input: CreateBuildTaskInput!) { + createBuildTask(input: $input) { + id + targetOs + buildImage + buildScript + builder { id } + } + }` + mutIDOnly := `mutation createBuildTask($input: CreateBuildTaskInput!) { + createBuildTask(input: $input) { + id + } + }` + + t.Run("NoBuilders", func(t *testing.T) { + var resp struct { + CreateBuildTask struct { + ID string + } + } + err := gqlClient.Post(mutIDOnly, &resp, client.Var("input", map[string]any{ + "targetOS": "PLATFORM_LINUX", + "buildImage": "golang:1.21", + "buildScript": "go build ./...", + })) + require.Error(t, err) + assert.Contains(t, err.Error(), "no builder available") + }) + + t.Run("NoMatchingBuilder", func(t *testing.T) { + // Create a builder that only supports Windows + graph.Builder.Create(). + SetSupportedTargets([]c2pb.Host_Platform{c2pb.Host_PLATFORM_WINDOWS}). + SetUpstream("https://example.com"). + SaveX(ctx) + + var resp struct { + CreateBuildTask struct { + ID string + } + } + err := gqlClient.Post(mutIDOnly, &resp, client.Var("input", map[string]any{ + "targetOS": "PLATFORM_LINUX", + "buildImage": "golang:1.21", + "buildScript": "go build ./...", + })) + require.Error(t, err) + assert.Contains(t, err.Error(), "no builder available") + }) + + t.Run("SingleMatchingBuilder", func(t *testing.T) { + // Clean up previous builders + graph.BuildTask.Delete().ExecX(ctx) + graph.Builder.Delete().ExecX(ctx) + + linuxBuilder := graph.Builder.Create(). + SetSupportedTargets([]c2pb.Host_Platform{c2pb.Host_PLATFORM_LINUX}). + SetUpstream("https://example.com"). + SaveX(ctx) + + var resp struct { + CreateBuildTask struct { + ID string + TargetOs string + BuildImage string + BuildScript string + Builder struct { + ID string + } + } + } + err := gqlClient.Post(mutFull, &resp, client.Var("input", map[string]any{ + "targetOS": "PLATFORM_LINUX", + "buildImage": "golang:1.21", + "buildScript": "go build ./...", + })) + require.NoError(t, err) + require.NotEmpty(t, resp.CreateBuildTask.ID) + assert.Equal(t, "PLATFORM_LINUX", resp.CreateBuildTask.TargetOs) + assert.Equal(t, "golang:1.21", resp.CreateBuildTask.BuildImage) + assert.Equal(t, "go build ./...", resp.CreateBuildTask.BuildScript) + + // Verify the builder edge + bt := graph.BuildTask.GetX(ctx, convertID(resp.CreateBuildTask.ID)) + assignedBuilder := bt.QueryBuilder().OnlyX(ctx) + assert.Equal(t, linuxBuilder.ID, assignedBuilder.ID) + }) + + t.Run("MultipleMatchingBuilders", func(t *testing.T) { + // Clean up + graph.BuildTask.Delete().ExecX(ctx) + graph.Builder.Delete().ExecX(ctx) + + // Create 3 builders that all support Linux + builders := make(map[int]bool) + for i := 0; i < 3; i++ { + b := graph.Builder.Create(). + SetSupportedTargets([]c2pb.Host_Platform{c2pb.Host_PLATFORM_LINUX}). + SetUpstream("https://example.com"). + SaveX(ctx) + builders[b.ID] = true + } + + // Create 20 build tasks and track which builders get selected + selectedBuilders := make(map[int]bool) + for i := 0; i < 20; i++ { + var resp struct { + CreateBuildTask struct { + ID string + } + } + err := gqlClient.Post(mutIDOnly, &resp, client.Var("input", map[string]any{ + "targetOS": "PLATFORM_LINUX", + "buildImage": "golang:1.21", + "buildScript": "go build ./...", + })) + require.NoError(t, err) + + bt := graph.BuildTask.GetX(ctx, convertID(resp.CreateBuildTask.ID)) + assignedBuilder := bt.QueryBuilder().OnlyX(ctx) + assert.True(t, builders[assignedBuilder.ID], "selected builder should be one of the candidates") + selectedBuilders[assignedBuilder.ID] = true + } + + // With 3 builders and 20 attempts, we should see at least 2 different builders selected + assert.Greater(t, len(selectedBuilders), 1, "expected random selection across multiple builders") + }) +} diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index 7c953ef9a..9c03c0bf4 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -36,6 +36,7 @@ type QueryResolver interface { Users(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.UserOrder, where *ent.UserWhereInput) (*ent.UserConnection, error) Portals(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.PortalOrder, where *ent.PortalWhereInput) (*ent.PortalConnection, error) Shells(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.ShellOrder, where *ent.ShellWhereInput) (*ent.ShellConnection, error) + BuildTasks(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BuildTaskOrder, where *ent.BuildTaskWhereInput) (*ent.BuildTaskConnection, error) Me(ctx context.Context) (*ent.User, error) } @@ -187,6 +188,42 @@ func (ec *executionContext) field_Beacon_tasks_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) field_Builder_buildTasks_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor) + if err != nil { + return nil, err + } + args["after"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) + if err != nil { + return nil, err + } + args["first"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "before", ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor) + if err != nil { + return nil, err + } + args["before"] = arg2 + arg3, err := graphql.ProcessArgField(ctx, rawArgs, "last", ec.unmarshalOInt2ᚖint) + if err != nil { + return nil, err + } + args["last"] = arg3 + arg4, err := graphql.ProcessArgField(ctx, rawArgs, "orderBy", ec.unmarshalOBuildTaskOrder2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskOrderᚄ) + if err != nil { + return nil, err + } + args["orderBy"] = arg4 + arg5, err := graphql.ProcessArgField(ctx, rawArgs, "where", ec.unmarshalOBuildTaskWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInput) + if err != nil { + return nil, err + } + args["where"] = arg5 + return args, nil +} + func (ec *executionContext) field_Host_beacons_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -486,6 +523,42 @@ func (ec *executionContext) field_Query_beacons_args(ctx context.Context, rawArg return args, nil } +func (ec *executionContext) field_Query_buildTasks_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor) + if err != nil { + return nil, err + } + args["after"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) + if err != nil { + return nil, err + } + args["first"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "before", ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor) + if err != nil { + return nil, err + } + args["before"] = arg2 + arg3, err := graphql.ProcessArgField(ctx, rawArgs, "last", ec.unmarshalOInt2ᚖint) + if err != nil { + return nil, err + } + args["last"] = arg3 + arg4, err := graphql.ProcessArgField(ctx, rawArgs, "orderBy", ec.unmarshalOBuildTaskOrder2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskOrderᚄ) + if err != nil { + return nil, err + } + args["orderBy"] = arg4 + arg5, err := graphql.ProcessArgField(ctx, rawArgs, "where", ec.unmarshalOBuildTaskWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInput) + if err != nil { + return nil, err + } + args["where"] = arg5 + return args, nil +} + func (ec *executionContext) field_Query_hosts_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -2439,12 +2512,12 @@ func (ec *executionContext) fieldContext_BeaconEdge_cursor(_ context.Context, fi return fc, nil } -func (ec *executionContext) _Builder_id(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_id(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Builder_id, + ec.fieldContext_BuildTask_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -2455,9 +2528,9 @@ func (ec *executionContext) _Builder_id(ctx context.Context, field graphql.Colle ) } -func (ec *executionContext) fieldContext_Builder_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Builder", + Object: "BuildTask", Field: field, IsMethod: false, IsResolver: false, @@ -2468,12 +2541,12 @@ func (ec *executionContext) fieldContext_Builder_id(_ context.Context, field gra return fc, nil } -func (ec *executionContext) _Builder_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Builder_createdAt, + ec.fieldContext_BuildTask_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -2484,9 +2557,9 @@ func (ec *executionContext) _Builder_createdAt(ctx context.Context, field graphq ) } -func (ec *executionContext) fieldContext_Builder_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Builder", + Object: "BuildTask", Field: field, IsMethod: false, IsResolver: false, @@ -2497,12 +2570,12 @@ func (ec *executionContext) fieldContext_Builder_createdAt(_ context.Context, fi return fc, nil } -func (ec *executionContext) _Builder_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Builder_lastModifiedAt, + ec.fieldContext_BuildTask_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -2513,9 +2586,9 @@ func (ec *executionContext) _Builder_lastModifiedAt(ctx context.Context, field g ) } -func (ec *executionContext) fieldContext_Builder_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Builder", + Object: "BuildTask", Field: field, IsMethod: false, IsResolver: false, @@ -2526,72 +2599,72 @@ func (ec *executionContext) fieldContext_Builder_lastModifiedAt(_ context.Contex return fc, nil } -func (ec *executionContext) _Builder_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_targetOs(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Builder_identifier, + ec.fieldContext_BuildTask_targetOs, func(ctx context.Context) (any, error) { - return obj.Identifier, nil + return obj.TargetOs, nil }, nil, - ec.marshalNString2string, + ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform, true, true, ) } -func (ec *executionContext) fieldContext_Builder_identifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_targetOs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Builder", + Object: "BuildTask", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type HostPlatform does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Builder_supportedTargets(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_buildImage(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Builder_supportedTargets, + ec.fieldContext_BuildTask_buildImage, func(ctx context.Context) (any, error) { - return obj.SupportedTargets, nil + return obj.BuildImage, nil }, nil, - ec.marshalNHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Builder_supportedTargets(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_buildImage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Builder", + Object: "BuildTask", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type HostPlatform does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Builder_upstream(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_buildScript(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Builder_upstream, + ec.fieldContext_BuildTask_buildScript, func(ctx context.Context) (any, error) { - return obj.Upstream, nil + return obj.BuildScript, nil }, nil, ec.marshalNString2string, @@ -2600,9 +2673,9 @@ func (ec *executionContext) _Builder_upstream(ctx context.Context, field graphql ) } -func (ec *executionContext) fieldContext_Builder_upstream(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_buildScript(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Builder", + Object: "BuildTask", Field: field, IsMethod: false, IsResolver: false, @@ -2613,432 +2686,460 @@ func (ec *executionContext) fieldContext_Builder_upstream(_ context.Context, fie return fc, nil } -func (ec *executionContext) _BuilderConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_BuilderConnection_edges, + ec.fieldContext_BuildTask_claimedAt, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.ClaimedAt, nil }, nil, - ec.marshalOBuilderEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderEdge, + ec.marshalOTime2timeᚐTime, true, false, ) } -func (ec *executionContext) fieldContext_BuilderConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_claimedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "BuilderConnection", + Object: "BuildTask", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_BuilderEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_BuilderEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type BuilderEdge", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _BuilderConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_startedAt(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_BuilderConnection_pageInfo, + ec.fieldContext_BuildTask_startedAt, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.StartedAt, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_BuilderConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_startedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "BuilderConnection", + Object: "BuildTask", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _BuilderConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_finishedAt(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_BuilderConnection_totalCount, + ec.fieldContext_BuildTask_finishedAt, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.FinishedAt, nil }, nil, - ec.marshalNInt2int, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_BuilderConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_finishedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "BuilderConnection", + Object: "BuildTask", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _BuilderEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_output(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_BuilderEdge_node, + ec.fieldContext_BuildTask_output, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.Output, nil }, nil, - ec.marshalOBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_BuilderEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_output(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "BuilderEdge", + Object: "BuildTask", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Builder_id(ctx, field) - case "createdAt": - return ec.fieldContext_Builder_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Builder_lastModifiedAt(ctx, field) - case "identifier": - return ec.fieldContext_Builder_identifier(ctx, field) - case "supportedTargets": - return ec.fieldContext_Builder_supportedTargets(ctx, field) - case "upstream": - return ec.fieldContext_Builder_upstream(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Builder", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _BuilderEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_error(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_BuilderEdge_cursor, + ec.fieldContext_BuildTask_error, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Error, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_BuilderEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_error(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "BuilderEdge", + Object: "BuildTask", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Host_id(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTask_builder(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_id, + ec.fieldContext_BuildTask_builder, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Builder(ctx) }, nil, - ec.marshalNID2int, + ec.marshalNBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder, true, true, ) } -func (ec *executionContext) fieldContext_Host_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTask_builder(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuildTask", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Builder_id(ctx, field) + case "createdAt": + return ec.fieldContext_Builder_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Builder_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Builder_identifier(ctx, field) + case "supportedTargets": + return ec.fieldContext_Builder_supportedTargets(ctx, field) + case "upstream": + return ec.fieldContext_Builder_upstream(ctx, field) + case "buildTasks": + return ec.fieldContext_Builder_buildTasks(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Builder", field.Name) }, } return fc, nil } -func (ec *executionContext) _Host_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_createdAt, + ec.fieldContext_BuildTaskConnection_edges, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Edges, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOBuildTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskEdge, true, + false, ) } -func (ec *executionContext) fieldContext_Host_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTaskConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuildTaskConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_BuildTaskEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_BuildTaskEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BuildTaskEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Host_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_lastModifiedAt, + ec.fieldContext_BuildTaskConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.PageInfo, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Host_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTaskConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuildTaskConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Host_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_identifier, + ec.fieldContext_BuildTaskConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Identifier, nil + return obj.TotalCount, nil }, nil, - ec.marshalNString2string, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Host_identifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTaskConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuildTaskConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Host_name(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTaskEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_name, + ec.fieldContext_BuildTaskEdge_node, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.Node, nil }, nil, - ec.marshalOString2string, + ec.marshalOBuildTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTask, true, false, ) } -func (ec *executionContext) fieldContext_Host_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTaskEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuildTaskEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_BuildTask_id(ctx, field) + case "createdAt": + return ec.fieldContext_BuildTask_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_BuildTask_lastModifiedAt(ctx, field) + case "targetOs": + return ec.fieldContext_BuildTask_targetOs(ctx, field) + case "buildImage": + return ec.fieldContext_BuildTask_buildImage(ctx, field) + case "buildScript": + return ec.fieldContext_BuildTask_buildScript(ctx, field) + case "claimedAt": + return ec.fieldContext_BuildTask_claimedAt(ctx, field) + case "startedAt": + return ec.fieldContext_BuildTask_startedAt(ctx, field) + case "finishedAt": + return ec.fieldContext_BuildTask_finishedAt(ctx, field) + case "output": + return ec.fieldContext_BuildTask_output(ctx, field) + case "error": + return ec.fieldContext_BuildTask_error(ctx, field) + case "builder": + return ec.fieldContext_BuildTask_builder(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BuildTask", field.Name) }, } return fc, nil } -func (ec *executionContext) _Host_primaryIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuildTaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTaskEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_primaryIP, + ec.fieldContext_BuildTaskEdge_cursor, func(ctx context.Context) (any, error) { - return obj.PrimaryIP, nil + return obj.Cursor, nil }, nil, - ec.marshalOString2string, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_primaryIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuildTaskEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuildTaskEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Host_externalIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_id(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_externalIP, + ec.fieldContext_Builder_id, func(ctx context.Context) (any, error) { - return obj.ExternalIP, nil + return obj.ID, nil }, nil, - ec.marshalOString2string, + ec.marshalNID2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_externalIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Host_platform(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_platform, + ec.fieldContext_Builder_createdAt, func(ctx context.Context) (any, error) { - return obj.Platform, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Host_platform(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type HostPlatform does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Host_lastSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_lastSeenAt, + ec.fieldContext_Builder_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.LastSeenAt, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_lastSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, @@ -3049,166 +3150,126 @@ func (ec *executionContext) fieldContext_Host_lastSeenAt(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _Host_nextSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_nextSeenAt, + ec.fieldContext_Builder_identifier, func(ctx context.Context) (any, error) { - return obj.NextSeenAt, nil + return obj.Identifier, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_nextSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_identifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Host_tags(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_supportedTargets(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_tags, + ec.fieldContext_Builder_supportedTargets, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) + return obj.SupportedTargets, nil }, nil, - ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, + ec.marshalNHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ, true, true, ) } -func (ec *executionContext) fieldContext_Host_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_supportedTargets(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TagConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TagConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TagConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) + return nil, errors.New("field of type HostPlatform does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Host_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Host_beacons(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_upstream(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_beacons, + ec.fieldContext_Builder_upstream, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) + return obj.Upstream, nil }, nil, - ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Host_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_upstream(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_BeaconConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_BeaconConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Host_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Host_files(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_buildTasks(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_files, + ec.fieldContext_Builder_buildTasks, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return obj.Files(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostFileOrder), fc.Args["where"].(*ent.HostFileWhereInput)) + return obj.BuildTasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BuildTaskOrder), fc.Args["where"].(*ent.BuildTaskWhereInput)) }, nil, - ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, + ec.marshalNBuildTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskConnection, true, true, ) } -func (ec *executionContext) fieldContext_Host_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_buildTasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_HostFileConnection_edges(ctx, field) + return ec.fieldContext_BuildTaskConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_HostFileConnection_pageInfo(ctx, field) + return ec.fieldContext_BuildTaskConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_HostFileConnection_totalCount(ctx, field) + return ec.fieldContext_BuildTaskConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostFileConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type BuildTaskConnection", field.Name) }, } defer func() { @@ -3218,220 +3279,196 @@ func (ec *executionContext) fieldContext_Host_files(ctx context.Context, field g } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Host_files_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Builder_buildTasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Host_processes(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_processes, + ec.fieldContext_BuilderConnection_edges, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Processes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostProcessOrder), fc.Args["where"].(*ent.HostProcessWhereInput)) + return obj.Edges, nil }, nil, - ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, - true, + ec.marshalOBuilderEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderEdge, true, + false, ) } -func (ec *executionContext) fieldContext_Host_processes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_HostProcessConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostProcessConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostProcessConnection_totalCount(ctx, field) + case "node": + return ec.fieldContext_BuilderEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_BuilderEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostProcessConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type BuilderEdge", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Host_processes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Host_credentials(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_credentials, + ec.fieldContext_BuilderConnection_pageInfo, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Credentials(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostCredentialOrder), fc.Args["where"].(*ent.HostCredentialWhereInput)) + return obj.PageInfo, nil }, nil, - ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Host_credentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_HostCredentialConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostCredentialConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostCredentialConnection_totalCount(ctx, field) + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Host_credentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _HostConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostConnection_edges, + ec.fieldContext_BuilderConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.TotalCount, nil }, nil, - ec.marshalOHostEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostEdge, + ec.marshalNInt2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostConnection", + Object: "BuilderConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_HostEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_HostEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostEdge", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostConnection_pageInfo, + ec.fieldContext_BuilderEdge_node, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.Node, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, + ec.marshalOBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder, true, + false, ) } -func (ec *executionContext) fieldContext_HostConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostConnection", + Object: "BuilderEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) + case "id": + return ec.fieldContext_Builder_id(ctx, field) + case "createdAt": + return ec.fieldContext_Builder_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Builder_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Builder_identifier(ctx, field) + case "supportedTargets": + return ec.fieldContext_Builder_supportedTargets(ctx, field) + case "upstream": + return ec.fieldContext_Builder_upstream(ctx, field) + case "buildTasks": + return ec.fieldContext_Builder_buildTasks(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Builder", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostConnection_totalCount, + ec.fieldContext_BuilderEdge_cursor, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.Cursor, nil }, nil, - ec.marshalNInt2int, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_HostConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostConnection", + Object: "BuilderEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredential_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_id(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_id, + ec.fieldContext_Host_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -3442,9 +3479,9 @@ func (ec *executionContext) _HostCredential_id(ctx context.Context, field graphq ) } -func (ec *executionContext) fieldContext_HostCredential_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, @@ -3455,12 +3492,12 @@ func (ec *executionContext) fieldContext_HostCredential_id(_ context.Context, fi return fc, nil } -func (ec *executionContext) _HostCredential_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_createdAt, + ec.fieldContext_Host_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -3471,9 +3508,9 @@ func (ec *executionContext) _HostCredential_createdAt(ctx context.Context, field ) } -func (ec *executionContext) fieldContext_HostCredential_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, @@ -3484,12 +3521,12 @@ func (ec *executionContext) fieldContext_HostCredential_createdAt(_ context.Cont return fc, nil } -func (ec *executionContext) _HostCredential_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_lastModifiedAt, + ec.fieldContext_Host_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -3500,9 +3537,9 @@ func (ec *executionContext) _HostCredential_lastModifiedAt(ctx context.Context, ) } -func (ec *executionContext) fieldContext_HostCredential_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, @@ -3513,14 +3550,14 @@ func (ec *executionContext) fieldContext_HostCredential_lastModifiedAt(_ context return fc, nil } -func (ec *executionContext) _HostCredential_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_principal, + ec.fieldContext_Host_identifier, func(ctx context.Context) (any, error) { - return obj.Principal, nil + return obj.Identifier, nil }, nil, ec.marshalNString2string, @@ -3529,9 +3566,9 @@ func (ec *executionContext) _HostCredential_principal(ctx context.Context, field ) } -func (ec *executionContext) fieldContext_HostCredential_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_identifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, @@ -3542,25 +3579,25 @@ func (ec *executionContext) fieldContext_HostCredential_principal(_ context.Cont return fc, nil } -func (ec *executionContext) _HostCredential_secret(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_name(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_secret, + ec.fieldContext_Host_name, func(ctx context.Context) (any, error) { - return obj.Secret, nil + return obj.Name, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostCredential_secret(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, @@ -3571,619 +3608,605 @@ func (ec *executionContext) fieldContext_HostCredential_secret(_ context.Context return fc, nil } -func (ec *executionContext) _HostCredential_kind(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_primaryIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_kind, + ec.fieldContext_Host_primaryIP, func(ctx context.Context) (any, error) { - return obj.Kind, nil + return obj.PrimaryIP, nil }, nil, - ec.marshalNHostCredentialKind2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kind, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostCredential_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_primaryIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type HostCredentialKind does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredential_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_externalIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_host, + ec.fieldContext_Host_externalIP, func(ctx context.Context) (any, error) { - return obj.Host(ctx) + return obj.ExternalIP, nil }, nil, - ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostCredential_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_externalIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Host_id(ctx, field) - case "createdAt": - return ec.fieldContext_Host_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Host_lastModifiedAt(ctx, field) - case "identifier": - return ec.fieldContext_Host_identifier(ctx, field) - case "name": - return ec.fieldContext_Host_name(ctx, field) - case "primaryIP": - return ec.fieldContext_Host_primaryIP(ctx, field) - case "externalIP": - return ec.fieldContext_Host_externalIP(ctx, field) - case "platform": - return ec.fieldContext_Host_platform(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Host_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Host_nextSeenAt(ctx, field) - case "tags": - return ec.fieldContext_Host_tags(ctx, field) - case "beacons": - return ec.fieldContext_Host_beacons(ctx, field) - case "files": - return ec.fieldContext_Host_files(ctx, field) - case "processes": - return ec.fieldContext_Host_processes(ctx, field) - case "credentials": - return ec.fieldContext_Host_credentials(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredential_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_platform(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_task, + ec.fieldContext_Host_platform, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + return obj.Platform, nil }, nil, - ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostCredential_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_platform(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, errors.New("field of type HostPlatform does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredentialConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_lastSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialConnection_edges, + ec.fieldContext_Host_lastSeenAt, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.LastSeenAt, nil }, nil, - ec.marshalOHostCredentialEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialEdge, + ec.marshalOTime2timeᚐTime, true, false, ) } -func (ec *executionContext) fieldContext_HostCredentialConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_lastSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialConnection", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_HostCredentialEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_HostCredentialEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostCredentialEdge", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredentialConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_nextSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialConnection_pageInfo, + ec.fieldContext_Host_nextSeenAt, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.NextSeenAt, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_HostCredentialConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_nextSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialConnection", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredentialConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_tags(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialConnection_totalCount, + ec.fieldContext_Host_tags, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + fc := graphql.GetFieldContext(ctx) + return obj.Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) }, nil, - ec.marshalNInt2int, + ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredentialConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialConnection", + Object: "Host", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_TagConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TagConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TagConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Host_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostCredentialEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_beacons(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialEdge_node, + ec.fieldContext_Host_beacons, func(ctx context.Context) (any, error) { - return obj.Node, nil + fc := graphql.GetFieldContext(ctx) + return obj.Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) }, nil, - ec.marshalOHostCredential2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredential, + ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostCredentialEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialEdge", + Object: "Host", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_HostCredential_id(ctx, field) - case "createdAt": - return ec.fieldContext_HostCredential_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_HostCredential_lastModifiedAt(ctx, field) - case "principal": - return ec.fieldContext_HostCredential_principal(ctx, field) - case "secret": - return ec.fieldContext_HostCredential_secret(ctx, field) - case "kind": - return ec.fieldContext_HostCredential_kind(ctx, field) - case "host": - return ec.fieldContext_HostCredential_host(ctx, field) - case "task": - return ec.fieldContext_HostCredential_task(ctx, field) + case "edges": + return ec.fieldContext_BeaconConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_BeaconConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostCredential", field.Name) + return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Host_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostCredentialEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_files(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialEdge_cursor, + ec.fieldContext_Host_files, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + fc := graphql.GetFieldContext(ctx) + return obj.Files(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostFileOrder), fc.Args["where"].(*ent.HostFileWhereInput)) }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredentialEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialEdge", + Object: "Host", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_HostFileConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostFileConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostFileConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostFileConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Host_files_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_processes(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostEdge_node, + ec.fieldContext_Host_processes, func(ctx context.Context) (any, error) { - return obj.Node, nil + fc := graphql.GetFieldContext(ctx) + return obj.Processes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostProcessOrder), fc.Args["where"].(*ent.HostProcessWhereInput)) }, nil, - ec.marshalOHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, + ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_processes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostEdge", + Object: "Host", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Host_id(ctx, field) - case "createdAt": - return ec.fieldContext_Host_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Host_lastModifiedAt(ctx, field) - case "identifier": - return ec.fieldContext_Host_identifier(ctx, field) - case "name": - return ec.fieldContext_Host_name(ctx, field) - case "primaryIP": - return ec.fieldContext_Host_primaryIP(ctx, field) - case "externalIP": - return ec.fieldContext_Host_externalIP(ctx, field) - case "platform": - return ec.fieldContext_Host_platform(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Host_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Host_nextSeenAt(ctx, field) - case "tags": - return ec.fieldContext_Host_tags(ctx, field) - case "beacons": - return ec.fieldContext_Host_beacons(ctx, field) - case "files": - return ec.fieldContext_Host_files(ctx, field) - case "processes": - return ec.fieldContext_Host_processes(ctx, field) - case "credentials": - return ec.fieldContext_Host_credentials(ctx, field) + case "edges": + return ec.fieldContext_HostProcessConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostProcessConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostProcessConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostProcessConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Host_processes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_credentials(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostEdge_cursor, + ec.fieldContext_Host_credentials, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + fc := graphql.GetFieldContext(ctx) + return obj.Credentials(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostCredentialOrder), fc.Args["where"].(*ent.HostCredentialWhereInput)) }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_credentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostEdge", + Object: "Host", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_HostCredentialConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostCredentialConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostCredentialConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Host_credentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostFile_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_id, + ec.fieldContext_HostConnection_edges, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Edges, nil }, nil, - ec.marshalNID2int, - true, + ec.marshalOHostEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostEdge, true, + false, ) } -func (ec *executionContext) fieldContext_HostFile_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_HostEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_HostEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostFile_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_createdAt, + ec.fieldContext_HostConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.PageInfo, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_HostFile_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostFile_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_lastModifiedAt, + ec.fieldContext_HostConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.TotalCount, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_HostFile_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_path, + ec.fieldContext_HostCredential_id, func(ctx context.Context) (any, error) { - return obj.Path, nil + return obj.ID, nil }, nil, - ec.marshalNString2string, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_HostFile_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_owner(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_owner, + ec.fieldContext_HostCredential_createdAt, func(ctx context.Context) (any, error) { - return obj.Owner, nil + return obj.CreatedAt, nil }, nil, - ec.marshalOString2string, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFile_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_group(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_group, + ec.fieldContext_HostCredential_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Group, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalOString2string, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFile_group(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_permissions(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_permissions, + ec.fieldContext_HostCredential_principal, func(ctx context.Context) (any, error) { - return obj.Permissions, nil + return obj.Principal, nil }, nil, - ec.marshalOString2string, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFile_permissions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, @@ -4194,70 +4217,70 @@ func (ec *executionContext) fieldContext_HostFile_permissions(_ context.Context, return fc, nil } -func (ec *executionContext) _HostFile_size(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_secret(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_size, + ec.fieldContext_HostCredential_secret, func(ctx context.Context) (any, error) { - return obj.Size, nil + return obj.Secret, nil }, nil, - ec.marshalNUint642uint64, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_HostFile_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_secret(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint64 does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_hash(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_kind(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_hash, + ec.fieldContext_HostCredential_kind, func(ctx context.Context) (any, error) { - return obj.Hash, nil + return obj.Kind, nil }, nil, - ec.marshalOString2string, + ec.marshalNHostCredentialKind2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kind, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFile_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type HostCredentialKind does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_host, + ec.fieldContext_HostCredential_host, func(ctx context.Context) (any, error) { return obj.Host(ctx) }, @@ -4268,9 +4291,9 @@ func (ec *executionContext) _HostFile_host(ctx context.Context, field graphql.Co ) } -func (ec *executionContext) fieldContext_HostFile_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, IsMethod: true, IsResolver: false, @@ -4313,25 +4336,25 @@ func (ec *executionContext) fieldContext_HostFile_host(_ context.Context, field return fc, nil } -func (ec *executionContext) _HostFile_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_task, + ec.fieldContext_HostCredential_task, func(ctx context.Context) (any, error) { return obj.Task(ctx) }, nil, - ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, - true, + ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, + false, ) } -func (ec *executionContext) fieldContext_HostFile_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", Field: field, IsMethod: true, IsResolver: false, @@ -4374,47 +4397,47 @@ func (ec *executionContext) fieldContext_HostFile_task(_ context.Context, field return fc, nil } -func (ec *executionContext) _HostFileConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileConnection_edges, + ec.fieldContext_HostCredentialConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, - ec.marshalOHostFileEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileEdge, + ec.marshalOHostCredentialEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialEdge, true, false, ) } -func (ec *executionContext) fieldContext_HostFileConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileConnection", + Object: "HostCredentialConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "node": - return ec.fieldContext_HostFileEdge_node(ctx, field) + return ec.fieldContext_HostCredentialEdge_node(ctx, field) case "cursor": - return ec.fieldContext_HostFileEdge_cursor(ctx, field) + return ec.fieldContext_HostCredentialEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostFileEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostCredentialEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostFileConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileConnection_pageInfo, + ec.fieldContext_HostCredentialConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -4425,9 +4448,9 @@ func (ec *executionContext) _HostFileConnection_pageInfo(ctx context.Context, fi ) } -func (ec *executionContext) fieldContext_HostFileConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileConnection", + Object: "HostCredentialConnection", Field: field, IsMethod: false, IsResolver: false, @@ -4448,12 +4471,12 @@ func (ec *executionContext) fieldContext_HostFileConnection_pageInfo(_ context.C return fc, nil } -func (ec *executionContext) _HostFileConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileConnection_totalCount, + ec.fieldContext_HostCredentialConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -4464,9 +4487,9 @@ func (ec *executionContext) _HostFileConnection_totalCount(ctx context.Context, ) } -func (ec *executionContext) fieldContext_HostFileConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileConnection", + Object: "HostCredentialConnection", Field: field, IsMethod: false, IsResolver: false, @@ -4477,65 +4500,59 @@ func (ec *executionContext) fieldContext_HostFileConnection_totalCount(_ context return fc, nil } -func (ec *executionContext) _HostFileEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileEdge_node, + ec.fieldContext_HostCredentialEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOHostFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFile, + ec.marshalOHostCredential2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredential, true, false, ) } -func (ec *executionContext) fieldContext_HostFileEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileEdge", + Object: "HostCredentialEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_HostFile_id(ctx, field) + return ec.fieldContext_HostCredential_id(ctx, field) case "createdAt": - return ec.fieldContext_HostFile_createdAt(ctx, field) + return ec.fieldContext_HostCredential_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_HostFile_lastModifiedAt(ctx, field) - case "path": - return ec.fieldContext_HostFile_path(ctx, field) - case "owner": - return ec.fieldContext_HostFile_owner(ctx, field) - case "group": - return ec.fieldContext_HostFile_group(ctx, field) - case "permissions": - return ec.fieldContext_HostFile_permissions(ctx, field) - case "size": - return ec.fieldContext_HostFile_size(ctx, field) - case "hash": - return ec.fieldContext_HostFile_hash(ctx, field) + return ec.fieldContext_HostCredential_lastModifiedAt(ctx, field) + case "principal": + return ec.fieldContext_HostCredential_principal(ctx, field) + case "secret": + return ec.fieldContext_HostCredential_secret(ctx, field) + case "kind": + return ec.fieldContext_HostCredential_kind(ctx, field) case "host": - return ec.fieldContext_HostFile_host(ctx, field) + return ec.fieldContext_HostCredential_host(ctx, field) case "task": - return ec.fieldContext_HostFile_task(ctx, field) + return ec.fieldContext_HostCredential_task(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostFile", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostCredential", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostFileEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileEdge_cursor, + ec.fieldContext_HostCredentialEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -4546,9 +4563,9 @@ func (ec *executionContext) _HostFileEdge_cursor(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_HostFileEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileEdge", + Object: "HostCredentialEdge", Field: field, IsMethod: false, IsResolver: false, @@ -4559,159 +4576,191 @@ func (ec *executionContext) fieldContext_HostFileEdge_cursor(_ context.Context, return fc, nil } -func (ec *executionContext) _HostProcess_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_id, + ec.fieldContext_HostEdge_node, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Node, nil }, nil, - ec.marshalNID2int, - true, + ec.marshalOHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcess_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Host_id(ctx, field) + case "createdAt": + return ec.fieldContext_Host_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Host_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Host_identifier(ctx, field) + case "name": + return ec.fieldContext_Host_name(ctx, field) + case "primaryIP": + return ec.fieldContext_Host_primaryIP(ctx, field) + case "externalIP": + return ec.fieldContext_Host_externalIP(ctx, field) + case "platform": + return ec.fieldContext_Host_platform(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Host_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Host_nextSeenAt(ctx, field) + case "tags": + return ec.fieldContext_Host_tags(ctx, field) + case "beacons": + return ec.fieldContext_Host_beacons(ctx, field) + case "files": + return ec.fieldContext_Host_files(ctx, field) + case "processes": + return ec.fieldContext_Host_processes(ctx, field) + case "credentials": + return ec.fieldContext_Host_credentials(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostProcess_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_createdAt, + ec.fieldContext_HostEdge_cursor, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Cursor, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_lastModifiedAt, + ec.fieldContext_HostFile_id, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.ID, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_pid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_pid, + ec.fieldContext_HostFile_createdAt, func(ctx context.Context) (any, error) { - return obj.Pid, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNUint642uint64, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_pid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint64 does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_ppid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_ppid, + ec.fieldContext_HostFile_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Ppid, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalNUint642uint64, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_ppid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint64 does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_name(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_name, + ec.fieldContext_HostFile_path, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.Path, nil }, nil, ec.marshalNString2string, @@ -4720,9 +4769,9 @@ func (ec *executionContext) _HostProcess_name(ctx context.Context, field graphql ) } -func (ec *executionContext) fieldContext_HostProcess_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, @@ -4733,25 +4782,25 @@ func (ec *executionContext) fieldContext_HostProcess_name(_ context.Context, fie return fc, nil } -func (ec *executionContext) _HostProcess_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_owner(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_principal, + ec.fieldContext_HostFile_owner, func(ctx context.Context) (any, error) { - return obj.Principal, nil + return obj.Owner, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcess_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, @@ -4762,14 +4811,14 @@ func (ec *executionContext) fieldContext_HostProcess_principal(_ context.Context return fc, nil } -func (ec *executionContext) _HostProcess_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_group(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_path, + ec.fieldContext_HostFile_group, func(ctx context.Context) (any, error) { - return obj.Path, nil + return obj.Group, nil }, nil, ec.marshalOString2string, @@ -4778,9 +4827,9 @@ func (ec *executionContext) _HostProcess_path(ctx context.Context, field graphql ) } -func (ec *executionContext) fieldContext_HostProcess_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_group(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, @@ -4791,14 +4840,14 @@ func (ec *executionContext) fieldContext_HostProcess_path(_ context.Context, fie return fc, nil } -func (ec *executionContext) _HostProcess_cmd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_permissions(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_cmd, + ec.fieldContext_HostFile_permissions, func(ctx context.Context) (any, error) { - return obj.Cmd, nil + return obj.Permissions, nil }, nil, ec.marshalOString2string, @@ -4807,9 +4856,9 @@ func (ec *executionContext) _HostProcess_cmd(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_HostProcess_cmd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_permissions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, @@ -4820,43 +4869,43 @@ func (ec *executionContext) fieldContext_HostProcess_cmd(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _HostProcess_env(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_size(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_env, + ec.fieldContext_HostFile_size, func(ctx context.Context) (any, error) { - return obj.Env, nil + return obj.Size, nil }, nil, - ec.marshalOString2string, + ec.marshalNUint642uint64, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostProcess_env(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Uint64 does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_cwd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_hash(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_cwd, + ec.fieldContext_HostFile_hash, func(ctx context.Context) (any, error) { - return obj.Cwd, nil + return obj.Hash, nil }, nil, ec.marshalOString2string, @@ -4865,9 +4914,9 @@ func (ec *executionContext) _HostProcess_cwd(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_HostProcess_cwd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, @@ -4878,41 +4927,12 @@ func (ec *executionContext) fieldContext_HostProcess_cwd(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _HostProcess_status(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_HostProcess_status, - func(ctx context.Context) (any, error) { - return obj.Status, nil - }, - nil, - ec.marshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_status(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostProcess", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type HostProcessStatus does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _HostProcess_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_host, + ec.fieldContext_HostFile_host, func(ctx context.Context) (any, error) { return obj.Host(ctx) }, @@ -4923,9 +4943,9 @@ func (ec *executionContext) _HostProcess_host(ctx context.Context, field graphql ) } -func (ec *executionContext) fieldContext_HostProcess_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: true, IsResolver: false, @@ -4968,12 +4988,12 @@ func (ec *executionContext) fieldContext_HostProcess_host(_ context.Context, fie return fc, nil } -func (ec *executionContext) _HostProcess_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_task, + ec.fieldContext_HostFile_task, func(ctx context.Context) (any, error) { return obj.Task(ctx) }, @@ -4984,9 +5004,9 @@ func (ec *executionContext) _HostProcess_task(ctx context.Context, field graphql ) } -func (ec *executionContext) fieldContext_HostProcess_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: true, IsResolver: false, @@ -5029,47 +5049,47 @@ func (ec *executionContext) fieldContext_HostProcess_task(_ context.Context, fie return fc, nil } -func (ec *executionContext) _HostProcessConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessConnection_edges, + ec.fieldContext_HostFileConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, - ec.marshalOHostProcessEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessEdge, + ec.marshalOHostFileEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileEdge, true, false, ) } -func (ec *executionContext) fieldContext_HostProcessConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessConnection", + Object: "HostFileConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "node": - return ec.fieldContext_HostProcessEdge_node(ctx, field) + return ec.fieldContext_HostFileEdge_node(ctx, field) case "cursor": - return ec.fieldContext_HostProcessEdge_cursor(ctx, field) + return ec.fieldContext_HostFileEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostProcessEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostFileEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostProcessConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessConnection_pageInfo, + ec.fieldContext_HostFileConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -5080,9 +5100,9 @@ func (ec *executionContext) _HostProcessConnection_pageInfo(ctx context.Context, ) } -func (ec *executionContext) fieldContext_HostProcessConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessConnection", + Object: "HostFileConnection", Field: field, IsMethod: false, IsResolver: false, @@ -5103,12 +5123,12 @@ func (ec *executionContext) fieldContext_HostProcessConnection_pageInfo(_ contex return fc, nil } -func (ec *executionContext) _HostProcessConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessConnection_totalCount, + ec.fieldContext_HostFileConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -5119,9 +5139,9 @@ func (ec *executionContext) _HostProcessConnection_totalCount(ctx context.Contex ) } -func (ec *executionContext) fieldContext_HostProcessConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessConnection", + Object: "HostFileConnection", Field: field, IsMethod: false, IsResolver: false, @@ -5132,71 +5152,65 @@ func (ec *executionContext) fieldContext_HostProcessConnection_totalCount(_ cont return fc, nil } -func (ec *executionContext) _HostProcessEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessEdge_node, + ec.fieldContext_HostFileEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOHostProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcess, + ec.marshalOHostFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFile, true, false, ) } -func (ec *executionContext) fieldContext_HostProcessEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessEdge", + Object: "HostFileEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_HostProcess_id(ctx, field) + return ec.fieldContext_HostFile_id(ctx, field) case "createdAt": - return ec.fieldContext_HostProcess_createdAt(ctx, field) + return ec.fieldContext_HostFile_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_HostProcess_lastModifiedAt(ctx, field) - case "pid": - return ec.fieldContext_HostProcess_pid(ctx, field) - case "ppid": - return ec.fieldContext_HostProcess_ppid(ctx, field) - case "name": - return ec.fieldContext_HostProcess_name(ctx, field) - case "principal": - return ec.fieldContext_HostProcess_principal(ctx, field) + return ec.fieldContext_HostFile_lastModifiedAt(ctx, field) case "path": - return ec.fieldContext_HostProcess_path(ctx, field) - case "cmd": - return ec.fieldContext_HostProcess_cmd(ctx, field) - case "env": - return ec.fieldContext_HostProcess_env(ctx, field) - case "cwd": - return ec.fieldContext_HostProcess_cwd(ctx, field) - case "status": - return ec.fieldContext_HostProcess_status(ctx, field) + return ec.fieldContext_HostFile_path(ctx, field) + case "owner": + return ec.fieldContext_HostFile_owner(ctx, field) + case "group": + return ec.fieldContext_HostFile_group(ctx, field) + case "permissions": + return ec.fieldContext_HostFile_permissions(ctx, field) + case "size": + return ec.fieldContext_HostFile_size(ctx, field) + case "hash": + return ec.fieldContext_HostFile_hash(ctx, field) case "host": - return ec.fieldContext_HostProcess_host(ctx, field) + return ec.fieldContext_HostFile_host(ctx, field) case "task": - return ec.fieldContext_HostProcess_task(ctx, field) + return ec.fieldContext_HostFile_task(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostProcess", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostFile", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostProcessEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessEdge_cursor, + ec.fieldContext_HostFileEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -5207,9 +5221,9 @@ func (ec *executionContext) _HostProcessEdge_cursor(ctx context.Context, field g ) } -func (ec *executionContext) fieldContext_HostProcessEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessEdge", + Object: "HostFileEdge", Field: field, IsMethod: false, IsResolver: false, @@ -5220,12 +5234,12 @@ func (ec *executionContext) fieldContext_HostProcessEdge_cursor(_ context.Contex return fc, nil } -func (ec *executionContext) _Link_id(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_id, + ec.fieldContext_HostProcess_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -5236,9 +5250,9 @@ func (ec *executionContext) _Link_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_Link_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, @@ -5249,12 +5263,12 @@ func (ec *executionContext) fieldContext_Link_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _Link_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_createdAt, + ec.fieldContext_HostProcess_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -5265,9 +5279,9 @@ func (ec *executionContext) _Link_createdAt(ctx context.Context, field graphql.C ) } -func (ec *executionContext) fieldContext_Link_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, @@ -5278,12 +5292,12 @@ func (ec *executionContext) fieldContext_Link_createdAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _Link_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_lastModifiedAt, + ec.fieldContext_HostProcess_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -5294,9 +5308,9 @@ func (ec *executionContext) _Link_lastModifiedAt(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Link_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, @@ -5307,579 +5321,617 @@ func (ec *executionContext) fieldContext_Link_lastModifiedAt(_ context.Context, return fc, nil } -func (ec *executionContext) _Link_path(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_pid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_path, + ec.fieldContext_HostProcess_pid, func(ctx context.Context) (any, error) { - return obj.Path, nil + return obj.Pid, nil }, nil, - ec.marshalNString2string, + ec.marshalNUint642uint64, true, true, ) } -func (ec *executionContext) fieldContext_Link_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_pid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Uint64 does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_expiresAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_ppid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_expiresAt, + ec.fieldContext_HostProcess_ppid, func(ctx context.Context) (any, error) { - return obj.ExpiresAt, nil + return obj.Ppid, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNUint642uint64, true, true, ) } -func (ec *executionContext) fieldContext_Link_expiresAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_ppid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Uint64 does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_downloadLimit(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_name(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_downloadLimit, + ec.fieldContext_HostProcess_name, func(ctx context.Context) (any, error) { - return obj.DownloadLimit, nil + return obj.Name, nil }, nil, - ec.marshalOInt2ᚖint, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Link_downloadLimit(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_downloads(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_downloads, + ec.fieldContext_HostProcess_principal, func(ctx context.Context) (any, error) { - return obj.Downloads, nil + return obj.Principal, nil }, nil, - ec.marshalNInt2int, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Link_downloads(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_asset(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_asset, + ec.fieldContext_HostProcess_path, func(ctx context.Context) (any, error) { - return obj.Asset(ctx) + return obj.Path, nil }, nil, - ec.marshalNAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Link_asset(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Asset_id(ctx, field) - case "createdAt": - return ec.fieldContext_Asset_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Asset_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Asset_name(ctx, field) - case "size": - return ec.fieldContext_Asset_size(ctx, field) - case "hash": - return ec.fieldContext_Asset_hash(ctx, field) - case "tomes": - return ec.fieldContext_Asset_tomes(ctx, field) - case "links": - return ec.fieldContext_Asset_links(ctx, field) - case "creator": - return ec.fieldContext_Asset_creator(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_cmd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_creator, + ec.fieldContext_HostProcess_cmd, func(ctx context.Context) (any, error) { - return obj.Creator(ctx) + return obj.Cmd, nil }, nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_Link_creator(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_cmd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_env(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkConnection_edges, + ec.fieldContext_HostProcess_env, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Env, nil }, nil, - ec.marshalOLinkEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkEdge, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_LinkConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_env(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkConnection", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_LinkEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_LinkEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type LinkEdge", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_cwd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkConnection_pageInfo, + ec.fieldContext_HostProcess_cwd, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.Cwd, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_LinkConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_cwd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkConnection", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_status(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkConnection_totalCount, + ec.fieldContext_HostProcess_status, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.Status, nil }, nil, - ec.marshalNInt2int, + ec.marshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status, true, true, ) } -func (ec *executionContext) fieldContext_LinkConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_status(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkConnection", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type HostProcessStatus does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkEdge_node, + ec.fieldContext_HostProcess_host, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.Host(ctx) }, nil, - ec.marshalOLink2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLink, + ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, + true, true, - false, ) } -func (ec *executionContext) fieldContext_LinkEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkEdge", + Object: "HostProcess", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Link_id(ctx, field) + return ec.fieldContext_Host_id(ctx, field) case "createdAt": - return ec.fieldContext_Link_createdAt(ctx, field) + return ec.fieldContext_Host_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Link_lastModifiedAt(ctx, field) - case "path": - return ec.fieldContext_Link_path(ctx, field) - case "expiresAt": - return ec.fieldContext_Link_expiresAt(ctx, field) - case "downloadLimit": - return ec.fieldContext_Link_downloadLimit(ctx, field) - case "downloads": - return ec.fieldContext_Link_downloads(ctx, field) - case "asset": - return ec.fieldContext_Link_asset(ctx, field) - case "creator": - return ec.fieldContext_Link_creator(ctx, field) + return ec.fieldContext_Host_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Host_identifier(ctx, field) + case "name": + return ec.fieldContext_Host_name(ctx, field) + case "primaryIP": + return ec.fieldContext_Host_primaryIP(ctx, field) + case "externalIP": + return ec.fieldContext_Host_externalIP(ctx, field) + case "platform": + return ec.fieldContext_Host_platform(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Host_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Host_nextSeenAt(ctx, field) + case "tags": + return ec.fieldContext_Host_tags(ctx, field) + case "beacons": + return ec.fieldContext_Host_beacons(ctx, field) + case "files": + return ec.fieldContext_Host_files(ctx, field) + case "processes": + return ec.fieldContext_Host_processes(ctx, field) + case "credentials": + return ec.fieldContext_Host_credentials(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Link", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, } return fc, nil } -func (ec *executionContext) _LinkEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkEdge_cursor, + ec.fieldContext_HostProcess_task, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Task(ctx) }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, true, ) } -func (ec *executionContext) fieldContext_LinkEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkEdge", + Object: "HostProcess", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_hasNextPage, + ec.fieldContext_HostProcessConnection_edges, func(ctx context.Context) (any, error) { - return obj.HasNextPage, nil + return obj.Edges, nil }, nil, - ec.marshalNBoolean2bool, - true, + ec.marshalOHostProcessEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessEdge, true, + false, ) } -func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "HostProcessConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_HostProcessEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_HostProcessEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostProcessEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_hasPreviousPage, + ec.fieldContext_HostProcessConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.HasPreviousPage, nil + return obj.PageInfo, nil }, nil, - ec.marshalNBoolean2bool, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "HostProcessConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_startCursor, + ec.fieldContext_HostProcessConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.StartCursor, nil + return obj.TotalCount, nil }, nil, - ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNInt2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "HostProcessConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_endCursor, + ec.fieldContext_HostProcessEdge_node, func(ctx context.Context) (any, error) { - return obj.EndCursor, nil + return obj.Node, nil }, nil, - ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalOHostProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcess, true, false, ) } -func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "HostProcessEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_HostProcess_id(ctx, field) + case "createdAt": + return ec.fieldContext_HostProcess_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_HostProcess_lastModifiedAt(ctx, field) + case "pid": + return ec.fieldContext_HostProcess_pid(ctx, field) + case "ppid": + return ec.fieldContext_HostProcess_ppid(ctx, field) + case "name": + return ec.fieldContext_HostProcess_name(ctx, field) + case "principal": + return ec.fieldContext_HostProcess_principal(ctx, field) + case "path": + return ec.fieldContext_HostProcess_path(ctx, field) + case "cmd": + return ec.fieldContext_HostProcess_cmd(ctx, field) + case "env": + return ec.fieldContext_HostProcess_env(ctx, field) + case "cwd": + return ec.fieldContext_HostProcess_cwd(ctx, field) + case "status": + return ec.fieldContext_HostProcess_status(ctx, field) + case "host": + return ec.fieldContext_HostProcess_host(ctx, field) + case "task": + return ec.fieldContext_HostProcess_task(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostProcess", field.Name) }, } return fc, nil } -func (ec *executionContext) _Portal_id(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_id, + ec.fieldContext_HostProcessEdge_cursor, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Cursor, nil }, nil, - ec.marshalNID2int, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Portal_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "HostProcessEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_id(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_createdAt, + ec.fieldContext_Link_id, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.ID, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Portal_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_lastModifiedAt, + ec.fieldContext_Link_createdAt, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.CreatedAt, nil }, nil, ec.marshalNTime2timeᚐTime, @@ -5888,9 +5940,9 @@ func (ec *executionContext) _Portal_lastModifiedAt(ctx context.Context, field gr ) } -func (ec *executionContext) fieldContext_Portal_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", Field: field, IsMethod: false, IsResolver: false, @@ -5901,25 +5953,25 @@ func (ec *executionContext) fieldContext_Portal_lastModifiedAt(_ context.Context return fc, nil } -func (ec *executionContext) _Portal_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_closedAt, + ec.fieldContext_Link_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.ClosedAt, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Portal_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", Field: field, IsMethod: false, IsResolver: false, @@ -5930,1226 +5982,757 @@ func (ec *executionContext) fieldContext_Portal_closedAt(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _Portal_task(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_path(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_task, + ec.fieldContext_Link_path, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + return obj.Path, nil }, nil, - ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Portal_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_expiresAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_beacon, + ec.fieldContext_Link_expiresAt, func(ctx context.Context) (any, error) { - return obj.Beacon(ctx) + return obj.ExpiresAt, nil }, nil, - ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Portal_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_expiresAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Beacon_id(ctx, field) - case "createdAt": - return ec.fieldContext_Beacon_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Beacon_name(ctx, field) - case "principal": - return ec.fieldContext_Beacon_principal(ctx, field) - case "identifier": - return ec.fieldContext_Beacon_identifier(ctx, field) - case "agentIdentifier": - return ec.fieldContext_Beacon_agentIdentifier(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Beacon_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Beacon_nextSeenAt(ctx, field) - case "interval": - return ec.fieldContext_Beacon_interval(ctx, field) - case "transport": - return ec.fieldContext_Beacon_transport(ctx, field) - case "host": - return ec.fieldContext_Beacon_host(ctx, field) - case "tasks": - return ec.fieldContext_Beacon_tasks(ctx, field) - case "shells": - return ec.fieldContext_Beacon_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_downloadLimit(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_owner, + ec.fieldContext_Link_downloadLimit, func(ctx context.Context) (any, error) { - return obj.Owner(ctx) + return obj.DownloadLimit, nil }, nil, - ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, - true, + ec.marshalOInt2ᚖint, true, + false, ) } -func (ec *executionContext) fieldContext_Portal_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_downloadLimit(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_downloads(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_activeUsers, + ec.fieldContext_Link_downloads, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ActiveUsers(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) + return obj.Downloads, nil }, nil, - ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Portal_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_downloads(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_UserConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_UserConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_UserConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Portal_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _PortalConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_asset(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalConnection_edges, + ec.fieldContext_Link_asset, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Asset(ctx) }, nil, - ec.marshalOPortalEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalEdge, + ec.marshalNAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, + true, true, - false, ) } -func (ec *executionContext) fieldContext_PortalConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_asset(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalConnection", + Object: "Link", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "node": - return ec.fieldContext_PortalEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_PortalEdge_cursor(ctx, field) + case "id": + return ec.fieldContext_Asset_id(ctx, field) + case "createdAt": + return ec.fieldContext_Asset_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Asset_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Asset_name(ctx, field) + case "size": + return ec.fieldContext_Asset_size(ctx, field) + case "hash": + return ec.fieldContext_Asset_hash(ctx, field) + case "tomes": + return ec.fieldContext_Asset_tomes(ctx, field) + case "links": + return ec.fieldContext_Asset_links(ctx, field) + case "creator": + return ec.fieldContext_Asset_creator(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PortalEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) }, } return fc, nil } -func (ec *executionContext) _PortalConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalConnection_pageInfo, + ec.fieldContext_Link_creator, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.Creator(ctx) }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, + false, ) } -func (ec *executionContext) fieldContext_PortalConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_creator(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalConnection", + Object: "Link", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _PortalConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalConnection_totalCount, + ec.fieldContext_LinkConnection_edges, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.Edges, nil }, nil, - ec.marshalNInt2int, - true, + ec.marshalOLinkEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkEdge, true, + false, ) } -func (ec *executionContext) fieldContext_PortalConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalConnection", + Object: "LinkConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_LinkEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_LinkEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type LinkEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _PortalEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalEdge_node, + ec.fieldContext_LinkConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.PageInfo, nil }, nil, - ec.marshalOPortal2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortal, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, true, - false, ) } -func (ec *executionContext) fieldContext_PortalEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalEdge", + Object: "LinkConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Portal_id(ctx, field) - case "createdAt": - return ec.fieldContext_Portal_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Portal_lastModifiedAt(ctx, field) - case "closedAt": - return ec.fieldContext_Portal_closedAt(ctx, field) - case "task": - return ec.fieldContext_Portal_task(ctx, field) - case "beacon": - return ec.fieldContext_Portal_beacon(ctx, field) - case "owner": - return ec.fieldContext_Portal_owner(ctx, field) - case "activeUsers": - return ec.fieldContext_Portal_activeUsers(ctx, field) + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Portal", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _PortalEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalEdge_cursor, + ec.fieldContext_LinkConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.TotalCount, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_PortalEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalEdge", + Object: "LinkConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_node, + ec.fieldContext_LinkEdge_node, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Node(ctx, fc.Args["id"].(int)) + return obj.Node, nil }, nil, - ec.marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder, + ec.marshalOLink2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLink, true, false, ) } -func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "LinkEdge", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + switch field.Name { + case "id": + return ec.fieldContext_Link_id(ctx, field) + case "createdAt": + return ec.fieldContext_Link_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Link_lastModifiedAt(ctx, field) + case "path": + return ec.fieldContext_Link_path(ctx, field) + case "expiresAt": + return ec.fieldContext_Link_expiresAt(ctx, field) + case "downloadLimit": + return ec.fieldContext_Link_downloadLimit(ctx, field) + case "downloads": + return ec.fieldContext_Link_downloads(ctx, field) + case "asset": + return ec.fieldContext_Link_asset(ctx, field) + case "creator": + return ec.fieldContext_Link_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Link", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_nodes, + ec.fieldContext_LinkEdge_cursor, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Nodes(ctx, fc.Args["ids"].([]int)) + return obj.Cursor, nil }, nil, - ec.marshalNNode2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚐNoder, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "LinkEdge", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + return nil, errors.New("field of type Cursor does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_assets(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_assets, + ec.fieldContext_PageInfo_hasNextPage, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Assets(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AssetOrder), fc.Args["where"].(*ent.AssetWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.AssetConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.AssetConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.HasNextPage, nil }, - ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, + nil, + ec.marshalNBoolean2bool, true, true, ) } -func (ec *executionContext) fieldContext_Query_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_AssetConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_AssetConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_AssetConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AssetConnection", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_quests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_quests, + ec.fieldContext_PageInfo_hasPreviousPage, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Quests(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.QuestOrder), fc.Args["where"].(*ent.QuestWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.QuestConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.QuestConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.HasPreviousPage, nil }, - ec.marshalNQuestConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestConnection, + nil, + ec.marshalNBoolean2bool, true, true, ) } -func (ec *executionContext) fieldContext_Query_quests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_QuestConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_QuestConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_QuestConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type QuestConnection", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_quests_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tasks, + ec.fieldContext_PageInfo_startCursor, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Tasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.TaskConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.TaskConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.StartCursor, nil }, - ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, - true, + nil, + ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, true, + false, ) } -func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TaskConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TaskConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TaskConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_repositories(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_repositories, + ec.fieldContext_PageInfo_endCursor, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Repositories(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.RepositoryOrder), fc.Args["where"].(*ent.RepositoryWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.RepositoryConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.RepositoryConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.EndCursor, nil }, - ec.marshalNRepositoryConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryConnection, - true, + nil, + ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, true, + false, ) } -func (ec *executionContext) fieldContext_Query_repositories(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_RepositoryConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_RepositoryConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_RepositoryConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type RepositoryConnection", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_repositories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_id(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_beacons, + ec.fieldContext_Portal_id, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.BeaconConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.BeaconConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.ID, nil }, - ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + nil, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Query_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_BeaconConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_BeaconConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_hosts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_hosts, + ec.fieldContext_Portal_createdAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Hosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.HostConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.HostConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.CreatedAt, nil }, - ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, + nil, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Query_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tags, + ec.fieldContext_Portal_lastModifiedAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) + return obj.LastModifiedAt, nil }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.TagConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.TagConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next - }, - ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, + nil, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TagConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TagConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TagConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tomes, + ec.fieldContext_Portal_closedAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.TomeConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.TomeConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.ClosedAt, nil }, - ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, - true, + nil, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Query_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TomeConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TomeConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TomeConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_task(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_users, + ec.fieldContext_Portal_task, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Users(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.UserConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.UserConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.Task(ctx) }, - ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + nil, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, true, ) } -func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_UserConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_UserConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_UserConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_portals(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_portals, + ec.fieldContext_Portal_beacon, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Portals(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.PortalOrder), fc.Args["where"].(*ent.PortalWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.PortalConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.PortalConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.Beacon(ctx) }, - ec.marshalNPortalConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalConnection, + nil, + ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, true, true, ) } -func (ec *executionContext) fieldContext_Query_portals(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_PortalConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_PortalConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_PortalConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PortalConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_portals_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_shells(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Query_shells, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Shells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.ShellConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.ShellConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next - }, - ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Query_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_ShellConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_ShellConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_ShellConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Beacon_name(ctx, field) + case "principal": + return ec.fieldContext_Beacon_principal(ctx, field) + case "identifier": + return ec.fieldContext_Beacon_identifier(ctx, field) + case "agentIdentifier": + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Beacon_nextSeenAt(ctx, field) + case "interval": + return ec.fieldContext_Beacon_interval(ctx, field) + case "transport": + return ec.fieldContext_Beacon_transport(ctx, field) + case "host": + return ec.fieldContext_Beacon_host(ctx, field) + case "tasks": + return ec.fieldContext_Beacon_tasks(ctx, field) + case "shells": + return ec.fieldContext_Beacon_shells(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_me, + ec.fieldContext_Portal_owner, func(ctx context.Context) (any, error) { - return ec.resolvers.Query().Me(ctx) + return obj.Owner(ctx) }, nil, ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, @@ -7158,12 +6741,12 @@ func (ec *executionContext) _Query_me(ctx context.Context, field graphql.Collect ) } -func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": @@ -7187,55 +6770,39 @@ func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graph return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query___type, + ec.fieldContext_Portal_activeUsers, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.introspectType(fc.Args["name"].(string)) + return obj.ActiveUsers(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) }, nil, - ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType, + ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) + case "edges": + return ec.fieldContext_UserConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_UserConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_UserConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) }, } defer func() { @@ -7245,406 +6812,526 @@ func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Portal_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PortalConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query___schema, + ec.fieldContext_PortalConnection_edges, func(ctx context.Context) (any, error) { - return ec.introspectSchema() + return obj.Edges, nil }, nil, - ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema, + ec.marshalOPortalEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalEdge, true, false, ) } -func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PortalConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) + case "node": + return ec.fieldContext_PortalEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_PortalEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PortalEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Quest_id(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _PortalConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_id, + ec.fieldContext_PortalConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.PageInfo, nil }, nil, - ec.marshalNID2int, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Quest_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "PortalConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Quest_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _PortalConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_createdAt, + ec.fieldContext_PortalConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.TotalCount, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Quest_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "PortalConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Quest_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _PortalEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_lastModifiedAt, + ec.fieldContext_PortalEdge_node, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Node, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOPortal2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortal, true, + false, ) } -func (ec *executionContext) fieldContext_Quest_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "PortalEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Portal_id(ctx, field) + case "createdAt": + return ec.fieldContext_Portal_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Portal_lastModifiedAt(ctx, field) + case "closedAt": + return ec.fieldContext_Portal_closedAt(ctx, field) + case "task": + return ec.fieldContext_Portal_task(ctx, field) + case "beacon": + return ec.fieldContext_Portal_beacon(ctx, field) + case "owner": + return ec.fieldContext_Portal_owner(ctx, field) + case "activeUsers": + return ec.fieldContext_Portal_activeUsers(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Portal", field.Name) }, } return fc, nil } -func (ec *executionContext) _Quest_name(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _PortalEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_name, + ec.fieldContext_PortalEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.Cursor, nil }, nil, - ec.marshalNString2string, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Quest_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "PortalEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Quest_parameters(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_parameters, + ec.fieldContext_Query_node, func(ctx context.Context) (any, error) { - return obj.Parameters, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Node(ctx, fc.Args["id"].(int)) }, nil, - ec.marshalOString2string, + ec.marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder, true, false, ) } -func (ec *executionContext) fieldContext_Quest_parameters(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_paramDefsAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_paramDefsAtCreation, + ec.fieldContext_Query_nodes, func(ctx context.Context) (any, error) { - return obj.ParamDefsAtCreation, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Nodes(ctx, fc.Args["ids"].([]int)) }, nil, - ec.marshalOString2string, + ec.marshalNNode2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚐNoder, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_paramDefsAtCreation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_eldritchAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_assets(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_eldritchAtCreation, + ec.fieldContext_Query_assets, func(ctx context.Context) (any, error) { - return obj.EldritchAtCreation, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Assets(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AssetOrder), fc.Args["where"].(*ent.AssetWhereInput)) }, - nil, - ec.marshalOString2string, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.AssetConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.AssetConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_eldritchAtCreation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_AssetConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_AssetConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_AssetConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type AssetConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_tome(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_quests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_tome, + ec.fieldContext_Query_quests, func(ctx context.Context) (any, error) { - return obj.Tome(ctx) + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Quests(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.QuestOrder), fc.Args["where"].(*ent.QuestWhereInput)) }, - nil, - ec.marshalNTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.QuestConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.QuestConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNQuestConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestConnection, true, true, ) } -func (ec *executionContext) fieldContext_Quest_tome(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_quests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Tome_id(ctx, field) - case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Tome_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Tome_name(ctx, field) - case "description": - return ec.fieldContext_Tome_description(ctx, field) - case "author": - return ec.fieldContext_Tome_author(ctx, field) - case "supportModel": - return ec.fieldContext_Tome_supportModel(ctx, field) - case "tactic": - return ec.fieldContext_Tome_tactic(ctx, field) - case "runOnNewBeaconCallback": - return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) - case "runOnFirstHostCallback": - return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) - case "runOnSchedule": - return ec.fieldContext_Tome_runOnSchedule(ctx, field) - case "paramDefs": - return ec.fieldContext_Tome_paramDefs(ctx, field) - case "eldritch": - return ec.fieldContext_Tome_eldritch(ctx, field) - case "assets": - return ec.fieldContext_Tome_assets(ctx, field) - case "uploader": - return ec.fieldContext_Tome_uploader(ctx, field) - case "repository": - return ec.fieldContext_Tome_repository(ctx, field) - case "scheduledHosts": - return ec.fieldContext_Tome_scheduledHosts(ctx, field) + case "edges": + return ec.fieldContext_QuestConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_QuestConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_QuestConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + return nil, fmt.Errorf("no field named %q was found under type QuestConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_quests_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_bundle(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_bundle, + ec.fieldContext_Query_tasks, func(ctx context.Context) (any, error) { - return obj.Bundle(ctx) + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Tasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) }, - nil, - ec.marshalOAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.TaskConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.TaskConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_bundle(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Asset_id(ctx, field) - case "createdAt": - return ec.fieldContext_Asset_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Asset_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Asset_name(ctx, field) - case "size": - return ec.fieldContext_Asset_size(ctx, field) - case "hash": - return ec.fieldContext_Asset_hash(ctx, field) - case "tomes": - return ec.fieldContext_Asset_tomes(ctx, field) - case "links": - return ec.fieldContext_Asset_links(ctx, field) - case "creator": - return ec.fieldContext_Asset_creator(ctx, field) + case "edges": + return ec.fieldContext_TaskConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TaskConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TaskConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_tasks(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_repositories(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_tasks, + ec.fieldContext_Query_repositories, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return obj.Tasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) + return ec.resolvers.Query().Repositories(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.RepositoryOrder), fc.Args["where"].(*ent.RepositoryWhereInput)) }, - nil, - ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.RepositoryConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.RepositoryConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNRepositoryConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryConnection, true, true, ) } -func (ec *executionContext) fieldContext_Quest_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_repositories(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_TaskConnection_edges(ctx, field) + return ec.fieldContext_RepositoryConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_TaskConnection_pageInfo(ctx, field) + return ec.fieldContext_RepositoryConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_TaskConnection_totalCount(ctx, field) + return ec.fieldContext_RepositoryConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type RepositoryConnection", field.Name) }, } defer func() { @@ -7654,1376 +7341,1607 @@ func (ec *executionContext) fieldContext_Quest_tasks(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Quest_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_repositories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Quest_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_creator, + ec.fieldContext_Query_beacons, func(ctx context.Context) (any, error) { - return obj.Creator(ctx) + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) }, - nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.BeaconConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.BeaconConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_creator(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) + case "edges": + return ec.fieldContext_BeaconConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_BeaconConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _QuestConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_hosts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestConnection_edges, + ec.fieldContext_Query_hosts, func(ctx context.Context) (any, error) { - return obj.Edges, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Hosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) }, - nil, - ec.marshalOQuestEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestEdge, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.HostConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.HostConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_QuestConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "node": - return ec.fieldContext_QuestEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_QuestEdge_cursor(ctx, field) + case "edges": + return ec.fieldContext_HostConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type QuestEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _QuestConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestConnection_pageInfo, + ec.fieldContext_Query_tags, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) }, - nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.TagConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.TagConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, true, true, ) } -func (ec *executionContext) fieldContext_QuestConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } + case "edges": + return ec.fieldContext_TagConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TagConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TagConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _QuestConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestConnection_totalCount, + ec.fieldContext_Query_tomes, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) }, - nil, - ec.marshalNInt2int, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.TomeConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.TomeConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, true, true, ) } -func (ec *executionContext) fieldContext_QuestConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_TomeConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TomeConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TomeConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _QuestEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestEdge_node, + ec.fieldContext_Query_users, func(ctx context.Context) (any, error) { - return obj.Node, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Users(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) }, - nil, - ec.marshalOQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.UserConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.UserConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_QuestEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestEdge", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Quest_id(ctx, field) - case "createdAt": - return ec.fieldContext_Quest_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Quest_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Quest_name(ctx, field) - case "parameters": - return ec.fieldContext_Quest_parameters(ctx, field) - case "paramDefsAtCreation": - return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) - case "eldritchAtCreation": - return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) - case "tome": - return ec.fieldContext_Quest_tome(ctx, field) - case "bundle": - return ec.fieldContext_Quest_bundle(ctx, field) - case "tasks": - return ec.fieldContext_Quest_tasks(ctx, field) - case "creator": - return ec.fieldContext_Quest_creator(ctx, field) + case "edges": + return ec.fieldContext_UserConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_UserConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_UserConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _QuestEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_portals(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestEdge_cursor, + ec.fieldContext_Query_portals, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Portals(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.PortalOrder), fc.Args["where"].(*ent.PortalWhereInput)) }, - nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.PortalConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.PortalConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNPortalConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalConnection, true, true, ) } -func (ec *executionContext) fieldContext_QuestEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_portals(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestEdge", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_PortalConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_PortalConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_PortalConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PortalConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_portals_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Repository_id(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_shells(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_id, + ec.fieldContext_Query_shells, func(ctx context.Context) (any, error) { - return obj.ID, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Shells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) }, - nil, - ec.marshalNID2int, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.ShellConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.ShellConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, true, true, ) } -func (ec *executionContext) fieldContext_Repository_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, + switch field.Name { + case "edges": + return ec.fieldContext_ShellConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ShellConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ShellConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err } return fc, nil } -func (ec *executionContext) _Repository_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_buildTasks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_createdAt, + ec.fieldContext_Query_buildTasks, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().BuildTasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BuildTaskOrder), fc.Args["where"].(*ent.BuildTaskWhereInput)) }, - nil, - ec.marshalNTime2timeᚐTime, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.BuildTaskConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.BuildTaskConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNBuildTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskConnection, true, true, ) } -func (ec *executionContext) fieldContext_Repository_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_buildTasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_BuildTaskConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_BuildTaskConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_BuildTaskConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BuildTaskConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_buildTasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Repository_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_lastModifiedAt, + ec.fieldContext_Query_me, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return ec.resolvers.Query().Me(ctx) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, true, ) } -func (ec *executionContext) fieldContext_Repository_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _Repository_url(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_url, + ec.fieldContext_Query___type, func(ctx context.Context) (any, error) { - return obj.URL, nil + fc := graphql.GetFieldContext(ctx) + return ec.introspectType(fc.Args["name"].(string)) }, nil, - ec.marshalNString2string, - true, + ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType, true, + false, ) } -func (ec *executionContext) fieldContext_Repository_url(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Repository_publicKey(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_publicKey, + ec.fieldContext_Query___schema, func(ctx context.Context) (any, error) { - return obj.PublicKey, nil + return ec.introspectSchema() }, nil, - ec.marshalNString2string, - true, + ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema, true, + false, ) } -func (ec *executionContext) fieldContext_Repository_publicKey(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } -func (ec *executionContext) _Repository_lastImportedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_id(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_lastImportedAt, + ec.fieldContext_Quest_id, func(ctx context.Context) (any, error) { - return obj.LastImportedAt, nil + return obj.ID, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNID2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Repository_lastImportedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Repository_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_tomes, + ec.fieldContext_Quest_createdAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) + return obj.CreatedAt, nil }, nil, - ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Repository_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TomeConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TomeConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TomeConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Repository_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Repository_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_owner, + ec.fieldContext_Quest_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Owner(ctx) + return obj.LastModifiedAt, nil }, nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Repository_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _RepositoryConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_name(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryConnection_edges, + ec.fieldContext_Quest_name, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Name, nil }, nil, - ec.marshalORepositoryEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryEdge, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_RepositoryConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryConnection", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_RepositoryEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_RepositoryEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type RepositoryEdge", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _RepositoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_parameters(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryConnection_pageInfo, + ec.fieldContext_Quest_parameters, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.Parameters, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_RepositoryConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_parameters(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryConnection", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _RepositoryConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_paramDefsAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryConnection_totalCount, + ec.fieldContext_Quest_paramDefsAtCreation, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.ParamDefsAtCreation, nil }, nil, - ec.marshalNInt2int, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_RepositoryConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_paramDefsAtCreation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryConnection", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _RepositoryEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_eldritchAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryEdge_node, + ec.fieldContext_Quest_eldritchAtCreation, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.EldritchAtCreation, nil }, nil, - ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_RepositoryEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_eldritchAtCreation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryEdge", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Repository_id(ctx, field) - case "createdAt": - return ec.fieldContext_Repository_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Repository_lastModifiedAt(ctx, field) - case "url": - return ec.fieldContext_Repository_url(ctx, field) - case "publicKey": - return ec.fieldContext_Repository_publicKey(ctx, field) - case "lastImportedAt": - return ec.fieldContext_Repository_lastImportedAt(ctx, field) - case "tomes": - return ec.fieldContext_Repository_tomes(ctx, field) - case "owner": - return ec.fieldContext_Repository_owner(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _RepositoryEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_tome(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryEdge_cursor, + ec.fieldContext_Quest_tome, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Tome(ctx) }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, true, true, ) } -func (ec *executionContext) fieldContext_RepositoryEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_tome(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryEdge", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Tome_id(ctx, field) + case "createdAt": + return ec.fieldContext_Tome_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Tome_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Tome_name(ctx, field) + case "description": + return ec.fieldContext_Tome_description(ctx, field) + case "author": + return ec.fieldContext_Tome_author(ctx, field) + case "supportModel": + return ec.fieldContext_Tome_supportModel(ctx, field) + case "tactic": + return ec.fieldContext_Tome_tactic(ctx, field) + case "runOnNewBeaconCallback": + return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) + case "runOnFirstHostCallback": + return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) + case "runOnSchedule": + return ec.fieldContext_Tome_runOnSchedule(ctx, field) + case "paramDefs": + return ec.fieldContext_Tome_paramDefs(ctx, field) + case "eldritch": + return ec.fieldContext_Tome_eldritch(ctx, field) + case "assets": + return ec.fieldContext_Tome_assets(ctx, field) + case "uploader": + return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) + case "scheduledHosts": + return ec.fieldContext_Tome_scheduledHosts(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shell_id(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_bundle(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_id, + ec.fieldContext_Quest_bundle, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Bundle(ctx) }, nil, - ec.marshalNID2int, - true, + ec.marshalOAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, true, + false, ) } -func (ec *executionContext) fieldContext_Shell_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_bundle(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Asset_id(ctx, field) + case "createdAt": + return ec.fieldContext_Asset_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Asset_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Asset_name(ctx, field) + case "size": + return ec.fieldContext_Asset_size(ctx, field) + case "hash": + return ec.fieldContext_Asset_hash(ctx, field) + case "tomes": + return ec.fieldContext_Asset_tomes(ctx, field) + case "links": + return ec.fieldContext_Asset_links(ctx, field) + case "creator": + return ec.fieldContext_Asset_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shell_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_tasks(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_createdAt, + ec.fieldContext_Quest_tasks, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + fc := graphql.GetFieldContext(ctx) + return obj.Tasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, true, true, ) } -func (ec *executionContext) fieldContext_Shell_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_TaskConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TaskConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TaskConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Quest_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Shell_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_lastModifiedAt, + ec.fieldContext_Quest_creator, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Creator(ctx) }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, + false, ) } -func (ec *executionContext) fieldContext_Shell_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_creator(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shell_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_closedAt, + ec.fieldContext_QuestConnection_edges, func(ctx context.Context) (any, error) { - return obj.ClosedAt, nil + return obj.Edges, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalOQuestEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestEdge, true, false, ) } -func (ec *executionContext) fieldContext_Shell_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_QuestEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_QuestEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type QuestEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shell_task(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_task, + ec.fieldContext_QuestConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + return obj.PageInfo, nil }, nil, - ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Shell_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shell_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_beacon, + ec.fieldContext_QuestConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Beacon(ctx) + return obj.TotalCount, nil }, nil, - ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Shell_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Beacon_id(ctx, field) - case "createdAt": - return ec.fieldContext_Beacon_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Beacon_name(ctx, field) - case "principal": - return ec.fieldContext_Beacon_principal(ctx, field) - case "identifier": - return ec.fieldContext_Beacon_identifier(ctx, field) - case "agentIdentifier": - return ec.fieldContext_Beacon_agentIdentifier(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Beacon_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Beacon_nextSeenAt(ctx, field) - case "interval": - return ec.fieldContext_Beacon_interval(ctx, field) - case "transport": - return ec.fieldContext_Beacon_transport(ctx, field) - case "host": - return ec.fieldContext_Beacon_host(ctx, field) - case "tasks": - return ec.fieldContext_Beacon_tasks(ctx, field) - case "shells": - return ec.fieldContext_Beacon_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Shell_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_owner, + ec.fieldContext_QuestEdge_node, func(ctx context.Context) (any, error) { - return obj.Owner(ctx) + return obj.Node, nil }, nil, - ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, - true, + ec.marshalOQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, true, + false, ) } -func (ec *executionContext) fieldContext_Shell_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_User_id(ctx, field) + return ec.fieldContext_Quest_id(ctx, field) + case "createdAt": + return ec.fieldContext_Quest_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) + return ec.fieldContext_Quest_name(ctx, field) + case "parameters": + return ec.fieldContext_Quest_parameters(ctx, field) + case "paramDefsAtCreation": + return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) + case "eldritchAtCreation": + return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) + case "tome": + return ec.fieldContext_Quest_tome(ctx, field) + case "bundle": + return ec.fieldContext_Quest_bundle(ctx, field) + case "tasks": + return ec.fieldContext_Quest_tasks(ctx, field) + case "creator": + return ec.fieldContext_Quest_creator(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shell_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_activeUsers, + ec.fieldContext_QuestEdge_cursor, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ActiveUsers(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) + return obj.Cursor, nil }, nil, - ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Shell_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_UserConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_UserConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_UserConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Shell_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _ShellConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_id(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_edges, + ec.fieldContext_Repository_id, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.ID, nil }, nil, - ec.marshalOShellEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellEdge, + ec.marshalNID2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_ShellConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellConnection", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_ShellEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_ShellEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ShellEdge", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _ShellConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_pageInfo, + ec.fieldContext_Repository_createdAt, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_ShellConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellConnection", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _ShellConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_totalCount, + ec.fieldContext_Repository_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalNInt2int, - true, + ec.marshalNTime2timeᚐTime, true, - ) -} - -func (ec *executionContext) fieldContext_ShellConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "ShellConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _ShellEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_ShellEdge_node, - func(ctx context.Context) (any, error) { - return obj.Node, nil - }, - nil, - ec.marshalOShell2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShell, true, - false, ) } -func (ec *executionContext) fieldContext_ShellEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellEdge", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Shell_id(ctx, field) - case "createdAt": - return ec.fieldContext_Shell_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Shell_lastModifiedAt(ctx, field) - case "closedAt": - return ec.fieldContext_Shell_closedAt(ctx, field) - case "task": - return ec.fieldContext_Shell_task(ctx, field) - case "beacon": - return ec.fieldContext_Shell_beacon(ctx, field) - case "owner": - return ec.fieldContext_Shell_owner(ctx, field) - case "activeUsers": - return ec.fieldContext_Shell_activeUsers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Shell", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _ShellEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_url(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellEdge_cursor, + ec.fieldContext_Repository_url, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.URL, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_ShellEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_url(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellEdge", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_publicKey(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_id, + ec.fieldContext_Repository_publicKey, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.PublicKey, nil }, nil, - ec.marshalNID2int, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Tag_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_publicKey(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_lastImportedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_name, + ec.fieldContext_Repository_lastImportedAt, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.LastImportedAt, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Tag_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_lastImportedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tag_kind(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_kind, + ec.fieldContext_Repository_tomes, func(ctx context.Context) (any, error) { - return obj.Kind, nil + fc := graphql.GetFieldContext(ctx) + return obj.Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) }, nil, - ec.marshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind, + ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, true, true, ) } -func (ec *executionContext) fieldContext_Tag_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Repository", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TagKind does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_TomeConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TomeConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TomeConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Repository_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tag_hosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_hosts, + ec.fieldContext_Repository_owner, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Hosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) + return obj.Owner(ctx) }, nil, - ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, - true, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, + false, ) } -func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Repository", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_HostConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Tag_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _TagConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagConnection_edges, + ec.fieldContext_RepositoryConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, - ec.marshalOTagEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagEdge, + ec.marshalORepositoryEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryEdge, true, false, ) } -func (ec *executionContext) fieldContext_TagConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "node": - return ec.fieldContext_TagEdge_node(ctx, field) + return ec.fieldContext_RepositoryEdge_node(ctx, field) case "cursor": - return ec.fieldContext_TagEdge_cursor(ctx, field) + return ec.fieldContext_RepositoryEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TagEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type RepositoryEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _TagConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagConnection_pageInfo, + ec.fieldContext_RepositoryConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -9034,9 +8952,9 @@ func (ec *executionContext) _TagConnection_pageInfo(ctx context.Context, field g ) } -func (ec *executionContext) fieldContext_TagConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, @@ -9057,12 +8975,12 @@ func (ec *executionContext) fieldContext_TagConnection_pageInfo(_ context.Contex return fc, nil } -func (ec *executionContext) _TagConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagConnection_totalCount, + ec.fieldContext_RepositoryConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -9073,9 +8991,9 @@ func (ec *executionContext) _TagConnection_totalCount(ctx context.Context, field ) } -func (ec *executionContext) fieldContext_TagConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, @@ -9086,51 +9004,59 @@ func (ec *executionContext) fieldContext_TagConnection_totalCount(_ context.Cont return fc, nil } -func (ec *executionContext) _TagEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagEdge_node, + ec.fieldContext_RepositoryEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOTag2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTag, + ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, true, false, ) } -func (ec *executionContext) fieldContext_TagEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagEdge", + Object: "RepositoryEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "kind": - return ec.fieldContext_Tag_kind(ctx, field) - case "hosts": - return ec.fieldContext_Tag_hosts(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) - }, - } - return fc, nil + return ec.fieldContext_Repository_id(ctx, field) + case "createdAt": + return ec.fieldContext_Repository_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Repository_lastModifiedAt(ctx, field) + case "url": + return ec.fieldContext_Repository_url(ctx, field) + case "publicKey": + return ec.fieldContext_Repository_publicKey(ctx, field) + case "lastImportedAt": + return ec.fieldContext_Repository_lastImportedAt(ctx, field) + case "tomes": + return ec.fieldContext_Repository_tomes(ctx, field) + case "owner": + return ec.fieldContext_Repository_owner(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) + }, + } + return fc, nil } -func (ec *executionContext) _TagEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagEdge_cursor, + ec.fieldContext_RepositoryEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -9141,9 +9067,9 @@ func (ec *executionContext) _TagEdge_cursor(ctx context.Context, field graphql.C ) } -func (ec *executionContext) fieldContext_TagEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagEdge", + Object: "RepositoryEdge", Field: field, IsMethod: false, IsResolver: false, @@ -9154,12 +9080,12 @@ func (ec *executionContext) fieldContext_TagEdge_cursor(_ context.Context, field return fc, nil } -func (ec *executionContext) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_id(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_id, + ec.fieldContext_Shell_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -9170,9 +9096,9 @@ func (ec *executionContext) _Task_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_Task_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, @@ -9183,12 +9109,12 @@ func (ec *executionContext) fieldContext_Task_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_createdAt, + ec.fieldContext_Shell_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -9199,9 +9125,9 @@ func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.C ) } -func (ec *executionContext) fieldContext_Task_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, @@ -9212,12 +9138,12 @@ func (ec *executionContext) fieldContext_Task_createdAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_lastModifiedAt, + ec.fieldContext_Shell_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -9228,9 +9154,9 @@ func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Task_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, @@ -9241,14 +9167,14 @@ func (ec *executionContext) fieldContext_Task_lastModifiedAt(_ context.Context, return fc, nil } -func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_claimedAt, + ec.fieldContext_Shell_closedAt, func(ctx context.Context) (any, error) { - return obj.ClaimedAt, nil + return obj.ClosedAt, nil }, nil, ec.marshalOTime2timeᚐTime, @@ -9257,9 +9183,9 @@ func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.C ) } -func (ec *executionContext) fieldContext_Task_claimedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, @@ -9270,500 +9196,576 @@ func (ec *executionContext) fieldContext_Task_claimedAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_task(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_execStartedAt, + ec.fieldContext_Shell_task, func(ctx context.Context) (any, error) { - return obj.ExecStartedAt, nil + return obj.Task(ctx) }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Task_execStartedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_execFinishedAt, + ec.fieldContext_Shell_beacon, func(ctx context.Context) (any, error) { - return obj.ExecFinishedAt, nil + return obj.Beacon(ctx) }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Task_execFinishedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Beacon_name(ctx, field) + case "principal": + return ec.fieldContext_Beacon_principal(ctx, field) + case "identifier": + return ec.fieldContext_Beacon_identifier(ctx, field) + case "agentIdentifier": + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Beacon_nextSeenAt(ctx, field) + case "interval": + return ec.fieldContext_Beacon_interval(ctx, field) + case "transport": + return ec.fieldContext_Beacon_transport(ctx, field) + case "host": + return ec.fieldContext_Beacon_host(ctx, field) + case "tasks": + return ec.fieldContext_Beacon_tasks(ctx, field) + case "shells": + return ec.fieldContext_Beacon_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_output(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_output, + ec.fieldContext_Shell_owner, func(ctx context.Context) (any, error) { - return obj.Output, nil + return obj.Owner(ctx) }, nil, - ec.marshalOString2string, + ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Task_output(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_outputSize, + ec.fieldContext_Shell_activeUsers, func(ctx context.Context) (any, error) { - return obj.OutputSize, nil + fc := graphql.GetFieldContext(ctx) + return obj.ActiveUsers(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) }, nil, - ec.marshalNInt2int, + ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, true, true, ) } -func (ec *executionContext) fieldContext_Task_outputSize(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_UserConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_UserConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_UserConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Shell_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_error, + ec.fieldContext_ShellConnection_edges, func(ctx context.Context) (any, error) { - return obj.Error, nil + return obj.Edges, nil }, nil, - ec.marshalOString2string, + ec.marshalOShellEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellEdge, true, false, ) } -func (ec *executionContext) fieldContext_Task_error(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_ShellEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_ShellEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ShellEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_quest, + ec.fieldContext_ShellConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.Quest(ctx) + return obj.PageInfo, nil }, nil, - ec.marshalNQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Task_quest(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Quest_id(ctx, field) - case "createdAt": - return ec.fieldContext_Quest_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Quest_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Quest_name(ctx, field) - case "parameters": - return ec.fieldContext_Quest_parameters(ctx, field) - case "paramDefsAtCreation": - return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) - case "eldritchAtCreation": - return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) - case "tome": - return ec.fieldContext_Quest_tome(ctx, field) - case "bundle": - return ec.fieldContext_Quest_bundle(ctx, field) - case "tasks": - return ec.fieldContext_Quest_tasks(ctx, field) - case "creator": - return ec.fieldContext_Quest_creator(ctx, field) + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_beacon, + ec.fieldContext_ShellConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Beacon(ctx) + return obj.TotalCount, nil }, nil, - ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Task_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Beacon_id(ctx, field) - case "createdAt": - return ec.fieldContext_Beacon_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Beacon_name(ctx, field) - case "principal": - return ec.fieldContext_Beacon_principal(ctx, field) - case "identifier": - return ec.fieldContext_Beacon_identifier(ctx, field) - case "agentIdentifier": - return ec.fieldContext_Beacon_agentIdentifier(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Beacon_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Beacon_nextSeenAt(ctx, field) - case "interval": - return ec.fieldContext_Beacon_interval(ctx, field) - case "transport": - return ec.fieldContext_Beacon_transport(ctx, field) - case "host": - return ec.fieldContext_Beacon_host(ctx, field) - case "tasks": - return ec.fieldContext_Beacon_tasks(ctx, field) - case "shells": - return ec.fieldContext_Beacon_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_reportedFiles(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_reportedFiles, + ec.fieldContext_ShellEdge_node, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ReportedFiles(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostFileOrder), fc.Args["where"].(*ent.HostFileWhereInput)) + return obj.Node, nil }, nil, - ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, - true, + ec.marshalOShell2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShell, true, + false, ) } -func (ec *executionContext) fieldContext_Task_reportedFiles(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_HostFileConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostFileConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostFileConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_Shell_id(ctx, field) + case "createdAt": + return ec.fieldContext_Shell_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Shell_lastModifiedAt(ctx, field) + case "closedAt": + return ec.fieldContext_Shell_closedAt(ctx, field) + case "task": + return ec.fieldContext_Shell_task(ctx, field) + case "beacon": + return ec.fieldContext_Shell_beacon(ctx, field) + case "owner": + return ec.fieldContext_Shell_owner(ctx, field) + case "activeUsers": + return ec.fieldContext_Shell_activeUsers(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostFileConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Shell", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Task_reportedFiles_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_reportedProcesses, + ec.fieldContext_ShellEdge_cursor, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ReportedProcesses(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostProcessOrder), fc.Args["where"].(*ent.HostProcessWhereInput)) + return obj.Cursor, nil }, nil, - ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostProcessConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostProcessConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostProcessConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostProcessConnection", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Task_reportedProcesses_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Task_reportedCredentials(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_reportedCredentials, + ec.fieldContext_Tag_id, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ReportedCredentials(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostCredentialOrder), fc.Args["where"].(*ent.HostCredentialWhereInput)) + return obj.ID, nil }, nil, - ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Task_reportedCredentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostCredentialConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostCredentialConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostCredentialConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Task_reportedCredentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Task_shells(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_shells, + ec.fieldContext_Tag_name, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Shells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) + return obj.Name, nil }, nil, - ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Task_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_ShellConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_ShellConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_ShellConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Task_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Tag_kind(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TaskConnection_edges, + ec.fieldContext_Tag_kind, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Kind, nil }, nil, - ec.marshalOTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskEdge, + ec.marshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind, + true, true, - false, ) } -func (ec *executionContext) fieldContext_TaskConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "Tag", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type TagKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tag_hosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tag_hosts, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.Hosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) + }, + nil, + ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tag", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_HostConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Tag_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _TagConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TagConnection_edges, + func(ctx context.Context) (any, error) { + return obj.Edges, nil + }, + nil, + ec.marshalOTagEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagEdge, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_TagConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TagConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "node": - return ec.fieldContext_TaskEdge_node(ctx, field) + return ec.fieldContext_TagEdge_node(ctx, field) case "cursor": - return ec.fieldContext_TaskEdge_cursor(ctx, field) + return ec.fieldContext_TagEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TagEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _TagConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TaskConnection_pageInfo, + ec.fieldContext_TagConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -9774,9 +9776,9 @@ func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field ) } -func (ec *executionContext) fieldContext_TaskConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "TagConnection", Field: field, IsMethod: false, IsResolver: false, @@ -9797,12 +9799,12 @@ func (ec *executionContext) fieldContext_TaskConnection_pageInfo(_ context.Conte return fc, nil } -func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _TagConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TaskConnection_totalCount, + ec.fieldContext_TagConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -9813,9 +9815,9 @@ func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, fiel ) } -func (ec *executionContext) fieldContext_TaskConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "TagConnection", Field: field, IsMethod: false, IsResolver: false, @@ -9826,73 +9828,51 @@ func (ec *executionContext) fieldContext_TaskConnection_totalCount(_ context.Con return fc, nil } -func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TagEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TaskEdge_node, + ec.fieldContext_TagEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalOTag2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTag, true, false, ) } -func (ec *executionContext) fieldContext_TaskEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "TagEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "kind": + return ec.fieldContext_Tag_kind(ctx, field) + case "hosts": + return ec.fieldContext_Tag_hosts(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } return fc, nil } -func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TagEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TaskEdge_cursor, + ec.fieldContext_TagEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -9903,9 +9883,9 @@ func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_TaskEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "TagEdge", Field: field, IsMethod: false, IsResolver: false, @@ -9916,12 +9896,12 @@ func (ec *executionContext) fieldContext_TaskEdge_cursor(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_id, + ec.fieldContext_Task_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -9932,9 +9912,9 @@ func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_Tome_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -9945,12 +9925,12 @@ func (ec *executionContext) fieldContext_Tome_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_createdAt, + ec.fieldContext_Task_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -9961,9 +9941,9 @@ func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.C ) } -func (ec *executionContext) fieldContext_Tome_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -9974,12 +9954,12 @@ func (ec *executionContext) fieldContext_Tome_createdAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_lastModifiedAt, + ec.fieldContext_Task_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -9990,9 +9970,9 @@ func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Tome_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -10003,329 +9983,423 @@ func (ec *executionContext) fieldContext_Tome_lastModifiedAt(_ context.Context, return fc, nil } -func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_name, + ec.fieldContext_Task_claimedAt, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.ClaimedAt, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_claimedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_description(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_description, + ec.fieldContext_Task_execStartedAt, func(ctx context.Context) (any, error) { - return obj.Description, nil + return obj.ExecStartedAt, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_execStartedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_author, + ec.fieldContext_Task_execFinishedAt, func(ctx context.Context) (any, error) { - return obj.Author, nil + return obj.ExecFinishedAt, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_author(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_execFinishedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_output(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_supportModel, + ec.fieldContext_Task_output, func(ctx context.Context) (any, error) { - return obj.SupportModel, nil + return obj.Output, nil }, nil, - ec.marshalNTomeSupportModel2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_supportModel(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_output(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TomeSupportModel does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_tactic, + ec.fieldContext_Task_outputSize, func(ctx context.Context) (any, error) { - return obj.Tactic, nil + return obj.OutputSize, nil }, nil, - ec.marshalNTomeTactic2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Tome_tactic(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_outputSize(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TomeTactic does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_runOnNewBeaconCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_runOnNewBeaconCallback, + ec.fieldContext_Task_error, func(ctx context.Context) (any, error) { - return obj.RunOnNewBeaconCallback, nil + return obj.Error, nil }, nil, - ec.marshalNBoolean2bool, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_runOnNewBeaconCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_error(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_runOnFirstHostCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_runOnFirstHostCallback, + ec.fieldContext_Task_quest, func(ctx context.Context) (any, error) { - return obj.RunOnFirstHostCallback, nil + return obj.Quest(ctx) }, nil, - ec.marshalNBoolean2bool, + ec.marshalNQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, true, true, ) } -func (ec *executionContext) fieldContext_Tome_runOnFirstHostCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_quest(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Quest_id(ctx, field) + case "createdAt": + return ec.fieldContext_Quest_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Quest_name(ctx, field) + case "parameters": + return ec.fieldContext_Quest_parameters(ctx, field) + case "paramDefsAtCreation": + return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) + case "eldritchAtCreation": + return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) + case "tome": + return ec.fieldContext_Quest_tome(ctx, field) + case "bundle": + return ec.fieldContext_Quest_bundle(ctx, field) + case "tasks": + return ec.fieldContext_Quest_tasks(ctx, field) + case "creator": + return ec.fieldContext_Quest_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_runOnSchedule(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_runOnSchedule, + ec.fieldContext_Task_beacon, func(ctx context.Context) (any, error) { - return obj.RunOnSchedule, nil + return obj.Beacon(ctx) }, nil, - ec.marshalNString2string, + ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, true, true, ) } -func (ec *executionContext) fieldContext_Tome_runOnSchedule(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Beacon_name(ctx, field) + case "principal": + return ec.fieldContext_Beacon_principal(ctx, field) + case "identifier": + return ec.fieldContext_Beacon_identifier(ctx, field) + case "agentIdentifier": + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Beacon_nextSeenAt(ctx, field) + case "interval": + return ec.fieldContext_Beacon_interval(ctx, field) + case "transport": + return ec.fieldContext_Beacon_transport(ctx, field) + case "host": + return ec.fieldContext_Beacon_host(ctx, field) + case "tasks": + return ec.fieldContext_Beacon_tasks(ctx, field) + case "shells": + return ec.fieldContext_Beacon_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_reportedFiles(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_paramDefs, + ec.fieldContext_Task_reportedFiles, func(ctx context.Context) (any, error) { - return obj.ParamDefs, nil + fc := graphql.GetFieldContext(ctx) + return obj.ReportedFiles(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostFileOrder), fc.Args["where"].(*ent.HostFileWhereInput)) }, nil, - ec.marshalOString2string, + ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Tome_paramDefs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedFiles(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_HostFileConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostFileConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostFileConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostFileConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Task_reportedFiles_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_eldritch, + ec.fieldContext_Task_reportedProcesses, func(ctx context.Context) (any, error) { - return obj.Eldritch, nil + fc := graphql.GetFieldContext(ctx) + return obj.ReportedProcesses(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostProcessOrder), fc.Args["where"].(*ent.HostProcessWhereInput)) }, nil, - ec.marshalNString2string, + ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, true, true, ) } -func (ec *executionContext) fieldContext_Tome_eldritch(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_HostProcessConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostProcessConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostProcessConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostProcessConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Task_reportedProcesses_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tome_assets(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_reportedCredentials(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_assets, + ec.fieldContext_Task_reportedCredentials, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return obj.Assets(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AssetOrder), fc.Args["where"].(*ent.AssetWhereInput)) + return obj.ReportedCredentials(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostCredentialOrder), fc.Args["where"].(*ent.HostCredentialWhereInput)) }, nil, - ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, + ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, true, true, ) } -func (ec *executionContext) fieldContext_Tome_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedCredentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_AssetConnection_edges(ctx, field) + return ec.fieldContext_HostCredentialConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_AssetConnection_pageInfo(ctx, field) + return ec.fieldContext_HostCredentialConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_AssetConnection_totalCount(ctx, field) + return ec.fieldContext_HostCredentialConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AssetConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", field.Name) }, } defer func() { @@ -10335,195 +10409,103 @@ func (ec *executionContext) fieldContext_Tome_assets(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Tome_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Task_reportedCredentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_shells(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_uploader, + ec.fieldContext_Task_shells, func(ctx context.Context) (any, error) { - return obj.Uploader(ctx) + fc := graphql.GetFieldContext(ctx) + return obj.Shells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) }, nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Tome_uploader(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) + case "edges": + return ec.fieldContext_ShellConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ShellConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ShellConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Task_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tome_repository(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_repository, - func(ctx context.Context) (any, error) { - return obj.Repository(ctx) - }, - nil, - ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_Tome_repository(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Tome", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Repository_id(ctx, field) - case "createdAt": - return ec.fieldContext_Repository_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Repository_lastModifiedAt(ctx, field) - case "url": - return ec.fieldContext_Repository_url(ctx, field) - case "publicKey": - return ec.fieldContext_Repository_publicKey(ctx, field) - case "lastImportedAt": - return ec.fieldContext_Repository_lastImportedAt(ctx, field) - case "tomes": - return ec.fieldContext_Repository_tomes(ctx, field) - case "owner": - return ec.fieldContext_Repository_owner(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Tome_scheduledHosts, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ScheduledHosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) - }, - nil, - ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Tome", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Tome_scheduledHosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _TomeConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_TomeConnection_edges, + ec.fieldContext_TaskConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, - ec.marshalOTomeEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeEdge, + ec.marshalOTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskEdge, true, false, ) } -func (ec *executionContext) fieldContext_TomeConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeConnection", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "node": - return ec.fieldContext_TomeEdge_node(ctx, field) + return ec.fieldContext_TaskEdge_node(ctx, field) case "cursor": - return ec.fieldContext_TomeEdge_cursor(ctx, field) + return ec.fieldContext_TaskEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TomeEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _TomeConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeConnection_pageInfo, + ec.fieldContext_TaskConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -10534,9 +10516,9 @@ func (ec *executionContext) _TomeConnection_pageInfo(ctx context.Context, field ) } -func (ec *executionContext) fieldContext_TomeConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeConnection", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, @@ -10557,12 +10539,12 @@ func (ec *executionContext) fieldContext_TomeConnection_pageInfo(_ context.Conte return fc, nil } -func (ec *executionContext) _TomeConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeConnection_totalCount, + ec.fieldContext_TaskConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -10573,9 +10555,9 @@ func (ec *executionContext) _TomeConnection_totalCount(ctx context.Context, fiel ) } -func (ec *executionContext) fieldContext_TomeConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeConnection", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, @@ -10586,77 +10568,73 @@ func (ec *executionContext) fieldContext_TomeConnection_totalCount(_ context.Con return fc, nil } -func (ec *executionContext) _TomeEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeEdge_node, + ec.fieldContext_TaskEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, + ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, false, ) } -func (ec *executionContext) fieldContext_TomeEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeEdge", + Object: "TaskEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Tome_id(ctx, field) + return ec.fieldContext_Task_id(ctx, field) case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) + return ec.fieldContext_Task_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Tome_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Tome_name(ctx, field) - case "description": - return ec.fieldContext_Tome_description(ctx, field) - case "author": - return ec.fieldContext_Tome_author(ctx, field) - case "supportModel": - return ec.fieldContext_Tome_supportModel(ctx, field) - case "tactic": - return ec.fieldContext_Tome_tactic(ctx, field) - case "runOnNewBeaconCallback": - return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) - case "runOnFirstHostCallback": - return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) - case "runOnSchedule": - return ec.fieldContext_Tome_runOnSchedule(ctx, field) - case "paramDefs": - return ec.fieldContext_Tome_paramDefs(ctx, field) - case "eldritch": - return ec.fieldContext_Tome_eldritch(ctx, field) - case "assets": - return ec.fieldContext_Tome_assets(ctx, field) - case "uploader": - return ec.fieldContext_Tome_uploader(ctx, field) - case "repository": - return ec.fieldContext_Tome_repository(ctx, field) - case "scheduledHosts": - return ec.fieldContext_Tome_scheduledHosts(ctx, field) + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _TomeEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeEdge_cursor, + ec.fieldContext_TaskEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -10667,9 +10645,9 @@ func (ec *executionContext) _TomeEdge_cursor(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_TomeEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeEdge", + Object: "TaskEdge", Field: field, IsMethod: false, IsResolver: false, @@ -10680,12 +10658,12 @@ func (ec *executionContext) fieldContext_TomeEdge_cursor(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_id, + ec.fieldContext_Tome_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -10696,9 +10674,9 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, @@ -10709,930 +10687,2613 @@ func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_name, + ec.fieldContext_Tome_createdAt, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNString2string, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_User_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_photoURL, + ec.fieldContext_Tome_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.PhotoURL, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalNString2string, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_User_photoURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_isActivated(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_isActivated, + ec.fieldContext_Tome_name, func(ctx context.Context) (any, error) { - return obj.IsActivated, nil + return obj.Name, nil }, nil, - ec.marshalNBoolean2bool, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_User_isActivated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_description(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_isAdmin, + ec.fieldContext_Tome_description, func(ctx context.Context) (any, error) { - return obj.IsAdmin, nil + return obj.Description, nil }, nil, - ec.marshalNBoolean2bool, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_User_isAdmin(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_tomes, + ec.fieldContext_Tome_author, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) + return obj.Author, nil }, nil, - ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_author(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TomeConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TomeConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TomeConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_User_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _User_activeShells(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_activeShells, + ec.fieldContext_Tome_supportModel, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ActiveShells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) + return obj.SupportModel, nil }, nil, - ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + ec.marshalNTomeSupportModel2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel, true, true, ) } -func (ec *executionContext) fieldContext_User_activeShells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_supportModel(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_ShellConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_ShellConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_ShellConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) + return nil, errors.New("field of type TomeSupportModel does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_User_activeShells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err + return fc, nil +} + +func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_tactic, + func(ctx context.Context) (any, error) { + return obj.Tactic, nil + }, + nil, + ec.marshalNTomeTactic2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Tome_tactic(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type TomeTactic does not have child fields") + }, } return fc, nil } -func (ec *executionContext) _UserConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_runOnNewBeaconCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserConnection_edges, + ec.fieldContext_Tome_runOnNewBeaconCallback, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.RunOnNewBeaconCallback, nil }, nil, - ec.marshalOUserEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserEdge, + ec.marshalNBoolean2bool, + true, true, - false, ) } -func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_runOnNewBeaconCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserConnection", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_UserEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_UserEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_runOnFirstHostCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserConnection_pageInfo, + ec.fieldContext_Tome_runOnFirstHostCallback, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.RunOnFirstHostCallback, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNBoolean2bool, true, true, ) } -func (ec *executionContext) fieldContext_UserConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_runOnFirstHostCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserConnection", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_runOnSchedule(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserConnection_totalCount, + ec.fieldContext_Tome_runOnSchedule, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.RunOnSchedule, nil }, nil, - ec.marshalNInt2int, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_UserConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_runOnSchedule(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserConnection", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserEdge_node, + ec.fieldContext_Tome_paramDefs, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.ParamDefs, nil }, nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_UserEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_paramDefs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserEdge", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserEdge_cursor, + ec.fieldContext_Tome_eldritch, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Eldritch, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_UserEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_eldritch(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserEdge", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** +func (ec *executionContext) _Tome_assets(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_assets, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.Assets(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AssetOrder), fc.Args["where"].(*ent.AssetWhereInput)) + }, + nil, + ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, + true, + true, + ) +} -func (ec *executionContext) unmarshalInputAssetOrder(ctx context.Context, obj any) (ent.AssetOrder, error) { - var it ent.AssetOrder - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v +func (ec *executionContext) fieldContext_Tome_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_AssetConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_AssetConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_AssetConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type AssetConnection", field.Name) + }, } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Tome_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err } + return fc, nil +} - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) - if err != nil { - return it, err +func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_uploader, + func(ctx context.Context) (any, error) { + return obj.Uploader(ctx) + }, + nil, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Tome_uploader(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNAssetOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetOrderField(ctx, v) - if err != nil { - return it, err + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_repository(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_repository, + func(ctx context.Context) (any, error) { + return obj.Repository(ctx) + }, + nil, + ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Tome_repository(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Repository_id(ctx, field) + case "createdAt": + return ec.fieldContext_Repository_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Repository_lastModifiedAt(ctx, field) + case "url": + return ec.fieldContext_Repository_url(ctx, field) + case "publicKey": + return ec.fieldContext_Repository_publicKey(ctx, field) + case "lastImportedAt": + return ec.fieldContext_Repository_lastImportedAt(ctx, field) + case "tomes": + return ec.fieldContext_Repository_tomes(ctx, field) + case "owner": + return ec.fieldContext_Repository_owner(ctx, field) } - it.Field = data + return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_scheduledHosts, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.ScheduledHosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) + }, + nil, + ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_HostConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Tome_scheduledHosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err } + return fc, nil +} - return it, nil +func (ec *executionContext) _TomeConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeConnection_edges, + func(ctx context.Context) (any, error) { + return obj.Edges, nil + }, + nil, + ec.marshalOTomeEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeEdge, + true, + false, + ) } -func (ec *executionContext) unmarshalInputAssetWhereInput(ctx context.Context, obj any) (ent.AssetWhereInput, error) { - var it ent.AssetWhereInput - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v +func (ec *executionContext) fieldContext_TomeConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "node": + return ec.fieldContext_TomeEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_TomeEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TomeEdge", field.Name) + }, } + return fc, nil +} - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashEqualFold", "hashContainsFold", "hasTomes", "hasTomesWith", "hasLinks", "hasLinksWith", "hasCreator", "hasCreatorWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOAssetWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInput(ctx, v) +func (ec *executionContext) _TomeConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeConnection_pageInfo, + func(ctx context.Context) (any, error) { + return obj.PageInfo, nil + }, + nil, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_TomeConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _TomeConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeConnection_totalCount, + func(ctx context.Context) (any, error) { + return obj.TotalCount, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_TomeConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _TomeEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeEdge_node, + func(ctx context.Context) (any, error) { + return obj.Node, nil + }, + nil, + ec.marshalOTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_TomeEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Tome_id(ctx, field) + case "createdAt": + return ec.fieldContext_Tome_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Tome_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Tome_name(ctx, field) + case "description": + return ec.fieldContext_Tome_description(ctx, field) + case "author": + return ec.fieldContext_Tome_author(ctx, field) + case "supportModel": + return ec.fieldContext_Tome_supportModel(ctx, field) + case "tactic": + return ec.fieldContext_Tome_tactic(ctx, field) + case "runOnNewBeaconCallback": + return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) + case "runOnFirstHostCallback": + return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) + case "runOnSchedule": + return ec.fieldContext_Tome_runOnSchedule(ctx, field) + case "paramDefs": + return ec.fieldContext_Tome_paramDefs(ctx, field) + case "eldritch": + return ec.fieldContext_Tome_eldritch(ctx, field) + case "assets": + return ec.fieldContext_Tome_assets(ctx, field) + case "uploader": + return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) + case "scheduledHosts": + return ec.fieldContext_Tome_scheduledHosts(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _TomeEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeEdge_cursor, + func(ctx context.Context) (any, error) { + return obj.Cursor, nil + }, + nil, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_TomeEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Cursor does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_id, + func(ctx context.Context) (any, error) { + return obj.ID, nil + }, + nil, + ec.marshalNID2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_name, + func(ctx context.Context) (any, error) { + return obj.Name, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_photoURL, + func(ctx context.Context) (any, error) { + return obj.PhotoURL, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_photoURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_isActivated(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_isActivated, + func(ctx context.Context) (any, error) { + return obj.IsActivated, nil + }, + nil, + ec.marshalNBoolean2bool, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_isActivated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_isAdmin, + func(ctx context.Context) (any, error) { + return obj.IsAdmin, nil + }, + nil, + ec.marshalNBoolean2bool, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_isAdmin(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_tomes, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) + }, + nil, + ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_TomeConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TomeConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TomeConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_User_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _User_activeShells(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_activeShells, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.ActiveShells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) + }, + nil, + ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_activeShells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_ShellConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ShellConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ShellConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_User_activeShells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserConnection_edges, + func(ctx context.Context) (any, error) { + return obj.Edges, nil + }, + nil, + ec.marshalOUserEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserEdge, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "node": + return ec.fieldContext_UserEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_UserEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserConnection_pageInfo, + func(ctx context.Context) (any, error) { + return obj.PageInfo, nil + }, + nil, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_UserConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserConnection_totalCount, + func(ctx context.Context) (any, error) { + return obj.TotalCount, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_UserConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _UserEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserEdge_node, + func(ctx context.Context) (any, error) { + return obj.Node, nil + }, + nil, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_UserEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _UserEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserEdge_cursor, + func(ctx context.Context) (any, error) { + return obj.Cursor, nil + }, + nil, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_UserEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Cursor does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputAssetOrder(ctx context.Context, obj any) (ent.AssetOrder, error) { + var it ent.AssetOrder + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + if err != nil { + return it, err + } + it.Direction = data + case "field": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNAssetOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputAssetWhereInput(ctx context.Context, obj any) (ent.AssetWhereInput, error) { + var it ent.AssetWhereInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashEqualFold", "hashContainsFold", "hasTomes", "hasTomesWith", "hasLinks", "hasLinksWith", "hasCreator", "hasCreatorWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOAssetWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createdAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNotIn = data + case "createdAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGT = data + case "createdAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGTE = data + case "createdAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLT = data + case "createdAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLTE = data + case "lastModifiedAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAt = data + case "lastModifiedAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLTE = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameNEQ = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data + case "size": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.Size = data + case "sizeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeNEQ = data + case "sizeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.SizeIn = data + case "sizeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.SizeNotIn = data + case "sizeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeGT = data + case "sizeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeGTE = data + case "sizeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeLT = data + case "sizeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeLTE = data + case "hash": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Hash = data + case "hashNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashNEQ = data + case "hashIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.HashIn = data + case "hashNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.HashNotIn = data + case "hashGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashGT = data + case "hashGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashGTE = data + case "hashLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashLT = data + case "hashLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashLTE = data + case "hashContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashContains = data + case "hashHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashHasPrefix = data + case "hashHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashHasSuffix = data + case "hashEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashEqualFold = data + case "hashContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashContainsFold = data + case "hasTomes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasTomes = data + case "hasTomesWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomesWith")) + data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasTomesWith = data + case "hasLinks": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinks")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasLinks = data + case "hasLinksWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinksWith")) + data, err := ec.unmarshalOLinkWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasLinksWith = data + case "hasCreator": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreator")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasCreator = data + case "hasCreatorWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreatorWith")) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasCreatorWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj any) (ent.BeaconOrder, error) { + var it ent.BeaconOrder + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + if err != nil { + return it, err + } + it.Direction = data + case "field": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNBeaconOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, obj any) (ent.BeaconWhereInput, error) { + var it ent.BeaconWhereInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "nextSeenAt", "nextSeenAtNEQ", "nextSeenAtIn", "nextSeenAtNotIn", "nextSeenAtGT", "nextSeenAtGTE", "nextSeenAtLT", "nextSeenAtLTE", "nextSeenAtIsNil", "nextSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "transport", "transportNEQ", "transportIn", "transportNotIn", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith", "hasShells", "hasShellsWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createdAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNotIn = data + case "createdAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGT = data + case "createdAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGTE = data + case "createdAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLT = data + case "createdAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLTE = data + case "lastModifiedAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAt = data + case "lastModifiedAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLTE = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameNEQ = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data + case "principal": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Principal = data + case "principalNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalNEQ = data + case "principalIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.PrincipalIn = data + case "principalNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.PrincipalNotIn = data + case "principalGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalGT = data + case "principalGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalGTE = data + case "principalLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalLT = data + case "principalLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalLTE = data + case "principalContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalContains = data + case "principalHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalHasPrefix = data + case "principalHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalHasSuffix = data + case "principalIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.PrincipalIsNil = data + case "principalNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.PrincipalNotNil = data + case "principalEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalEqualFold = data + case "principalContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + it.PrincipalContainsFold = data + case "identifier": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + it.Identifier = data + case "identifierNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.IdentifierNEQ = data + case "identifierIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.IdentifierIn = data + case "identifierNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.IdentifierNotIn = data + case "identifierGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + it.IdentifierGT = data + case "identifierGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.IdentifierGTE = data + case "identifierLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.IdentifierLT = data + case "identifierLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.IdentifierLTE = data + case "identifierContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.IdentifierContains = data + case "identifierHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLTE = data - case "createdAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierHasPrefix = data + case "identifierHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAt = data - case "createdAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierHasSuffix = data + case "identifierEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNEQ = data - case "createdAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.IdentifierEqualFold = data + case "identifierContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtIn = data - case "createdAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.IdentifierContainsFold = data + case "agentIdentifier": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifier")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNotIn = data - case "createdAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.AgentIdentifier = data + case "agentIdentifierNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtGT = data - case "createdAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.AgentIdentifierNEQ = data + case "agentIdentifierIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.CreatedAtGTE = data - case "createdAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.AgentIdentifierIn = data + case "agentIdentifierNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.CreatedAtLT = data - case "createdAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.AgentIdentifierNotIn = data + case "agentIdentifierGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtLTE = data - case "lastModifiedAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.AgentIdentifierGT = data + case "agentIdentifierGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAt = data - case "lastModifiedAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.AgentIdentifierGTE = data + case "agentIdentifierLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtNEQ = data - case "lastModifiedAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.AgentIdentifierLT = data + case "agentIdentifierLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtIn = data - case "lastModifiedAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.AgentIdentifierLTE = data + case "agentIdentifierContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtNotIn = data - case "lastModifiedAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.AgentIdentifierContains = data + case "agentIdentifierHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtGT = data - case "lastModifiedAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.AgentIdentifierHasPrefix = data + case "agentIdentifierHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtGTE = data - case "lastModifiedAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.AgentIdentifierHasSuffix = data + case "agentIdentifierIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.LastModifiedAtLT = data - case "lastModifiedAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.AgentIdentifierIsNil = data + case "agentIdentifierNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.LastModifiedAtLTE = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.AgentIdentifierNotNil = data + case "agentIdentifierEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "nameNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + it.AgentIdentifierEqualFold = data + case "agentIdentifierContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameNEQ = data - case "nameIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.AgentIdentifierContainsFold = data + case "lastSeenAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameIn = data - case "nameNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.LastSeenAt = data + case "lastSeenAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameNotIn = data - case "nameGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtNEQ = data + case "lastSeenAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtIn = data + case "lastSeenAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.NameGT = data - case "nameGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtNotIn = data + case "lastSeenAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameGTE = data - case "nameLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtGT = data + case "lastSeenAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameLT = data - case "nameLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtGTE = data + case "lastSeenAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameLTE = data - case "nameContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtLT = data + case "lastSeenAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameContains = data - case "nameHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtLTE = data + case "lastSeenAtIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.NameHasPrefix = data - case "nameHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtIsNil = data + case "lastSeenAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastSeenAtNotNil = data + case "nextSeenAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NextSeenAt = data + case "nextSeenAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "size": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.NextSeenAtNEQ = data + case "nextSeenAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.Size = data - case "sizeNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.NextSeenAtIn = data + case "nextSeenAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.SizeNEQ = data - case "sizeIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + it.NextSeenAtNotIn = data + case "nextSeenAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.SizeIn = data - case "sizeNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + it.NextSeenAtGT = data + case "nextSeenAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.SizeNotIn = data - case "sizeGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.NextSeenAtGTE = data + case "nextSeenAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.SizeGT = data - case "sizeGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.NextSeenAtLT = data + case "nextSeenAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.SizeGTE = data - case "sizeLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.NextSeenAtLTE = data + case "nextSeenAtIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.SizeLT = data - case "sizeLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.NextSeenAtIsNil = data + case "nextSeenAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.SizeLTE = data - case "hash": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NextSeenAtNotNil = data + case "interval": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.Hash = data - case "hashNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.Interval = data + case "intervalNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNEQ")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.HashNEQ = data - case "hashIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.IntervalNEQ = data + case "intervalIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.HashIn = data - case "hashNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.IntervalIn = data + case "intervalNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.HashNotIn = data - case "hashGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalNotIn = data + case "intervalGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.HashGT = data - case "hashGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalGT = data + case "intervalGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.HashGTE = data - case "hashLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalGTE = data + case "intervalLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.HashLT = data - case "hashLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalLT = data + case "intervalLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.HashLTE = data - case "hashContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalLTE = data + case "intervalIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.HashContains = data - case "hashHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalIsNil = data + case "intervalNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.HashHasPrefix = data - case "hashHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IntervalNotNil = data + case "transport": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transport")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) if err != nil { return it, err } - it.HashHasSuffix = data - case "hashEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.Transport = data + case "transportNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNEQ")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) if err != nil { return it, err } - it.HashEqualFold = data - case "hashContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.TransportNEQ = data + case "transportIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportIn")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) if err != nil { return it, err } - it.HashContainsFold = data - case "hasTomes": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.TransportIn = data + case "transportNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNotIn")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) if err != nil { return it, err } - it.HasTomes = data - case "hasTomesWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomesWith")) - data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) + it.TransportNotIn = data + case "hasHost": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasTomesWith = data - case "hasLinks": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinks")) + it.HasHost = data + case "hasHostWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasHostWith = data + case "hasTasks": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasLinks = data - case "hasLinksWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinksWith")) - data, err := ec.unmarshalOLinkWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkWhereInputᚄ(ctx, v) + it.HasTasks = data + case "hasTasksWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasLinksWith = data - case "hasCreator": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreator")) + it.HasTasksWith = data + case "hasShells": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShells")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasCreator = data - case "hasCreatorWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreatorWith")) - data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(ctx, v) + it.HasShells = data + case "hasShellsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellsWith")) + data, err := ec.unmarshalOShellWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasCreatorWith = data + it.HasShellsWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj any) (ent.BeaconOrder, error) { - var it ent.BeaconOrder +func (ec *executionContext) unmarshalInputBuildTaskOrder(ctx context.Context, obj any) (ent.BuildTaskOrder, error) { + var it ent.BuildTaskOrder asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -11658,7 +13319,7 @@ func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj a it.Direction = data case "field": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNBeaconOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconOrderField(ctx, v) + data, err := ec.unmarshalNBuildTaskOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskOrderField(ctx, v) if err != nil { return it, err } @@ -11669,14 +13330,14 @@ func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj a return it, nil } -func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, obj any) (ent.BeaconWhereInput, error) { - var it ent.BeaconWhereInput +func (ec *executionContext) unmarshalInputBuildTaskWhereInput(ctx context.Context, obj any) (ent.BuildTaskWhereInput, error) { + var it ent.BuildTaskWhereInput asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "nextSeenAt", "nextSeenAtNEQ", "nextSeenAtIn", "nextSeenAtNotIn", "nextSeenAtGT", "nextSeenAtGTE", "nextSeenAtLT", "nextSeenAtLTE", "nextSeenAtIsNil", "nextSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "transport", "transportNEQ", "transportIn", "transportNotIn", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith", "hasShells", "hasShellsWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "targetOs", "targetOsNEQ", "targetOsIn", "targetOsNotIn", "buildImage", "buildImageNEQ", "buildImageIn", "buildImageNotIn", "buildImageGT", "buildImageGTE", "buildImageLT", "buildImageLTE", "buildImageContains", "buildImageHasPrefix", "buildImageHasSuffix", "buildImageEqualFold", "buildImageContainsFold", "buildScript", "buildScriptNEQ", "buildScriptIn", "buildScriptNotIn", "buildScriptGT", "buildScriptGTE", "buildScriptLT", "buildScriptLTE", "buildScriptContains", "buildScriptHasPrefix", "buildScriptHasSuffix", "buildScriptEqualFold", "buildScriptContainsFold", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "startedAt", "startedAtNEQ", "startedAtIn", "startedAtNotIn", "startedAtGT", "startedAtGTE", "startedAtLT", "startedAtLTE", "startedAtIsNil", "startedAtNotNil", "finishedAt", "finishedAtNEQ", "finishedAtIn", "finishedAtNotIn", "finishedAtGT", "finishedAtGTE", "finishedAtLT", "finishedAtLTE", "finishedAtIsNil", "finishedAtNotNil", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "hasBuilder", "hasBuilderWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -11685,21 +13346,21 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, switch k { case "not": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInput(ctx, v) + data, err := ec.unmarshalOBuildTaskWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInput(ctx, v) if err != nil { return it, err } it.Not = data case "and": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBuildTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } it.And = data case "or": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBuildTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -11872,678 +13533,650 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, return it, err } it.LastModifiedAtLTE = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + case "targetOs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetOs")) + data, err := ec.unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, v) if err != nil { return it, err } - it.Name = data - case "nameNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.TargetOs = data + case "targetOsNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetOsNEQ")) + data, err := ec.unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, v) if err != nil { return it, err } - it.NameNEQ = data - case "nameIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.TargetOsNEQ = data + case "targetOsIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetOsIn")) + data, err := ec.unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx, v) if err != nil { return it, err } - it.NameIn = data - case "nameNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.TargetOsIn = data + case "targetOsNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetOsNotIn")) + data, err := ec.unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx, v) if err != nil { return it, err } - it.NameNotIn = data - case "nameGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + it.TargetOsNotIn = data + case "buildImage": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImage")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGT = data - case "nameGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + it.BuildImage = data + case "buildImageNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGTE = data - case "nameLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.BuildImageNEQ = data + case "buildImageIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameLT = data - case "nameLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.BuildImageIn = data + case "buildImageNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameLTE = data - case "nameContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + it.BuildImageNotIn = data + case "buildImageGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContains = data - case "nameHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + it.BuildImageGT = data + case "buildImageGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasPrefix = data - case "nameHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + it.BuildImageGTE = data + case "buildImageLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + it.BuildImageLT = data + case "buildImageLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + it.BuildImageLTE = data + case "buildImageContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "principal": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + it.BuildImageContains = data + case "buildImageHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Principal = data - case "principalNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + it.BuildImageHasPrefix = data + case "buildImageHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalNEQ = data - case "principalIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.PrincipalIn = data - case "principalNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.PrincipalNotIn = data - case "principalGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) + it.BuildImageHasSuffix = data + case "buildImageEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalGT = data - case "principalGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + it.BuildImageEqualFold = data + case "buildImageContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImageContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalGTE = data - case "principalLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + it.BuildImageContainsFold = data + case "buildScript": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScript")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalLT = data - case "principalLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + it.BuildScript = data + case "buildScriptNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalLTE = data - case "principalContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.BuildScriptNEQ = data + case "buildScriptIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalContains = data - case "principalHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.BuildScriptIn = data + case "buildScriptNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalHasPrefix = data - case "principalHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + it.BuildScriptNotIn = data + case "buildScriptGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalHasSuffix = data - case "principalIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.PrincipalIsNil = data - case "principalNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.PrincipalNotNil = data - case "principalEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + it.BuildScriptGT = data + case "buildScriptGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalEqualFold = data - case "principalContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + it.BuildScriptGTE = data + case "buildScriptLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalContainsFold = data - case "identifier": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + it.BuildScriptLT = data + case "buildScriptLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Identifier = data - case "identifierNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + it.BuildScriptLTE = data + case "buildScriptContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierNEQ = data - case "identifierIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.IdentifierIn = data - case "identifierNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.IdentifierNotIn = data - case "identifierGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) + it.BuildScriptContains = data + case "buildScriptHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierGT = data - case "identifierGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) + it.BuildScriptHasPrefix = data + case "buildScriptHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierGTE = data - case "identifierLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) + it.BuildScriptHasSuffix = data + case "buildScriptEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierLT = data - case "identifierLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) + it.BuildScriptEqualFold = data + case "buildScriptContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierLTE = data - case "identifierContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.BuildScriptContainsFold = data + case "claimedAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("claimedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IdentifierContains = data - case "identifierHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.ClaimedAt = data + case "claimedAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("claimedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IdentifierHasPrefix = data - case "identifierHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.ClaimedAtNEQ = data + case "claimedAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("claimedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierHasSuffix = data - case "identifierEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.ClaimedAtIn = data + case "claimedAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("claimedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierEqualFold = data - case "identifierContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.ClaimedAtNotIn = data + case "claimedAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("claimedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IdentifierContainsFold = data - case "agentIdentifier": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifier")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.ClaimedAtGT = data + case "claimedAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("claimedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifier = data - case "agentIdentifierNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.ClaimedAtGTE = data + case "claimedAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("claimedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNEQ = data - case "agentIdentifierIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.ClaimedAtLT = data + case "claimedAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("claimedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierIn = data - case "agentIdentifierNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.ClaimedAtLTE = data + case "claimedAtIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("claimedAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNotIn = data - case "agentIdentifierGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.ClaimedAtIsNil = data + case "claimedAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("claimedAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.AgentIdentifierGT = data - case "agentIdentifierGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.ClaimedAtNotNil = data + case "startedAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("startedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierGTE = data - case "agentIdentifierLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.StartedAt = data + case "startedAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("startedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierLT = data - case "agentIdentifierLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.StartedAtNEQ = data + case "startedAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("startedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierLTE = data - case "agentIdentifierContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.StartedAtIn = data + case "startedAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("startedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierContains = data - case "agentIdentifierHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.StartedAtNotIn = data + case "startedAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("startedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierHasPrefix = data - case "agentIdentifierHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.StartedAtGT = data + case "startedAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("startedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierHasSuffix = data - case "agentIdentifierIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.StartedAtGTE = data + case "startedAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("startedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierIsNil = data - case "agentIdentifierNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.StartedAtLT = data + case "startedAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("startedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNotNil = data - case "agentIdentifierEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.StartedAtLTE = data + case "startedAtIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("startedAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.AgentIdentifierEqualFold = data - case "agentIdentifierContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.StartedAtIsNil = data + case "startedAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("startedAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.AgentIdentifierContainsFold = data - case "lastSeenAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) + it.StartedAtNotNil = data + case "finishedAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("finishedAt")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAt = data - case "lastSeenAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) + it.FinishedAt = data + case "finishedAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("finishedAtNEQ")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtNEQ = data - case "lastSeenAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) + it.FinishedAtNEQ = data + case "finishedAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("finishedAtIn")) data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.LastSeenAtIn = data - case "lastSeenAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) + it.FinishedAtIn = data + case "finishedAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("finishedAtNotIn")) data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotIn = data - case "lastSeenAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) + it.FinishedAtNotIn = data + case "finishedAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("finishedAtGT")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtGT = data - case "lastSeenAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) + it.FinishedAtGT = data + case "finishedAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("finishedAtGTE")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtGTE = data - case "lastSeenAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) + it.FinishedAtGTE = data + case "finishedAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("finishedAtLT")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtLT = data - case "lastSeenAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) + it.FinishedAtLT = data + case "finishedAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("finishedAtLTE")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtLTE = data - case "lastSeenAtIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) + it.FinishedAtLTE = data + case "finishedAtIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("finishedAtIsNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.LastSeenAtIsNil = data - case "lastSeenAtNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) + it.FinishedAtIsNil = data + case "finishedAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("finishedAtNotNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotNil = data - case "nextSeenAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.FinishedAtNotNil = data + case "output": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("output")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAt = data - case "nextSeenAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.Output = data + case "outputNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtNEQ = data - case "nextSeenAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.OutputNEQ = data + case "outputIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NextSeenAtIn = data - case "nextSeenAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.OutputIn = data + case "outputNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NextSeenAtNotIn = data - case "nextSeenAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.OutputNotIn = data + case "outputGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtGT = data - case "nextSeenAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.OutputGT = data + case "outputGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtGTE = data - case "nextSeenAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.OutputGTE = data + case "outputLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtLT = data - case "nextSeenAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.OutputLT = data + case "outputLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtLTE = data - case "nextSeenAtIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.OutputLTE = data + case "outputContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtIsNil = data - case "nextSeenAtNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.OutputContains = data + case "outputHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtNotNil = data - case "interval": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.OutputHasPrefix = data + case "outputHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Interval = data - case "intervalNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNEQ")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.OutputHasSuffix = data + case "outputIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.IntervalNEQ = data - case "intervalIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + it.OutputIsNil = data + case "outputNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.IntervalIn = data - case "intervalNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + it.OutputNotNil = data + case "outputEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalNotIn = data - case "intervalGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.OutputEqualFold = data + case "outputContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalGT = data - case "intervalGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.OutputContainsFold = data + case "error": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("error")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalGTE = data - case "intervalLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.Error = data + case "errorNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalLT = data - case "intervalLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.ErrorNEQ = data + case "errorIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IntervalLTE = data - case "intervalIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.ErrorIn = data + case "errorNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IntervalIsNil = data - case "intervalNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.ErrorNotIn = data + case "errorGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ErrorGT = data + case "errorGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ErrorGTE = data + case "errorLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalNotNil = data - case "transport": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transport")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) + it.ErrorLT = data + case "errorLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Transport = data - case "transportNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNEQ")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) + it.ErrorLTE = data + case "errorContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TransportNEQ = data - case "transportIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportIn")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) + it.ErrorContains = data + case "errorHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TransportIn = data - case "transportNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNotIn")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) + it.ErrorHasPrefix = data + case "errorHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TransportNotIn = data - case "hasHost": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.ErrorHasSuffix = data + case "errorIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.HasHost = data - case "hasHostWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + it.ErrorIsNil = data + case "errorNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.HasHostWith = data - case "hasTasks": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.ErrorNotNil = data + case "errorEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTasks = data - case "hasTasksWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + it.ErrorEqualFold = data + case "errorContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTasksWith = data - case "hasShells": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShells")) + it.ErrorContainsFold = data + case "hasBuilder": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBuilder")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasShells = data - case "hasShellsWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellsWith")) - data, err := ec.unmarshalOShellWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellWhereInputᚄ(ctx, v) + it.HasBuilder = data + case "hasBuilderWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBuilderWith")) + data, err := ec.unmarshalOBuilderWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasShellsWith = data + it.HasBuilderWith = data } } @@ -12595,7 +14228,7 @@ func (ec *executionContext) unmarshalInputBuilderWhereInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "upstream", "upstreamNEQ", "upstreamIn", "upstreamNotIn", "upstreamGT", "upstreamGTE", "upstreamLT", "upstreamLTE", "upstreamContains", "upstreamHasPrefix", "upstreamHasSuffix", "upstreamEqualFold", "upstreamContainsFold"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "upstream", "upstreamNEQ", "upstreamIn", "upstreamNotIn", "upstreamGT", "upstreamGTE", "upstreamLT", "upstreamLTE", "upstreamContains", "upstreamHasPrefix", "upstreamHasSuffix", "upstreamEqualFold", "upstreamContainsFold", "hasBuildTasks", "hasBuildTasksWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -12973,6 +14606,20 @@ func (ec *executionContext) unmarshalInputBuilderWhereInput(ctx context.Context, return it, err } it.UpstreamContainsFold = data + case "hasBuildTasks": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBuildTasks")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasBuildTasks = data + case "hasBuildTasksWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBuildTasksWith")) + data, err := ec.unmarshalOBuildTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasBuildTasksWith = data } } @@ -12986,7 +14633,7 @@ func (ec *executionContext) unmarshalInputCreateBuilderInput(ctx context.Context asMap[k] = v } - fieldsInOrder := [...]string{"supportedTargets", "upstream"} + fieldsInOrder := [...]string{"supportedTargets", "upstream", "buildTaskIDs"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -13007,6 +14654,13 @@ func (ec *executionContext) unmarshalInputCreateBuilderInput(ctx context.Context return it, err } it.Upstream = data + case "buildTaskIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildTaskIDs")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.BuildTaskIDs = data } } @@ -22121,6 +23775,11 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Builder(ctx, sel, obj) + case *ent.BuildTask: + if obj == nil { + return graphql.Null + } + return ec._BuildTask(ctx, sel, obj) case *ent.Beacon: if obj == nil { return graphql.Null @@ -22503,27 +24162,224 @@ func (ec *executionContext) _Beacon(ctx context.Context, sel ast.SelectionSet, o return res } - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "shells": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Beacon_shells(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var beaconConnectionImplementors = []string{"BeaconConnection"} + +func (ec *executionContext) _BeaconConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, beaconConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BeaconConnection") + case "edges": + out.Values[i] = ec._BeaconConnection_edges(ctx, field, obj) + case "pageInfo": + out.Values[i] = ec._BeaconConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "totalCount": + out.Values[i] = ec._BeaconConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var beaconEdgeImplementors = []string{"BeaconEdge"} + +func (ec *executionContext) _BeaconEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, beaconEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BeaconEdge") + case "node": + out.Values[i] = ec._BeaconEdge_node(ctx, field, obj) + case "cursor": + out.Values[i] = ec._BeaconEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } +var buildTaskImplementors = []string{"BuildTask", "Node"} - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "shells": +func (ec *executionContext) _BuildTask(ctx context.Context, sel ast.SelectionSet, obj *ent.BuildTask) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, buildTaskImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BuildTask") + case "id": + out.Values[i] = ec._BuildTask_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "createdAt": + out.Values[i] = ec._BuildTask_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "lastModifiedAt": + out.Values[i] = ec._BuildTask_lastModifiedAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "targetOs": + out.Values[i] = ec._BuildTask_targetOs(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "buildImage": + out.Values[i] = ec._BuildTask_buildImage(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "buildScript": + out.Values[i] = ec._BuildTask_buildScript(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "claimedAt": + out.Values[i] = ec._BuildTask_claimedAt(ctx, field, obj) + case "startedAt": + out.Values[i] = ec._BuildTask_startedAt(ctx, field, obj) + case "finishedAt": + out.Values[i] = ec._BuildTask_finishedAt(ctx, field, obj) + case "output": + out.Values[i] = ec._BuildTask_output(ctx, field, obj) + case "error": + out.Values[i] = ec._BuildTask_error(ctx, field, obj) + case "builder": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -22532,7 +24388,7 @@ func (ec *executionContext) _Beacon(ctx context.Context, sel ast.SelectionSet, o ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Beacon_shells(ctx, field, obj) + res = ec._BuildTask_builder(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22582,26 +24438,26 @@ func (ec *executionContext) _Beacon(ctx context.Context, sel ast.SelectionSet, o return out } -var beaconConnectionImplementors = []string{"BeaconConnection"} +var buildTaskConnectionImplementors = []string{"BuildTaskConnection"} -func (ec *executionContext) _BeaconConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, beaconConnectionImplementors) +func (ec *executionContext) _BuildTaskConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.BuildTaskConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, buildTaskConnectionImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("BeaconConnection") + out.Values[i] = graphql.MarshalString("BuildTaskConnection") case "edges": - out.Values[i] = ec._BeaconConnection_edges(ctx, field, obj) + out.Values[i] = ec._BuildTaskConnection_edges(ctx, field, obj) case "pageInfo": - out.Values[i] = ec._BeaconConnection_pageInfo(ctx, field, obj) + out.Values[i] = ec._BuildTaskConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "totalCount": - out.Values[i] = ec._BeaconConnection_totalCount(ctx, field, obj) + out.Values[i] = ec._BuildTaskConnection_totalCount(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -22628,21 +24484,21 @@ func (ec *executionContext) _BeaconConnection(ctx context.Context, sel ast.Selec return out } -var beaconEdgeImplementors = []string{"BeaconEdge"} +var buildTaskEdgeImplementors = []string{"BuildTaskEdge"} -func (ec *executionContext) _BeaconEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, beaconEdgeImplementors) +func (ec *executionContext) _BuildTaskEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.BuildTaskEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, buildTaskEdgeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("BeaconEdge") + out.Values[i] = graphql.MarshalString("BuildTaskEdge") case "node": - out.Values[i] = ec._BeaconEdge_node(ctx, field, obj) + out.Values[i] = ec._BuildTaskEdge_node(ctx, field, obj) case "cursor": - out.Values[i] = ec._BeaconEdge_cursor(ctx, field, obj) + out.Values[i] = ec._BuildTaskEdge_cursor(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -22683,33 +24539,69 @@ func (ec *executionContext) _Builder(ctx context.Context, sel ast.SelectionSet, case "id": out.Values[i] = ec._Builder_id(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "createdAt": out.Values[i] = ec._Builder_createdAt(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "lastModifiedAt": out.Values[i] = ec._Builder_lastModifiedAt(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "identifier": out.Values[i] = ec._Builder_identifier(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "supportedTargets": out.Values[i] = ec._Builder_supportedTargets(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "upstream": out.Values[i] = ec._Builder_upstream(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) + } + case "buildTasks": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Builder_buildTasks(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -24696,6 +26588,28 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "buildTasks": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_buildTasks(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "me": field := field @@ -26730,6 +28644,60 @@ func (ec *executionContext) unmarshalNBeaconWhereInput2ᚖrealmᚗpubᚋtavern return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNBuildTask2realmᚗpubᚋtavernᚋinternalᚋentᚐBuildTask(ctx context.Context, sel ast.SelectionSet, v ent.BuildTask) graphql.Marshaler { + return ec._BuildTask(ctx, sel, &v) +} + +func (ec *executionContext) marshalNBuildTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTask(ctx context.Context, sel ast.SelectionSet, v *ent.BuildTask) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._BuildTask(ctx, sel, v) +} + +func (ec *executionContext) marshalNBuildTaskConnection2realmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskConnection(ctx context.Context, sel ast.SelectionSet, v ent.BuildTaskConnection) graphql.Marshaler { + return ec._BuildTaskConnection(ctx, sel, &v) +} + +func (ec *executionContext) marshalNBuildTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskConnection(ctx context.Context, sel ast.SelectionSet, v *ent.BuildTaskConnection) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._BuildTaskConnection(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNBuildTaskOrder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskOrder(ctx context.Context, v any) (*ent.BuildTaskOrder, error) { + res, err := ec.unmarshalInputBuildTaskOrder(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNBuildTaskOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskOrderField(ctx context.Context, v any) (*ent.BuildTaskOrderField, error) { + var res = new(ent.BuildTaskOrderField) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNBuildTaskOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.BuildTaskOrderField) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalNBuildTaskWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInput(ctx context.Context, v any) (*ent.BuildTaskWhereInput, error) { + res, err := ec.unmarshalInputBuildTaskWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalNBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder(ctx context.Context, sel ast.SelectionSet, v *ent.Builder) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -27908,6 +29876,105 @@ func (ec *executionContext) unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavern return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOBuildTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTask(ctx context.Context, sel ast.SelectionSet, v *ent.BuildTask) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._BuildTask(ctx, sel, v) +} + +func (ec *executionContext) marshalOBuildTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.BuildTaskEdge) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOBuildTaskEdge2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOBuildTaskEdge2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskEdge(ctx context.Context, sel ast.SelectionSet, v *ent.BuildTaskEdge) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._BuildTaskEdge(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOBuildTaskOrder2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskOrderᚄ(ctx context.Context, v any) ([]*ent.BuildTaskOrder, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]*ent.BuildTaskOrder, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNBuildTaskOrder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskOrder(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOBuildTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInputᚄ(ctx context.Context, v any) ([]*ent.BuildTaskWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]*ent.BuildTaskWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNBuildTaskWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOBuildTaskWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInput(ctx context.Context, v any) (*ent.BuildTaskWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputBuildTaskWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder(ctx context.Context, sel ast.SelectionSet, v *ent.Builder) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/tavern/internal/graphql/generated/inputs.generated.go b/tavern/internal/graphql/generated/inputs.generated.go index 0fbd94e21..fedacaeff 100644 --- a/tavern/internal/graphql/generated/inputs.generated.go +++ b/tavern/internal/graphql/generated/inputs.generated.go @@ -64,6 +64,8 @@ func (ec *executionContext) fieldContext_RegisterBuilderOutput_builder(_ context return ec.fieldContext_Builder_supportedTargets(ctx, field) case "upstream": return ec.fieldContext_Builder_upstream(ctx, field) + case "buildTasks": + return ec.fieldContext_Builder_buildTasks(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Builder", field.Name) }, @@ -202,6 +204,47 @@ func (ec *executionContext) unmarshalInputClaimTasksInput(ctx context.Context, o return it, nil } +func (ec *executionContext) unmarshalInputCreateBuildTaskInput(ctx context.Context, obj any) (models.CreateBuildTaskInput, error) { + var it models.CreateBuildTaskInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"targetOS", "buildImage", "buildScript"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "targetOS": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetOS")) + data, err := ec.unmarshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, v) + if err != nil { + return it, err + } + it.TargetOs = data + case "buildImage": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImage")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.BuildImage = data + case "buildScript": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScript")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.BuildScript = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputImportRepositoryInput(ctx context.Context, obj any) (models.ImportRepositoryInput, error) { var it models.ImportRepositoryInput asMap := map[string]any{} @@ -345,6 +388,11 @@ func (ec *executionContext) _RegisterBuilderOutput(ctx context.Context, sel ast. // region ***************************** type.gotpl ***************************** +func (ec *executionContext) unmarshalNCreateBuildTaskInput2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐCreateBuildTaskInput(ctx context.Context, v any) (models.CreateBuildTaskInput, error) { + res, err := ec.unmarshalInputCreateBuildTaskInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalNRegisterBuilderOutput2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRegisterBuilderOutput(ctx context.Context, sel ast.SelectionSet, v models.RegisterBuilderOutput) graphql.Marshaler { return ec._RegisterBuilderOutput(ctx, sel, &v) } diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index 406082cb5..37d6f6fe3 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -35,12 +35,24 @@ type MutationResolver interface { UpdateLink(ctx context.Context, linkID int, input ent.UpdateLinkInput) (*ent.Link, error) DisableLink(ctx context.Context, linkID int) (*ent.Link, error) RegisterBuilder(ctx context.Context, input ent.CreateBuilderInput) (*models.RegisterBuilderOutput, error) + CreateBuildTask(ctx context.Context, input models.CreateBuildTaskInput) (*ent.BuildTask, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** +func (ec *executionContext) field_Mutation_createBuildTask_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNCreateBuildTaskInput2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐCreateBuildTaskInput) + if err != nil { + return nil, err + } + args["input"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation_createCredential_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -1572,6 +1584,91 @@ func (ec *executionContext) fieldContext_Mutation_registerBuilder(ctx context.Co return fc, nil } +func (ec *executionContext) _Mutation_createBuildTask(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Mutation_createBuildTask, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Mutation().CreateBuildTask(ctx, fc.Args["input"].(models.CreateBuildTaskInput)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "ADMIN") + if err != nil { + var zeroVal *ent.BuildTask + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.BuildTask + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNBuildTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTask, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Mutation_createBuildTask(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_BuildTask_id(ctx, field) + case "createdAt": + return ec.fieldContext_BuildTask_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_BuildTask_lastModifiedAt(ctx, field) + case "targetOs": + return ec.fieldContext_BuildTask_targetOs(ctx, field) + case "buildImage": + return ec.fieldContext_BuildTask_buildImage(ctx, field) + case "buildScript": + return ec.fieldContext_BuildTask_buildScript(ctx, field) + case "claimedAt": + return ec.fieldContext_BuildTask_claimedAt(ctx, field) + case "startedAt": + return ec.fieldContext_BuildTask_startedAt(ctx, field) + case "finishedAt": + return ec.fieldContext_BuildTask_finishedAt(ctx, field) + case "output": + return ec.fieldContext_BuildTask_output(ctx, field) + case "error": + return ec.fieldContext_BuildTask_error(ctx, field) + case "builder": + return ec.fieldContext_BuildTask_builder(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BuildTask", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createBuildTask_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -1716,6 +1813,13 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "createBuildTask": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createBuildTask(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index e3474e9a5..ff866f5ce 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -95,7 +95,34 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + BuildTask struct { + BuildImage func(childComplexity int) int + BuildScript func(childComplexity int) int + Builder func(childComplexity int) int + ClaimedAt func(childComplexity int) int + CreatedAt func(childComplexity int) int + Error func(childComplexity int) int + FinishedAt func(childComplexity int) int + ID func(childComplexity int) int + LastModifiedAt func(childComplexity int) int + Output func(childComplexity int) int + StartedAt func(childComplexity int) int + TargetOs func(childComplexity int) int + } + + BuildTaskConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + BuildTaskEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Builder struct { + BuildTasks func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BuildTaskOrder, where *ent.BuildTaskWhereInput) int CreatedAt func(childComplexity int) int ID func(childComplexity int) int Identifier func(childComplexity int) int @@ -243,6 +270,7 @@ type ComplexityRoot struct { } Mutation struct { + CreateBuildTask func(childComplexity int, input models.CreateBuildTaskInput) int CreateCredential func(childComplexity int, input ent.CreateHostCredentialInput) int CreateLink func(childComplexity int, input ent.CreateLinkInput) int CreateQuest func(childComplexity int, beaconIDs []int, input ent.CreateQuestInput) int @@ -294,6 +322,7 @@ type ComplexityRoot struct { Query struct { Assets func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.AssetOrder, where *ent.AssetWhereInput) int Beacons func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BeaconOrder, where *ent.BeaconWhereInput) int + BuildTasks func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BuildTaskOrder, where *ent.BuildTaskWhereInput) int Hosts func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.HostOrder, where *ent.HostWhereInput) int Me func(childComplexity int) int Node func(childComplexity int, id int) int @@ -753,6 +782,137 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.BeaconEdge.Node(childComplexity), true + case "BuildTask.buildImage": + if e.complexity.BuildTask.BuildImage == nil { + break + } + + return e.complexity.BuildTask.BuildImage(childComplexity), true + + case "BuildTask.buildScript": + if e.complexity.BuildTask.BuildScript == nil { + break + } + + return e.complexity.BuildTask.BuildScript(childComplexity), true + + case "BuildTask.builder": + if e.complexity.BuildTask.Builder == nil { + break + } + + return e.complexity.BuildTask.Builder(childComplexity), true + + case "BuildTask.claimedAt": + if e.complexity.BuildTask.ClaimedAt == nil { + break + } + + return e.complexity.BuildTask.ClaimedAt(childComplexity), true + + case "BuildTask.createdAt": + if e.complexity.BuildTask.CreatedAt == nil { + break + } + + return e.complexity.BuildTask.CreatedAt(childComplexity), true + + case "BuildTask.error": + if e.complexity.BuildTask.Error == nil { + break + } + + return e.complexity.BuildTask.Error(childComplexity), true + + case "BuildTask.finishedAt": + if e.complexity.BuildTask.FinishedAt == nil { + break + } + + return e.complexity.BuildTask.FinishedAt(childComplexity), true + + case "BuildTask.id": + if e.complexity.BuildTask.ID == nil { + break + } + + return e.complexity.BuildTask.ID(childComplexity), true + + case "BuildTask.lastModifiedAt": + if e.complexity.BuildTask.LastModifiedAt == nil { + break + } + + return e.complexity.BuildTask.LastModifiedAt(childComplexity), true + + case "BuildTask.output": + if e.complexity.BuildTask.Output == nil { + break + } + + return e.complexity.BuildTask.Output(childComplexity), true + + case "BuildTask.startedAt": + if e.complexity.BuildTask.StartedAt == nil { + break + } + + return e.complexity.BuildTask.StartedAt(childComplexity), true + + case "BuildTask.targetOs": + if e.complexity.BuildTask.TargetOs == nil { + break + } + + return e.complexity.BuildTask.TargetOs(childComplexity), true + + case "BuildTaskConnection.edges": + if e.complexity.BuildTaskConnection.Edges == nil { + break + } + + return e.complexity.BuildTaskConnection.Edges(childComplexity), true + + case "BuildTaskConnection.pageInfo": + if e.complexity.BuildTaskConnection.PageInfo == nil { + break + } + + return e.complexity.BuildTaskConnection.PageInfo(childComplexity), true + + case "BuildTaskConnection.totalCount": + if e.complexity.BuildTaskConnection.TotalCount == nil { + break + } + + return e.complexity.BuildTaskConnection.TotalCount(childComplexity), true + + case "BuildTaskEdge.cursor": + if e.complexity.BuildTaskEdge.Cursor == nil { + break + } + + return e.complexity.BuildTaskEdge.Cursor(childComplexity), true + + case "BuildTaskEdge.node": + if e.complexity.BuildTaskEdge.Node == nil { + break + } + + return e.complexity.BuildTaskEdge.Node(childComplexity), true + + case "Builder.buildTasks": + if e.complexity.Builder.BuildTasks == nil { + break + } + + args, err := ec.field_Builder_buildTasks_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Builder.BuildTasks(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].([]*ent.BuildTaskOrder), args["where"].(*ent.BuildTaskWhereInput)), true + case "Builder.createdAt": if e.complexity.Builder.CreatedAt == nil { break @@ -1429,6 +1589,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.LinkEdge.Node(childComplexity), true + case "Mutation.createBuildTask": + if e.complexity.Mutation.CreateBuildTask == nil { + break + } + + args, err := ec.field_Mutation_createBuildTask_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateBuildTask(childComplexity, args["input"].(models.CreateBuildTaskInput)), true + case "Mutation.createCredential": if e.complexity.Mutation.CreateCredential == nil { break @@ -1776,6 +1948,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Query.Beacons(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].([]*ent.BeaconOrder), args["where"].(*ent.BeaconWhereInput)), true + case "Query.buildTasks": + if e.complexity.Query.BuildTasks == nil { + break + } + + args, err := ec.field_Query_buildTasks_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.BuildTasks(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].([]*ent.BuildTaskOrder), args["where"].(*ent.BuildTaskWhereInput)), true + case "Query.hosts": if e.complexity.Query.Hosts == nil { break @@ -2743,9 +2927,12 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputAssetWhereInput, ec.unmarshalInputBeaconOrder, ec.unmarshalInputBeaconWhereInput, + ec.unmarshalInputBuildTaskOrder, + ec.unmarshalInputBuildTaskWhereInput, ec.unmarshalInputBuilderOrder, ec.unmarshalInputBuilderWhereInput, ec.unmarshalInputClaimTasksInput, + ec.unmarshalInputCreateBuildTaskInput, ec.unmarshalInputCreateBuilderInput, ec.unmarshalInputCreateHostCredentialInput, ec.unmarshalInputCreateLinkInput, @@ -3475,6 +3662,268 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type BuildTask implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + The target operating system platform for this build. + """ + targetOs: HostPlatform! + """ + Docker container image name to use for the build. + """ + buildImage: String! + """ + The script to execute inside the build container. + """ + buildScript: String! + """ + Timestamp of when a builder claimed this task, null if unclaimed. + """ + claimedAt: Time + """ + Timestamp of when the build execution started, null if not yet started. + """ + startedAt: Time + """ + Timestamp of when the build finished, null if not yet finished. + """ + finishedAt: Time + """ + Output from the build execution. + """ + output: String + """ + Error message if the build failed. + """ + error: String + """ + The builder assigned to execute this build task. + """ + builder: Builder! +} +""" +A connection to a list of items. +""" +type BuildTaskConnection { + """ + A list of edges. + """ + edges: [BuildTaskEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuildTaskEdge { + """ + The item at the end of the edge. + """ + node: BuildTask + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for BuildTask connections +""" +input BuildTaskOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order BuildTasks. + """ + field: BuildTaskOrderField! +} +""" +Properties by which BuildTask connections can be ordered. +""" +enum BuildTaskOrderField { + CREATED_AT + LAST_MODIFIED_AT + TARGET_OS + CLAIMED_AT + STARTED_AT + FINISHED_AT +} +""" +BuildTaskWhereInput is used for filtering BuildTask objects. +Input was generated by ent. +""" +input BuildTaskWhereInput { + not: BuildTaskWhereInput + and: [BuildTaskWhereInput!] + or: [BuildTaskWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + created_at field predicates + """ + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """ + last_modified_at field predicates + """ + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """ + target_os field predicates + """ + targetOs: HostPlatform + targetOsNEQ: HostPlatform + targetOsIn: [HostPlatform!] + targetOsNotIn: [HostPlatform!] + """ + build_image field predicates + """ + buildImage: String + buildImageNEQ: String + buildImageIn: [String!] + buildImageNotIn: [String!] + buildImageGT: String + buildImageGTE: String + buildImageLT: String + buildImageLTE: String + buildImageContains: String + buildImageHasPrefix: String + buildImageHasSuffix: String + buildImageEqualFold: String + buildImageContainsFold: String + """ + build_script field predicates + """ + buildScript: String + buildScriptNEQ: String + buildScriptIn: [String!] + buildScriptNotIn: [String!] + buildScriptGT: String + buildScriptGTE: String + buildScriptLT: String + buildScriptLTE: String + buildScriptContains: String + buildScriptHasPrefix: String + buildScriptHasSuffix: String + buildScriptEqualFold: String + buildScriptContainsFold: String + """ + claimed_at field predicates + """ + claimedAt: Time + claimedAtNEQ: Time + claimedAtIn: [Time!] + claimedAtNotIn: [Time!] + claimedAtGT: Time + claimedAtGTE: Time + claimedAtLT: Time + claimedAtLTE: Time + claimedAtIsNil: Boolean + claimedAtNotNil: Boolean + """ + started_at field predicates + """ + startedAt: Time + startedAtNEQ: Time + startedAtIn: [Time!] + startedAtNotIn: [Time!] + startedAtGT: Time + startedAtGTE: Time + startedAtLT: Time + startedAtLTE: Time + startedAtIsNil: Boolean + startedAtNotNil: Boolean + """ + finished_at field predicates + """ + finishedAt: Time + finishedAtNEQ: Time + finishedAtIn: [Time!] + finishedAtNotIn: [Time!] + finishedAtGT: Time + finishedAtGTE: Time + finishedAtLT: Time + finishedAtLTE: Time + finishedAtIsNil: Boolean + finishedAtNotNil: Boolean + """ + output field predicates + """ + output: String + outputNEQ: String + outputIn: [String!] + outputNotIn: [String!] + outputGT: String + outputGTE: String + outputLT: String + outputLTE: String + outputContains: String + outputHasPrefix: String + outputHasSuffix: String + outputIsNil: Boolean + outputNotNil: Boolean + outputEqualFold: String + outputContainsFold: String + """ + error field predicates + """ + error: String + errorNEQ: String + errorIn: [String!] + errorNotIn: [String!] + errorGT: String + errorGTE: String + errorLT: String + errorLTE: String + errorContains: String + errorHasPrefix: String + errorHasSuffix: String + errorIsNil: Boolean + errorNotNil: Boolean + errorEqualFold: String + errorContainsFold: String + """ + builder edge predicates + """ + hasBuilder: Boolean + hasBuilderWith: [BuilderWhereInput!] +} type Builder implements Node { id: ID! """ @@ -3497,6 +3946,37 @@ type Builder implements Node { The server address that the builder should connect to. """ upstream: String! + buildTasks( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for BuildTasks returned from the connection. + """ + orderBy: [BuildTaskOrder!] + + """ + Filtering options for BuildTasks returned from the connection. + """ + where: BuildTaskWhereInput + ): BuildTaskConnection! } """ A connection to a list of items. @@ -3621,6 +4101,11 @@ input BuilderWhereInput { upstreamHasSuffix: String upstreamEqualFold: String upstreamContainsFold: String + """ + build_tasks edge predicates + """ + hasBuildTasks: Boolean + hasBuildTasksWith: [BuildTaskWhereInput!] } """ CreateBuilderInput is used for create Builder object. @@ -3635,6 +4120,7 @@ input CreateBuilderInput { The server address that the builder should connect to. """ upstream: String! + buildTaskIDs: [ID!] } """ CreateHostCredentialInput is used for create HostCredential object. @@ -4447,7 +4933,7 @@ enum HostOrderField { NEXT_SEEN_AT } """ -HostPlatform is enum for the field platform +HostPlatform is enum for the field target_os """ enum HostPlatform @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Host_Platform") { PLATFORM_BSD @@ -7513,6 +7999,25 @@ scalar Uint64 """Filtering options for Shells returned from the connection.""" where: ShellWhereInput): ShellConnection! @requireRole(role: USER) + buildTasks( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for BuildTasks returned from the connection.""" + orderBy: [BuildTaskOrder!] + + """Filtering options for BuildTasks returned from the connection.""" + where: BuildTaskWhereInput + ): BuildTaskConnection! @requireRole(role: USER) me: User! } `, BuiltIn: false}, @@ -7577,6 +8082,11 @@ scalar Uint64 # Builder ### registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) + + ### + # BuildTask + ### + createBuildTask(input: CreateBuildTaskInput!): BuildTask! @requireRole(role: ADMIN) } `, BuiltIn: false}, {Name: "../schema/inputs.graphql", Input: `input ClaimTasksInput { @@ -7629,12 +8139,24 @@ input ImportRepositoryInput { includeDirs: [String!] } +"""Input for creating a new build task.""" +input CreateBuildTaskInput { + """The target operating system for the build.""" + targetOS: HostPlatform! + + """Docker container image name to use for the build.""" + buildImage: String! + + """The script to execute inside the build container.""" + buildScript: String! +} + """Output returned when registering a new builder.""" type RegisterBuilderOutput { """The created builder entity.""" builder: Builder! - """mTLS certificate in base64 encoding for the builder to authenticate.""" + """mTLS certificate PEM bundle for the builder to authenticate.""" mtlsCert: String! """YAML-formatted configuration for the builder.""" diff --git a/tavern/internal/graphql/models/gqlgen_models.go b/tavern/internal/graphql/models/gqlgen_models.go index b8bffa6ce..93952b4aa 100644 --- a/tavern/internal/graphql/models/gqlgen_models.go +++ b/tavern/internal/graphql/models/gqlgen_models.go @@ -30,6 +30,16 @@ type ClaimTasksInput struct { AgentIdentifier string `json:"agentIdentifier"` } +// Input for creating a new build task. +type CreateBuildTaskInput struct { + // The target operating system for the build. + TargetOs c2pb.Host_Platform `json:"targetOS"` + // Docker container image name to use for the build. + BuildImage string `json:"buildImage"` + // The script to execute inside the build container. + BuildScript string `json:"buildScript"` +} + type ImportRepositoryInput struct { // Optionally, specify directories to include. // Only tomes that have a main.eldritch in one of these directory prefixes will be included. @@ -40,7 +50,7 @@ type ImportRepositoryInput struct { type RegisterBuilderOutput struct { // The created builder entity. Builder *ent.Builder `json:"builder"` - // mTLS certificate in base64 encoding for the builder to authenticate. + // mTLS certificate PEM bundle for the builder to authenticate. MtlsCert string `json:"mtlsCert"` // YAML-formatted configuration for the builder. Config string `json:"config"` diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index 058b06a88..e3c4ffc60 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -8,6 +8,7 @@ package graphql import ( "context" "fmt" + "math/rand" "strings" "time" @@ -58,6 +59,9 @@ func (r *mutationResolver) DropAllData(ctx context.Context) (bool, error) { if _, err := client.Tag.Delete().Exec(ctx); err != nil { return false, rollback(tx, fmt.Errorf("failed to delete tags: %w", err)) } + if _, err := client.BuildTask.Delete().Exec(ctx); err != nil { + return false, rollback(tx, fmt.Errorf("failed to delete build tasks: %w", err)) + } if _, err := client.Builder.Delete().Exec(ctx); err != nil { return false, rollback(tx, fmt.Errorf("failed to delete builders: %w", err)) } @@ -335,6 +339,46 @@ func (r *mutationResolver) RegisterBuilder(ctx context.Context, input ent.Create }, nil } +// CreateBuildTask is the resolver for the createBuildTask field. +func (r *mutationResolver) CreateBuildTask(ctx context.Context, input models.CreateBuildTaskInput) (*ent.BuildTask, error) { + // 1. Query all builders + allBuilders, err := r.client.Builder.Query().All(ctx) + if err != nil { + return nil, fmt.Errorf("failed to query builders: %w", err) + } + + // 2. Filter builders that support the target OS + var candidates []*ent.Builder + for _, b := range allBuilders { + for _, target := range b.SupportedTargets { + if target == input.TargetOs { + candidates = append(candidates, b) + break + } + } + } + + if len(candidates) == 0 { + return nil, fmt.Errorf("no builder available that supports target %s", input.TargetOs.String()) + } + + // 3. Randomly select one builder + selected := candidates[rand.Intn(len(candidates))] + + // 4. Create the build task + bt, err := r.client.BuildTask.Create(). + SetTargetOs(input.TargetOs). + SetBuildImage(input.BuildImage). + SetBuildScript(input.BuildScript). + SetBuilder(selected). + Save(ctx) + if err != nil { + return nil, fmt.Errorf("failed to create build task: %w", err) + } + + return bt, nil +} + // Mutation returns generated.MutationResolver implementation. func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } diff --git a/tavern/internal/graphql/query.resolvers.go b/tavern/internal/graphql/query.resolvers.go index 87870032e..c2498e9af 100644 --- a/tavern/internal/graphql/query.resolvers.go +++ b/tavern/internal/graphql/query.resolvers.go @@ -190,6 +190,22 @@ func (r *queryResolver) Shells(ctx context.Context, after *entgql.Cursor[int], f return query.Paginate(ctx, after, first, before, last, ent.WithShellOrder(orderBy)) } +// BuildTasks is the resolver for the buildTasks field. +func (r *queryResolver) BuildTasks(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BuildTaskOrder, where *ent.BuildTaskWhereInput) (*ent.BuildTaskConnection, error) { + query, err := r.client.BuildTask.Query().CollectFields(ctx) + if err != nil { + return nil, fmt.Errorf("failed to collect fields: %w", err) + } + if where != nil { + query, err := where.Filter(query) + if err != nil { + return nil, fmt.Errorf("failed to apply filter: %w", err) + } + return query.Paginate(ctx, after, first, before, last, ent.WithBuildTaskOrder(orderBy)) + } + return query.Paginate(ctx, after, first, before, last, ent.WithBuildTaskOrder(orderBy)) +} + // Me is the resolver for the me field. func (r *queryResolver) Me(ctx context.Context) (*ent.User, error) { if authUser := auth.UserFromContext(ctx); authUser != nil { diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index 3970a63e4..5e1c48c1e 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -588,6 +588,268 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type BuildTask implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + The target operating system platform for this build. + """ + targetOs: HostPlatform! + """ + Docker container image name to use for the build. + """ + buildImage: String! + """ + The script to execute inside the build container. + """ + buildScript: String! + """ + Timestamp of when a builder claimed this task, null if unclaimed. + """ + claimedAt: Time + """ + Timestamp of when the build execution started, null if not yet started. + """ + startedAt: Time + """ + Timestamp of when the build finished, null if not yet finished. + """ + finishedAt: Time + """ + Output from the build execution. + """ + output: String + """ + Error message if the build failed. + """ + error: String + """ + The builder assigned to execute this build task. + """ + builder: Builder! +} +""" +A connection to a list of items. +""" +type BuildTaskConnection { + """ + A list of edges. + """ + edges: [BuildTaskEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuildTaskEdge { + """ + The item at the end of the edge. + """ + node: BuildTask + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for BuildTask connections +""" +input BuildTaskOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order BuildTasks. + """ + field: BuildTaskOrderField! +} +""" +Properties by which BuildTask connections can be ordered. +""" +enum BuildTaskOrderField { + CREATED_AT + LAST_MODIFIED_AT + TARGET_OS + CLAIMED_AT + STARTED_AT + FINISHED_AT +} +""" +BuildTaskWhereInput is used for filtering BuildTask objects. +Input was generated by ent. +""" +input BuildTaskWhereInput { + not: BuildTaskWhereInput + and: [BuildTaskWhereInput!] + or: [BuildTaskWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + created_at field predicates + """ + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """ + last_modified_at field predicates + """ + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """ + target_os field predicates + """ + targetOs: HostPlatform + targetOsNEQ: HostPlatform + targetOsIn: [HostPlatform!] + targetOsNotIn: [HostPlatform!] + """ + build_image field predicates + """ + buildImage: String + buildImageNEQ: String + buildImageIn: [String!] + buildImageNotIn: [String!] + buildImageGT: String + buildImageGTE: String + buildImageLT: String + buildImageLTE: String + buildImageContains: String + buildImageHasPrefix: String + buildImageHasSuffix: String + buildImageEqualFold: String + buildImageContainsFold: String + """ + build_script field predicates + """ + buildScript: String + buildScriptNEQ: String + buildScriptIn: [String!] + buildScriptNotIn: [String!] + buildScriptGT: String + buildScriptGTE: String + buildScriptLT: String + buildScriptLTE: String + buildScriptContains: String + buildScriptHasPrefix: String + buildScriptHasSuffix: String + buildScriptEqualFold: String + buildScriptContainsFold: String + """ + claimed_at field predicates + """ + claimedAt: Time + claimedAtNEQ: Time + claimedAtIn: [Time!] + claimedAtNotIn: [Time!] + claimedAtGT: Time + claimedAtGTE: Time + claimedAtLT: Time + claimedAtLTE: Time + claimedAtIsNil: Boolean + claimedAtNotNil: Boolean + """ + started_at field predicates + """ + startedAt: Time + startedAtNEQ: Time + startedAtIn: [Time!] + startedAtNotIn: [Time!] + startedAtGT: Time + startedAtGTE: Time + startedAtLT: Time + startedAtLTE: Time + startedAtIsNil: Boolean + startedAtNotNil: Boolean + """ + finished_at field predicates + """ + finishedAt: Time + finishedAtNEQ: Time + finishedAtIn: [Time!] + finishedAtNotIn: [Time!] + finishedAtGT: Time + finishedAtGTE: Time + finishedAtLT: Time + finishedAtLTE: Time + finishedAtIsNil: Boolean + finishedAtNotNil: Boolean + """ + output field predicates + """ + output: String + outputNEQ: String + outputIn: [String!] + outputNotIn: [String!] + outputGT: String + outputGTE: String + outputLT: String + outputLTE: String + outputContains: String + outputHasPrefix: String + outputHasSuffix: String + outputIsNil: Boolean + outputNotNil: Boolean + outputEqualFold: String + outputContainsFold: String + """ + error field predicates + """ + error: String + errorNEQ: String + errorIn: [String!] + errorNotIn: [String!] + errorGT: String + errorGTE: String + errorLT: String + errorLTE: String + errorContains: String + errorHasPrefix: String + errorHasSuffix: String + errorIsNil: Boolean + errorNotNil: Boolean + errorEqualFold: String + errorContainsFold: String + """ + builder edge predicates + """ + hasBuilder: Boolean + hasBuilderWith: [BuilderWhereInput!] +} type Builder implements Node { id: ID! """ @@ -610,6 +872,37 @@ type Builder implements Node { The server address that the builder should connect to. """ upstream: String! + buildTasks( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for BuildTasks returned from the connection. + """ + orderBy: [BuildTaskOrder!] + + """ + Filtering options for BuildTasks returned from the connection. + """ + where: BuildTaskWhereInput + ): BuildTaskConnection! } """ A connection to a list of items. @@ -734,6 +1027,11 @@ input BuilderWhereInput { upstreamHasSuffix: String upstreamEqualFold: String upstreamContainsFold: String + """ + build_tasks edge predicates + """ + hasBuildTasks: Boolean + hasBuildTasksWith: [BuildTaskWhereInput!] } """ CreateBuilderInput is used for create Builder object. @@ -748,6 +1046,7 @@ input CreateBuilderInput { The server address that the builder should connect to. """ upstream: String! + buildTaskIDs: [ID!] } """ CreateHostCredentialInput is used for create HostCredential object. @@ -1560,7 +1859,7 @@ enum HostOrderField { NEXT_SEEN_AT } """ -HostPlatform is enum for the field platform +HostPlatform is enum for the field target_os """ enum HostPlatform @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Host_Platform") { PLATFORM_BSD @@ -4462,12 +4761,24 @@ input ImportRepositoryInput { includeDirs: [String!] } +"""Input for creating a new build task.""" +input CreateBuildTaskInput { + """The target operating system for the build.""" + targetOS: HostPlatform! + + """Docker container image name to use for the build.""" + buildImage: String! + + """The script to execute inside the build container.""" + buildScript: String! +} + """Output returned when registering a new builder.""" type RegisterBuilderOutput { """The created builder entity.""" builder: Builder! - """mTLS certificate in base64 encoding for the builder to authenticate.""" + """mTLS certificate PEM bundle for the builder to authenticate.""" mtlsCert: String! """YAML-formatted configuration for the builder.""" @@ -4534,6 +4845,11 @@ type Mutation { # Builder ### registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) + + ### + # BuildTask + ### + createBuildTask(input: CreateBuildTaskInput!): BuildTask! @requireRole(role: ADMIN) } extend type Query { assets( @@ -4745,6 +5061,25 @@ extend type Query { """Filtering options for Shells returned from the connection.""" where: ShellWhereInput): ShellConnection! @requireRole(role: USER) + buildTasks( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for BuildTasks returned from the connection.""" + orderBy: [BuildTaskOrder!] + + """Filtering options for BuildTasks returned from the connection.""" + where: BuildTaskWhereInput + ): BuildTaskConnection! @requireRole(role: USER) me: User! } scalar Time diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index 6d4cf986d..f0bc83b1e 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -583,6 +583,268 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type BuildTask implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + The target operating system platform for this build. + """ + targetOs: HostPlatform! + """ + Docker container image name to use for the build. + """ + buildImage: String! + """ + The script to execute inside the build container. + """ + buildScript: String! + """ + Timestamp of when a builder claimed this task, null if unclaimed. + """ + claimedAt: Time + """ + Timestamp of when the build execution started, null if not yet started. + """ + startedAt: Time + """ + Timestamp of when the build finished, null if not yet finished. + """ + finishedAt: Time + """ + Output from the build execution. + """ + output: String + """ + Error message if the build failed. + """ + error: String + """ + The builder assigned to execute this build task. + """ + builder: Builder! +} +""" +A connection to a list of items. +""" +type BuildTaskConnection { + """ + A list of edges. + """ + edges: [BuildTaskEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuildTaskEdge { + """ + The item at the end of the edge. + """ + node: BuildTask + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for BuildTask connections +""" +input BuildTaskOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order BuildTasks. + """ + field: BuildTaskOrderField! +} +""" +Properties by which BuildTask connections can be ordered. +""" +enum BuildTaskOrderField { + CREATED_AT + LAST_MODIFIED_AT + TARGET_OS + CLAIMED_AT + STARTED_AT + FINISHED_AT +} +""" +BuildTaskWhereInput is used for filtering BuildTask objects. +Input was generated by ent. +""" +input BuildTaskWhereInput { + not: BuildTaskWhereInput + and: [BuildTaskWhereInput!] + or: [BuildTaskWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + created_at field predicates + """ + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """ + last_modified_at field predicates + """ + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """ + target_os field predicates + """ + targetOs: HostPlatform + targetOsNEQ: HostPlatform + targetOsIn: [HostPlatform!] + targetOsNotIn: [HostPlatform!] + """ + build_image field predicates + """ + buildImage: String + buildImageNEQ: String + buildImageIn: [String!] + buildImageNotIn: [String!] + buildImageGT: String + buildImageGTE: String + buildImageLT: String + buildImageLTE: String + buildImageContains: String + buildImageHasPrefix: String + buildImageHasSuffix: String + buildImageEqualFold: String + buildImageContainsFold: String + """ + build_script field predicates + """ + buildScript: String + buildScriptNEQ: String + buildScriptIn: [String!] + buildScriptNotIn: [String!] + buildScriptGT: String + buildScriptGTE: String + buildScriptLT: String + buildScriptLTE: String + buildScriptContains: String + buildScriptHasPrefix: String + buildScriptHasSuffix: String + buildScriptEqualFold: String + buildScriptContainsFold: String + """ + claimed_at field predicates + """ + claimedAt: Time + claimedAtNEQ: Time + claimedAtIn: [Time!] + claimedAtNotIn: [Time!] + claimedAtGT: Time + claimedAtGTE: Time + claimedAtLT: Time + claimedAtLTE: Time + claimedAtIsNil: Boolean + claimedAtNotNil: Boolean + """ + started_at field predicates + """ + startedAt: Time + startedAtNEQ: Time + startedAtIn: [Time!] + startedAtNotIn: [Time!] + startedAtGT: Time + startedAtGTE: Time + startedAtLT: Time + startedAtLTE: Time + startedAtIsNil: Boolean + startedAtNotNil: Boolean + """ + finished_at field predicates + """ + finishedAt: Time + finishedAtNEQ: Time + finishedAtIn: [Time!] + finishedAtNotIn: [Time!] + finishedAtGT: Time + finishedAtGTE: Time + finishedAtLT: Time + finishedAtLTE: Time + finishedAtIsNil: Boolean + finishedAtNotNil: Boolean + """ + output field predicates + """ + output: String + outputNEQ: String + outputIn: [String!] + outputNotIn: [String!] + outputGT: String + outputGTE: String + outputLT: String + outputLTE: String + outputContains: String + outputHasPrefix: String + outputHasSuffix: String + outputIsNil: Boolean + outputNotNil: Boolean + outputEqualFold: String + outputContainsFold: String + """ + error field predicates + """ + error: String + errorNEQ: String + errorIn: [String!] + errorNotIn: [String!] + errorGT: String + errorGTE: String + errorLT: String + errorLTE: String + errorContains: String + errorHasPrefix: String + errorHasSuffix: String + errorIsNil: Boolean + errorNotNil: Boolean + errorEqualFold: String + errorContainsFold: String + """ + builder edge predicates + """ + hasBuilder: Boolean + hasBuilderWith: [BuilderWhereInput!] +} type Builder implements Node { id: ID! """ @@ -605,6 +867,37 @@ type Builder implements Node { The server address that the builder should connect to. """ upstream: String! + buildTasks( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for BuildTasks returned from the connection. + """ + orderBy: [BuildTaskOrder!] + + """ + Filtering options for BuildTasks returned from the connection. + """ + where: BuildTaskWhereInput + ): BuildTaskConnection! } """ A connection to a list of items. @@ -729,6 +1022,11 @@ input BuilderWhereInput { upstreamHasSuffix: String upstreamEqualFold: String upstreamContainsFold: String + """ + build_tasks edge predicates + """ + hasBuildTasks: Boolean + hasBuildTasksWith: [BuildTaskWhereInput!] } """ CreateBuilderInput is used for create Builder object. @@ -743,6 +1041,7 @@ input CreateBuilderInput { The server address that the builder should connect to. """ upstream: String! + buildTaskIDs: [ID!] } """ CreateHostCredentialInput is used for create HostCredential object. @@ -1555,7 +1854,7 @@ enum HostOrderField { NEXT_SEEN_AT } """ -HostPlatform is enum for the field platform +HostPlatform is enum for the field target_os """ enum HostPlatform @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Host_Platform") { PLATFORM_BSD diff --git a/tavern/internal/graphql/schema/inputs.graphql b/tavern/internal/graphql/schema/inputs.graphql index b8f8234b9..39df200df 100644 --- a/tavern/internal/graphql/schema/inputs.graphql +++ b/tavern/internal/graphql/schema/inputs.graphql @@ -48,6 +48,18 @@ input ImportRepositoryInput { includeDirs: [String!] } +"""Input for creating a new build task.""" +input CreateBuildTaskInput { + """The target operating system for the build.""" + targetOS: HostPlatform! + + """Docker container image name to use for the build.""" + buildImage: String! + + """The script to execute inside the build container.""" + buildScript: String! +} + """Output returned when registering a new builder.""" type RegisterBuilderOutput { """The created builder entity.""" diff --git a/tavern/internal/graphql/schema/mutation.graphql b/tavern/internal/graphql/schema/mutation.graphql index e2de39ca3..f9b0ee09e 100644 --- a/tavern/internal/graphql/schema/mutation.graphql +++ b/tavern/internal/graphql/schema/mutation.graphql @@ -59,4 +59,9 @@ type Mutation { # Builder ### registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) + + ### + # BuildTask + ### + createBuildTask(input: CreateBuildTaskInput!): BuildTask! @requireRole(role: ADMIN) } diff --git a/tavern/internal/graphql/schema/query.graphql b/tavern/internal/graphql/schema/query.graphql index 17c2215b7..e720a1a2d 100644 --- a/tavern/internal/graphql/schema/query.graphql +++ b/tavern/internal/graphql/schema/query.graphql @@ -208,5 +208,24 @@ extend type Query { """Filtering options for Shells returned from the connection.""" where: ShellWhereInput): ShellConnection! @requireRole(role: USER) + buildTasks( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for BuildTasks returned from the connection.""" + orderBy: [BuildTaskOrder!] + + """Filtering options for BuildTasks returned from the connection.""" + where: BuildTaskWhereInput + ): BuildTaskConnection! @requireRole(role: USER) me: User! } diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index 3970a63e4..5e1c48c1e 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -588,6 +588,268 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type BuildTask implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + The target operating system platform for this build. + """ + targetOs: HostPlatform! + """ + Docker container image name to use for the build. + """ + buildImage: String! + """ + The script to execute inside the build container. + """ + buildScript: String! + """ + Timestamp of when a builder claimed this task, null if unclaimed. + """ + claimedAt: Time + """ + Timestamp of when the build execution started, null if not yet started. + """ + startedAt: Time + """ + Timestamp of when the build finished, null if not yet finished. + """ + finishedAt: Time + """ + Output from the build execution. + """ + output: String + """ + Error message if the build failed. + """ + error: String + """ + The builder assigned to execute this build task. + """ + builder: Builder! +} +""" +A connection to a list of items. +""" +type BuildTaskConnection { + """ + A list of edges. + """ + edges: [BuildTaskEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuildTaskEdge { + """ + The item at the end of the edge. + """ + node: BuildTask + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for BuildTask connections +""" +input BuildTaskOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order BuildTasks. + """ + field: BuildTaskOrderField! +} +""" +Properties by which BuildTask connections can be ordered. +""" +enum BuildTaskOrderField { + CREATED_AT + LAST_MODIFIED_AT + TARGET_OS + CLAIMED_AT + STARTED_AT + FINISHED_AT +} +""" +BuildTaskWhereInput is used for filtering BuildTask objects. +Input was generated by ent. +""" +input BuildTaskWhereInput { + not: BuildTaskWhereInput + and: [BuildTaskWhereInput!] + or: [BuildTaskWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + created_at field predicates + """ + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """ + last_modified_at field predicates + """ + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """ + target_os field predicates + """ + targetOs: HostPlatform + targetOsNEQ: HostPlatform + targetOsIn: [HostPlatform!] + targetOsNotIn: [HostPlatform!] + """ + build_image field predicates + """ + buildImage: String + buildImageNEQ: String + buildImageIn: [String!] + buildImageNotIn: [String!] + buildImageGT: String + buildImageGTE: String + buildImageLT: String + buildImageLTE: String + buildImageContains: String + buildImageHasPrefix: String + buildImageHasSuffix: String + buildImageEqualFold: String + buildImageContainsFold: String + """ + build_script field predicates + """ + buildScript: String + buildScriptNEQ: String + buildScriptIn: [String!] + buildScriptNotIn: [String!] + buildScriptGT: String + buildScriptGTE: String + buildScriptLT: String + buildScriptLTE: String + buildScriptContains: String + buildScriptHasPrefix: String + buildScriptHasSuffix: String + buildScriptEqualFold: String + buildScriptContainsFold: String + """ + claimed_at field predicates + """ + claimedAt: Time + claimedAtNEQ: Time + claimedAtIn: [Time!] + claimedAtNotIn: [Time!] + claimedAtGT: Time + claimedAtGTE: Time + claimedAtLT: Time + claimedAtLTE: Time + claimedAtIsNil: Boolean + claimedAtNotNil: Boolean + """ + started_at field predicates + """ + startedAt: Time + startedAtNEQ: Time + startedAtIn: [Time!] + startedAtNotIn: [Time!] + startedAtGT: Time + startedAtGTE: Time + startedAtLT: Time + startedAtLTE: Time + startedAtIsNil: Boolean + startedAtNotNil: Boolean + """ + finished_at field predicates + """ + finishedAt: Time + finishedAtNEQ: Time + finishedAtIn: [Time!] + finishedAtNotIn: [Time!] + finishedAtGT: Time + finishedAtGTE: Time + finishedAtLT: Time + finishedAtLTE: Time + finishedAtIsNil: Boolean + finishedAtNotNil: Boolean + """ + output field predicates + """ + output: String + outputNEQ: String + outputIn: [String!] + outputNotIn: [String!] + outputGT: String + outputGTE: String + outputLT: String + outputLTE: String + outputContains: String + outputHasPrefix: String + outputHasSuffix: String + outputIsNil: Boolean + outputNotNil: Boolean + outputEqualFold: String + outputContainsFold: String + """ + error field predicates + """ + error: String + errorNEQ: String + errorIn: [String!] + errorNotIn: [String!] + errorGT: String + errorGTE: String + errorLT: String + errorLTE: String + errorContains: String + errorHasPrefix: String + errorHasSuffix: String + errorIsNil: Boolean + errorNotNil: Boolean + errorEqualFold: String + errorContainsFold: String + """ + builder edge predicates + """ + hasBuilder: Boolean + hasBuilderWith: [BuilderWhereInput!] +} type Builder implements Node { id: ID! """ @@ -610,6 +872,37 @@ type Builder implements Node { The server address that the builder should connect to. """ upstream: String! + buildTasks( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for BuildTasks returned from the connection. + """ + orderBy: [BuildTaskOrder!] + + """ + Filtering options for BuildTasks returned from the connection. + """ + where: BuildTaskWhereInput + ): BuildTaskConnection! } """ A connection to a list of items. @@ -734,6 +1027,11 @@ input BuilderWhereInput { upstreamHasSuffix: String upstreamEqualFold: String upstreamContainsFold: String + """ + build_tasks edge predicates + """ + hasBuildTasks: Boolean + hasBuildTasksWith: [BuildTaskWhereInput!] } """ CreateBuilderInput is used for create Builder object. @@ -748,6 +1046,7 @@ input CreateBuilderInput { The server address that the builder should connect to. """ upstream: String! + buildTaskIDs: [ID!] } """ CreateHostCredentialInput is used for create HostCredential object. @@ -1560,7 +1859,7 @@ enum HostOrderField { NEXT_SEEN_AT } """ -HostPlatform is enum for the field platform +HostPlatform is enum for the field target_os """ enum HostPlatform @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Host_Platform") { PLATFORM_BSD @@ -4462,12 +4761,24 @@ input ImportRepositoryInput { includeDirs: [String!] } +"""Input for creating a new build task.""" +input CreateBuildTaskInput { + """The target operating system for the build.""" + targetOS: HostPlatform! + + """Docker container image name to use for the build.""" + buildImage: String! + + """The script to execute inside the build container.""" + buildScript: String! +} + """Output returned when registering a new builder.""" type RegisterBuilderOutput { """The created builder entity.""" builder: Builder! - """mTLS certificate in base64 encoding for the builder to authenticate.""" + """mTLS certificate PEM bundle for the builder to authenticate.""" mtlsCert: String! """YAML-formatted configuration for the builder.""" @@ -4534,6 +4845,11 @@ type Mutation { # Builder ### registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) + + ### + # BuildTask + ### + createBuildTask(input: CreateBuildTaskInput!): BuildTask! @requireRole(role: ADMIN) } extend type Query { assets( @@ -4745,6 +5061,25 @@ extend type Query { """Filtering options for Shells returned from the connection.""" where: ShellWhereInput): ShellConnection! @requireRole(role: USER) + buildTasks( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for BuildTasks returned from the connection.""" + orderBy: [BuildTaskOrder!] + + """Filtering options for BuildTasks returned from the connection.""" + where: BuildTaskWhereInput + ): BuildTaskConnection! @requireRole(role: USER) me: User! } scalar Time From 372012417cec7bbf4819b577af5fed9deda4158c Mon Sep 17 00:00:00 2001 From: Hulto <7121375+hulto@users.noreply.github.com> Date: Tue, 10 Feb 2026 21:06:53 -0500 Subject: [PATCH 08/19] Claude/add executor library jl xt k (#1790) * Add executor library with mock and Docker implementations Introduce an executor interface for build task execution with two implementations: MockExecutor for testing and DockerExecutor for production use. The Docker executor pulls the specified build image, runs the build script as the container entrypoint, and streams stdout/stderr over channels. The builder agent now passes claimed tasks to the executor, collects output/errors from channels, and reports results back to the server via gRPC. https://claude.ai/code/session_017WBbxwiwQS6tXTNcaBrfBH * cleanup --------- Co-authored-by: Claude --- go.mod | 31 +- go.sum | 74 ++++- tavern/app.go | 8 +- tavern/internal/builder/client.go | 122 +++++-- tavern/internal/builder/executor/docker.go | 141 ++++++++ .../internal/builder/executor/docker_test.go | 229 +++++++++++++ tavern/internal/builder/executor/executor.go | 25 ++ tavern/internal/builder/executor/mock.go | 34 ++ tavern/internal/builder/executor/mock_test.go | 190 +++++++++++ .../builder/executor_integration_test.go | 303 ++++++++++++++++++ 10 files changed, 1109 insertions(+), 48 deletions(-) create mode 100644 tavern/internal/builder/executor/docker.go create mode 100644 tavern/internal/builder/executor/docker_test.go create mode 100644 tavern/internal/builder/executor/executor.go create mode 100644 tavern/internal/builder/executor/mock.go create mode 100644 tavern/internal/builder/executor/mock_test.go create mode 100644 tavern/internal/builder/executor_integration_test.go diff --git a/go.mod b/go.mod index f29997710..fe122c28d 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/99designs/gqlgen v0.17.86 github.com/caddyserver/certmagic v0.25.1 github.com/cloudflare/circl v1.6.1 + github.com/docker/docker v28.5.2+incompatible github.com/go-sql-driver/mysql v1.9.3 github.com/golang-jwt/jwt/v5 v5.3.1 github.com/google/go-cmp v0.7.0 @@ -26,7 +27,7 @@ require ( github.com/vektah/gqlparser/v2 v2.5.31 go.opencensus.io v0.24.0 golang.org/x/crypto v0.47.0 - golang.org/x/net v0.48.0 + golang.org/x/net v0.49.0 golang.org/x/oauth2 v0.32.0 golang.org/x/sync v0.19.0 google.golang.org/api v0.247.0 @@ -45,7 +46,13 @@ require ( github.com/Microsoft/go-winio v0.6.2 // indirect github.com/ProtonMail/go-crypto v1.1.6 // indirect github.com/caddyserver/zerossl v0.1.4 // indirect + github.com/containerd/errdefs v1.0.0 // indirect + github.com/containerd/errdefs/pkg v0.3.0 // indirect + github.com/containerd/log v0.1.0 // indirect github.com/cyphar/filepath-securejoin v0.4.1 // indirect + github.com/distribution/reference v0.6.0 // indirect + github.com/docker/go-connections v0.6.0 // indirect + github.com/docker/go-units v0.5.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect @@ -68,8 +75,15 @@ require ( github.com/libdns/libdns v1.1.1 // indirect github.com/mholt/acmez/v3 v3.1.4 // indirect github.com/miekg/dns v1.1.69 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect + github.com/moby/sys/atomicwriter v0.1.0 // indirect + github.com/moby/term v0.5.2 // indirect + github.com/morikuni/aec v1.1.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.1 // indirect github.com/pjbgf/sha1cd v0.3.2 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/statsd_exporter v0.22.7 // indirect github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect github.com/skeema/knownhosts v1.3.1 // indirect @@ -79,18 +93,19 @@ require ( go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect - go.opentelemetry.io/otel v1.38.0 // indirect - go.opentelemetry.io/otel/metric v1.38.0 // indirect - go.opentelemetry.io/otel/sdk v1.38.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect - go.opentelemetry.io/otel/trace v1.38.0 // indirect + go.opentelemetry.io/otel v1.40.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0 // indirect + go.opentelemetry.io/otel/metric v1.40.0 // indirect + go.opentelemetry.io/otel/sdk v1.40.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.40.0 // indirect + go.opentelemetry.io/otel/trace v1.40.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.1 // indirect go.uber.org/zap/exp v0.3.0 // indirect golang.org/x/time v0.12.0 // indirect golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) @@ -128,5 +143,5 @@ require ( golang.org/x/sys v0.40.0 // indirect golang.org/x/text v0.33.0 // indirect golang.org/x/tools v0.40.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20251029180050-ab9386a59fda // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect ) diff --git a/go.sum b/go.sum index 86a329071..8cfef2219 100644 --- a/go.sum +++ b/go.sum @@ -61,6 +61,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/99designs/gqlgen v0.17.86 h1:C8N3UTa5heXX6twl+b0AJyGkTwYL6dNmFrgZNLRcU6w= github.com/99designs/gqlgen v0.17.86/go.mod h1:KTrPl+vHA1IUzNlh4EYkl7+tcErL3MgKnhHrBcV74Fw= +github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg= +github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= @@ -128,6 +130,8 @@ github.com/caddyserver/certmagic v0.25.1 h1:4sIKKbOt5pg6+sL7tEwymE1x2bj6CHr80da1 github.com/caddyserver/certmagic v0.25.1/go.mod h1:VhyvndxtVton/Fo/wKhRoC46Rbw1fmjvQ3GjHYSQTEY= github.com/caddyserver/zerossl v0.1.4 h1:CVJOE3MZeFisCERZjkxIcsqIH4fnFdlYWnPYeFtBHRw= github.com/caddyserver/zerossl v0.1.4/go.mod h1:CxA0acn7oEGO6//4rtrRjYgEoa4MFw/XofZnrYwGqG4= +github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM= +github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -142,6 +146,12 @@ github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f h1:Y8xYupdHxryycyPlc9Y+bSQAYZnetRJ70VMVKm5CKI0= github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f/go.mod h1:HlzOvOjVBOfTGSRXRyY0OiCS/3J1akRGQQpRO/7zyF4= +github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= +github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= +github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= +github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= +github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= +github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= @@ -152,6 +162,14 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54 h1:SG7nF6SRlWhcT7cNTs5R6Hk4V2lcmLz2NsG2VnInyNo= github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= +github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= +github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/docker v28.5.2+incompatible h1:DBX0Y0zAjZbSrm1uzOkdr1onVghKaftjlSWt4AFexzM= +github.com/docker/docker v28.5.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pMmjSD94= +github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o= github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVoIbS6XaE= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= @@ -290,6 +308,8 @@ github.com/googleapis/gax-go/v2 v2.15.0 h1:SyjDc1mGgZU5LncH8gimWo9lW1DtIfPibOG81 github.com/googleapis/gax-go/v2 v2.15.0/go.mod h1:zVVkkxAQHa1RQpg9z2AUCMnKhi0Qld9rcmyfL1OZhoc= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7 h1:X+2YciYSxvMQK0UZ7sg45ZVabVZBeBuvMkmuI2V3Fak= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7/go.mod h1:lW34nIZuQ8UDPdkon5fmfp2l3+ZkQ2me/+oecHYLOII= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -343,17 +363,31 @@ github.com/miekg/dns v1.1.69 h1:Kb7Y/1Jo+SG+a2GtfoFUfDkG//csdRPwRLkCsxDG9Sc= github.com/miekg/dns v1.1.69/go.mod h1:7OyjD9nEba5OkqQ/hB4fy3PIoxafSZJtducccIelz3g= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= +github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw= +github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs= +github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU= +github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko= +github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= +github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/morikuni/aec v1.1.0 h1:vBBl0pUnvi/Je71dsRrhMBtreIqNMYErSAbEeb8jrXQ= +github.com/morikuni/aec v1.1.0/go.mod h1:xDRgiq/iw5l+zkao76YTKzKttOp2cwPEne25HDkJnBw= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= +github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4= github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -412,6 +446,8 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8= github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY= github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= @@ -471,16 +507,22 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.6 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0/go.mod h1:ru6KHrNtNHxM4nD/vd6QrLVWgKhxPYgblq4VAtNawTQ= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 h1:Hf9xI/XLML9ElpiHVDNwvqI0hIFlzV8dgIr35kV1kRU= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0/go.mod h1:NfchwuyNoMcZ5MLHwPrODwUF1HWCXWrL31s8gSAdIKY= -go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= -go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= -go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= -go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= -go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= -go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= +go.opentelemetry.io/otel v1.40.0 h1:oA5YeOcpRTXq6NN7frwmwFR0Cn3RhTVZvXsP4duvCms= +go.opentelemetry.io/otel v1.40.0/go.mod h1:IMb+uXZUKkMXdPddhwAHm6UfOwJyh4ct1ybIlV14J0g= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 h1:QKdN8ly8zEMrByybbQgv8cWBcdAarwmIPZ6FThrWXJs= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0/go.mod h1:bTdK1nhqF76qiPoCCdyFIV+N/sRHYXYCTQc+3VCi3MI= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0 h1:wVZXIWjQSeSmMoxF74LzAnpVQOAFDo3pPji9Y4SOFKc= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0/go.mod h1:khvBS2IggMFNwZK/6lEeHg/W57h/IX6J4URh57fuI40= +go.opentelemetry.io/otel/metric v1.40.0 h1:rcZe317KPftE2rstWIBitCdVp89A2HqjkxR3c11+p9g= +go.opentelemetry.io/otel/metric v1.40.0/go.mod h1:ib/crwQH7N3r5kfiBZQbwrTge743UDc7DTFVZrrXnqc= +go.opentelemetry.io/otel/sdk v1.40.0 h1:KHW/jUzgo6wsPh9At46+h4upjtccTmuZCFAc9OJ71f8= +go.opentelemetry.io/otel/sdk v1.40.0/go.mod h1:Ph7EFdYvxq72Y8Li9q8KebuYUr2KoeyHx0DRMKrYBUE= +go.opentelemetry.io/otel/sdk/metric v1.40.0 h1:mtmdVqgQkeRxHgRv4qhyJduP3fYJRMX4AtAlbuWdCYw= +go.opentelemetry.io/otel/sdk/metric v1.40.0/go.mod h1:4Z2bGMf0KSK3uRjlczMOeMhKU2rhUqdWNoKcYrtcBPg= +go.opentelemetry.io/otel/trace v1.40.0 h1:WA4etStDttCSYuhwvEa8OP8I5EWu24lkOzp+ZYblVjw= +go.opentelemetry.io/otel/trace v1.40.0/go.mod h1:zeAhriXecNGP/s2SEG3+Y8X9ujcJOTqQ5RgdEJcawiA= +go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A= +go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -567,8 +609,8 @@ golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= +golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -758,10 +800,10 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79 h1:Nt6z9UHqSlIdIGJdz6KhTIs2VRx/iOsA5iE8bmQNcxs= google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79/go.mod h1:kTmlBHMPqR5uCZPBvwa2B18mvubkjyY3CRLI0c6fj0s= -google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda h1:+2XxjfsAu6vqFxwGBRcHiMaDCuZiqXGDUDVWVtrFAnE= -google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda/go.mod h1:fDMmzKV90WSg1NbozdqrE64fkuTv6mlq2zxo9ad+3yo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20251029180050-ab9386a59fda h1:i/Q+bfisr7gq6feoJnS/DlpdwEL4ihp41fvRiM3Ork0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20251029180050-ab9386a59fda/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= +google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 h1:merA0rdPeUV3YIIfHHcH4qBkiQAc1nfCKSI7lB4cV2M= +google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409/go.mod h1:fl8J1IvUjCilwZzQowmw2b7HQB2eAuYBabMXzWurF+I= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 h1:H86B94AW+VfJWDqFeEbBPhEtHzJwJfTbgE2lZa54ZAQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/tavern/app.go b/tavern/app.go index 658c347a4..f2161869f 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -27,6 +27,7 @@ import ( "realm.pub/tavern/internal/auth" "realm.pub/tavern/internal/builder" "realm.pub/tavern/internal/builder/builderpb" + "realm.pub/tavern/internal/builder/executor" "realm.pub/tavern/internal/c2" "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/cdn" @@ -163,7 +164,12 @@ func newApp(ctx context.Context) (app *cli.App) { "supported_targets", cfg.SupportedTargets, ) - return builder.Run(ctx, cfg) + exec, err := executor.NewDockerExecutorFromEnv(ctx) + if err != nil { + return fmt.Errorf("failed to create docker executor: %w", err) + } + + return builder.Run(ctx, cfg, exec) }, }, } diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index ef2e92f59..63947493a 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -7,6 +7,7 @@ import ( "encoding/pem" "fmt" "log/slog" + "strings" "time" "google.golang.org/grpc" @@ -14,6 +15,7 @@ import ( "google.golang.org/grpc/credentials/insecure" "realm.pub/tavern/internal/builder/builderpb" + "realm.pub/tavern/internal/builder/executor" ) // builderCredentials implements grpc.PerRPCCredentials for mTLS authentication. @@ -93,8 +95,9 @@ func parseMTLSCredentials(mtlsPEM string) (*builderCredentials, error) { // Run starts the builder process using the provided configuration. // It connects to the configured upstream server with mTLS credentials, -// then enters a polling loop to claim and execute build tasks. -func Run(ctx context.Context, cfg *Config) error { +// then enters a polling loop to claim and execute build tasks using the +// provided executor. +func Run(ctx context.Context, cfg *Config, exec executor.Executor) error { slog.InfoContext(ctx, "builder started", "id", cfg.ID, "supported_targets", cfg.SupportedTargets, @@ -125,7 +128,11 @@ func Run(ctx context.Context, cfg *Config) error { slog.InfoContext(ctx, "successfully pinged upstream", "upstream", cfg.Upstream) - // Main polling loop + // Check for tasks immediately, then poll on interval + if err := claimAndExecuteTasks(ctx, client, exec); err != nil { + slog.ErrorContext(ctx, "error processing build tasks", "error", err) + } + ticker := time.NewTicker(5 * time.Second) defer ticker.Stop() @@ -134,14 +141,14 @@ func Run(ctx context.Context, cfg *Config) error { case <-ctx.Done(): return ctx.Err() case <-ticker.C: - if err := claimAndExecuteTasks(ctx, client); err != nil { + if err := claimAndExecuteTasks(ctx, client, exec); err != nil { slog.ErrorContext(ctx, "error processing build tasks", "error", err) } } } } -func claimAndExecuteTasks(ctx context.Context, client builderpb.BuilderClient) error { +func claimAndExecuteTasks(ctx context.Context, client builderpb.BuilderClient, exec executor.Executor) error { resp, err := client.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) if err != nil { return fmt.Errorf("failed to claim build tasks: %w", err) @@ -154,25 +161,94 @@ func claimAndExecuteTasks(ctx context.Context, client builderpb.BuilderClient) e "build_image", task.BuildImage, ) - // Print the build script - fmt.Printf("=== Build Task %d ===\n", task.Id) - fmt.Printf("Target OS: %s\n", task.TargetOs) - fmt.Printf("Build Image: %s\n", task.BuildImage) - fmt.Printf("Build Script:\n%s\n", task.BuildScript) - fmt.Println("====================") - - // Report completion - _, err := client.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ - TaskId: task.Id, - Output: fmt.Sprintf("Build script printed successfully for target %s", task.TargetOs), - }) - if err != nil { - slog.ErrorContext(ctx, "failed to submit build task output", - "task_id", task.Id, - "error", err, - ) - } + executeTask(ctx, client, exec, task) } return nil } + +// executeTask runs a single build task through the executor, streaming output +// and errors back to the server, then reports completion. +func executeTask(ctx context.Context, client builderpb.BuilderClient, exec executor.Executor, task *builderpb.BuildTaskSpec) { + outputCh := make(chan string, 64) + errorCh := make(chan string, 64) + + var outputLines []string + var errorLines []string + + // Collect output and errors in a background goroutine. + done := make(chan struct{}) + go func() { + defer close(done) + for { + select { + case line, ok := <-outputCh: + if !ok { + outputCh = nil + if errorCh == nil { + return + } + continue + } + outputLines = append(outputLines, line) + slog.InfoContext(ctx, "build output", + "task_id", task.Id, + "line", line, + ) + case line, ok := <-errorCh: + if !ok { + errorCh = nil + if outputCh == nil { + return + } + continue + } + errorLines = append(errorLines, line) + slog.WarnContext(ctx, "build error output", + "task_id", task.Id, + "line", line, + ) + } + } + }() + + // Run the build through the executor. + buildErr := exec.Build(ctx, executor.BuildSpec{ + TaskID: task.Id, + TargetOS: task.TargetOs, + BuildImage: task.BuildImage, + BuildScript: task.BuildScript, + }, outputCh, errorCh) + + // Close channels to signal collector goroutine to finish. + close(outputCh) + close(errorCh) + <-done + + // Build the submission request with collected output. + submitReq := &builderpb.SubmitBuildTaskOutputRequest{ + TaskId: task.Id, + Output: strings.Join(outputLines, "\n"), + } + + if buildErr != nil { + errMsg := buildErr.Error() + if len(errorLines) > 0 { + errMsg = strings.Join(errorLines, "\n") + "\n" + errMsg + } + submitReq.Error = errMsg + slog.ErrorContext(ctx, "build task failed", + "task_id", task.Id, + "error", buildErr, + ) + } else if len(errorLines) > 0 { + submitReq.Error = strings.Join(errorLines, "\n") + } + + if _, err := client.SubmitBuildTaskOutput(ctx, submitReq); err != nil { + slog.ErrorContext(ctx, "failed to submit build task output", + "task_id", task.Id, + "error", err, + ) + } +} diff --git a/tavern/internal/builder/executor/docker.go b/tavern/internal/builder/executor/docker.go new file mode 100644 index 000000000..0298d1a77 --- /dev/null +++ b/tavern/internal/builder/executor/docker.go @@ -0,0 +1,141 @@ +package executor + +import ( + "bufio" + "context" + "fmt" + "io" + "log/slog" + + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" + "github.com/docker/docker/client" + "github.com/docker/docker/pkg/stdcopy" +) + +// DockerExecutor runs build tasks inside Docker containers. +// It pulls the specified image, creates a container using the build script +// as the entrypoint, and streams stdout/stderr over the provided channels. +type DockerExecutor struct { + client client.APIClient +} + +// NewDockerExecutor creates a DockerExecutor using the provided Docker API client. +func NewDockerExecutor(cli client.APIClient) *DockerExecutor { + return &DockerExecutor{client: cli} +} + +// NewDockerExecutorFromEnv creates a DockerExecutor using the default +// Docker client configuration from environment variables. +func NewDockerExecutorFromEnv(ctx context.Context) (*DockerExecutor, error) { + cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) + if err != nil { + return nil, fmt.Errorf("failed to create docker client: %w", err) + } + return &DockerExecutor{client: cli}, nil +} + +// Build pulls the build image, starts a container with the build script as +// the shell entrypoint, and streams output/error lines over the channels. +func (d *DockerExecutor) Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + slog.InfoContext(ctx, "pulling docker image", "image", spec.BuildImage, "task_id", spec.TaskID) + + pullReader, err := d.client.ImagePull(ctx, spec.BuildImage, image.PullOptions{}) + if err != nil { + return fmt.Errorf("failed to pull image %q: %w", spec.BuildImage, err) + } + // Drain and close the pull output to ensure the image is fully downloaded. + if _, err := io.Copy(io.Discard, pullReader); err != nil { + pullReader.Close() + return fmt.Errorf("error reading image pull output: %w", err) + } + pullReader.Close() + + slog.InfoContext(ctx, "creating container", "image", spec.BuildImage, "task_id", spec.TaskID) + + resp, err := d.client.ContainerCreate(ctx, + &container.Config{ + Image: spec.BuildImage, + Entrypoint: []string{"/bin/sh", "-c", spec.BuildScript}, + }, + nil, // host config + nil, // networking config + nil, // platform + "", // container name (auto-generated) + ) + if err != nil { + return fmt.Errorf("failed to create container: %w", err) + } + containerID := resp.ID + + // Ensure the container is removed when we're done. + defer func() { + removeErr := d.client.ContainerRemove(context.Background(), containerID, container.RemoveOptions{Force: true}) + if removeErr != nil { + slog.Warn("failed to remove container", "container_id", containerID, "error", removeErr) + } + }() + + if err := d.client.ContainerStart(ctx, containerID, container.StartOptions{}); err != nil { + return fmt.Errorf("failed to start container: %w", err) + } + + slog.InfoContext(ctx, "container started", "container_id", containerID, "task_id", spec.TaskID) + + // Attach to container logs to stream stdout and stderr. + logReader, err := d.client.ContainerLogs(ctx, containerID, container.LogsOptions{ + ShowStdout: true, + ShowStderr: true, + Follow: true, + }) + if err != nil { + return fmt.Errorf("failed to attach to container logs: %w", err) + } + defer logReader.Close() + + // Docker multiplexes stdout/stderr into a single stream with headers. + // stdcopy.StdCopy demultiplexes them. + stdoutPR, stdoutPW := io.Pipe() + stderrPR, stderrPW := io.Pipe() + + go func() { + _, err := stdcopy.StdCopy(stdoutPW, stderrPW, logReader) + stdoutPW.CloseWithError(err) + stderrPW.CloseWithError(err) + }() + + // Stream stderr lines over errorCh in a background goroutine. + done := make(chan struct{}) + go func() { + defer close(done) + scanner := bufio.NewScanner(stderrPR) + for scanner.Scan() { + errorCh <- scanner.Text() + } + }() + + scanner := bufio.NewScanner(stdoutPR) + for scanner.Scan() { + outputCh <- scanner.Text() + } + + // Wait for stderr goroutine to finish. + <-done + + // Wait for the container to exit and check its status. + statusCh, errCh := d.client.ContainerWait(ctx, containerID, container.WaitConditionNotRunning) + select { + case err := <-errCh: + if err != nil { + return fmt.Errorf("error waiting for container: %w", err) + } + case result := <-statusCh: + if result.StatusCode != 0 { + return fmt.Errorf("container exited with status %d", result.StatusCode) + } + case <-ctx.Done(): + return ctx.Err() + } + + return nil +} diff --git a/tavern/internal/builder/executor/docker_test.go b/tavern/internal/builder/executor/docker_test.go new file mode 100644 index 000000000..f5b4e7c37 --- /dev/null +++ b/tavern/internal/builder/executor/docker_test.go @@ -0,0 +1,229 @@ +package executor_test + +import ( + "context" + "strings" + "sync" + "testing" + "time" + + "github.com/docker/docker/client" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "realm.pub/tavern/internal/builder/executor" +) + +// skipIfNoDocker skips the test if Docker is not available. +func skipIfNoDocker(t *testing.T) client.APIClient { + t.Helper() + cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) + if err != nil { + t.Skipf("skipping docker test: %v", err) + } + _, err = cli.Ping(context.Background()) + if err != nil { + t.Skipf("skipping docker test: docker not reachable: %v", err) + } + return cli +} + +func TestDockerExecutor_ImplementsInterface(t *testing.T) { + var _ executor.Executor = (*executor.DockerExecutor)(nil) +} + +func TestDockerExecutor_Build_SimpleEcho(t *testing.T) { + cli := skipIfNoDocker(t) + exec := executor.NewDockerExecutor(cli) + + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer cancel() + + spec := executor.BuildSpec{ + TaskID: 1, + TargetOS: "linux", + BuildImage: "alpine:latest", + BuildScript: "echo hello world", + } + + outputCh := make(chan string, 100) + errorCh := make(chan string, 100) + + err := exec.Build(ctx, spec, outputCh, errorCh) + require.NoError(t, err) + + close(outputCh) + close(errorCh) + + var output []string + for line := range outputCh { + output = append(output, line) + } + assert.Contains(t, output, "hello world") +} + +func TestDockerExecutor_Build_MultiLineOutput(t *testing.T) { + cli := skipIfNoDocker(t) + exec := executor.NewDockerExecutor(cli) + + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer cancel() + + spec := executor.BuildSpec{ + TaskID: 2, + TargetOS: "linux", + BuildImage: "alpine:latest", + BuildScript: "echo line1 && echo line2 && echo line3", + } + + outputCh := make(chan string, 100) + errorCh := make(chan string, 100) + + err := exec.Build(ctx, spec, outputCh, errorCh) + require.NoError(t, err) + + close(outputCh) + close(errorCh) + + var output []string + for line := range outputCh { + output = append(output, line) + } + assert.Equal(t, []string{"line1", "line2", "line3"}, output) +} + +func TestDockerExecutor_Build_StderrOutput(t *testing.T) { + cli := skipIfNoDocker(t) + exec := executor.NewDockerExecutor(cli) + + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer cancel() + + spec := executor.BuildSpec{ + TaskID: 3, + TargetOS: "linux", + BuildImage: "alpine:latest", + BuildScript: "echo stdout_line && echo stderr_line >&2", + } + + outputCh := make(chan string, 100) + errorCh := make(chan string, 100) + + err := exec.Build(ctx, spec, outputCh, errorCh) + require.NoError(t, err) + + close(outputCh) + close(errorCh) + + var output []string + for line := range outputCh { + output = append(output, line) + } + var errOutput []string + for line := range errorCh { + errOutput = append(errOutput, line) + } + + assert.Contains(t, output, "stdout_line") + assert.Contains(t, errOutput, "stderr_line") +} + +func TestDockerExecutor_Build_NonZeroExit(t *testing.T) { + cli := skipIfNoDocker(t) + exec := executor.NewDockerExecutor(cli) + + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer cancel() + + spec := executor.BuildSpec{ + TaskID: 4, + TargetOS: "linux", + BuildImage: "alpine:latest", + BuildScript: "echo before_fail && exit 42", + } + + outputCh := make(chan string, 100) + errorCh := make(chan string, 100) + + err := exec.Build(ctx, spec, outputCh, errorCh) + require.Error(t, err) + assert.Contains(t, err.Error(), "42") + + close(outputCh) + var output []string + for line := range outputCh { + output = append(output, line) + } + assert.Contains(t, output, "before_fail") +} + +func TestDockerExecutor_Build_ContextCancellation(t *testing.T) { + cli := skipIfNoDocker(t) + exec := executor.NewDockerExecutor(cli) + + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + spec := executor.BuildSpec{ + TaskID: 5, + TargetOS: "linux", + BuildImage: "alpine:latest", + BuildScript: "echo started && sleep 120", + } + + outputCh := make(chan string, 100) + errorCh := make(chan string, 100) + + var buildErr error + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + buildErr = exec.Build(ctx, spec, outputCh, errorCh) + }() + + wg.Wait() + + // The build should have been cancelled or errored due to timeout. + require.Error(t, buildErr) +} + +func TestDockerExecutor_Build_StreamsOutputInRealTime(t *testing.T) { + cli := skipIfNoDocker(t) + exec := executor.NewDockerExecutor(cli) + + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer cancel() + + spec := executor.BuildSpec{ + TaskID: 6, + TargetOS: "linux", + BuildImage: "alpine:latest", + BuildScript: "for i in 1 2 3 4 5; do echo line_$i; sleep 0.1; done", + } + + outputCh := make(chan string, 100) + errorCh := make(chan string, 100) + + var wg sync.WaitGroup + wg.Add(1) + + var output []string + go func() { + defer wg.Done() + for line := range outputCh { + output = append(output, line) + } + }() + + err := exec.Build(ctx, spec, outputCh, errorCh) + close(outputCh) + close(errorCh) + wg.Wait() + + require.NoError(t, err) + require.Len(t, output, 5) + for i, line := range output { + assert.True(t, strings.HasPrefix(line, "line_"), "unexpected line %d: %s", i, line) + } +} diff --git a/tavern/internal/builder/executor/executor.go b/tavern/internal/builder/executor/executor.go new file mode 100644 index 000000000..e0542f680 --- /dev/null +++ b/tavern/internal/builder/executor/executor.go @@ -0,0 +1,25 @@ +package executor + +import ( + "context" +) + +// BuildSpec contains the parameters for a build task execution. +type BuildSpec struct { + TaskID int64 + TargetOS string + BuildImage string + BuildScript string +} + +// Executor defines the interface for build task execution. +// Implementations must stream output and errors over the provided channels +// as the build progresses. Both channels are closed by the caller after +// Build returns. +type Executor interface { + // Build executes a build task described by spec. As the build runs, + // stdout lines are sent to outputCh and stderr lines to errorCh. + // Build blocks until the build completes (or the context is cancelled) + // and returns any execution error. + Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) error +} diff --git a/tavern/internal/builder/executor/mock.go b/tavern/internal/builder/executor/mock.go new file mode 100644 index 000000000..266a226b1 --- /dev/null +++ b/tavern/internal/builder/executor/mock.go @@ -0,0 +1,34 @@ +package executor + +import ( + "context" +) + +// MockExecutor is a test double for the Executor interface. +// It records calls and allows tests to configure the output, errors, +// and return value for each invocation. +type MockExecutor struct { + // BuildCalls records each BuildSpec passed to Build. + BuildCalls []BuildSpec + + // BuildFn, if set, is called for each Build invocation. + // It gives tests full control over what gets sent to the channels + // and what error (if any) is returned. + BuildFn func(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) error +} + +// NewMockExecutor returns a MockExecutor with no configured behavior. +// By default, Build succeeds immediately without producing output. +func NewMockExecutor() *MockExecutor { + return &MockExecutor{} +} + +// Build implements Executor. It records the call and delegates to BuildFn +// if set, otherwise returns nil. +func (m *MockExecutor) Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + m.BuildCalls = append(m.BuildCalls, spec) + if m.BuildFn != nil { + return m.BuildFn(ctx, spec, outputCh, errorCh) + } + return nil +} diff --git a/tavern/internal/builder/executor/mock_test.go b/tavern/internal/builder/executor/mock_test.go new file mode 100644 index 000000000..121f35eca --- /dev/null +++ b/tavern/internal/builder/executor/mock_test.go @@ -0,0 +1,190 @@ +package executor_test + +import ( + "context" + "errors" + "sync" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "realm.pub/tavern/internal/builder/executor" +) + +func TestMockExecutor_DefaultBehavior(t *testing.T) { + mock := executor.NewMockExecutor() + spec := executor.BuildSpec{ + TaskID: 1, + TargetOS: "linux", + BuildImage: "golang:1.21", + BuildScript: "go build ./...", + } + + outputCh := make(chan string, 10) + errorCh := make(chan string, 10) + + err := mock.Build(context.Background(), spec, outputCh, errorCh) + require.NoError(t, err) + + // Should have recorded the call. + require.Len(t, mock.BuildCalls, 1) + assert.Equal(t, spec, mock.BuildCalls[0]) + + // No output or errors by default. + assert.Empty(t, outputCh) + assert.Empty(t, errorCh) +} + +func TestMockExecutor_RecordsMultipleCalls(t *testing.T) { + mock := executor.NewMockExecutor() + outputCh := make(chan string, 10) + errorCh := make(chan string, 10) + + specs := []executor.BuildSpec{ + {TaskID: 1, BuildImage: "golang:1.21", BuildScript: "go build ./..."}, + {TaskID: 2, BuildImage: "rust:1.75", BuildScript: "cargo build --release"}, + {TaskID: 3, BuildImage: "node:20", BuildScript: "npm run build"}, + } + + for _, s := range specs { + err := mock.Build(context.Background(), s, outputCh, errorCh) + require.NoError(t, err) + } + + require.Len(t, mock.BuildCalls, 3) + for i, s := range specs { + assert.Equal(t, s, mock.BuildCalls[i]) + } +} + +func TestMockExecutor_CustomBuildFn_StreamsOutput(t *testing.T) { + mock := executor.NewMockExecutor() + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + outputCh <- "Compiling main.go" + outputCh <- "Linking binary" + outputCh <- "Build succeeded" + return nil + } + + outputCh := make(chan string, 10) + errorCh := make(chan string, 10) + + err := mock.Build(context.Background(), executor.BuildSpec{TaskID: 1}, outputCh, errorCh) + require.NoError(t, err) + + close(outputCh) + close(errorCh) + + var output []string + for line := range outputCh { + output = append(output, line) + } + assert.Equal(t, []string{"Compiling main.go", "Linking binary", "Build succeeded"}, output) + assert.Empty(t, errorCh) +} + +func TestMockExecutor_CustomBuildFn_StreamsErrors(t *testing.T) { + mock := executor.NewMockExecutor() + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + outputCh <- "Compiling..." + errorCh <- "warning: unused variable" + errorCh <- "error: type mismatch" + return errors.New("build failed with exit code 1") + } + + outputCh := make(chan string, 10) + errorCh := make(chan string, 10) + + err := mock.Build(context.Background(), executor.BuildSpec{TaskID: 2}, outputCh, errorCh) + require.Error(t, err) + assert.Contains(t, err.Error(), "build failed") + + close(outputCh) + close(errorCh) + + var output []string + for line := range outputCh { + output = append(output, line) + } + assert.Equal(t, []string{"Compiling..."}, output) + + var errs []string + for line := range errorCh { + errs = append(errs, line) + } + assert.Equal(t, []string{"warning: unused variable", "error: type mismatch"}, errs) +} + +func TestMockExecutor_CustomBuildFn_ContextCancellation(t *testing.T) { + mock := executor.NewMockExecutor() + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + outputCh <- "Starting build..." + <-ctx.Done() + return ctx.Err() + } + + ctx, cancel := context.WithCancel(context.Background()) + outputCh := make(chan string, 10) + errorCh := make(chan string, 10) + + var wg sync.WaitGroup + var buildErr error + wg.Add(1) + go func() { + defer wg.Done() + buildErr = mock.Build(ctx, executor.BuildSpec{TaskID: 3}, outputCh, errorCh) + }() + + // Wait for the first output line to confirm Build started. + select { + case line := <-outputCh: + assert.Equal(t, "Starting build...", line) + case <-time.After(2 * time.Second): + t.Fatal("timed out waiting for build to start") + } + + cancel() + wg.Wait() + + require.Error(t, buildErr) + assert.ErrorIs(t, buildErr, context.Canceled) +} + +func TestMockExecutor_CustomBuildFn_InterleavedOutputAndErrors(t *testing.T) { + mock := executor.NewMockExecutor() + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + outputCh <- "step 1" + errorCh <- "warn 1" + outputCh <- "step 2" + errorCh <- "warn 2" + outputCh <- "step 3" + return nil + } + + outputCh := make(chan string, 10) + errorCh := make(chan string, 10) + + err := mock.Build(context.Background(), executor.BuildSpec{TaskID: 4}, outputCh, errorCh) + require.NoError(t, err) + + close(outputCh) + close(errorCh) + + var output []string + for line := range outputCh { + output = append(output, line) + } + assert.Equal(t, []string{"step 1", "step 2", "step 3"}, output) + + var errs []string + for line := range errorCh { + errs = append(errs, line) + } + assert.Equal(t, []string{"warn 1", "warn 2"}, errs) +} + +func TestMockExecutor_ImplementsInterface(t *testing.T) { + var _ executor.Executor = (*executor.MockExecutor)(nil) +} diff --git a/tavern/internal/builder/executor_integration_test.go b/tavern/internal/builder/executor_integration_test.go new file mode 100644 index 000000000..d61a9be31 --- /dev/null +++ b/tavern/internal/builder/executor_integration_test.go @@ -0,0 +1,303 @@ +package builder_test + +import ( + "context" + "crypto/ed25519" + "crypto/rand" + "errors" + "net" + "strings" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql/handler" + _ "github.com/mattn/go-sqlite3" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/test/bufconn" + + "realm.pub/tavern/internal/builder" + "realm.pub/tavern/internal/builder/builderpb" + "realm.pub/tavern/internal/builder/executor" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/enttest" + "realm.pub/tavern/internal/graphql" + tavernhttp "realm.pub/tavern/internal/http" + "realm.pub/tavern/tomes" +) + +func TestExecutorIntegration_ClaimAndExecuteWithMock(t *testing.T) { + ctx := context.Background() + + // Full infrastructure setup + graph := enttest.Open(t, "sqlite3", "file:ent_claim_exec?mode=memory&cache=shared&_fk=1") + defer graph.Close() + + _, caPrivKey, err := ed25519.GenerateKey(rand.Reader) + require.NoError(t, err) + caCert, err := builder.CreateCA(caPrivKey) + require.NoError(t, err) + + git := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( + tavernhttp.RouteMap{ + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), + }, + tavernhttp.WithAuthenticationBypass(graph), + ) + gqlClient := client.New(srv, client.Path("/graphql")) + + // Register builder + var registerResp struct { + RegisterBuilder struct { + Builder struct{ ID string } + Config string + } + } + err = gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { + registerBuilder(input: $input) { + builder { id } + config + } + }`, ®isterResp, client.Var("input", map[string]any{ + "supportedTargets": []string{"PLATFORM_LINUX"}, + "upstream": "https://tavern.example.com:443", + })) + require.NoError(t, err) + + // Get builder DB entity + builders, err := graph.Builder.Query().All(ctx) + require.NoError(t, err) + require.Len(t, builders, 1) + + // Create a build task + bt := graph.BuildTask.Create(). + SetTargetOs(c2pb.Host_PLATFORM_LINUX). + SetBuildImage("golang:1.21"). + SetBuildScript("go build ./..."). + SetBuilderID(builders[0].ID). + SaveX(ctx) + + // Setup gRPC + lis := bufconn.Listen(1024 * 1024) + grpcSrv := grpc.NewServer( + grpc.ChainUnaryInterceptor( + builder.NewMTLSAuthInterceptor(caCert, graph), + ), + ) + builderSrv := builder.New(graph) + builderpb.RegisterBuilderServer(grpcSrv, builderSrv) + + go func() { + if err := grpcSrv.Serve(lis); err != nil { + t.Logf("gRPC server exited: %v", err) + } + }() + defer grpcSrv.Stop() + + bufDialer := func(context.Context, string) (net.Conn, error) { + return lis.Dial() + } + + cfg, err := builder.ParseConfigBytes([]byte(registerResp.RegisterBuilder.Config)) + require.NoError(t, err) + + creds, err := builder.NewCredentialsFromConfig(cfg) + require.NoError(t, err) + + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + require.NoError(t, err) + defer conn.Close() + + authClient := builderpb.NewBuilderClient(conn) + + // Claim the task + claimResp, err := authClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) + require.NoError(t, err) + require.Len(t, claimResp.Tasks, 1) + assert.Equal(t, int64(bt.ID), claimResp.Tasks[0].Id) + + // Execute using mock executor + mock := executor.NewMockExecutor() + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + outputCh <- "Building for linux..." + outputCh <- "Success" + return nil + } + + task := claimResp.Tasks[0] + outputCh := make(chan string, 64) + errorCh := make(chan string, 64) + + buildErr := mock.Build(ctx, executor.BuildSpec{ + TaskID: task.Id, + TargetOS: task.TargetOs, + BuildImage: task.BuildImage, + BuildScript: task.BuildScript, + }, outputCh, errorCh) + require.NoError(t, buildErr) + + close(outputCh) + close(errorCh) + + var outputLines []string + for line := range outputCh { + outputLines = append(outputLines, line) + } + + // Submit output to server + _, err = authClient.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ + TaskId: task.Id, + Output: strings.Join(outputLines, "\n"), + }) + require.NoError(t, err) + + // Verify the task was updated in the database + reloaded := graph.BuildTask.GetX(ctx, bt.ID) + assert.Equal(t, "Building for linux...\nSuccess", reloaded.Output) + assert.False(t, reloaded.FinishedAt.IsZero()) + assert.Empty(t, reloaded.Error) +} + +func TestExecutorIntegration_ClaimAndExecuteWithMockError(t *testing.T) { + ctx := context.Background() + + graph := enttest.Open(t, "sqlite3", "file:ent_claim_exec_err?mode=memory&cache=shared&_fk=1") + defer graph.Close() + + _, caPrivKey, err := ed25519.GenerateKey(rand.Reader) + require.NoError(t, err) + caCert, err := builder.CreateCA(caPrivKey) + require.NoError(t, err) + + git := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( + tavernhttp.RouteMap{ + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), + }, + tavernhttp.WithAuthenticationBypass(graph), + ) + gqlClient := client.New(srv, client.Path("/graphql")) + + var registerResp struct { + RegisterBuilder struct { + Builder struct{ ID string } + Config string + } + } + err = gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { + registerBuilder(input: $input) { + builder { id } + config + } + }`, ®isterResp, client.Var("input", map[string]any{ + "supportedTargets": []string{"PLATFORM_LINUX"}, + "upstream": "https://tavern.example.com:443", + })) + require.NoError(t, err) + + builders, err := graph.Builder.Query().All(ctx) + require.NoError(t, err) + require.Len(t, builders, 1) + + bt := graph.BuildTask.Create(). + SetTargetOs(c2pb.Host_PLATFORM_LINUX). + SetBuildImage("golang:1.21"). + SetBuildScript("go build ./..."). + SetBuilderID(builders[0].ID). + SaveX(ctx) + + lis := bufconn.Listen(1024 * 1024) + grpcSrv := grpc.NewServer( + grpc.ChainUnaryInterceptor( + builder.NewMTLSAuthInterceptor(caCert, graph), + ), + ) + builderSrv := builder.New(graph) + builderpb.RegisterBuilderServer(grpcSrv, builderSrv) + + go func() { + if err := grpcSrv.Serve(lis); err != nil { + t.Logf("gRPC server exited: %v", err) + } + }() + defer grpcSrv.Stop() + + bufDialer := func(context.Context, string) (net.Conn, error) { + return lis.Dial() + } + + cfg, err := builder.ParseConfigBytes([]byte(registerResp.RegisterBuilder.Config)) + require.NoError(t, err) + + creds, err := builder.NewCredentialsFromConfig(cfg) + require.NoError(t, err) + + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + require.NoError(t, err) + defer conn.Close() + + authClient := builderpb.NewBuilderClient(conn) + + claimResp, err := authClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) + require.NoError(t, err) + require.Len(t, claimResp.Tasks, 1) + + // Execute using mock that fails + mock := executor.NewMockExecutor() + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + outputCh <- "Compiling..." + errorCh <- "fatal: cannot find package" + return errors.New("exit code 1") + } + + task := claimResp.Tasks[0] + outputCh := make(chan string, 64) + errorCh := make(chan string, 64) + + buildErr := mock.Build(ctx, executor.BuildSpec{ + TaskID: task.Id, + TargetOS: task.TargetOs, + BuildImage: task.BuildImage, + BuildScript: task.BuildScript, + }, outputCh, errorCh) + require.Error(t, buildErr) + + close(outputCh) + close(errorCh) + + var outputLines []string + for line := range outputCh { + outputLines = append(outputLines, line) + } + var errorLines []string + for line := range errorCh { + errorLines = append(errorLines, line) + } + + // Submit output with error + errMsg := strings.Join(errorLines, "\n") + "\n" + buildErr.Error() + _, err = authClient.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ + TaskId: task.Id, + Output: strings.Join(outputLines, "\n"), + Error: errMsg, + }) + require.NoError(t, err) + + // Verify the task was updated + reloaded := graph.BuildTask.GetX(ctx, bt.ID) + assert.Equal(t, "Compiling...", reloaded.Output) + assert.Contains(t, reloaded.Error, "fatal: cannot find package") + assert.Contains(t, reloaded.Error, "exit code 1") + assert.False(t, reloaded.FinishedAt.IsZero()) +} From fee27da7870ebc44edc6555c1445dd03acbfb71b Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Wed, 11 Feb 2026 03:31:04 +0000 Subject: [PATCH 09/19] Address PR #1791 feedback on builder executor - Extract poll interval magic number to taskPollInterval const - Simplify ClaimBuildTasks to follow beacon task claiming pattern (use rollback helper, reload tasks after commit, remove debug query) - Add rollback.go helper matching c2 package pattern - Add TODO section to README: concurrent builds, streaming tests, gRPC streaming for SubmitBuildTaskOutput Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- tavern/internal/builder/README.md | 6 ++++ tavern/internal/builder/client.go | 7 ++++- tavern/internal/builder/rollback.go | 16 ++++++++++ tavern/internal/builder/server.go | 49 ++++++++++++++--------------- 4 files changed, 51 insertions(+), 27 deletions(-) create mode 100644 tavern/internal/builder/rollback.go diff --git a/tavern/internal/builder/README.md b/tavern/internal/builder/README.md index 1d914a279..d9785badc 100644 --- a/tavern/internal/builder/README.md +++ b/tavern/internal/builder/README.md @@ -54,6 +54,12 @@ upstream: go run ./tavern builder --config /path/to/builder-config.yaml ``` +## TODO + +- Add support for concurrent builds +- Test client to server output streaming +- Update `SubmitBuildTaskOutput` to use gRPC streaming + ## Package Structure | File | Purpose | diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index 63947493a..12f9d08c8 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -18,6 +18,11 @@ import ( "realm.pub/tavern/internal/builder/executor" ) +const ( + // taskPollInterval is how often the builder polls for new build tasks. + taskPollInterval = 5 * time.Second +) + // builderCredentials implements grpc.PerRPCCredentials for mTLS authentication. type builderCredentials struct { certDER []byte @@ -133,7 +138,7 @@ func Run(ctx context.Context, cfg *Config, exec executor.Executor) error { slog.ErrorContext(ctx, "error processing build tasks", "error", err) } - ticker := time.NewTicker(5 * time.Second) + ticker := time.NewTicker(taskPollInterval) defer ticker.Stop() for { diff --git a/tavern/internal/builder/rollback.go b/tavern/internal/builder/rollback.go new file mode 100644 index 000000000..370ab7c93 --- /dev/null +++ b/tavern/internal/builder/rollback.go @@ -0,0 +1,16 @@ +package builder + +import ( + "fmt" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "realm.pub/tavern/internal/ent" +) + +func rollback(tx *ent.Tx, err error) error { + if rerr := tx.Rollback(); rerr != nil { + err = fmt.Errorf("%w: %v", err, rerr) + } + return status.Errorf(codes.Internal, "%v", err) +} diff --git a/tavern/internal/builder/server.go b/tavern/internal/builder/server.go index a033fe8cd..4caaad4bd 100644 --- a/tavern/internal/builder/server.go +++ b/tavern/internal/builder/server.go @@ -2,6 +2,7 @@ package builder import ( "context" + "fmt" "log/slog" "time" @@ -37,13 +38,13 @@ func (s *Server) Ping(ctx context.Context, req *builderpb.PingRequest) (*builder func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildTasksRequest) (*builderpb.ClaimBuildTasksResponse, error) { now := time.Now() - // 1. Extract authenticated builder from context + // Extract authenticated builder from context b, ok := BuilderFromContext(ctx) if !ok { return nil, status.Error(codes.Unauthenticated, "builder not authenticated") } - // 2. Query unclaimed build tasks assigned to this builder + // Load unclaimed build tasks assigned to this builder tasks, err := s.graph.BuildTask.Query(). Where( buildtask.HasBuilderWith(entbuilder.ID(b.ID)), @@ -54,23 +55,14 @@ func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildT return nil, status.Errorf(codes.Internal, "failed to query build tasks: %v", err) } - if len(tasks) == 0 { - // Log for debugging: count total tasks (including claimed) for this builder - total, _ := s.graph.BuildTask.Query(). - Where(buildtask.HasBuilderWith(entbuilder.ID(b.ID))). - Count(ctx) - slog.InfoContext(ctx, "no unclaimed build tasks found", - "builder_id", b.ID, - "total_tasks_for_builder", total, - ) - return &builderpb.ClaimBuildTasksResponse{}, nil - } - - // 3. Begin transaction to claim tasks atomically + // Prepare transaction for claiming tasks tx, err := s.graph.Tx(ctx) if err != nil { - return nil, status.Errorf(codes.Internal, "failed to start transaction: %v", err) + return nil, status.Errorf(codes.Internal, "failed to initialize transaction: %v", err) } + client := tx.Client() + + // Rollback transaction if we panic defer func() { if v := recover(); v != nil { tx.Rollback() @@ -78,7 +70,7 @@ func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildT } }() - client := tx.Client() + // Update all ClaimedAt timestamps to claim tasks taskIDs := make([]int, 0, len(tasks)) for _, t := range tasks { _, err := client.BuildTask.UpdateOne(t). @@ -86,24 +78,29 @@ func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildT SetStartedAt(now). Save(ctx) if err != nil { - tx.Rollback() - return nil, status.Errorf(codes.Internal, "failed to claim build task %d: %v", t.ID, err) + return nil, rollback(tx, fmt.Errorf("failed to update build task %d: %w", t.ID, err)) } taskIDs = append(taskIDs, t.ID) } + // Commit the transaction if err := tx.Commit(); err != nil { - return nil, status.Errorf(codes.Internal, "failed to commit transaction: %v", err) + return nil, rollback(tx, fmt.Errorf("failed to commit transaction: %w", err)) } - // 4. Build response from claimed tasks + // Load the tasks with our non-transactional client (cannot use transaction after commit) resp := &builderpb.ClaimBuildTasksResponse{} - for _, t := range tasks { + resp.Tasks = make([]*builderpb.BuildTaskSpec, 0, len(taskIDs)) + for _, taskID := range taskIDs { + claimedTask, err := s.graph.BuildTask.Get(ctx, taskID) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to load claimed build task (but it was still claimed) %d: %v", taskID, err) + } resp.Tasks = append(resp.Tasks, &builderpb.BuildTaskSpec{ - Id: int64(t.ID), - TargetOs: t.TargetOs.String(), - BuildImage: t.BuildImage, - BuildScript: t.BuildScript, + Id: int64(claimedTask.ID), + TargetOs: claimedTask.TargetOs.String(), + BuildImage: claimedTask.BuildImage, + BuildScript: claimedTask.BuildScript, }) } From f058af03972d2ac40f527b43c82b1e1cf1520da6 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Wed, 11 Feb 2026 03:52:18 +0000 Subject: [PATCH 10/19] Review fixes: remove premature started_at, update README, fix error field type - Remove SetStartedAt from ClaimBuildTasks so claimed_at and started_at are distinct lifecycle stages (started_at should be set at execution time) - Update README with current gRPC API, executor docs, and full package table - Change BuildTask error field from String to Text for consistency with the output field and the Task schema pattern Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- tavern/internal/builder/README.md | 14 ++++++++++---- tavern/internal/builder/server.go | 1 - tavern/internal/ent/migrate/schema.go | 2 +- tavern/internal/ent/schema/build_task.go | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tavern/internal/builder/README.md b/tavern/internal/builder/README.md index d9785badc..48049df22 100644 --- a/tavern/internal/builder/README.md +++ b/tavern/internal/builder/README.md @@ -6,7 +6,8 @@ The builder package orchestrates agent compilation for target platforms. It conn - **Registration**: Builders register with Tavern via the `registerBuilder` GraphQL mutation, which returns an mTLS certificate signed by the Tavern Builder CA and a YAML configuration file. - **mTLS Authentication**: All gRPC requests are authenticated using application-level mTLS. The builder presents its CA-signed certificate and a signed timestamp in gRPC metadata on each request. The server verifies the certificate chain, proof of private key possession, and looks up the builder by the identifier embedded in the certificate CN. -- **gRPC API**: Builders communicate with Tavern over gRPC at the `/builder.Builder/` route. Currently supports a `Ping` health check endpoint. +- **gRPC API**: Builders communicate with Tavern over gRPC at the `/builder.Builder/` route. Supports `Ping` (health check), `ClaimBuildTasks` (poll for unclaimed tasks), and `SubmitBuildTaskOutput` (report build results). +- **Executor**: Build tasks are executed via the `executor.Executor` interface. The `DockerExecutor` runs builds inside Docker containers; the `MockExecutor` is used in tests. - **CLI**: Run a builder using the `builder` subcommand with a `--config` flag pointing to a YAML configuration file. ## Configuration @@ -66,9 +67,14 @@ go run ./tavern builder --config /path/to/builder-config.yaml |------|---------| | `auth.go` | gRPC unary interceptor for mTLS authentication | | `ca.go` | Builder CA generation, persistence, and certificate signing | -| `client.go` | Builder client with `PerRPCCredentials` for mTLS auth | +| `client.go` | Builder client: mTLS credentials, polling loop, task execution | | `config.go` | YAML configuration parsing and validation | -| `server.go` | gRPC server implementation (Ping) | +| `server.go` | gRPC server: `Ping`, `ClaimBuildTasks`, `SubmitBuildTaskOutput` | +| `rollback.go` | Transaction rollback helper (matches c2 pattern) | +| `executor/executor.go` | `Executor` interface and `BuildSpec` definition | +| `executor/docker.go` | `DockerExecutor`: runs builds in Docker containers | +| `executor/mock.go` | `MockExecutor`: test double for unit tests | | `proto/builder.proto` | Protobuf service definition | | `builderpb/` | Generated protobuf Go code | -| `integration_test.go` | End-to-end test covering registration, mTLS auth, and unauthenticated rejection | +| `integration_test.go` | End-to-end test: registration, mTLS auth, task claiming | +| `executor_integration_test.go` | End-to-end test: claim → execute → submit flow | diff --git a/tavern/internal/builder/server.go b/tavern/internal/builder/server.go index 4caaad4bd..23a8fe412 100644 --- a/tavern/internal/builder/server.go +++ b/tavern/internal/builder/server.go @@ -75,7 +75,6 @@ func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildT for _, t := range tasks { _, err := client.BuildTask.UpdateOne(t). SetClaimedAt(now). - SetStartedAt(now). Save(ctx) if err != nil { return nil, rollback(tx, fmt.Errorf("failed to update build task %d: %w", t.ID, err)) diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index c64806547..6b7c5c6ae 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -75,7 +75,7 @@ var ( {Name: "started_at", Type: field.TypeTime, Nullable: true}, {Name: "finished_at", Type: field.TypeTime, Nullable: true}, {Name: "output", Type: field.TypeString, Nullable: true, Size: 2147483647, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, - {Name: "error", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, + {Name: "error", Type: field.TypeString, Nullable: true, Size: 2147483647, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, {Name: "build_task_builder", Type: field.TypeInt}, } // BuildTasksTable holds the schema information for the "build_tasks" table. diff --git a/tavern/internal/ent/schema/build_task.go b/tavern/internal/ent/schema/build_task.go index 0b0a40529..be3d90f2a 100644 --- a/tavern/internal/ent/schema/build_task.go +++ b/tavern/internal/ent/schema/build_task.go @@ -59,7 +59,7 @@ func (BuildTask) Fields() []ent.Field { dialect.MySQL: "LONGTEXT", }). Comment("Output from the build execution."), - field.String("error"). + field.Text("error"). Optional(). SchemaType(map[string]string{ dialect.MySQL: "LONGTEXT", From bb9752c7e6ef6b108802248f31019daae2383aba Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Wed, 11 Feb 2026 03:55:59 +0000 Subject: [PATCH 11/19] Add output_size derived field and hook to BuildTask schema Mirror the Task schema pattern: add output_size field with a HookDeriveBuildTaskInfo hook that auto-computes byte length from the output field on create/update. Enables sorting and filtering build tasks by output size in GraphQL. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- tavern/internal/ent/buildtask.go | 13 ++- tavern/internal/ent/buildtask/buildtask.go | 19 ++++ tavern/internal/ent/buildtask/where.go | 45 ++++++++ tavern/internal/ent/buildtask_create.go | 103 +++++++++++++++++- tavern/internal/ent/buildtask_update.go | 84 +++++++++++++- tavern/internal/ent/client.go | 3 +- tavern/internal/ent/gql_collection.go | 5 + tavern/internal/ent/gql_pagination.go | 18 +++ tavern/internal/ent/gql_where_input.go | 34 ++++++ tavern/internal/ent/migrate/schema.go | 3 +- tavern/internal/ent/mutation.go | 94 +++++++++++++++- tavern/internal/ent/runtime/runtime.go | 8 ++ tavern/internal/ent/schema/build_task.go | 40 +++++++ .../graphql/generated/ent.generated.go | 94 +++++++++++++++- .../graphql/generated/mutation.generated.go | 2 + .../graphql/generated/root_.generated.go | 24 ++++ tavern/internal/graphql/schema.graphql | 16 +++ tavern/internal/graphql/schema/ent.graphql | 16 +++ tavern/internal/www/schema.graphql | 16 +++ 19 files changed, 625 insertions(+), 12 deletions(-) diff --git a/tavern/internal/ent/buildtask.go b/tavern/internal/ent/buildtask.go index 870132d81..e4592d4de 100644 --- a/tavern/internal/ent/buildtask.go +++ b/tavern/internal/ent/buildtask.go @@ -37,6 +37,8 @@ type BuildTask struct { FinishedAt time.Time `json:"finished_at,omitempty"` // Output from the build execution. Output string `json:"output,omitempty"` + // The size of the output in bytes + OutputSize int `json:"output_size,omitempty"` // Error message if the build failed. Error string `json:"error,omitempty"` // Edges holds the relations/edges for other nodes in the graph. @@ -75,7 +77,7 @@ func (*BuildTask) scanValues(columns []string) ([]any, error) { switch columns[i] { case buildtask.FieldTargetOs: values[i] = new(c2pb.Host_Platform) - case buildtask.FieldID: + case buildtask.FieldID, buildtask.FieldOutputSize: values[i] = new(sql.NullInt64) case buildtask.FieldBuildImage, buildtask.FieldBuildScript, buildtask.FieldOutput, buildtask.FieldError: values[i] = new(sql.NullString) @@ -158,6 +160,12 @@ func (bt *BuildTask) assignValues(columns []string, values []any) error { } else if value.Valid { bt.Output = value.String } + case buildtask.FieldOutputSize: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field output_size", values[i]) + } else if value.Valid { + bt.OutputSize = int(value.Int64) + } case buildtask.FieldError: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field error", values[i]) @@ -239,6 +247,9 @@ func (bt *BuildTask) String() string { builder.WriteString("output=") builder.WriteString(bt.Output) builder.WriteString(", ") + builder.WriteString("output_size=") + builder.WriteString(fmt.Sprintf("%v", bt.OutputSize)) + builder.WriteString(", ") builder.WriteString("error=") builder.WriteString(bt.Error) builder.WriteByte(')') diff --git a/tavern/internal/ent/buildtask/buildtask.go b/tavern/internal/ent/buildtask/buildtask.go index c1f064b77..64865b5c9 100644 --- a/tavern/internal/ent/buildtask/buildtask.go +++ b/tavern/internal/ent/buildtask/buildtask.go @@ -6,6 +6,7 @@ import ( "fmt" "time" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/99designs/gqlgen/graphql" @@ -35,6 +36,8 @@ const ( FieldFinishedAt = "finished_at" // FieldOutput holds the string denoting the output field in the database. FieldOutput = "output" + // FieldOutputSize holds the string denoting the output_size field in the database. + FieldOutputSize = "output_size" // FieldError holds the string denoting the error field in the database. FieldError = "error" // EdgeBuilder holds the string denoting the builder edge name in mutations. @@ -62,6 +65,7 @@ var Columns = []string{ FieldStartedAt, FieldFinishedAt, FieldOutput, + FieldOutputSize, FieldError, } @@ -86,7 +90,13 @@ func ValidColumn(column string) bool { return false } +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "realm.pub/tavern/internal/ent/runtime" var ( + Hooks [1]ent.Hook // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time // DefaultLastModifiedAt holds the default value on creation for the "last_modified_at" field. @@ -97,6 +107,10 @@ var ( BuildImageValidator func(string) error // BuildScriptValidator is a validator for the "build_script" field. It is called by the builders before save. BuildScriptValidator func(string) error + // DefaultOutputSize holds the default value on creation for the "output_size" field. + DefaultOutputSize int + // OutputSizeValidator is a validator for the "output_size" field. It is called by the builders before save. + OutputSizeValidator func(int) error ) // TargetOsValidator is a validator for the "target_os" field enum values. It is called by the builders before save. @@ -162,6 +176,11 @@ func ByOutput(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldOutput, opts...).ToFunc() } +// ByOutputSize orders the results by the output_size field. +func ByOutputSize(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOutputSize, opts...).ToFunc() +} + // ByError orders the results by the error field. func ByError(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldError, opts...).ToFunc() diff --git a/tavern/internal/ent/buildtask/where.go b/tavern/internal/ent/buildtask/where.go index 597121c12..e4a09ea1a 100644 --- a/tavern/internal/ent/buildtask/where.go +++ b/tavern/internal/ent/buildtask/where.go @@ -96,6 +96,11 @@ func Output(v string) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldOutput, v)) } +// OutputSize applies equality check predicate on the "output_size" field. It's identical to OutputSizeEQ. +func OutputSize(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldOutputSize, v)) +} + // Error applies equality check predicate on the "error" field. It's identical to ErrorEQ. func Error(v string) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldError, v)) @@ -556,6 +561,46 @@ func OutputContainsFold(v string) predicate.BuildTask { return predicate.BuildTask(sql.FieldContainsFold(FieldOutput, v)) } +// OutputSizeEQ applies the EQ predicate on the "output_size" field. +func OutputSizeEQ(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldOutputSize, v)) +} + +// OutputSizeNEQ applies the NEQ predicate on the "output_size" field. +func OutputSizeNEQ(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldOutputSize, v)) +} + +// OutputSizeIn applies the In predicate on the "output_size" field. +func OutputSizeIn(vs ...int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldOutputSize, vs...)) +} + +// OutputSizeNotIn applies the NotIn predicate on the "output_size" field. +func OutputSizeNotIn(vs ...int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldOutputSize, vs...)) +} + +// OutputSizeGT applies the GT predicate on the "output_size" field. +func OutputSizeGT(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldOutputSize, v)) +} + +// OutputSizeGTE applies the GTE predicate on the "output_size" field. +func OutputSizeGTE(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldOutputSize, v)) +} + +// OutputSizeLT applies the LT predicate on the "output_size" field. +func OutputSizeLT(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldOutputSize, v)) +} + +// OutputSizeLTE applies the LTE predicate on the "output_size" field. +func OutputSizeLTE(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldOutputSize, v)) +} + // ErrorEQ applies the EQ predicate on the "error" field. func ErrorEQ(v string) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldError, v)) diff --git a/tavern/internal/ent/buildtask_create.go b/tavern/internal/ent/buildtask_create.go index e2660cc1e..eed3ae246 100644 --- a/tavern/internal/ent/buildtask_create.go +++ b/tavern/internal/ent/buildtask_create.go @@ -126,6 +126,20 @@ func (btc *BuildTaskCreate) SetNillableOutput(s *string) *BuildTaskCreate { return btc } +// SetOutputSize sets the "output_size" field. +func (btc *BuildTaskCreate) SetOutputSize(i int) *BuildTaskCreate { + btc.mutation.SetOutputSize(i) + return btc +} + +// SetNillableOutputSize sets the "output_size" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableOutputSize(i *int) *BuildTaskCreate { + if i != nil { + btc.SetOutputSize(*i) + } + return btc +} + // SetError sets the "error" field. func (btc *BuildTaskCreate) SetError(s string) *BuildTaskCreate { btc.mutation.SetError(s) @@ -158,7 +172,9 @@ func (btc *BuildTaskCreate) Mutation() *BuildTaskMutation { // Save creates the BuildTask in the database. func (btc *BuildTaskCreate) Save(ctx context.Context) (*BuildTask, error) { - btc.defaults() + if err := btc.defaults(); err != nil { + return nil, err + } return withHooks(ctx, btc.sqlSave, btc.mutation, btc.hooks) } @@ -185,15 +201,26 @@ func (btc *BuildTaskCreate) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (btc *BuildTaskCreate) defaults() { +func (btc *BuildTaskCreate) defaults() error { if _, ok := btc.mutation.CreatedAt(); !ok { + if buildtask.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized buildtask.DefaultCreatedAt (forgotten import ent/runtime?)") + } v := buildtask.DefaultCreatedAt() btc.mutation.SetCreatedAt(v) } if _, ok := btc.mutation.LastModifiedAt(); !ok { + if buildtask.DefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized buildtask.DefaultLastModifiedAt (forgotten import ent/runtime?)") + } v := buildtask.DefaultLastModifiedAt() btc.mutation.SetLastModifiedAt(v) } + if _, ok := btc.mutation.OutputSize(); !ok { + v := buildtask.DefaultOutputSize + btc.mutation.SetOutputSize(v) + } + return nil } // check runs all checks and user-defined validators on the builder. @@ -228,6 +255,14 @@ func (btc *BuildTaskCreate) check() error { return &ValidationError{Name: "build_script", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_script": %w`, err)} } } + if _, ok := btc.mutation.OutputSize(); !ok { + return &ValidationError{Name: "output_size", err: errors.New(`ent: missing required field "BuildTask.output_size"`)} + } + if v, ok := btc.mutation.OutputSize(); ok { + if err := buildtask.OutputSizeValidator(v); err != nil { + return &ValidationError{Name: "output_size", err: fmt.Errorf(`ent: validator failed for field "BuildTask.output_size": %w`, err)} + } + } if len(btc.mutation.BuilderIDs()) == 0 { return &ValidationError{Name: "builder", err: errors.New(`ent: missing required edge "BuildTask.builder"`)} } @@ -294,6 +329,10 @@ func (btc *BuildTaskCreate) createSpec() (*BuildTask, *sqlgraph.CreateSpec) { _spec.SetField(buildtask.FieldOutput, field.TypeString, value) _node.Output = value } + if value, ok := btc.mutation.OutputSize(); ok { + _spec.SetField(buildtask.FieldOutputSize, field.TypeInt, value) + _node.OutputSize = value + } if value, ok := btc.mutation.Error(); ok { _spec.SetField(buildtask.FieldError, field.TypeString, value) _node.Error = value @@ -487,6 +526,24 @@ func (u *BuildTaskUpsert) ClearOutput() *BuildTaskUpsert { return u } +// SetOutputSize sets the "output_size" field. +func (u *BuildTaskUpsert) SetOutputSize(v int) *BuildTaskUpsert { + u.Set(buildtask.FieldOutputSize, v) + return u +} + +// UpdateOutputSize sets the "output_size" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateOutputSize() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldOutputSize) + return u +} + +// AddOutputSize adds v to the "output_size" field. +func (u *BuildTaskUpsert) AddOutputSize(v int) *BuildTaskUpsert { + u.Add(buildtask.FieldOutputSize, v) + return u +} + // SetError sets the "error" field. func (u *BuildTaskUpsert) SetError(v string) *BuildTaskUpsert { u.Set(buildtask.FieldError, v) @@ -690,6 +747,27 @@ func (u *BuildTaskUpsertOne) ClearOutput() *BuildTaskUpsertOne { }) } +// SetOutputSize sets the "output_size" field. +func (u *BuildTaskUpsertOne) SetOutputSize(v int) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetOutputSize(v) + }) +} + +// AddOutputSize adds v to the "output_size" field. +func (u *BuildTaskUpsertOne) AddOutputSize(v int) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.AddOutputSize(v) + }) +} + +// UpdateOutputSize sets the "output_size" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateOutputSize() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateOutputSize() + }) +} + // SetError sets the "error" field. func (u *BuildTaskUpsertOne) SetError(v string) *BuildTaskUpsertOne { return u.Update(func(s *BuildTaskUpsert) { @@ -1062,6 +1140,27 @@ func (u *BuildTaskUpsertBulk) ClearOutput() *BuildTaskUpsertBulk { }) } +// SetOutputSize sets the "output_size" field. +func (u *BuildTaskUpsertBulk) SetOutputSize(v int) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetOutputSize(v) + }) +} + +// AddOutputSize adds v to the "output_size" field. +func (u *BuildTaskUpsertBulk) AddOutputSize(v int) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.AddOutputSize(v) + }) +} + +// UpdateOutputSize sets the "output_size" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateOutputSize() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateOutputSize() + }) +} + // SetError sets the "error" field. func (u *BuildTaskUpsertBulk) SetError(v string) *BuildTaskUpsertBulk { return u.Update(func(s *BuildTaskUpsert) { diff --git a/tavern/internal/ent/buildtask_update.go b/tavern/internal/ent/buildtask_update.go index 7e466dffa..d2b4327c8 100644 --- a/tavern/internal/ent/buildtask_update.go +++ b/tavern/internal/ent/buildtask_update.go @@ -158,6 +158,27 @@ func (btu *BuildTaskUpdate) ClearOutput() *BuildTaskUpdate { return btu } +// SetOutputSize sets the "output_size" field. +func (btu *BuildTaskUpdate) SetOutputSize(i int) *BuildTaskUpdate { + btu.mutation.ResetOutputSize() + btu.mutation.SetOutputSize(i) + return btu +} + +// SetNillableOutputSize sets the "output_size" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableOutputSize(i *int) *BuildTaskUpdate { + if i != nil { + btu.SetOutputSize(*i) + } + return btu +} + +// AddOutputSize adds i to the "output_size" field. +func (btu *BuildTaskUpdate) AddOutputSize(i int) *BuildTaskUpdate { + btu.mutation.AddOutputSize(i) + return btu +} + // SetError sets the "error" field. func (btu *BuildTaskUpdate) SetError(s string) *BuildTaskUpdate { btu.mutation.SetError(s) @@ -202,7 +223,9 @@ func (btu *BuildTaskUpdate) ClearBuilder() *BuildTaskUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (btu *BuildTaskUpdate) Save(ctx context.Context) (int, error) { - btu.defaults() + if err := btu.defaults(); err != nil { + return 0, err + } return withHooks(ctx, btu.sqlSave, btu.mutation, btu.hooks) } @@ -229,11 +252,15 @@ func (btu *BuildTaskUpdate) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (btu *BuildTaskUpdate) defaults() { +func (btu *BuildTaskUpdate) defaults() error { if _, ok := btu.mutation.LastModifiedAt(); !ok { + if buildtask.UpdateDefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized buildtask.UpdateDefaultLastModifiedAt (forgotten import ent/runtime?)") + } v := buildtask.UpdateDefaultLastModifiedAt() btu.mutation.SetLastModifiedAt(v) } + return nil } // check runs all checks and user-defined validators on the builder. @@ -253,6 +280,11 @@ func (btu *BuildTaskUpdate) check() error { return &ValidationError{Name: "build_script", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_script": %w`, err)} } } + if v, ok := btu.mutation.OutputSize(); ok { + if err := buildtask.OutputSizeValidator(v); err != nil { + return &ValidationError{Name: "output_size", err: fmt.Errorf(`ent: validator failed for field "BuildTask.output_size": %w`, err)} + } + } if btu.mutation.BuilderCleared() && len(btu.mutation.BuilderIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "BuildTask.builder"`) } @@ -307,6 +339,12 @@ func (btu *BuildTaskUpdate) sqlSave(ctx context.Context) (n int, err error) { if btu.mutation.OutputCleared() { _spec.ClearField(buildtask.FieldOutput, field.TypeString) } + if value, ok := btu.mutation.OutputSize(); ok { + _spec.SetField(buildtask.FieldOutputSize, field.TypeInt, value) + } + if value, ok := btu.mutation.AddedOutputSize(); ok { + _spec.AddField(buildtask.FieldOutputSize, field.TypeInt, value) + } if value, ok := btu.mutation.Error(); ok { _spec.SetField(buildtask.FieldError, field.TypeString, value) } @@ -490,6 +528,27 @@ func (btuo *BuildTaskUpdateOne) ClearOutput() *BuildTaskUpdateOne { return btuo } +// SetOutputSize sets the "output_size" field. +func (btuo *BuildTaskUpdateOne) SetOutputSize(i int) *BuildTaskUpdateOne { + btuo.mutation.ResetOutputSize() + btuo.mutation.SetOutputSize(i) + return btuo +} + +// SetNillableOutputSize sets the "output_size" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableOutputSize(i *int) *BuildTaskUpdateOne { + if i != nil { + btuo.SetOutputSize(*i) + } + return btuo +} + +// AddOutputSize adds i to the "output_size" field. +func (btuo *BuildTaskUpdateOne) AddOutputSize(i int) *BuildTaskUpdateOne { + btuo.mutation.AddOutputSize(i) + return btuo +} + // SetError sets the "error" field. func (btuo *BuildTaskUpdateOne) SetError(s string) *BuildTaskUpdateOne { btuo.mutation.SetError(s) @@ -547,7 +606,9 @@ func (btuo *BuildTaskUpdateOne) Select(field string, fields ...string) *BuildTas // Save executes the query and returns the updated BuildTask entity. func (btuo *BuildTaskUpdateOne) Save(ctx context.Context) (*BuildTask, error) { - btuo.defaults() + if err := btuo.defaults(); err != nil { + return nil, err + } return withHooks(ctx, btuo.sqlSave, btuo.mutation, btuo.hooks) } @@ -574,11 +635,15 @@ func (btuo *BuildTaskUpdateOne) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (btuo *BuildTaskUpdateOne) defaults() { +func (btuo *BuildTaskUpdateOne) defaults() error { if _, ok := btuo.mutation.LastModifiedAt(); !ok { + if buildtask.UpdateDefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized buildtask.UpdateDefaultLastModifiedAt (forgotten import ent/runtime?)") + } v := buildtask.UpdateDefaultLastModifiedAt() btuo.mutation.SetLastModifiedAt(v) } + return nil } // check runs all checks and user-defined validators on the builder. @@ -598,6 +663,11 @@ func (btuo *BuildTaskUpdateOne) check() error { return &ValidationError{Name: "build_script", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_script": %w`, err)} } } + if v, ok := btuo.mutation.OutputSize(); ok { + if err := buildtask.OutputSizeValidator(v); err != nil { + return &ValidationError{Name: "output_size", err: fmt.Errorf(`ent: validator failed for field "BuildTask.output_size": %w`, err)} + } + } if btuo.mutation.BuilderCleared() && len(btuo.mutation.BuilderIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "BuildTask.builder"`) } @@ -669,6 +739,12 @@ func (btuo *BuildTaskUpdateOne) sqlSave(ctx context.Context) (_node *BuildTask, if btuo.mutation.OutputCleared() { _spec.ClearField(buildtask.FieldOutput, field.TypeString) } + if value, ok := btuo.mutation.OutputSize(); ok { + _spec.SetField(buildtask.FieldOutputSize, field.TypeInt, value) + } + if value, ok := btuo.mutation.AddedOutputSize(); ok { + _spec.AddField(buildtask.FieldOutputSize, field.TypeInt, value) + } if value, ok := btuo.mutation.Error(); ok { _spec.SetField(buildtask.FieldError, field.TypeString, value) } diff --git a/tavern/internal/ent/client.go b/tavern/internal/ent/client.go index 9473dfb61..d18289462 100644 --- a/tavern/internal/ent/client.go +++ b/tavern/internal/ent/client.go @@ -828,7 +828,8 @@ func (c *BuildTaskClient) QueryBuilder(bt *BuildTask) *BuilderQuery { // Hooks returns the client hooks. func (c *BuildTaskClient) Hooks() []Hook { - return c.hooks.BuildTask + hooks := c.hooks.BuildTask + return append(hooks[:len(hooks):len(hooks)], buildtask.Hooks[:]...) } // Interceptors returns the client interceptors. diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index e976f33ff..37b75099a 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -743,6 +743,11 @@ func (bt *BuildTaskQuery) collectField(ctx context.Context, oneNode bool, opCtx selectedFields = append(selectedFields, buildtask.FieldOutput) fieldSeen[buildtask.FieldOutput] = struct{}{} } + case "outputSize": + if _, ok := fieldSeen[buildtask.FieldOutputSize]; !ok { + selectedFields = append(selectedFields, buildtask.FieldOutputSize) + fieldSeen[buildtask.FieldOutputSize] = struct{}{} + } case "error": if _, ok := fieldSeen[buildtask.FieldError]; !ok { selectedFields = append(selectedFields, buildtask.FieldError) diff --git a/tavern/internal/ent/gql_pagination.go b/tavern/internal/ent/gql_pagination.go index 7cbd0179f..a8362e608 100644 --- a/tavern/internal/ent/gql_pagination.go +++ b/tavern/internal/ent/gql_pagination.go @@ -1233,6 +1233,20 @@ var ( } }, } + // BuildTaskOrderFieldOutputSize orders BuildTask by output_size. + BuildTaskOrderFieldOutputSize = &BuildTaskOrderField{ + Value: func(bt *BuildTask) (ent.Value, error) { + return bt.OutputSize, nil + }, + column: buildtask.FieldOutputSize, + toTerm: buildtask.ByOutputSize, + toCursor: func(bt *BuildTask) Cursor { + return Cursor{ + ID: bt.ID, + Value: bt.OutputSize, + } + }, + } ) // String implement fmt.Stringer interface. @@ -1251,6 +1265,8 @@ func (f BuildTaskOrderField) String() string { str = "STARTED_AT" case BuildTaskOrderFieldFinishedAt.column: str = "FINISHED_AT" + case BuildTaskOrderFieldOutputSize.column: + str = "OUTPUT_SIZE" } return str } @@ -1279,6 +1295,8 @@ func (f *BuildTaskOrderField) UnmarshalGQL(v interface{}) error { *f = *BuildTaskOrderFieldStartedAt case "FINISHED_AT": *f = *BuildTaskOrderFieldFinishedAt + case "OUTPUT_SIZE": + *f = *BuildTaskOrderFieldOutputSize default: return fmt.Errorf("%s is not a valid BuildTaskOrderField", str) } diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index 3b615794a..71903bc07 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -1189,6 +1189,16 @@ type BuildTaskWhereInput struct { OutputEqualFold *string `json:"outputEqualFold,omitempty"` OutputContainsFold *string `json:"outputContainsFold,omitempty"` + // "output_size" field predicates. + OutputSize *int `json:"outputSize,omitempty"` + OutputSizeNEQ *int `json:"outputSizeNEQ,omitempty"` + OutputSizeIn []int `json:"outputSizeIn,omitempty"` + OutputSizeNotIn []int `json:"outputSizeNotIn,omitempty"` + OutputSizeGT *int `json:"outputSizeGT,omitempty"` + OutputSizeGTE *int `json:"outputSizeGTE,omitempty"` + OutputSizeLT *int `json:"outputSizeLT,omitempty"` + OutputSizeLTE *int `json:"outputSizeLTE,omitempty"` + // "error" field predicates. Error *string `json:"error,omitempty"` ErrorNEQ *string `json:"errorNEQ,omitempty"` @@ -1579,6 +1589,30 @@ func (i *BuildTaskWhereInput) P() (predicate.BuildTask, error) { if i.OutputContainsFold != nil { predicates = append(predicates, buildtask.OutputContainsFold(*i.OutputContainsFold)) } + if i.OutputSize != nil { + predicates = append(predicates, buildtask.OutputSizeEQ(*i.OutputSize)) + } + if i.OutputSizeNEQ != nil { + predicates = append(predicates, buildtask.OutputSizeNEQ(*i.OutputSizeNEQ)) + } + if len(i.OutputSizeIn) > 0 { + predicates = append(predicates, buildtask.OutputSizeIn(i.OutputSizeIn...)) + } + if len(i.OutputSizeNotIn) > 0 { + predicates = append(predicates, buildtask.OutputSizeNotIn(i.OutputSizeNotIn...)) + } + if i.OutputSizeGT != nil { + predicates = append(predicates, buildtask.OutputSizeGT(*i.OutputSizeGT)) + } + if i.OutputSizeGTE != nil { + predicates = append(predicates, buildtask.OutputSizeGTE(*i.OutputSizeGTE)) + } + if i.OutputSizeLT != nil { + predicates = append(predicates, buildtask.OutputSizeLT(*i.OutputSizeLT)) + } + if i.OutputSizeLTE != nil { + predicates = append(predicates, buildtask.OutputSizeLTE(*i.OutputSizeLTE)) + } if i.Error != nil { predicates = append(predicates, buildtask.ErrorEQ(*i.Error)) } diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index 6b7c5c6ae..9582d40ad 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -75,6 +75,7 @@ var ( {Name: "started_at", Type: field.TypeTime, Nullable: true}, {Name: "finished_at", Type: field.TypeTime, Nullable: true}, {Name: "output", Type: field.TypeString, Nullable: true, Size: 2147483647, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, + {Name: "output_size", Type: field.TypeInt, Default: 0}, {Name: "error", Type: field.TypeString, Nullable: true, Size: 2147483647, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, {Name: "build_task_builder", Type: field.TypeInt}, } @@ -86,7 +87,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "build_tasks_builders_builder", - Columns: []*schema.Column{BuildTasksColumns[11]}, + Columns: []*schema.Column{BuildTasksColumns[12]}, RefColumns: []*schema.Column{BuildersColumns[0]}, OnDelete: schema.Cascade, }, diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index e1c551a60..3d4757b66 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -2125,6 +2125,8 @@ type BuildTaskMutation struct { started_at *time.Time finished_at *time.Time output *string + output_size *int + addoutput_size *int error *string clearedFields map[string]struct{} builder *int @@ -2608,6 +2610,62 @@ func (m *BuildTaskMutation) ResetOutput() { delete(m.clearedFields, buildtask.FieldOutput) } +// SetOutputSize sets the "output_size" field. +func (m *BuildTaskMutation) SetOutputSize(i int) { + m.output_size = &i + m.addoutput_size = nil +} + +// OutputSize returns the value of the "output_size" field in the mutation. +func (m *BuildTaskMutation) OutputSize() (r int, exists bool) { + v := m.output_size + if v == nil { + return + } + return *v, true +} + +// OldOutputSize returns the old "output_size" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldOutputSize(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOutputSize is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOutputSize requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOutputSize: %w", err) + } + return oldValue.OutputSize, nil +} + +// AddOutputSize adds i to the "output_size" field. +func (m *BuildTaskMutation) AddOutputSize(i int) { + if m.addoutput_size != nil { + *m.addoutput_size += i + } else { + m.addoutput_size = &i + } +} + +// AddedOutputSize returns the value that was added to the "output_size" field in this mutation. +func (m *BuildTaskMutation) AddedOutputSize() (r int, exists bool) { + v := m.addoutput_size + if v == nil { + return + } + return *v, true +} + +// ResetOutputSize resets all changes to the "output_size" field. +func (m *BuildTaskMutation) ResetOutputSize() { + m.output_size = nil + m.addoutput_size = nil +} + // SetError sets the "error" field. func (m *BuildTaskMutation) SetError(s string) { m.error = &s @@ -2730,7 +2788,7 @@ func (m *BuildTaskMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BuildTaskMutation) Fields() []string { - fields := make([]string, 0, 10) + fields := make([]string, 0, 11) if m.created_at != nil { fields = append(fields, buildtask.FieldCreatedAt) } @@ -2758,6 +2816,9 @@ func (m *BuildTaskMutation) Fields() []string { if m.output != nil { fields = append(fields, buildtask.FieldOutput) } + if m.output_size != nil { + fields = append(fields, buildtask.FieldOutputSize) + } if m.error != nil { fields = append(fields, buildtask.FieldError) } @@ -2787,6 +2848,8 @@ func (m *BuildTaskMutation) Field(name string) (ent.Value, bool) { return m.FinishedAt() case buildtask.FieldOutput: return m.Output() + case buildtask.FieldOutputSize: + return m.OutputSize() case buildtask.FieldError: return m.Error() } @@ -2816,6 +2879,8 @@ func (m *BuildTaskMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldFinishedAt(ctx) case buildtask.FieldOutput: return m.OldOutput(ctx) + case buildtask.FieldOutputSize: + return m.OldOutputSize(ctx) case buildtask.FieldError: return m.OldError(ctx) } @@ -2890,6 +2955,13 @@ func (m *BuildTaskMutation) SetField(name string, value ent.Value) error { } m.SetOutput(v) return nil + case buildtask.FieldOutputSize: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOutputSize(v) + return nil case buildtask.FieldError: v, ok := value.(string) if !ok { @@ -2904,13 +2976,21 @@ func (m *BuildTaskMutation) SetField(name string, value ent.Value) error { // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *BuildTaskMutation) AddedFields() []string { - return nil + var fields []string + if m.addoutput_size != nil { + fields = append(fields, buildtask.FieldOutputSize) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *BuildTaskMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case buildtask.FieldOutputSize: + return m.AddedOutputSize() + } return nil, false } @@ -2919,6 +2999,13 @@ func (m *BuildTaskMutation) AddedField(name string) (ent.Value, bool) { // type. func (m *BuildTaskMutation) AddField(name string, value ent.Value) error { switch name { + case buildtask.FieldOutputSize: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddOutputSize(v) + return nil } return fmt.Errorf("unknown BuildTask numeric field %s", name) } @@ -3006,6 +3093,9 @@ func (m *BuildTaskMutation) ResetField(name string) error { case buildtask.FieldOutput: m.ResetOutput() return nil + case buildtask.FieldOutputSize: + m.ResetOutputSize() + return nil case buildtask.FieldError: m.ResetError() return nil diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index 83ee281a7..33159771c 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -96,6 +96,8 @@ func init() { // beacon.AgentIdentifierValidator is a validator for the "agent_identifier" field. It is called by the builders before save. beacon.AgentIdentifierValidator = beaconDescAgentIdentifier.Validators[0].(func(string) error) buildtaskMixin := schema.BuildTask{}.Mixin() + buildtaskHooks := schema.BuildTask{}.Hooks() + buildtask.Hooks[0] = buildtaskHooks[0] buildtaskMixinFields0 := buildtaskMixin[0].Fields() _ = buildtaskMixinFields0 buildtaskFields := schema.BuildTask{}.Fields() @@ -118,6 +120,12 @@ func init() { buildtaskDescBuildScript := buildtaskFields[2].Descriptor() // buildtask.BuildScriptValidator is a validator for the "build_script" field. It is called by the builders before save. buildtask.BuildScriptValidator = buildtaskDescBuildScript.Validators[0].(func(string) error) + // buildtaskDescOutputSize is the schema descriptor for output_size field. + buildtaskDescOutputSize := buildtaskFields[7].Descriptor() + // buildtask.DefaultOutputSize holds the default value on creation for the output_size field. + buildtask.DefaultOutputSize = buildtaskDescOutputSize.Default.(int) + // buildtask.OutputSizeValidator is a validator for the "output_size" field. It is called by the builders before save. + buildtask.OutputSizeValidator = buildtaskDescOutputSize.Validators[0].(func(int) error) builderMixin := schema.Builder{}.Mixin() builderMixinFields0 := builderMixin[0].Fields() _ = builderMixinFields0 diff --git a/tavern/internal/ent/schema/build_task.go b/tavern/internal/ent/schema/build_task.go index be3d90f2a..652e54cde 100644 --- a/tavern/internal/ent/schema/build_task.go +++ b/tavern/internal/ent/schema/build_task.go @@ -1,6 +1,9 @@ package schema import ( + "context" + "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent" "entgo.io/ent/dialect" @@ -9,6 +12,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/hook" ) // BuildTask holds the schema definition for the BuildTask entity. @@ -59,6 +63,13 @@ func (BuildTask) Fields() []ent.Field { dialect.MySQL: "LONGTEXT", }). Comment("Output from the build execution."), + field.Int("output_size"). + Default(0). + Min(0). + Annotations( + entgql.OrderField("OUTPUT_SIZE"), + ). + Comment("The size of the output in bytes"), field.Text("error"). Optional(). SchemaType(map[string]string{ @@ -98,3 +109,32 @@ func (BuildTask) Mixin() []ent.Mixin { MixinHistory{}, // created_at, last_modified_at } } + +// Hooks defines middleware for mutations for the ent. +func (BuildTask) Hooks() []ent.Hook { + return []ent.Hook{ + hook.On(HookDeriveBuildTaskInfo(), ent.OpCreate|ent.OpUpdate|ent.OpUpdateOne), + } +} + +// HookDeriveBuildTaskInfo will update build task info (e.g. output_size) whenever it is mutated. +func HookDeriveBuildTaskInfo() ent.Hook { + type btMutation interface { + Output() (string, bool) + SetOutputSize(i int) + } + + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + bt, ok := m.(btMutation) + if !ok { + return nil, fmt.Errorf("expected build task mutation in schema hook, got: %+v", m) + } + + output, _ := bt.Output() + bt.SetOutputSize(len([]byte(output))) + + return next.Mutate(ctx, m) + }) + } +} diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index 9c03c0bf4..da17aacd6 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -2802,6 +2802,35 @@ func (ec *executionContext) fieldContext_BuildTask_output(_ context.Context, fie return fc, nil } +func (ec *executionContext) _BuildTask_outputSize(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_BuildTask_outputSize, + func(ctx context.Context) (any, error) { + return obj.OutputSize, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_BuildTask_outputSize(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuildTask", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _BuildTask_error(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -3023,6 +3052,8 @@ func (ec *executionContext) fieldContext_BuildTaskEdge_node(_ context.Context, f return ec.fieldContext_BuildTask_finishedAt(ctx, field) case "output": return ec.fieldContext_BuildTask_output(ctx, field) + case "outputSize": + return ec.fieldContext_BuildTask_outputSize(ctx, field) case "error": return ec.fieldContext_BuildTask_error(ctx, field) case "builder": @@ -13337,7 +13368,7 @@ func (ec *executionContext) unmarshalInputBuildTaskWhereInput(ctx context.Contex asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "targetOs", "targetOsNEQ", "targetOsIn", "targetOsNotIn", "buildImage", "buildImageNEQ", "buildImageIn", "buildImageNotIn", "buildImageGT", "buildImageGTE", "buildImageLT", "buildImageLTE", "buildImageContains", "buildImageHasPrefix", "buildImageHasSuffix", "buildImageEqualFold", "buildImageContainsFold", "buildScript", "buildScriptNEQ", "buildScriptIn", "buildScriptNotIn", "buildScriptGT", "buildScriptGTE", "buildScriptLT", "buildScriptLTE", "buildScriptContains", "buildScriptHasPrefix", "buildScriptHasSuffix", "buildScriptEqualFold", "buildScriptContainsFold", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "startedAt", "startedAtNEQ", "startedAtIn", "startedAtNotIn", "startedAtGT", "startedAtGTE", "startedAtLT", "startedAtLTE", "startedAtIsNil", "startedAtNotNil", "finishedAt", "finishedAtNEQ", "finishedAtIn", "finishedAtNotIn", "finishedAtGT", "finishedAtGTE", "finishedAtLT", "finishedAtLTE", "finishedAtIsNil", "finishedAtNotNil", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "hasBuilder", "hasBuilderWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "targetOs", "targetOsNEQ", "targetOsIn", "targetOsNotIn", "buildImage", "buildImageNEQ", "buildImageIn", "buildImageNotIn", "buildImageGT", "buildImageGTE", "buildImageLT", "buildImageLTE", "buildImageContains", "buildImageHasPrefix", "buildImageHasSuffix", "buildImageEqualFold", "buildImageContainsFold", "buildScript", "buildScriptNEQ", "buildScriptIn", "buildScriptNotIn", "buildScriptGT", "buildScriptGTE", "buildScriptLT", "buildScriptLTE", "buildScriptContains", "buildScriptHasPrefix", "buildScriptHasSuffix", "buildScriptEqualFold", "buildScriptContainsFold", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "startedAt", "startedAtNEQ", "startedAtIn", "startedAtNotIn", "startedAtGT", "startedAtGTE", "startedAtLT", "startedAtLTE", "startedAtIsNil", "startedAtNotNil", "finishedAt", "finishedAtNEQ", "finishedAtIn", "finishedAtNotIn", "finishedAtGT", "finishedAtGTE", "finishedAtLT", "finishedAtLTE", "finishedAtIsNil", "finishedAtNotNil", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "outputSize", "outputSizeNEQ", "outputSizeIn", "outputSizeNotIn", "outputSizeGT", "outputSizeGTE", "outputSizeLT", "outputSizeLTE", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "hasBuilder", "hasBuilderWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -14058,6 +14089,62 @@ func (ec *executionContext) unmarshalInputBuildTaskWhereInput(ctx context.Contex return it, err } it.OutputContainsFold = data + case "outputSize": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputSize")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.OutputSize = data + case "outputSizeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputSizeNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.OutputSizeNEQ = data + case "outputSizeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputSizeIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.OutputSizeIn = data + case "outputSizeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputSizeNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.OutputSizeNotIn = data + case "outputSizeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputSizeGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.OutputSizeGT = data + case "outputSizeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputSizeGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.OutputSizeGTE = data + case "outputSizeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputSizeLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.OutputSizeLT = data + case "outputSizeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("outputSizeLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.OutputSizeLTE = data case "error": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("error")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) @@ -24377,6 +24464,11 @@ func (ec *executionContext) _BuildTask(ctx context.Context, sel ast.SelectionSet out.Values[i] = ec._BuildTask_finishedAt(ctx, field, obj) case "output": out.Values[i] = ec._BuildTask_output(ctx, field, obj) + case "outputSize": + out.Values[i] = ec._BuildTask_outputSize(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "error": out.Values[i] = ec._BuildTask_error(ctx, field, obj) case "builder": diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index 37d6f6fe3..8c3574078 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -1647,6 +1647,8 @@ func (ec *executionContext) fieldContext_Mutation_createBuildTask(ctx context.Co return ec.fieldContext_BuildTask_finishedAt(ctx, field) case "output": return ec.fieldContext_BuildTask_output(ctx, field) + case "outputSize": + return ec.fieldContext_BuildTask_outputSize(ctx, field) case "error": return ec.fieldContext_BuildTask_error(ctx, field) case "builder": diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index ff866f5ce..01b8342e0 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -106,6 +106,7 @@ type ComplexityRoot struct { ID func(childComplexity int) int LastModifiedAt func(childComplexity int) int Output func(childComplexity int) int + OutputSize func(childComplexity int) int StartedAt func(childComplexity int) int TargetOs func(childComplexity int) int } @@ -852,6 +853,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.BuildTask.Output(childComplexity), true + case "BuildTask.outputSize": + if e.complexity.BuildTask.OutputSize == nil { + break + } + + return e.complexity.BuildTask.OutputSize(childComplexity), true + case "BuildTask.startedAt": if e.complexity.BuildTask.StartedAt == nil { break @@ -3701,6 +3709,10 @@ type BuildTask implements Node { """ output: String """ + The size of the output in bytes + """ + outputSize: Int! + """ Error message if the build failed. """ error: String @@ -3762,6 +3774,7 @@ enum BuildTaskOrderField { CLAIMED_AT STARTED_AT FINISHED_AT + OUTPUT_SIZE } """ BuildTaskWhereInput is used for filtering BuildTask objects. @@ -3901,6 +3914,17 @@ input BuildTaskWhereInput { outputEqualFold: String outputContainsFold: String """ + output_size field predicates + """ + outputSize: Int + outputSizeNEQ: Int + outputSizeIn: [Int!] + outputSizeNotIn: [Int!] + outputSizeGT: Int + outputSizeGTE: Int + outputSizeLT: Int + outputSizeLTE: Int + """ error field predicates """ error: String diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index 5e1c48c1e..f0d40fa1a 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -627,6 +627,10 @@ type BuildTask implements Node { """ output: String """ + The size of the output in bytes + """ + outputSize: Int! + """ Error message if the build failed. """ error: String @@ -688,6 +692,7 @@ enum BuildTaskOrderField { CLAIMED_AT STARTED_AT FINISHED_AT + OUTPUT_SIZE } """ BuildTaskWhereInput is used for filtering BuildTask objects. @@ -827,6 +832,17 @@ input BuildTaskWhereInput { outputEqualFold: String outputContainsFold: String """ + output_size field predicates + """ + outputSize: Int + outputSizeNEQ: Int + outputSizeIn: [Int!] + outputSizeNotIn: [Int!] + outputSizeGT: Int + outputSizeGTE: Int + outputSizeLT: Int + outputSizeLTE: Int + """ error field predicates """ error: String diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index f0bc83b1e..85f0b6ebe 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -622,6 +622,10 @@ type BuildTask implements Node { """ output: String """ + The size of the output in bytes + """ + outputSize: Int! + """ Error message if the build failed. """ error: String @@ -683,6 +687,7 @@ enum BuildTaskOrderField { CLAIMED_AT STARTED_AT FINISHED_AT + OUTPUT_SIZE } """ BuildTaskWhereInput is used for filtering BuildTask objects. @@ -822,6 +827,17 @@ input BuildTaskWhereInput { outputEqualFold: String outputContainsFold: String """ + output_size field predicates + """ + outputSize: Int + outputSizeNEQ: Int + outputSizeIn: [Int!] + outputSizeNotIn: [Int!] + outputSizeGT: Int + outputSizeGTE: Int + outputSizeLT: Int + outputSizeLTE: Int + """ error field predicates """ error: String diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index 5e1c48c1e..f0d40fa1a 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -627,6 +627,10 @@ type BuildTask implements Node { """ output: String """ + The size of the output in bytes + """ + outputSize: Int! + """ Error message if the build failed. """ error: String @@ -688,6 +692,7 @@ enum BuildTaskOrderField { CLAIMED_AT STARTED_AT FINISHED_AT + OUTPUT_SIZE } """ BuildTaskWhereInput is used for filtering BuildTask objects. @@ -827,6 +832,17 @@ input BuildTaskWhereInput { outputEqualFold: String outputContainsFold: String """ + output_size field predicates + """ + outputSize: Int + outputSizeNEQ: Int + outputSizeIn: [Int!] + outputSizeNotIn: [Int!] + outputSizeGT: Int + outputSizeGTE: Int + outputSizeLT: Int + outputSizeLTE: Int + """ error field predicates """ error: String From a9d54d9728ac0182a9bb2d7f1a4ae8d5ab6c88f9 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Wed, 11 Feb 2026 04:02:04 +0000 Subject: [PATCH 12/19] Concurrent builds, executor-owned channels, idempotent output submission - Run build tasks concurrently with a semaphore (max 4) instead of sequentially blocking the poll loop. Wait for in-flight builds on context cancellation. - Invert channel ownership: executor implementations now close both outputCh and errorCh before returning (sender closes). This follows standard Go channel conventions and prevents fragile caller-side close ordering. - Make SubmitBuildTaskOutput idempotent: if a task is already finished, return success without overwriting. Handles network retries safely. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- tavern/internal/builder/client.go | 29 ++++++++++++++----- tavern/internal/builder/executor/docker.go | 3 ++ .../internal/builder/executor/docker_test.go | 13 +-------- tavern/internal/builder/executor/executor.go | 7 +++-- tavern/internal/builder/executor/mock.go | 7 +++-- tavern/internal/builder/executor/mock_test.go | 16 ++++------ .../builder/executor_integration_test.go | 8 ++--- tavern/internal/builder/server.go | 11 ++++++- 8 files changed, 52 insertions(+), 42 deletions(-) diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index 12f9d08c8..322180bd8 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -8,6 +8,7 @@ import ( "fmt" "log/slog" "strings" + "sync" "time" "google.golang.org/grpc" @@ -21,6 +22,9 @@ import ( const ( // taskPollInterval is how often the builder polls for new build tasks. taskPollInterval = 5 * time.Second + + // maxConcurrentBuilds is the maximum number of builds that can run simultaneously. + maxConcurrentBuilds = 4 ) // builderCredentials implements grpc.PerRPCCredentials for mTLS authentication. @@ -133,8 +137,12 @@ func Run(ctx context.Context, cfg *Config, exec executor.Executor) error { slog.InfoContext(ctx, "successfully pinged upstream", "upstream", cfg.Upstream) + // Semaphore limits concurrent builds. + sem := make(chan struct{}, maxConcurrentBuilds) + var wg sync.WaitGroup + // Check for tasks immediately, then poll on interval - if err := claimAndExecuteTasks(ctx, client, exec); err != nil { + if err := claimAndExecuteTasks(ctx, client, exec, sem, &wg); err != nil { slog.ErrorContext(ctx, "error processing build tasks", "error", err) } @@ -144,16 +152,17 @@ func Run(ctx context.Context, cfg *Config, exec executor.Executor) error { for { select { case <-ctx.Done(): + wg.Wait() return ctx.Err() case <-ticker.C: - if err := claimAndExecuteTasks(ctx, client, exec); err != nil { + if err := claimAndExecuteTasks(ctx, client, exec, sem, &wg); err != nil { slog.ErrorContext(ctx, "error processing build tasks", "error", err) } } } } -func claimAndExecuteTasks(ctx context.Context, client builderpb.BuilderClient, exec executor.Executor) error { +func claimAndExecuteTasks(ctx context.Context, client builderpb.BuilderClient, exec executor.Executor, sem chan struct{}, wg *sync.WaitGroup) error { resp, err := client.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) if err != nil { return fmt.Errorf("failed to claim build tasks: %w", err) @@ -166,7 +175,14 @@ func claimAndExecuteTasks(ctx context.Context, client builderpb.BuilderClient, e "build_image", task.BuildImage, ) - executeTask(ctx, client, exec, task) + // Acquire semaphore slot (blocks if at max concurrency). + sem <- struct{}{} + wg.Add(1) + go func(t *builderpb.BuildTaskSpec) { + defer wg.Done() + defer func() { <-sem }() + executeTask(ctx, client, exec, t) + }(task) } return nil @@ -218,6 +234,7 @@ func executeTask(ctx context.Context, client builderpb.BuilderClient, exec execu }() // Run the build through the executor. + // The executor closes both channels when done. buildErr := exec.Build(ctx, executor.BuildSpec{ TaskID: task.Id, TargetOS: task.TargetOs, @@ -225,9 +242,7 @@ func executeTask(ctx context.Context, client builderpb.BuilderClient, exec execu BuildScript: task.BuildScript, }, outputCh, errorCh) - // Close channels to signal collector goroutine to finish. - close(outputCh) - close(errorCh) + // Wait for collector goroutine to drain remaining channel data. <-done // Build the submission request with collected output. diff --git a/tavern/internal/builder/executor/docker.go b/tavern/internal/builder/executor/docker.go index 0298d1a77..c054ac1ac 100644 --- a/tavern/internal/builder/executor/docker.go +++ b/tavern/internal/builder/executor/docker.go @@ -38,6 +38,9 @@ func NewDockerExecutorFromEnv(ctx context.Context) (*DockerExecutor, error) { // Build pulls the build image, starts a container with the build script as // the shell entrypoint, and streams output/error lines over the channels. func (d *DockerExecutor) Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + defer close(outputCh) + defer close(errorCh) + slog.InfoContext(ctx, "pulling docker image", "image", spec.BuildImage, "task_id", spec.TaskID) pullReader, err := d.client.ImagePull(ctx, spec.BuildImage, image.PullOptions{}) diff --git a/tavern/internal/builder/executor/docker_test.go b/tavern/internal/builder/executor/docker_test.go index f5b4e7c37..38a01517f 100644 --- a/tavern/internal/builder/executor/docker_test.go +++ b/tavern/internal/builder/executor/docker_test.go @@ -52,9 +52,6 @@ func TestDockerExecutor_Build_SimpleEcho(t *testing.T) { err := exec.Build(ctx, spec, outputCh, errorCh) require.NoError(t, err) - close(outputCh) - close(errorCh) - var output []string for line := range outputCh { output = append(output, line) @@ -82,9 +79,6 @@ func TestDockerExecutor_Build_MultiLineOutput(t *testing.T) { err := exec.Build(ctx, spec, outputCh, errorCh) require.NoError(t, err) - close(outputCh) - close(errorCh) - var output []string for line := range outputCh { output = append(output, line) @@ -112,9 +106,6 @@ func TestDockerExecutor_Build_StderrOutput(t *testing.T) { err := exec.Build(ctx, spec, outputCh, errorCh) require.NoError(t, err) - close(outputCh) - close(errorCh) - var output []string for line := range outputCh { output = append(output, line) @@ -149,7 +140,6 @@ func TestDockerExecutor_Build_NonZeroExit(t *testing.T) { require.Error(t, err) assert.Contains(t, err.Error(), "42") - close(outputCh) var output []string for line := range outputCh { output = append(output, line) @@ -217,8 +207,7 @@ func TestDockerExecutor_Build_StreamsOutputInRealTime(t *testing.T) { }() err := exec.Build(ctx, spec, outputCh, errorCh) - close(outputCh) - close(errorCh) + // Build closes outputCh, which unblocks the range loop in the goroutine. wg.Wait() require.NoError(t, err) diff --git a/tavern/internal/builder/executor/executor.go b/tavern/internal/builder/executor/executor.go index e0542f680..65da4814a 100644 --- a/tavern/internal/builder/executor/executor.go +++ b/tavern/internal/builder/executor/executor.go @@ -14,12 +14,13 @@ type BuildSpec struct { // Executor defines the interface for build task execution. // Implementations must stream output and errors over the provided channels -// as the build progresses. Both channels are closed by the caller after -// Build returns. +// as the build progresses. Implementations MUST close both outputCh and +// errorCh before returning, regardless of whether an error occurred. type Executor interface { // Build executes a build task described by spec. As the build runs, // stdout lines are sent to outputCh and stderr lines to errorCh. // Build blocks until the build completes (or the context is cancelled) - // and returns any execution error. + // and returns any execution error. Build must close both channels + // before returning. Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) error } diff --git a/tavern/internal/builder/executor/mock.go b/tavern/internal/builder/executor/mock.go index 266a226b1..dcaa9afd7 100644 --- a/tavern/internal/builder/executor/mock.go +++ b/tavern/internal/builder/executor/mock.go @@ -23,9 +23,12 @@ func NewMockExecutor() *MockExecutor { return &MockExecutor{} } -// Build implements Executor. It records the call and delegates to BuildFn -// if set, otherwise returns nil. +// Build implements Executor. It records the call, delegates to BuildFn +// if set, and closes both channels before returning. func (m *MockExecutor) Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + defer close(outputCh) + defer close(errorCh) + m.BuildCalls = append(m.BuildCalls, spec) if m.BuildFn != nil { return m.BuildFn(ctx, spec, outputCh, errorCh) diff --git a/tavern/internal/builder/executor/mock_test.go b/tavern/internal/builder/executor/mock_test.go index 121f35eca..3fc5b0ca1 100644 --- a/tavern/internal/builder/executor/mock_test.go +++ b/tavern/internal/builder/executor/mock_test.go @@ -39,8 +39,6 @@ func TestMockExecutor_DefaultBehavior(t *testing.T) { func TestMockExecutor_RecordsMultipleCalls(t *testing.T) { mock := executor.NewMockExecutor() - outputCh := make(chan string, 10) - errorCh := make(chan string, 10) specs := []executor.BuildSpec{ {TaskID: 1, BuildImage: "golang:1.21", BuildScript: "go build ./..."}, @@ -49,6 +47,8 @@ func TestMockExecutor_RecordsMultipleCalls(t *testing.T) { } for _, s := range specs { + outputCh := make(chan string, 10) + errorCh := make(chan string, 10) err := mock.Build(context.Background(), s, outputCh, errorCh) require.NoError(t, err) } @@ -74,9 +74,7 @@ func TestMockExecutor_CustomBuildFn_StreamsOutput(t *testing.T) { err := mock.Build(context.Background(), executor.BuildSpec{TaskID: 1}, outputCh, errorCh) require.NoError(t, err) - close(outputCh) - close(errorCh) - + // Channels are closed by Build; drain them. var output []string for line := range outputCh { output = append(output, line) @@ -101,9 +99,7 @@ func TestMockExecutor_CustomBuildFn_StreamsErrors(t *testing.T) { require.Error(t, err) assert.Contains(t, err.Error(), "build failed") - close(outputCh) - close(errorCh) - + // Channels are closed by Build; drain them. var output []string for line := range outputCh { output = append(output, line) @@ -169,9 +165,7 @@ func TestMockExecutor_CustomBuildFn_InterleavedOutputAndErrors(t *testing.T) { err := mock.Build(context.Background(), executor.BuildSpec{TaskID: 4}, outputCh, errorCh) require.NoError(t, err) - close(outputCh) - close(errorCh) - + // Channels are closed by Build; drain them. var output []string for line := range outputCh { output = append(output, line) diff --git a/tavern/internal/builder/executor_integration_test.go b/tavern/internal/builder/executor_integration_test.go index d61a9be31..788fda04f 100644 --- a/tavern/internal/builder/executor_integration_test.go +++ b/tavern/internal/builder/executor_integration_test.go @@ -143,9 +143,7 @@ func TestExecutorIntegration_ClaimAndExecuteWithMock(t *testing.T) { }, outputCh, errorCh) require.NoError(t, buildErr) - close(outputCh) - close(errorCh) - + // Channels are closed by Build; drain them. var outputLines []string for line := range outputCh { outputLines = append(outputLines, line) @@ -273,9 +271,7 @@ func TestExecutorIntegration_ClaimAndExecuteWithMockError(t *testing.T) { }, outputCh, errorCh) require.Error(t, buildErr) - close(outputCh) - close(errorCh) - + // Channels are closed by Build; drain them. var outputLines []string for line := range outputCh { outputLines = append(outputLines, line) diff --git a/tavern/internal/builder/server.go b/tavern/internal/builder/server.go index 23a8fe412..99beccd5e 100644 --- a/tavern/internal/builder/server.go +++ b/tavern/internal/builder/server.go @@ -135,7 +135,16 @@ func (s *Server) SubmitBuildTaskOutput(ctx context.Context, req *builderpb.Submi return nil, status.Errorf(codes.PermissionDenied, "build task %d is not assigned to this builder", req.TaskId) } - // 3. Update the build task with output and mark as finished + // 3. Idempotency: if the task is already finished, return success without modification + if !bt.FinishedAt.IsZero() { + slog.WarnContext(ctx, "duplicate build task output submission (already finished)", + "task_id", req.TaskId, + "builder_id", b.ID, + ) + return &builderpb.SubmitBuildTaskOutputResponse{}, nil + } + + // 4. Update the build task with output and mark as finished update := s.graph.BuildTask.UpdateOne(bt). SetFinishedAt(now). SetOutput(req.Output) From a558722c23c38897d520a939afa20bbadbb6dc30 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Wed, 11 Feb 2026 23:18:23 +0000 Subject: [PATCH 13/19] updates --- CLAUDE.md | 6 + tavern/app.go | 19 +- tavern/internal/builder/README.md | 80 +- tavern/internal/builder/auth.go | 157 +-- tavern/internal/builder/build_config.go | 158 +++ .../internal/builder/builderpb/builder.pb.go | 363 ++++--- .../builder/builderpb/builder_grpc.pb.go | 189 ++-- .../builder/builderpb/target_format.go | 89 ++ tavern/internal/builder/client.go | 178 ++-- tavern/internal/builder/executor/docker.go | 78 +- .../internal/builder/executor/docker_test.go | 12 +- tavern/internal/builder/executor/executor.go | 32 +- tavern/internal/builder/executor/mock.go | 8 +- tavern/internal/builder/executor/mock_test.go | 28 +- .../builder/executor_integration_test.go | 482 ++++++++- tavern/internal/builder/integration_test.go | 88 +- tavern/internal/builder/proto/builder.proto | 24 +- tavern/internal/builder/server.go | 287 +++++- tavern/internal/ent/buildtask.go | 127 ++- tavern/internal/ent/buildtask/buildtask.go | 123 +++ tavern/internal/ent/buildtask/where.go | 384 +++++++ tavern/internal/ent/buildtask_create.go | 543 ++++++++++ tavern/internal/ent/buildtask_query.go | 107 +- tavern/internal/ent/buildtask_update.go | 464 +++++++++ tavern/internal/ent/client.go | 16 + tavern/internal/ent/gql_collection.go | 46 + tavern/internal/ent/gql_edge.go | 8 + tavern/internal/ent/gql_pagination.go | 18 + tavern/internal/ent/gql_where_input.go | 305 ++++++ tavern/internal/ent/migrate/schema.go | 17 +- tavern/internal/ent/mutation.go | 550 +++++++++- tavern/internal/ent/runtime/runtime.go | 20 +- tavern/internal/ent/schema/build_task.go | 50 +- tavern/internal/graphql/build_task_test.go | 186 +++- .../graphql/generated/ent.generated.go | 961 +++++++++++++++++- .../graphql/generated/inputs.generated.go | 49 +- .../graphql/generated/mutation.generated.go | 16 + .../graphql/generated/root_.generated.go | 219 +++- tavern/internal/graphql/gqlgen.yml | 3 + .../internal/graphql/models/gqlgen_models.go | 15 +- tavern/internal/graphql/mutation.resolvers.go | 58 +- tavern/internal/graphql/schema.graphql | 155 ++- tavern/internal/graphql/schema/ent.graphql | 136 ++- tavern/internal/graphql/schema/inputs.graphql | 19 +- tavern/internal/www/schema.graphql | 155 ++- 45 files changed, 6441 insertions(+), 587 deletions(-) create mode 100644 tavern/internal/builder/build_config.go create mode 100644 tavern/internal/builder/builderpb/target_format.go diff --git a/CLAUDE.md b/CLAUDE.md index 6c6d7c9be..ffa9033e0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -79,6 +79,12 @@ cargo fmt 2. **Code Generation**: Run `go generate ./...` after modifying ent schemas, GraphQL, or frontend 3. **Rust Formatting**: Always run `cargo fmt` - CI will fail without it 4. **Linear History**: Use squash merge for PRs +5. **Generated Files**: Never manually edit generated files. Key generated files include: + - `tavern/internal/graphql/models/gqlgen_models.go` (generated by gqlgen) + - `tavern/internal/graphql/generated/*.go` (generated by gqlgen) + - `tavern/internal/ent/*.go` (generated by ent) + - `tavern/internal/builder/builderpb/*.pb.go` (generated by protoc) + - Run `go generate ./tavern/...` to regenerate after schema changes ## Documentation Structure diff --git a/tavern/app.go b/tavern/app.go index f2161869f..fdf190c0e 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -272,6 +272,14 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { return nil, fmt.Errorf("failed to initialize builder CA: %w", err) } + // Get server X25519 public key for agent builds + serverX25519PubKey, err := GetPubKey() + if err != nil { + client.Close() + return nil, fmt.Errorf("failed to get server X25519 public key: %w", err) + } + serverPubkeyB64 := base64.StdEncoding.EncodeToString(serverX25519PubKey.Bytes()) + // Initialize Test Data if cfg.IsTestDataEnabled() { createTestData(ctx, client) @@ -343,7 +351,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { Handler: newPortalGRPCHandler(client, portalMux), }, "/builder.Builder/": tavernhttp.Endpoint{ - Handler: newBuilderGRPCHandler(client, builderCACert), + Handler: newBuilderGRPCHandler(client, builderCACert, serverPubkeyB64), AllowUnauthenticated: true, AllowUnactivated: true, }, @@ -590,14 +598,17 @@ func newPortalGRPCHandler(graph *ent.Client, portalMux *mux.Mux) http.Handler { }) } -func newBuilderGRPCHandler(client *ent.Client, caCert *x509.Certificate) http.Handler { - builderSrv := builder.New(client) +func newBuilderGRPCHandler(client *ent.Client, caCert *x509.Certificate, serverPubkey string) http.Handler { + builderSrv := builder.New(client, serverPubkey) grpcSrv := grpc.NewServer( grpc.ChainUnaryInterceptor( builder.NewMTLSAuthInterceptor(caCert, client), grpcWithUnaryMetrics, ), - grpc.StreamInterceptor(grpcWithStreamMetrics), + grpc.ChainStreamInterceptor( + builder.NewMTLSStreamAuthInterceptor(caCert, client), + grpcWithStreamMetrics, + ), ) builderpb.RegisterBuilderServer(grpcSrv, builderSrv) return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/tavern/internal/builder/README.md b/tavern/internal/builder/README.md index 48049df22..356d2963f 100644 --- a/tavern/internal/builder/README.md +++ b/tavern/internal/builder/README.md @@ -6,7 +6,7 @@ The builder package orchestrates agent compilation for target platforms. It conn - **Registration**: Builders register with Tavern via the `registerBuilder` GraphQL mutation, which returns an mTLS certificate signed by the Tavern Builder CA and a YAML configuration file. - **mTLS Authentication**: All gRPC requests are authenticated using application-level mTLS. The builder presents its CA-signed certificate and a signed timestamp in gRPC metadata on each request. The server verifies the certificate chain, proof of private key possession, and looks up the builder by the identifier embedded in the certificate CN. -- **gRPC API**: Builders communicate with Tavern over gRPC at the `/builder.Builder/` route. Supports `Ping` (health check), `ClaimBuildTasks` (poll for unclaimed tasks), and `SubmitBuildTaskOutput` (report build results). +- **gRPC API**: Builders communicate with Tavern over gRPC at the `/builder.Builder/` route. Supports `Ping` (health check), `ClaimBuildTasks` (poll for unclaimed tasks), `StreamBuildTaskOutput` (stream build output incrementally), and `UploadBuildArtifact` (upload compiled binaries). - **Executor**: Build tasks are executed via the `executor.Executor` interface. The `DockerExecutor` runs builds inside Docker containers; the `MockExecutor` is used in tests. - **CLI**: Run a builder using the `builder` subcommand with a `--config` flag pointing to a YAML configuration file. @@ -55,23 +55,87 @@ upstream: go run ./tavern builder --config /path/to/builder-config.yaml ``` -## TODO +## Streaming Build Output + +The `StreamBuildTaskOutput` RPC uses client-streaming to send build output incrementally. +The builder sends one message per output/error line as the executor produces them, and each +message is flushed to the database immediately. The final message sets `finished=true` to +signal completion. The `started_at` timestamp is set when the first message is received. +If the stream is interrupted before `finished=true`, partial output is preserved but +`finished_at` is not set. + +## Artifact Extraction + +Build tasks can specify an `artifact_path` field — the path inside the container where the +compiled binary or output file is written. When the build finishes successfully, the +`DockerExecutor` copies the file from the stopped container using Docker's `CopyFromContainer` +API (which returns a tar archive), extracts the first regular file, and returns the bytes in +`BuildResult`. The builder client then streams the artifact to Tavern via the +`UploadBuildArtifact` RPC in 1 MB chunks. The server creates an `Asset` entity. +The artifact is downloadable via the existing CDN endpoint at `GET /assets/download/{name}`. + + +### Easy +- Add exitCode to the buildTask ent update executor and build client with build exitCode. +- Builder management + - Add a remove builder mutation + - Add Builder as a queryable type + - Add a last seen at field to builder ent that's updated on each `ClaimBuildTask` call +- Defaults + - Add default bulidImage: `spellshift/devcontainer:main` + - Add default target format: `BIN` + - 'buildImage' should be optional in the mutation and default to `spellshift/devcontainer:main` + - `artifactPath` should be an optional param to the createBuildTask mutation. + - `artifactPath` should default to the derived path only if no other path is specified. Use the same pattern as interval: + ``` + interval := builder.DefaultInterval + if input.Interval != nil { + interval = *input.Interval + } + ``` + + + +### Architectural +- Add a way for the server to interrupt and cancel a build. +- Add support for build caching between jobs (will speed up rust builds a lot) +- Instead of assuming `/home/vscode` create a correctly permissioned build dir +- Add support for mulitple transports in the builder + + +### future +- Register redirectors so bulider callback uri can be a drop down. +- Modifying the agent IMIX_CONFIG currently requires changes to both imix and tavern code bases now. Is there a way to codegen a YAML spec from tavern to the agent? +- De-dupe agent builds should the API stop builds that have the same params and point to the existing build? Or is this a UI thing? + + +### Planning +- Where should realm source code be pulled? + - which version'd copy of the code to checkout + - Can we automatically determine which version / main,edge the server is and pass that ot the build script. + - Ship tavern with imix source code embedded? + - Hard for teams to bring their own changes. + +- Update schema for UX + - Target OS + Target Format ---> rust target + - TargetOS's only support certain formats + - where to get the realm source code from - pull public repo? + - Currentt pattern with arbitrary bulid script is RCE as a service. Scope and limit this to just build configuration options. + - upstream should be free form + - pubkey can be set by the server -- Add support for concurrent builds -- Test client to server output streaming -- Update `SubmitBuildTaskOutput` to use gRPC streaming ## Package Structure | File | Purpose | |------|---------| -| `auth.go` | gRPC unary interceptor for mTLS authentication | +| `auth.go` | gRPC unary and stream interceptors for mTLS authentication | | `ca.go` | Builder CA generation, persistence, and certificate signing | | `client.go` | Builder client: mTLS credentials, polling loop, task execution | | `config.go` | YAML configuration parsing and validation | -| `server.go` | gRPC server: `Ping`, `ClaimBuildTasks`, `SubmitBuildTaskOutput` | +| `server.go` | gRPC server: `Ping`, `ClaimBuildTasks`, `StreamBuildTaskOutput`, `UploadBuildArtifact` | | `rollback.go` | Transaction rollback helper (matches c2 pattern) | -| `executor/executor.go` | `Executor` interface and `BuildSpec` definition | +| `executor/executor.go` | `Executor` interface, `BuildSpec`, and `BuildResult` definitions | | `executor/docker.go` | `DockerExecutor`: runs builds in Docker containers | | `executor/mock.go` | `MockExecutor`: test double for unit tests | | `proto/builder.proto` | Protobuf service definition | diff --git a/tavern/internal/builder/auth.go b/tavern/internal/builder/auth.go index eb85a6a6a..9059bd467 100644 --- a/tavern/internal/builder/auth.go +++ b/tavern/internal/builder/auth.go @@ -39,6 +39,79 @@ func BuilderFromContext(ctx context.Context) (*ent.Builder, bool) { return b, ok } +// authenticateBuilder extracts and validates mTLS credentials from gRPC metadata, +// returning a context enriched with the authenticated builder entity. +func authenticateBuilder(ctx context.Context, caCert *x509.Certificate, graph *ent.Client) (context.Context, error) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return nil, status.Error(codes.Unauthenticated, "missing metadata") + } + + // Extract metadata values. + // Binary metadata (keys ending in "-bin") is automatically base64 decoded by gRPC. + certDER := getMetadataValue(md, mdKeyBuilderCert) + signature := getMetadataValue(md, mdKeyBuilderSignature) + timestamp := getMetadataValue(md, mdKeyBuilderTimestamp) + + if certDER == "" || signature == "" || timestamp == "" { + return nil, status.Error(codes.Unauthenticated, "missing builder credentials") + } + + // Parse the certificate + cert, err := x509.ParseCertificate([]byte(certDER)) + if err != nil { + return nil, status.Error(codes.Unauthenticated, "invalid certificate") + } + + // Verify certificate was signed by our CA + if err := cert.CheckSignatureFrom(caCert); err != nil { + return nil, status.Error(codes.Unauthenticated, "certificate not signed by trusted CA") + } + + // Verify certificate validity period + now := time.Now() + if now.Before(cert.NotBefore) || now.After(cert.NotAfter) { + return nil, status.Error(codes.Unauthenticated, "certificate expired or not yet valid") + } + + // Verify timestamp freshness + ts, err := time.Parse(time.RFC3339Nano, timestamp) + if err != nil { + return nil, status.Error(codes.Unauthenticated, "invalid timestamp format") + } + if now.Sub(ts).Abs() > maxTimestampAge { + return nil, status.Error(codes.Unauthenticated, "timestamp too old or too far in the future") + } + + // Verify signature (proof of private key possession) + pubKey, ok := cert.PublicKey.(ed25519.PublicKey) + if !ok { + return nil, status.Error(codes.Unauthenticated, "certificate does not contain ED25519 public key") + } + if !ed25519.Verify(pubKey, []byte(timestamp), []byte(signature)) { + return nil, status.Error(codes.Unauthenticated, "invalid signature") + } + + // Extract builder identifier from CN + cn := cert.Subject.CommonName + if !strings.HasPrefix(cn, builderCNPrefix) { + return nil, status.Error(codes.Unauthenticated, "invalid certificate CN format") + } + identifier := strings.TrimPrefix(cn, builderCNPrefix) + + // Look up builder in database + b, err := graph.Builder.Query().Where(entbuilder.IdentifierEQ(identifier)).Only(ctx) + if err != nil { + slog.WarnContext(ctx, "builder authentication failed: builder not found", "identifier", identifier, "error", err) + return nil, status.Error(codes.Unauthenticated, "builder not found") + } + + slog.InfoContext(ctx, "builder authenticated", "builder_id", b.ID, "identifier", identifier) + + // Store builder in context for downstream handlers + return context.WithValue(ctx, builderContextKey{}, b), nil +} + // NewMTLSAuthInterceptor creates a gRPC unary server interceptor that validates // builder mTLS credentials. It verifies: // 1. The certificate was signed by the provided CA @@ -47,76 +120,34 @@ func BuilderFromContext(ctx context.Context) (*ent.Builder, bool) { // 4. The builder identifier from the CN exists in the database func NewMTLSAuthInterceptor(caCert *x509.Certificate, graph *ent.Client) grpc.UnaryServerInterceptor { return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { - md, ok := metadata.FromIncomingContext(ctx) - if !ok { - return nil, status.Error(codes.Unauthenticated, "missing metadata") - } - - // Extract metadata values. - // Binary metadata (keys ending in "-bin") is automatically base64 decoded by gRPC. - certDER := getMetadataValue(md, mdKeyBuilderCert) - signature := getMetadataValue(md, mdKeyBuilderSignature) - timestamp := getMetadataValue(md, mdKeyBuilderTimestamp) - - if certDER == "" || signature == "" || timestamp == "" { - return nil, status.Error(codes.Unauthenticated, "missing builder credentials") - } - - // Parse the certificate - cert, err := x509.ParseCertificate([]byte(certDER)) - if err != nil { - return nil, status.Error(codes.Unauthenticated, "invalid certificate") - } - - // Verify certificate was signed by our CA - if err := cert.CheckSignatureFrom(caCert); err != nil { - return nil, status.Error(codes.Unauthenticated, "certificate not signed by trusted CA") - } - - // Verify certificate validity period - now := time.Now() - if now.Before(cert.NotBefore) || now.After(cert.NotAfter) { - return nil, status.Error(codes.Unauthenticated, "certificate expired or not yet valid") - } - - // Verify timestamp freshness - ts, err := time.Parse(time.RFC3339Nano, timestamp) + authCtx, err := authenticateBuilder(ctx, caCert, graph) if err != nil { - return nil, status.Error(codes.Unauthenticated, "invalid timestamp format") + return nil, err } - if now.Sub(ts).Abs() > maxTimestampAge { - return nil, status.Error(codes.Unauthenticated, "timestamp too old or too far in the future") - } - - // Verify signature (proof of private key possession) - pubKey, ok := cert.PublicKey.(ed25519.PublicKey) - if !ok { - return nil, status.Error(codes.Unauthenticated, "certificate does not contain ED25519 public key") - } - if !ed25519.Verify(pubKey, []byte(timestamp), []byte(signature)) { - return nil, status.Error(codes.Unauthenticated, "invalid signature") - } - - // Extract builder identifier from CN - cn := cert.Subject.CommonName - if !strings.HasPrefix(cn, builderCNPrefix) { - return nil, status.Error(codes.Unauthenticated, "invalid certificate CN format") - } - identifier := strings.TrimPrefix(cn, builderCNPrefix) + return handler(authCtx, req) + } +} - // Look up builder in database - b, err := graph.Builder.Query().Where(entbuilder.IdentifierEQ(identifier)).Only(ctx) +// NewMTLSStreamAuthInterceptor creates a gRPC stream server interceptor that validates +// builder mTLS credentials. It uses the same authentication logic as the unary interceptor. +func NewMTLSStreamAuthInterceptor(caCert *x509.Certificate, graph *ent.Client) grpc.StreamServerInterceptor { + return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + authCtx, err := authenticateBuilder(ss.Context(), caCert, graph) if err != nil { - slog.WarnContext(ctx, "builder authentication failed: builder not found", "identifier", identifier, "error", err) - return nil, status.Error(codes.Unauthenticated, "builder not found") + return err } + return handler(srv, &wrappedServerStream{ServerStream: ss, ctx: authCtx}) + } +} - slog.InfoContext(ctx, "builder authenticated", "builder_id", b.ID, "identifier", identifier) +// wrappedServerStream wraps a grpc.ServerStream to override its Context(). +type wrappedServerStream struct { + grpc.ServerStream + ctx context.Context +} - // Store builder in context for downstream handlers - ctx = context.WithValue(ctx, builderContextKey{}, b) - return handler(ctx, req) - } +func (w *wrappedServerStream) Context() context.Context { + return w.ctx } func getMetadataValue(md metadata.MD, key string) string { diff --git a/tavern/internal/builder/build_config.go b/tavern/internal/builder/build_config.go new file mode 100644 index 000000000..37ae682b4 --- /dev/null +++ b/tavern/internal/builder/build_config.go @@ -0,0 +1,158 @@ +package builder + +import ( + "fmt" + "strings" + + yaml "gopkg.in/yaml.v3" + "realm.pub/tavern/internal/builder/builderpb" + "realm.pub/tavern/internal/c2/c2pb" +) + +const ( + // RealmRepoURL is the default git repository URL for building realm agents. + RealmRepoURL = "https://github.com/spellshift/realm.git" + + // DefaultInterval is re-exported from builderpb for convenience. + DefaultInterval = builderpb.DefaultInterval + + // DefaultCallbackURI is the default callback URI for the IMIX agent, + // derived from the IMIX compile-time default (IMIX_CALLBACK_URI). + DefaultCallbackURI = "http://127.0.0.1:8000" + + // DefaultTransportType is the default transport type for the IMIX agent, + // derived from the IMIX default behavior for http:// URIs. + DefaultTransportType = c2pb.Transport_TRANSPORT_GRPC +) + +// TargetFormat is an alias for builderpb.TargetFormat. +type TargetFormat = builderpb.TargetFormat + +const ( + TargetFormatBin = builderpb.TargetFormatBin + TargetFormatCdylib = builderpb.TargetFormatCdylib + TargetFormatWindowsService = builderpb.TargetFormatWindowsService +) + +// SupportedFormats maps each target OS to its supported output formats. +var SupportedFormats = map[c2pb.Host_Platform][]TargetFormat{ + c2pb.Host_PLATFORM_LINUX: {TargetFormatBin}, + c2pb.Host_PLATFORM_WINDOWS: {TargetFormatBin, TargetFormatCdylib, TargetFormatWindowsService}, + c2pb.Host_PLATFORM_MACOS: {TargetFormatBin}, +} + +// buildTarget maps target OS to the Rust --target triple. +var buildTarget = map[c2pb.Host_Platform]string{ + c2pb.Host_PLATFORM_LINUX: "x86_64-unknown-linux-musl", + c2pb.Host_PLATFORM_WINDOWS: "x86_64-pc-windows-gnu", + c2pb.Host_PLATFORM_MACOS: "aarch64-apple-darwin", +} + +type buildKey struct { + OS c2pb.Host_Platform + Format TargetFormat +} + +// buildCommands maps (target_os, target_format) -> cargo build command. +var buildCommands = map[buildKey]string{ + {c2pb.Host_PLATFORM_LINUX, TargetFormatBin}: "cargo build --release --bin imix --target=x86_64-unknown-linux-musl", + {c2pb.Host_PLATFORM_MACOS, TargetFormatBin}: "cargo zigbuild --release --target aarch64-apple-darwin", + {c2pb.Host_PLATFORM_WINDOWS, TargetFormatBin}: "cargo build --release --target=x86_64-pc-windows-gnu", + {c2pb.Host_PLATFORM_WINDOWS, TargetFormatWindowsService}: "cargo build --release --features win_service --target=x86_64-pc-windows-gnu", + {c2pb.Host_PLATFORM_WINDOWS, TargetFormatCdylib}: "cargo build --release --lib --target=x86_64-pc-windows-gnu", +} + +// ValidateTargetFormat checks whether the given format is supported for the given OS. +func ValidateTargetFormat(os c2pb.Host_Platform, format TargetFormat) error { + formats, ok := SupportedFormats[os] + if !ok { + return fmt.Errorf("unsupported target OS: %s", os.String()) + } + for _, f := range formats { + if f == format { + return nil + } + } + supported := make([]string, len(formats)) + for i, f := range formats { + supported[i] = string(f) + } + return fmt.Errorf("target format %q is not supported for %s (supported: %s)", format, os.String(), strings.Join(supported, ", ")) +} + +// BuildCommand returns the cargo build command for the given OS and format. +func BuildCommand(os c2pb.Host_Platform, format TargetFormat) (string, error) { + cmd, ok := buildCommands[buildKey{os, format}] + if !ok { + return "", fmt.Errorf("no build command for %s + %s", os.String(), format) + } + return cmd, nil +} + +// TransportTypeToString converts a c2pb.Transport_Type to the lowercase string +// used in the IMIX agent configuration YAML. +func TransportTypeToString(t c2pb.Transport_Type) string { + switch t { + case c2pb.Transport_TRANSPORT_GRPC: + return "grpc" + case c2pb.Transport_TRANSPORT_HTTP1: + return "http" + case c2pb.Transport_TRANSPORT_DNS: + return "dns" + default: + return "unspecified" + } +} + +// ImixTransportConfig represents the transport section of the IMIX configuration. +type ImixTransportConfig struct { + URI string `yaml:"URI"` + Interval int `yaml:"interval"` + Type string `yaml:"type"` + Extra string `yaml:"extra"` +} + +// ImixConfig represents the IMIX agent configuration YAML. +type ImixConfig struct { + ServerPubkey string `yaml:"server_pubkey"` + Transports []ImixTransportConfig `yaml:"transports"` +} + +// DeriveArtifactPath returns the artifact path inside the build container +// based on the target OS. +func DeriveArtifactPath(os c2pb.Host_Platform) string { + target, ok := buildTarget[os] + if !ok { + return "/home/vscode/realm/implants/target/release/imix" + } + return fmt.Sprintf("/home/vscode/realm/implants/target/%s/release/imix", target) +} + +// MarshalImixConfig serializes the ImixConfig to a YAML string suitable +// for passing as the IMIX_CONFIG environment variable. +func MarshalImixConfig(cfg ImixConfig) (string, error) { + cfgBytes, err := yaml.Marshal(cfg) + if err != nil { + return "", fmt.Errorf("failed to marshal IMIX config: %w", err) + } + return string(cfgBytes), nil +} + +// GenerateBuildScript generates the full build script from the build configuration. +// It clones the repository and runs the build command. The IMIX configuration +// is passed via the IMIX_CONFIG environment variable rather than being written +// to a file in the build script. +func GenerateBuildScript(os c2pb.Host_Platform, format TargetFormat) (string, error) { + buildCmd, err := BuildCommand(os, format) + if err != nil { + return "", err + } + + script := fmt.Sprintf( + `cd /home/vscode && git clone %s realm && cd realm/implants/imix && %s`, + RealmRepoURL, + buildCmd, + ) + + return script, nil +} diff --git a/tavern/internal/builder/builderpb/builder.pb.go b/tavern/internal/builder/builderpb/builder.pb.go index 25b650204..227fad4bd 100644 --- a/tavern/internal/builder/builderpb/builder.pb.go +++ b/tavern/internal/builder/builderpb/builder.pb.go @@ -21,26 +21,26 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type PingRequest struct { +type ClaimBuildTasksRequest struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *PingRequest) Reset() { - *x = PingRequest{} +func (x *ClaimBuildTasksRequest) Reset() { + *x = ClaimBuildTasksRequest{} mi := &file_builder_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *PingRequest) String() string { +func (x *ClaimBuildTasksRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*PingRequest) ProtoMessage() {} +func (*ClaimBuildTasksRequest) ProtoMessage() {} -func (x *PingRequest) ProtoReflect() protoreflect.Message { +func (x *ClaimBuildTasksRequest) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -52,31 +52,37 @@ func (x *PingRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use PingRequest.ProtoReflect.Descriptor instead. -func (*PingRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use ClaimBuildTasksRequest.ProtoReflect.Descriptor instead. +func (*ClaimBuildTasksRequest) Descriptor() ([]byte, []int) { return file_builder_proto_rawDescGZIP(), []int{0} } -type PingResponse struct { +type BuildTaskSpec struct { state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + TargetOs string `protobuf:"bytes,2,opt,name=target_os,json=targetOs,proto3" json:"target_os,omitempty"` + BuildImage string `protobuf:"bytes,3,opt,name=build_image,json=buildImage,proto3" json:"build_image,omitempty"` + BuildScript string `protobuf:"bytes,4,opt,name=build_script,json=buildScript,proto3" json:"build_script,omitempty"` + ArtifactPath string `protobuf:"bytes,6,opt,name=artifact_path,json=artifactPath,proto3" json:"artifact_path,omitempty"` + Env []string `protobuf:"bytes,7,rep,name=env,proto3" json:"env,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *PingResponse) Reset() { - *x = PingResponse{} +func (x *BuildTaskSpec) Reset() { + *x = BuildTaskSpec{} mi := &file_builder_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *PingResponse) String() string { +func (x *BuildTaskSpec) String() string { return protoimpl.X.MessageStringOf(x) } -func (*PingResponse) ProtoMessage() {} +func (*BuildTaskSpec) ProtoMessage() {} -func (x *PingResponse) ProtoReflect() protoreflect.Message { +func (x *BuildTaskSpec) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -88,31 +94,74 @@ func (x *PingResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use PingResponse.ProtoReflect.Descriptor instead. -func (*PingResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use BuildTaskSpec.ProtoReflect.Descriptor instead. +func (*BuildTaskSpec) Descriptor() ([]byte, []int) { return file_builder_proto_rawDescGZIP(), []int{1} } -type ClaimBuildTasksRequest struct { +func (x *BuildTaskSpec) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *BuildTaskSpec) GetTargetOs() string { + if x != nil { + return x.TargetOs + } + return "" +} + +func (x *BuildTaskSpec) GetBuildImage() string { + if x != nil { + return x.BuildImage + } + return "" +} + +func (x *BuildTaskSpec) GetBuildScript() string { + if x != nil { + return x.BuildScript + } + return "" +} + +func (x *BuildTaskSpec) GetArtifactPath() string { + if x != nil { + return x.ArtifactPath + } + return "" +} + +func (x *BuildTaskSpec) GetEnv() []string { + if x != nil { + return x.Env + } + return nil +} + +type ClaimBuildTasksResponse struct { state protoimpl.MessageState `protogen:"open.v1"` + Tasks []*BuildTaskSpec `protobuf:"bytes,1,rep,name=tasks,proto3" json:"tasks,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *ClaimBuildTasksRequest) Reset() { - *x = ClaimBuildTasksRequest{} +func (x *ClaimBuildTasksResponse) Reset() { + *x = ClaimBuildTasksResponse{} mi := &file_builder_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *ClaimBuildTasksRequest) String() string { +func (x *ClaimBuildTasksResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ClaimBuildTasksRequest) ProtoMessage() {} +func (*ClaimBuildTasksResponse) ProtoMessage() {} -func (x *ClaimBuildTasksRequest) ProtoReflect() protoreflect.Message { +func (x *ClaimBuildTasksResponse) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -124,35 +173,42 @@ func (x *ClaimBuildTasksRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ClaimBuildTasksRequest.ProtoReflect.Descriptor instead. -func (*ClaimBuildTasksRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use ClaimBuildTasksResponse.ProtoReflect.Descriptor instead. +func (*ClaimBuildTasksResponse) Descriptor() ([]byte, []int) { return file_builder_proto_rawDescGZIP(), []int{2} } -type BuildTaskSpec struct { +func (x *ClaimBuildTasksResponse) GetTasks() []*BuildTaskSpec { + if x != nil { + return x.Tasks + } + return nil +} + +type StreamBuildTaskOutputRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - TargetOs string `protobuf:"bytes,2,opt,name=target_os,json=targetOs,proto3" json:"target_os,omitempty"` - BuildImage string `protobuf:"bytes,3,opt,name=build_image,json=buildImage,proto3" json:"build_image,omitempty"` - BuildScript string `protobuf:"bytes,4,opt,name=build_script,json=buildScript,proto3" json:"build_script,omitempty"` + TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` + Output string `protobuf:"bytes,2,opt,name=output,proto3" json:"output,omitempty"` + Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` + Finished bool `protobuf:"varint,4,opt,name=finished,proto3" json:"finished,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *BuildTaskSpec) Reset() { - *x = BuildTaskSpec{} +func (x *StreamBuildTaskOutputRequest) Reset() { + *x = StreamBuildTaskOutputRequest{} mi := &file_builder_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *BuildTaskSpec) String() string { +func (x *StreamBuildTaskOutputRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*BuildTaskSpec) ProtoMessage() {} +func (*StreamBuildTaskOutputRequest) ProtoMessage() {} -func (x *BuildTaskSpec) ProtoReflect() protoreflect.Message { +func (x *StreamBuildTaskOutputRequest) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -164,60 +220,59 @@ func (x *BuildTaskSpec) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use BuildTaskSpec.ProtoReflect.Descriptor instead. -func (*BuildTaskSpec) Descriptor() ([]byte, []int) { +// Deprecated: Use StreamBuildTaskOutputRequest.ProtoReflect.Descriptor instead. +func (*StreamBuildTaskOutputRequest) Descriptor() ([]byte, []int) { return file_builder_proto_rawDescGZIP(), []int{3} } -func (x *BuildTaskSpec) GetId() int64 { +func (x *StreamBuildTaskOutputRequest) GetTaskId() int64 { if x != nil { - return x.Id + return x.TaskId } return 0 } -func (x *BuildTaskSpec) GetTargetOs() string { +func (x *StreamBuildTaskOutputRequest) GetOutput() string { if x != nil { - return x.TargetOs + return x.Output } return "" } -func (x *BuildTaskSpec) GetBuildImage() string { +func (x *StreamBuildTaskOutputRequest) GetError() string { if x != nil { - return x.BuildImage + return x.Error } return "" } -func (x *BuildTaskSpec) GetBuildScript() string { +func (x *StreamBuildTaskOutputRequest) GetFinished() bool { if x != nil { - return x.BuildScript + return x.Finished } - return "" + return false } -type ClaimBuildTasksResponse struct { +type StreamBuildTaskOutputResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Tasks []*BuildTaskSpec `protobuf:"bytes,1,rep,name=tasks,proto3" json:"tasks,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *ClaimBuildTasksResponse) Reset() { - *x = ClaimBuildTasksResponse{} +func (x *StreamBuildTaskOutputResponse) Reset() { + *x = StreamBuildTaskOutputResponse{} mi := &file_builder_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *ClaimBuildTasksResponse) String() string { +func (x *StreamBuildTaskOutputResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ClaimBuildTasksResponse) ProtoMessage() {} +func (*StreamBuildTaskOutputResponse) ProtoMessage() {} -func (x *ClaimBuildTasksResponse) ProtoReflect() protoreflect.Message { +func (x *StreamBuildTaskOutputResponse) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -229,41 +284,34 @@ func (x *ClaimBuildTasksResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ClaimBuildTasksResponse.ProtoReflect.Descriptor instead. -func (*ClaimBuildTasksResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use StreamBuildTaskOutputResponse.ProtoReflect.Descriptor instead. +func (*StreamBuildTaskOutputResponse) Descriptor() ([]byte, []int) { return file_builder_proto_rawDescGZIP(), []int{4} } -func (x *ClaimBuildTasksResponse) GetTasks() []*BuildTaskSpec { - if x != nil { - return x.Tasks - } - return nil -} - -type SubmitBuildTaskOutputRequest struct { +type UploadBuildArtifactRequest struct { state protoimpl.MessageState `protogen:"open.v1"` TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` - Output string `protobuf:"bytes,2,opt,name=output,proto3" json:"output,omitempty"` - Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` + ArtifactName string `protobuf:"bytes,2,opt,name=artifact_name,json=artifactName,proto3" json:"artifact_name,omitempty"` + Chunk []byte `protobuf:"bytes,3,opt,name=chunk,proto3" json:"chunk,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *SubmitBuildTaskOutputRequest) Reset() { - *x = SubmitBuildTaskOutputRequest{} +func (x *UploadBuildArtifactRequest) Reset() { + *x = UploadBuildArtifactRequest{} mi := &file_builder_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *SubmitBuildTaskOutputRequest) String() string { +func (x *UploadBuildArtifactRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SubmitBuildTaskOutputRequest) ProtoMessage() {} +func (*UploadBuildArtifactRequest) ProtoMessage() {} -func (x *SubmitBuildTaskOutputRequest) ProtoReflect() protoreflect.Message { +func (x *UploadBuildArtifactRequest) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -275,52 +323,53 @@ func (x *SubmitBuildTaskOutputRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SubmitBuildTaskOutputRequest.ProtoReflect.Descriptor instead. -func (*SubmitBuildTaskOutputRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use UploadBuildArtifactRequest.ProtoReflect.Descriptor instead. +func (*UploadBuildArtifactRequest) Descriptor() ([]byte, []int) { return file_builder_proto_rawDescGZIP(), []int{5} } -func (x *SubmitBuildTaskOutputRequest) GetTaskId() int64 { +func (x *UploadBuildArtifactRequest) GetTaskId() int64 { if x != nil { return x.TaskId } return 0 } -func (x *SubmitBuildTaskOutputRequest) GetOutput() string { +func (x *UploadBuildArtifactRequest) GetArtifactName() string { if x != nil { - return x.Output + return x.ArtifactName } return "" } -func (x *SubmitBuildTaskOutputRequest) GetError() string { +func (x *UploadBuildArtifactRequest) GetChunk() []byte { if x != nil { - return x.Error + return x.Chunk } - return "" + return nil } -type SubmitBuildTaskOutputResponse struct { +type UploadBuildArtifactResponse struct { state protoimpl.MessageState `protogen:"open.v1"` + AssetId int64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *SubmitBuildTaskOutputResponse) Reset() { - *x = SubmitBuildTaskOutputResponse{} +func (x *UploadBuildArtifactResponse) Reset() { + *x = UploadBuildArtifactResponse{} mi := &file_builder_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *SubmitBuildTaskOutputResponse) String() string { +func (x *UploadBuildArtifactResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SubmitBuildTaskOutputResponse) ProtoMessage() {} +func (*UploadBuildArtifactResponse) ProtoMessage() {} -func (x *SubmitBuildTaskOutputResponse) ProtoReflect() protoreflect.Message { +func (x *UploadBuildArtifactResponse) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -332,61 +381,85 @@ func (x *SubmitBuildTaskOutputResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SubmitBuildTaskOutputResponse.ProtoReflect.Descriptor instead. -func (*SubmitBuildTaskOutputResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use UploadBuildArtifactResponse.ProtoReflect.Descriptor instead. +func (*UploadBuildArtifactResponse) Descriptor() ([]byte, []int) { return file_builder_proto_rawDescGZIP(), []int{6} } +func (x *UploadBuildArtifactResponse) GetAssetId() int64 { + if x != nil { + return x.AssetId + } + return 0 +} + var File_builder_proto protoreflect.FileDescriptor var file_builder_proto_rawDesc = string([]byte{ 0x0a, 0x0d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x22, 0x0d, 0x0a, 0x0b, 0x50, 0x69, 0x6e, 0x67, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x69, 0x6e, 0x67, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x0a, 0x16, 0x43, 0x6c, 0x61, 0x69, 0x6d, - 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x22, 0x80, 0x01, 0x0a, 0x0d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x53, - 0x70, 0x65, 0x63, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x6f, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4f, 0x73, - 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6d, 0x61, 0x67, - 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x53, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x22, 0x47, 0x0a, 0x17, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, - 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x2c, 0x0a, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, - 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, - 0x73, 0x6b, 0x53, 0x70, 0x65, 0x63, 0x52, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x22, 0x65, 0x0a, - 0x1c, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, - 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, - 0x07, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, - 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x14, - 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x22, 0x1f, 0x0a, 0x1d, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x42, 0x75, - 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x82, 0x02, 0x0a, 0x07, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65, - 0x72, 0x12, 0x35, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x2e, 0x62, 0x75, 0x69, 0x6c, - 0x64, 0x65, 0x72, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x15, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x56, 0x0a, 0x0f, 0x43, 0x6c, 0x61, 0x69, - 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x1f, 0x2e, 0x62, 0x75, - 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, - 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, - 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x68, 0x0a, 0x15, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, - 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x25, 0x2e, 0x62, 0x75, 0x69, 0x6c, - 0x64, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, - 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x26, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, - 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2d, 0x5a, 0x2b, 0x72, 0x65, - 0x61, 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, 0x6e, 0x2f, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2f, - 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x22, 0x18, 0x0a, 0x16, 0x43, 0x6c, 0x61, 0x69, + 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x22, 0xb7, 0x01, 0x0a, 0x0d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, + 0x53, 0x70, 0x65, 0x63, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x6f, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4f, + 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6d, 0x61, + 0x67, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x53, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, + 0x74, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, + 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x50, 0x61, 0x74, 0x68, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, + 0x76, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x76, 0x22, 0x47, 0x0a, 0x17, + 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, + 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x53, 0x70, 0x65, 0x63, 0x52, 0x05, + 0x74, 0x61, 0x73, 0x6b, 0x73, 0x22, 0x81, 0x01, 0x0a, 0x1c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, + 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x1a, 0x0a, + 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x22, 0x1f, 0x0a, 0x1d, 0x53, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, + 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x70, 0x0a, 0x1a, 0x55, 0x70, + 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, + 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, + 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x22, 0x38, 0x0a, 0x1b, + 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, + 0x61, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x61, + 0x73, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, + 0x73, 0x73, 0x65, 0x74, 0x49, 0x64, 0x32, 0xb3, 0x02, 0x0a, 0x07, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x65, 0x72, 0x12, 0x56, 0x0a, 0x0f, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x1f, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, + 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, + 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6a, 0x0a, 0x15, 0x53, 0x74, + 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, + 0x70, 0x75, 0x74, 0x12, 0x25, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, + 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, + 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x64, 0x0a, 0x13, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, + 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x23, 0x2e, + 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, + 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x6c, + 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x42, 0x2d, 0x5a, 0x2b, + 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, 0x6e, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, + 0x72, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, }) var ( @@ -403,22 +476,22 @@ func file_builder_proto_rawDescGZIP() []byte { var file_builder_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_builder_proto_goTypes = []any{ - (*PingRequest)(nil), // 0: builder.PingRequest - (*PingResponse)(nil), // 1: builder.PingResponse - (*ClaimBuildTasksRequest)(nil), // 2: builder.ClaimBuildTasksRequest - (*BuildTaskSpec)(nil), // 3: builder.BuildTaskSpec - (*ClaimBuildTasksResponse)(nil), // 4: builder.ClaimBuildTasksResponse - (*SubmitBuildTaskOutputRequest)(nil), // 5: builder.SubmitBuildTaskOutputRequest - (*SubmitBuildTaskOutputResponse)(nil), // 6: builder.SubmitBuildTaskOutputResponse + (*ClaimBuildTasksRequest)(nil), // 0: builder.ClaimBuildTasksRequest + (*BuildTaskSpec)(nil), // 1: builder.BuildTaskSpec + (*ClaimBuildTasksResponse)(nil), // 2: builder.ClaimBuildTasksResponse + (*StreamBuildTaskOutputRequest)(nil), // 3: builder.StreamBuildTaskOutputRequest + (*StreamBuildTaskOutputResponse)(nil), // 4: builder.StreamBuildTaskOutputResponse + (*UploadBuildArtifactRequest)(nil), // 5: builder.UploadBuildArtifactRequest + (*UploadBuildArtifactResponse)(nil), // 6: builder.UploadBuildArtifactResponse } var file_builder_proto_depIdxs = []int32{ - 3, // 0: builder.ClaimBuildTasksResponse.tasks:type_name -> builder.BuildTaskSpec - 0, // 1: builder.Builder.Ping:input_type -> builder.PingRequest - 2, // 2: builder.Builder.ClaimBuildTasks:input_type -> builder.ClaimBuildTasksRequest - 5, // 3: builder.Builder.SubmitBuildTaskOutput:input_type -> builder.SubmitBuildTaskOutputRequest - 1, // 4: builder.Builder.Ping:output_type -> builder.PingResponse - 4, // 5: builder.Builder.ClaimBuildTasks:output_type -> builder.ClaimBuildTasksResponse - 6, // 6: builder.Builder.SubmitBuildTaskOutput:output_type -> builder.SubmitBuildTaskOutputResponse + 1, // 0: builder.ClaimBuildTasksResponse.tasks:type_name -> builder.BuildTaskSpec + 0, // 1: builder.Builder.ClaimBuildTasks:input_type -> builder.ClaimBuildTasksRequest + 3, // 2: builder.Builder.StreamBuildTaskOutput:input_type -> builder.StreamBuildTaskOutputRequest + 5, // 3: builder.Builder.UploadBuildArtifact:input_type -> builder.UploadBuildArtifactRequest + 2, // 4: builder.Builder.ClaimBuildTasks:output_type -> builder.ClaimBuildTasksResponse + 4, // 5: builder.Builder.StreamBuildTaskOutput:output_type -> builder.StreamBuildTaskOutputResponse + 6, // 6: builder.Builder.UploadBuildArtifact:output_type -> builder.UploadBuildArtifactResponse 4, // [4:7] is the sub-list for method output_type 1, // [1:4] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name diff --git a/tavern/internal/builder/builderpb/builder_grpc.pb.go b/tavern/internal/builder/builderpb/builder_grpc.pb.go index 242846d9e..e1e3e13ca 100644 --- a/tavern/internal/builder/builderpb/builder_grpc.pb.go +++ b/tavern/internal/builder/builderpb/builder_grpc.pb.go @@ -19,18 +19,18 @@ import ( const _ = grpc.SupportPackageIsVersion8 const ( - Builder_Ping_FullMethodName = "/builder.Builder/Ping" Builder_ClaimBuildTasks_FullMethodName = "/builder.Builder/ClaimBuildTasks" - Builder_SubmitBuildTaskOutput_FullMethodName = "/builder.Builder/SubmitBuildTaskOutput" + Builder_StreamBuildTaskOutput_FullMethodName = "/builder.Builder/StreamBuildTaskOutput" + Builder_UploadBuildArtifact_FullMethodName = "/builder.Builder/UploadBuildArtifact" ) // BuilderClient is the client API for Builder service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type BuilderClient interface { - Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) ClaimBuildTasks(ctx context.Context, in *ClaimBuildTasksRequest, opts ...grpc.CallOption) (*ClaimBuildTasksResponse, error) - SubmitBuildTaskOutput(ctx context.Context, in *SubmitBuildTaskOutputRequest, opts ...grpc.CallOption) (*SubmitBuildTaskOutputResponse, error) + StreamBuildTaskOutput(ctx context.Context, opts ...grpc.CallOption) (Builder_StreamBuildTaskOutputClient, error) + UploadBuildArtifact(ctx context.Context, opts ...grpc.CallOption) (Builder_UploadBuildArtifactClient, error) } type builderClient struct { @@ -41,43 +41,93 @@ func NewBuilderClient(cc grpc.ClientConnInterface) BuilderClient { return &builderClient{cc} } -func (c *builderClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) { +func (c *builderClient) ClaimBuildTasks(ctx context.Context, in *ClaimBuildTasksRequest, opts ...grpc.CallOption) (*ClaimBuildTasksResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(PingResponse) - err := c.cc.Invoke(ctx, Builder_Ping_FullMethodName, in, out, cOpts...) + out := new(ClaimBuildTasksResponse) + err := c.cc.Invoke(ctx, Builder_ClaimBuildTasks_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *builderClient) ClaimBuildTasks(ctx context.Context, in *ClaimBuildTasksRequest, opts ...grpc.CallOption) (*ClaimBuildTasksResponse, error) { +func (c *builderClient) StreamBuildTaskOutput(ctx context.Context, opts ...grpc.CallOption) (Builder_StreamBuildTaskOutputClient, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ClaimBuildTasksResponse) - err := c.cc.Invoke(ctx, Builder_ClaimBuildTasks_FullMethodName, in, out, cOpts...) + stream, err := c.cc.NewStream(ctx, &Builder_ServiceDesc.Streams[0], Builder_StreamBuildTaskOutput_FullMethodName, cOpts...) if err != nil { return nil, err } - return out, nil + x := &builderStreamBuildTaskOutputClient{ClientStream: stream} + return x, nil +} + +type Builder_StreamBuildTaskOutputClient interface { + Send(*StreamBuildTaskOutputRequest) error + CloseAndRecv() (*StreamBuildTaskOutputResponse, error) + grpc.ClientStream +} + +type builderStreamBuildTaskOutputClient struct { + grpc.ClientStream +} + +func (x *builderStreamBuildTaskOutputClient) Send(m *StreamBuildTaskOutputRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *builderStreamBuildTaskOutputClient) CloseAndRecv() (*StreamBuildTaskOutputResponse, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(StreamBuildTaskOutputResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil } -func (c *builderClient) SubmitBuildTaskOutput(ctx context.Context, in *SubmitBuildTaskOutputRequest, opts ...grpc.CallOption) (*SubmitBuildTaskOutputResponse, error) { +func (c *builderClient) UploadBuildArtifact(ctx context.Context, opts ...grpc.CallOption) (Builder_UploadBuildArtifactClient, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(SubmitBuildTaskOutputResponse) - err := c.cc.Invoke(ctx, Builder_SubmitBuildTaskOutput_FullMethodName, in, out, cOpts...) + stream, err := c.cc.NewStream(ctx, &Builder_ServiceDesc.Streams[1], Builder_UploadBuildArtifact_FullMethodName, cOpts...) if err != nil { return nil, err } - return out, nil + x := &builderUploadBuildArtifactClient{ClientStream: stream} + return x, nil +} + +type Builder_UploadBuildArtifactClient interface { + Send(*UploadBuildArtifactRequest) error + CloseAndRecv() (*UploadBuildArtifactResponse, error) + grpc.ClientStream +} + +type builderUploadBuildArtifactClient struct { + grpc.ClientStream +} + +func (x *builderUploadBuildArtifactClient) Send(m *UploadBuildArtifactRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *builderUploadBuildArtifactClient) CloseAndRecv() (*UploadBuildArtifactResponse, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(UploadBuildArtifactResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil } // BuilderServer is the server API for Builder service. // All implementations must embed UnimplementedBuilderServer // for forward compatibility type BuilderServer interface { - Ping(context.Context, *PingRequest) (*PingResponse, error) ClaimBuildTasks(context.Context, *ClaimBuildTasksRequest) (*ClaimBuildTasksResponse, error) - SubmitBuildTaskOutput(context.Context, *SubmitBuildTaskOutputRequest) (*SubmitBuildTaskOutputResponse, error) + StreamBuildTaskOutput(Builder_StreamBuildTaskOutputServer) error + UploadBuildArtifact(Builder_UploadBuildArtifactServer) error mustEmbedUnimplementedBuilderServer() } @@ -85,14 +135,14 @@ type BuilderServer interface { type UnimplementedBuilderServer struct { } -func (UnimplementedBuilderServer) Ping(context.Context, *PingRequest) (*PingResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") -} func (UnimplementedBuilderServer) ClaimBuildTasks(context.Context, *ClaimBuildTasksRequest) (*ClaimBuildTasksResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ClaimBuildTasks not implemented") } -func (UnimplementedBuilderServer) SubmitBuildTaskOutput(context.Context, *SubmitBuildTaskOutputRequest) (*SubmitBuildTaskOutputResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SubmitBuildTaskOutput not implemented") +func (UnimplementedBuilderServer) StreamBuildTaskOutput(Builder_StreamBuildTaskOutputServer) error { + return status.Errorf(codes.Unimplemented, "method StreamBuildTaskOutput not implemented") +} +func (UnimplementedBuilderServer) UploadBuildArtifact(Builder_UploadBuildArtifactServer) error { + return status.Errorf(codes.Unimplemented, "method UploadBuildArtifact not implemented") } func (UnimplementedBuilderServer) mustEmbedUnimplementedBuilderServer() {} @@ -107,24 +157,6 @@ func RegisterBuilderServer(s grpc.ServiceRegistrar, srv BuilderServer) { s.RegisterService(&Builder_ServiceDesc, srv) } -func _Builder_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PingRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(BuilderServer).Ping(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Builder_Ping_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(BuilderServer).Ping(ctx, req.(*PingRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Builder_ClaimBuildTasks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ClaimBuildTasksRequest) if err := dec(in); err != nil { @@ -143,22 +175,56 @@ func _Builder_ClaimBuildTasks_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } -func _Builder_SubmitBuildTaskOutput_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SubmitBuildTaskOutputRequest) - if err := dec(in); err != nil { +func _Builder_StreamBuildTaskOutput_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(BuilderServer).StreamBuildTaskOutput(&builderStreamBuildTaskOutputServer{ServerStream: stream}) +} + +type Builder_StreamBuildTaskOutputServer interface { + SendAndClose(*StreamBuildTaskOutputResponse) error + Recv() (*StreamBuildTaskOutputRequest, error) + grpc.ServerStream +} + +type builderStreamBuildTaskOutputServer struct { + grpc.ServerStream +} + +func (x *builderStreamBuildTaskOutputServer) SendAndClose(m *StreamBuildTaskOutputResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *builderStreamBuildTaskOutputServer) Recv() (*StreamBuildTaskOutputRequest, error) { + m := new(StreamBuildTaskOutputRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { return nil, err } - if interceptor == nil { - return srv.(BuilderServer).SubmitBuildTaskOutput(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Builder_SubmitBuildTaskOutput_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(BuilderServer).SubmitBuildTaskOutput(ctx, req.(*SubmitBuildTaskOutputRequest)) + return m, nil +} + +func _Builder_UploadBuildArtifact_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(BuilderServer).UploadBuildArtifact(&builderUploadBuildArtifactServer{ServerStream: stream}) +} + +type Builder_UploadBuildArtifactServer interface { + SendAndClose(*UploadBuildArtifactResponse) error + Recv() (*UploadBuildArtifactRequest, error) + grpc.ServerStream +} + +type builderUploadBuildArtifactServer struct { + grpc.ServerStream +} + +func (x *builderUploadBuildArtifactServer) SendAndClose(m *UploadBuildArtifactResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *builderUploadBuildArtifactServer) Recv() (*UploadBuildArtifactRequest, error) { + m := new(UploadBuildArtifactRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err } - return interceptor(ctx, in, info, handler) + return m, nil } // Builder_ServiceDesc is the grpc.ServiceDesc for Builder service. @@ -168,19 +234,22 @@ var Builder_ServiceDesc = grpc.ServiceDesc{ ServiceName: "builder.Builder", HandlerType: (*BuilderServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "Ping", - Handler: _Builder_Ping_Handler, - }, { MethodName: "ClaimBuildTasks", Handler: _Builder_ClaimBuildTasks_Handler, }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "StreamBuildTaskOutput", + Handler: _Builder_StreamBuildTaskOutput_Handler, + ClientStreams: true, + }, { - MethodName: "SubmitBuildTaskOutput", - Handler: _Builder_SubmitBuildTaskOutput_Handler, + StreamName: "UploadBuildArtifact", + Handler: _Builder_UploadBuildArtifact_Handler, + ClientStreams: true, }, }, - Streams: []grpc.StreamDesc{}, Metadata: "builder.proto", } diff --git a/tavern/internal/builder/builderpb/target_format.go b/tavern/internal/builder/builderpb/target_format.go new file mode 100644 index 000000000..b50477bf3 --- /dev/null +++ b/tavern/internal/builder/builderpb/target_format.go @@ -0,0 +1,89 @@ +package builderpb + +import ( + "database/sql/driver" + "fmt" + "io" + "sort" + + "github.com/99designs/gqlgen/graphql" +) + +const ( + // DefaultInterval is the default callback interval in seconds for the IMIX agent. + DefaultInterval = 5 +) + +// TargetFormat represents the output format for a build. +type TargetFormat string + +const ( + TargetFormatBin TargetFormat = "BIN" + TargetFormatCdylib TargetFormat = "CDYLIB" + TargetFormatWindowsService TargetFormat = "WINDOWS_SERVICE" +) + +// targetFormatName maps each TargetFormat to its string representation. +var targetFormatName = map[TargetFormat]string{ + TargetFormatBin: "BIN", + TargetFormatCdylib: "CDYLIB", + TargetFormatWindowsService: "WINDOWS_SERVICE", +} + +// targetFormatValue maps string names to TargetFormat values. +var targetFormatValue = map[string]TargetFormat{ + "BIN": TargetFormatBin, + "CDYLIB": TargetFormatCdylib, + "WINDOWS_SERVICE": TargetFormatWindowsService, +} + +// Values provides list of valid values for the ent enum interface. +func (TargetFormat) Values() []string { + values := make([]string, 0, len(targetFormatName)) + for _, name := range targetFormatName { + values = append(values, name) + } + sort.Strings(values) + return values +} + +// Value provides the DB a string from the enum (implements driver.Valuer). +func (f TargetFormat) Value() (driver.Value, error) { + return string(f), nil +} + +// Scan tells our code how to read the enum from the database (implements sql.Scanner). +func (f *TargetFormat) Scan(val any) error { + var name string + switch v := val.(type) { + case nil: + return nil + case string: + name = v + case []uint8: + name = string(v) + default: + return fmt.Errorf("unsupported type for TargetFormat: %T", val) + } + + tf, ok := targetFormatValue[name] + if !ok { + return fmt.Errorf("invalid TargetFormat value: %q", name) + } + *f = tf + return nil +} + +// MarshalGQL writes a formatted string value for GraphQL. +func (f TargetFormat) MarshalGQL(w io.Writer) { + graphql.MarshalString(string(f)).MarshalGQL(w) +} + +// UnmarshalGQL parses a GraphQL string representation into the enum. +func (f *TargetFormat) UnmarshalGQL(v interface{}) error { + str, err := graphql.UnmarshalString(v) + if err != nil { + return err + } + return f.Scan(str) +} diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index 322180bd8..31de0176f 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -7,7 +7,6 @@ import ( "encoding/pem" "fmt" "log/slog" - "strings" "sync" "time" @@ -129,14 +128,6 @@ func Run(ctx context.Context, cfg *Config, exec executor.Executor) error { client := builderpb.NewBuilderClient(conn) - // Initial ping to verify connectivity - _, err = client.Ping(ctx, &builderpb.PingRequest{}) - if err != nil { - return fmt.Errorf("failed to ping upstream: %w", err) - } - - slog.InfoContext(ctx, "successfully pinged upstream", "upstream", cfg.Upstream) - // Semaphore limits concurrent builds. sem := make(chan struct{}, maxConcurrentBuilds) var wg sync.WaitGroup @@ -189,86 +180,151 @@ func claimAndExecuteTasks(ctx context.Context, client builderpb.BuilderClient, e } // executeTask runs a single build task through the executor, streaming output -// and errors back to the server, then reports completion. +// and errors back to the server via the StreamBuildTaskOutput RPC. func executeTask(ctx context.Context, client builderpb.BuilderClient, exec executor.Executor, task *builderpb.BuildTaskSpec) { + stream, err := client.StreamBuildTaskOutput(ctx) + if err != nil { + slog.ErrorContext(ctx, "failed to open build output stream", + "task_id", task.Id, "error", err) + return + } + outputCh := make(chan string, 64) errorCh := make(chan string, 64) - var outputLines []string - var errorLines []string - - // Collect output and errors in a background goroutine. - done := make(chan struct{}) + // Stream output and errors to the server in a background goroutine. + var sendErr error + collectorDone := make(chan struct{}) go func() { - defer close(done) - for { + defer close(collectorDone) + outCh, errCh := outputCh, errorCh + for outCh != nil || errCh != nil { select { - case line, ok := <-outputCh: + case line, ok := <-outCh: if !ok { - outputCh = nil - if errorCh == nil { - return - } + outCh = nil continue } - outputLines = append(outputLines, line) + if err := stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Output: line, + }); err != nil { + sendErr = err + return + } slog.InfoContext(ctx, "build output", - "task_id", task.Id, - "line", line, - ) - case line, ok := <-errorCh: + "task_id", task.Id, "line", line) + case line, ok := <-errCh: if !ok { - errorCh = nil - if outputCh == nil { - return - } + errCh = nil continue } - errorLines = append(errorLines, line) + if err := stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Error: line, + }); err != nil { + sendErr = err + return + } slog.WarnContext(ctx, "build error output", - "task_id", task.Id, - "line", line, - ) + "task_id", task.Id, "line", line) } } }() // Run the build through the executor. // The executor closes both channels when done. - buildErr := exec.Build(ctx, executor.BuildSpec{ - TaskID: task.Id, - TargetOS: task.TargetOs, - BuildImage: task.BuildImage, - BuildScript: task.BuildScript, + result, buildErr := exec.Build(ctx, executor.BuildSpec{ + TaskID: task.Id, + TargetOS: task.TargetOs, + BuildImage: task.BuildImage, + BuildScript: task.BuildScript, + ArtifactPath: task.ArtifactPath, + Env: task.Env, }, outputCh, errorCh) - // Wait for collector goroutine to drain remaining channel data. - <-done + // Wait for the collector goroutine to drain remaining channel data. + <-collectorDone - // Build the submission request with collected output. - submitReq := &builderpb.SubmitBuildTaskOutputRequest{ - TaskId: task.Id, - Output: strings.Join(outputLines, "\n"), + if sendErr != nil { + slog.ErrorContext(ctx, "stream send failed during build", + "task_id", task.Id, "error", sendErr) + return } + // Send the final message signaling completion. + finalMsg := &builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Finished: true, + } if buildErr != nil { - errMsg := buildErr.Error() - if len(errorLines) > 0 { - errMsg = strings.Join(errorLines, "\n") + "\n" + errMsg - } - submitReq.Error = errMsg + finalMsg.Error = buildErr.Error() slog.ErrorContext(ctx, "build task failed", - "task_id", task.Id, - "error", buildErr, - ) - } else if len(errorLines) > 0 { - submitReq.Error = strings.Join(errorLines, "\n") + "task_id", task.Id, "error", buildErr) } - if _, err := client.SubmitBuildTaskOutput(ctx, submitReq); err != nil { - slog.ErrorContext(ctx, "failed to submit build task output", - "task_id", task.Id, - "error", err, - ) + if err := stream.Send(finalMsg); err != nil { + slog.ErrorContext(ctx, "failed to send final stream message", + "task_id", task.Id, "error", err) + return + } + + if _, err := stream.CloseAndRecv(); err != nil { + slog.ErrorContext(ctx, "failed to close build output stream", + "task_id", task.Id, "error", err) + return + } + + // Upload artifact if the build succeeded and produced one. + if buildErr == nil && result != nil && result.Artifact != nil { + if err := uploadArtifact(ctx, client, task.Id, result); err != nil { + slog.ErrorContext(ctx, "failed to upload build artifact", + "task_id", task.Id, "error", err) + } } } + +// uploadArtifact streams the build artifact to the server in chunks via the +// UploadBuildArtifact RPC. +func uploadArtifact(ctx context.Context, client builderpb.BuilderClient, taskID int64, result *executor.BuildResult) error { + stream, err := client.UploadBuildArtifact(ctx) + if err != nil { + return fmt.Errorf("failed to open artifact upload stream: %w", err) + } + + const chunkSize = 1 * 1024 * 1024 // 1MB chunks + data := result.Artifact + + for i := 0; i < len(data); i += chunkSize { + end := i + chunkSize + if end > len(data) { + end = len(data) + } + + msg := &builderpb.UploadBuildArtifactRequest{ + Chunk: data[i:end], + } + // Set metadata only on the first message. + if i == 0 { + msg.TaskId = taskID + msg.ArtifactName = result.ArtifactName + } + + if err := stream.Send(msg); err != nil { + return fmt.Errorf("failed to send artifact chunk: %w", err) + } + } + + resp, err := stream.CloseAndRecv() + if err != nil { + return fmt.Errorf("failed to close artifact stream: %w", err) + } + + slog.InfoContext(ctx, "artifact uploaded", + "task_id", taskID, + "asset_id", resp.AssetId, + "size", len(data), + ) + + return nil +} diff --git a/tavern/internal/builder/executor/docker.go b/tavern/internal/builder/executor/docker.go index c054ac1ac..c12ffef14 100644 --- a/tavern/internal/builder/executor/docker.go +++ b/tavern/internal/builder/executor/docker.go @@ -1,11 +1,13 @@ package executor import ( + "archive/tar" "bufio" "context" "fmt" "io" "log/slog" + "path/filepath" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/image" @@ -37,7 +39,9 @@ func NewDockerExecutorFromEnv(ctx context.Context) (*DockerExecutor, error) { // Build pulls the build image, starts a container with the build script as // the shell entrypoint, and streams output/error lines over the channels. -func (d *DockerExecutor) Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) error { +// After the container exits successfully, if spec.ArtifactPath is set, the +// artifact is copied from the stopped container before removal. +func (d *DockerExecutor) Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) (*BuildResult, error) { defer close(outputCh) defer close(errorCh) @@ -45,12 +49,12 @@ func (d *DockerExecutor) Build(ctx context.Context, spec BuildSpec, outputCh cha pullReader, err := d.client.ImagePull(ctx, spec.BuildImage, image.PullOptions{}) if err != nil { - return fmt.Errorf("failed to pull image %q: %w", spec.BuildImage, err) + return nil, fmt.Errorf("failed to pull image %q: %w", spec.BuildImage, err) } // Drain and close the pull output to ensure the image is fully downloaded. if _, err := io.Copy(io.Discard, pullReader); err != nil { pullReader.Close() - return fmt.Errorf("error reading image pull output: %w", err) + return nil, fmt.Errorf("error reading image pull output: %w", err) } pullReader.Close() @@ -60,6 +64,7 @@ func (d *DockerExecutor) Build(ctx context.Context, spec BuildSpec, outputCh cha &container.Config{ Image: spec.BuildImage, Entrypoint: []string{"/bin/sh", "-c", spec.BuildScript}, + Env: spec.Env, }, nil, // host config nil, // networking config @@ -67,7 +72,7 @@ func (d *DockerExecutor) Build(ctx context.Context, spec BuildSpec, outputCh cha "", // container name (auto-generated) ) if err != nil { - return fmt.Errorf("failed to create container: %w", err) + return nil, fmt.Errorf("failed to create container: %w", err) } containerID := resp.ID @@ -80,7 +85,7 @@ func (d *DockerExecutor) Build(ctx context.Context, spec BuildSpec, outputCh cha }() if err := d.client.ContainerStart(ctx, containerID, container.StartOptions{}); err != nil { - return fmt.Errorf("failed to start container: %w", err) + return nil, fmt.Errorf("failed to start container: %w", err) } slog.InfoContext(ctx, "container started", "container_id", containerID, "task_id", spec.TaskID) @@ -92,7 +97,7 @@ func (d *DockerExecutor) Build(ctx context.Context, spec BuildSpec, outputCh cha Follow: true, }) if err != nil { - return fmt.Errorf("failed to attach to container logs: %w", err) + return nil, fmt.Errorf("failed to attach to container logs: %w", err) } defer logReader.Close() @@ -127,18 +132,67 @@ func (d *DockerExecutor) Build(ctx context.Context, spec BuildSpec, outputCh cha // Wait for the container to exit and check its status. statusCh, errCh := d.client.ContainerWait(ctx, containerID, container.WaitConditionNotRunning) + var exitCode int64 select { case err := <-errCh: if err != nil { - return fmt.Errorf("error waiting for container: %w", err) + return nil, fmt.Errorf("error waiting for container: %w", err) } case result := <-statusCh: - if result.StatusCode != 0 { - return fmt.Errorf("container exited with status %d", result.StatusCode) - } + exitCode = result.StatusCode case <-ctx.Done(): - return ctx.Err() + return nil, ctx.Err() + } + + // Extract artifact from the stopped container (before deferred removal). + buildResult := BuildResult{ExitCode: exitCode} + if exitCode == ExpectedExitCode && spec.ArtifactPath != "" { + data, name, extractErr := d.extractArtifact(ctx, containerID, spec.ArtifactPath) + if extractErr != nil { + slog.WarnContext(ctx, "artifact extraction failed", + "task_id", spec.TaskID, "path", spec.ArtifactPath, "error", extractErr) + } else { + buildResult.Artifact = data + buildResult.ArtifactName = name + slog.InfoContext(ctx, "artifact extracted", + "task_id", spec.TaskID, "name", name, "size", len(data)) + } + } + + if exitCode != ExpectedExitCode { + return &buildResult, fmt.Errorf("container exited with status %d", exitCode) + } + + return &buildResult, nil +} + +// extractArtifact copies a file from a stopped container using the Docker API. +// CopyFromContainer returns a tar archive; this method extracts the first +// regular file from that archive and returns its contents and basename. +func (d *DockerExecutor) extractArtifact(ctx context.Context, containerID, path string) ([]byte, string, error) { + tarReader, _, err := d.client.CopyFromContainer(ctx, containerID, path) + if err != nil { + return nil, "", fmt.Errorf("CopyFromContainer %q: %w", path, err) + } + defer tarReader.Close() + + tr := tar.NewReader(tarReader) + for { + hdr, err := tr.Next() + if err == io.EOF { + break + } + if err != nil { + return nil, "", fmt.Errorf("reading tar entry: %w", err) + } + if hdr.Typeflag == tar.TypeReg { + data, err := io.ReadAll(tr) + if err != nil { + return nil, "", fmt.Errorf("reading artifact data: %w", err) + } + return data, filepath.Base(hdr.Name), nil + } } - return nil + return nil, "", fmt.Errorf("no regular file found at %q", path) } diff --git a/tavern/internal/builder/executor/docker_test.go b/tavern/internal/builder/executor/docker_test.go index 38a01517f..a371aef08 100644 --- a/tavern/internal/builder/executor/docker_test.go +++ b/tavern/internal/builder/executor/docker_test.go @@ -49,7 +49,7 @@ func TestDockerExecutor_Build_SimpleEcho(t *testing.T) { outputCh := make(chan string, 100) errorCh := make(chan string, 100) - err := exec.Build(ctx, spec, outputCh, errorCh) + _, err := exec.Build(ctx, spec, outputCh, errorCh) require.NoError(t, err) var output []string @@ -76,7 +76,7 @@ func TestDockerExecutor_Build_MultiLineOutput(t *testing.T) { outputCh := make(chan string, 100) errorCh := make(chan string, 100) - err := exec.Build(ctx, spec, outputCh, errorCh) + _, err := exec.Build(ctx, spec, outputCh, errorCh) require.NoError(t, err) var output []string @@ -103,7 +103,7 @@ func TestDockerExecutor_Build_StderrOutput(t *testing.T) { outputCh := make(chan string, 100) errorCh := make(chan string, 100) - err := exec.Build(ctx, spec, outputCh, errorCh) + _, err := exec.Build(ctx, spec, outputCh, errorCh) require.NoError(t, err) var output []string @@ -136,7 +136,7 @@ func TestDockerExecutor_Build_NonZeroExit(t *testing.T) { outputCh := make(chan string, 100) errorCh := make(chan string, 100) - err := exec.Build(ctx, spec, outputCh, errorCh) + _, err := exec.Build(ctx, spec, outputCh, errorCh) require.Error(t, err) assert.Contains(t, err.Error(), "42") @@ -169,7 +169,7 @@ func TestDockerExecutor_Build_ContextCancellation(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - buildErr = exec.Build(ctx, spec, outputCh, errorCh) + _, buildErr = exec.Build(ctx, spec, outputCh, errorCh) }() wg.Wait() @@ -206,7 +206,7 @@ func TestDockerExecutor_Build_StreamsOutputInRealTime(t *testing.T) { } }() - err := exec.Build(ctx, spec, outputCh, errorCh) + _, err := exec.Build(ctx, spec, outputCh, errorCh) // Build closes outputCh, which unblocks the range loop in the goroutine. wg.Wait() diff --git a/tavern/internal/builder/executor/executor.go b/tavern/internal/builder/executor/executor.go index 65da4814a..d17d5ac7c 100644 --- a/tavern/internal/builder/executor/executor.go +++ b/tavern/internal/builder/executor/executor.go @@ -4,12 +4,38 @@ import ( "context" ) +const ( + // ExpectedExitCode is the expected container exit code for a successful build. + ExpectedExitCode int64 = 0 +) + // BuildSpec contains the parameters for a build task execution. type BuildSpec struct { TaskID int64 TargetOS string BuildImage string BuildScript string + + // ArtifactPath is the path inside the container to extract after the build. + // If empty, no artifact extraction is performed. + ArtifactPath string + + // Env is a list of environment variables to set in the build container, + // in the form "KEY=VALUE". + Env []string +} + +// BuildResult holds the results of a build execution, including any extracted artifacts. +type BuildResult struct { + // ExitCode is the container's exit status code. + ExitCode int64 + + // Artifact contains the raw bytes of the extracted build artifact. + // nil if no artifact was configured or extraction failed. + Artifact []byte + + // ArtifactName is the filename of the extracted artifact. + ArtifactName string } // Executor defines the interface for build task execution. @@ -20,7 +46,7 @@ type Executor interface { // Build executes a build task described by spec. As the build runs, // stdout lines are sent to outputCh and stderr lines to errorCh. // Build blocks until the build completes (or the context is cancelled) - // and returns any execution error. Build must close both channels - // before returning. - Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) error + // and returns a BuildResult (which may contain extracted artifacts) and + // any execution error. Build must close both channels before returning. + Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) (*BuildResult, error) } diff --git a/tavern/internal/builder/executor/mock.go b/tavern/internal/builder/executor/mock.go index dcaa9afd7..9ac4b7d84 100644 --- a/tavern/internal/builder/executor/mock.go +++ b/tavern/internal/builder/executor/mock.go @@ -13,8 +13,8 @@ type MockExecutor struct { // BuildFn, if set, is called for each Build invocation. // It gives tests full control over what gets sent to the channels - // and what error (if any) is returned. - BuildFn func(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) error + // and what result/error is returned. + BuildFn func(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) (*BuildResult, error) } // NewMockExecutor returns a MockExecutor with no configured behavior. @@ -25,7 +25,7 @@ func NewMockExecutor() *MockExecutor { // Build implements Executor. It records the call, delegates to BuildFn // if set, and closes both channels before returning. -func (m *MockExecutor) Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) error { +func (m *MockExecutor) Build(ctx context.Context, spec BuildSpec, outputCh chan<- string, errorCh chan<- string) (*BuildResult, error) { defer close(outputCh) defer close(errorCh) @@ -33,5 +33,5 @@ func (m *MockExecutor) Build(ctx context.Context, spec BuildSpec, outputCh chan< if m.BuildFn != nil { return m.BuildFn(ctx, spec, outputCh, errorCh) } - return nil + return &BuildResult{}, nil } diff --git a/tavern/internal/builder/executor/mock_test.go b/tavern/internal/builder/executor/mock_test.go index 3fc5b0ca1..2539c9dd2 100644 --- a/tavern/internal/builder/executor/mock_test.go +++ b/tavern/internal/builder/executor/mock_test.go @@ -25,7 +25,7 @@ func TestMockExecutor_DefaultBehavior(t *testing.T) { outputCh := make(chan string, 10) errorCh := make(chan string, 10) - err := mock.Build(context.Background(), spec, outputCh, errorCh) + _, err := mock.Build(context.Background(), spec, outputCh, errorCh) require.NoError(t, err) // Should have recorded the call. @@ -49,7 +49,7 @@ func TestMockExecutor_RecordsMultipleCalls(t *testing.T) { for _, s := range specs { outputCh := make(chan string, 10) errorCh := make(chan string, 10) - err := mock.Build(context.Background(), s, outputCh, errorCh) + _, err := mock.Build(context.Background(), s, outputCh, errorCh) require.NoError(t, err) } @@ -61,17 +61,17 @@ func TestMockExecutor_RecordsMultipleCalls(t *testing.T) { func TestMockExecutor_CustomBuildFn_StreamsOutput(t *testing.T) { mock := executor.NewMockExecutor() - mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) (*executor.BuildResult, error) { outputCh <- "Compiling main.go" outputCh <- "Linking binary" outputCh <- "Build succeeded" - return nil + return &executor.BuildResult{}, nil } outputCh := make(chan string, 10) errorCh := make(chan string, 10) - err := mock.Build(context.Background(), executor.BuildSpec{TaskID: 1}, outputCh, errorCh) + _, err := mock.Build(context.Background(), executor.BuildSpec{TaskID: 1}, outputCh, errorCh) require.NoError(t, err) // Channels are closed by Build; drain them. @@ -85,17 +85,17 @@ func TestMockExecutor_CustomBuildFn_StreamsOutput(t *testing.T) { func TestMockExecutor_CustomBuildFn_StreamsErrors(t *testing.T) { mock := executor.NewMockExecutor() - mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) (*executor.BuildResult, error) { outputCh <- "Compiling..." errorCh <- "warning: unused variable" errorCh <- "error: type mismatch" - return errors.New("build failed with exit code 1") + return &executor.BuildResult{}, errors.New("build failed with exit code 1") } outputCh := make(chan string, 10) errorCh := make(chan string, 10) - err := mock.Build(context.Background(), executor.BuildSpec{TaskID: 2}, outputCh, errorCh) + _, err := mock.Build(context.Background(), executor.BuildSpec{TaskID: 2}, outputCh, errorCh) require.Error(t, err) assert.Contains(t, err.Error(), "build failed") @@ -115,10 +115,10 @@ func TestMockExecutor_CustomBuildFn_StreamsErrors(t *testing.T) { func TestMockExecutor_CustomBuildFn_ContextCancellation(t *testing.T) { mock := executor.NewMockExecutor() - mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) (*executor.BuildResult, error) { outputCh <- "Starting build..." <-ctx.Done() - return ctx.Err() + return nil, ctx.Err() } ctx, cancel := context.WithCancel(context.Background()) @@ -130,7 +130,7 @@ func TestMockExecutor_CustomBuildFn_ContextCancellation(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - buildErr = mock.Build(ctx, executor.BuildSpec{TaskID: 3}, outputCh, errorCh) + _, buildErr = mock.Build(ctx, executor.BuildSpec{TaskID: 3}, outputCh, errorCh) }() // Wait for the first output line to confirm Build started. @@ -150,19 +150,19 @@ func TestMockExecutor_CustomBuildFn_ContextCancellation(t *testing.T) { func TestMockExecutor_CustomBuildFn_InterleavedOutputAndErrors(t *testing.T) { mock := executor.NewMockExecutor() - mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) (*executor.BuildResult, error) { outputCh <- "step 1" errorCh <- "warn 1" outputCh <- "step 2" errorCh <- "warn 2" outputCh <- "step 3" - return nil + return &executor.BuildResult{}, nil } outputCh := make(chan string, 10) errorCh := make(chan string, 10) - err := mock.Build(context.Background(), executor.BuildSpec{TaskID: 4}, outputCh, errorCh) + _, err := mock.Build(context.Background(), executor.BuildSpec{TaskID: 4}, outputCh, errorCh) require.NoError(t, err) // Channels are closed by Build; drain them. diff --git a/tavern/internal/builder/executor_integration_test.go b/tavern/internal/builder/executor_integration_test.go index 788fda04f..f32be5c02 100644 --- a/tavern/internal/builder/executor_integration_test.go +++ b/tavern/internal/builder/executor_integration_test.go @@ -6,7 +6,6 @@ import ( "crypto/rand" "errors" "net" - "strings" "testing" "github.com/99designs/gqlgen/client" @@ -75,8 +74,11 @@ func TestExecutorIntegration_ClaimAndExecuteWithMock(t *testing.T) { // Create a build task bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_LINUX). + SetTargetFormat("BIN"). SetBuildImage("golang:1.21"). SetBuildScript("go build ./..."). + SetCallbackURI("https://callback.example.com"). + SetTransportType(c2pb.Transport_TRANSPORT_GRPC). SetBuilderID(builders[0].ID). SaveX(ctx) @@ -86,8 +88,11 @@ func TestExecutorIntegration_ClaimAndExecuteWithMock(t *testing.T) { grpc.ChainUnaryInterceptor( builder.NewMTLSAuthInterceptor(caCert, graph), ), + grpc.ChainStreamInterceptor( + builder.NewMTLSStreamAuthInterceptor(caCert, graph), + ), ) - builderSrv := builder.New(graph) + builderSrv := builder.New(graph, "dGVzdC1wdWJrZXk=") builderpb.RegisterBuilderServer(grpcSrv, builderSrv) go func() { @@ -125,17 +130,17 @@ func TestExecutorIntegration_ClaimAndExecuteWithMock(t *testing.T) { // Execute using mock executor mock := executor.NewMockExecutor() - mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) (*executor.BuildResult, error) { outputCh <- "Building for linux..." outputCh <- "Success" - return nil + return &executor.BuildResult{}, nil } task := claimResp.Tasks[0] outputCh := make(chan string, 64) errorCh := make(chan string, 64) - buildErr := mock.Build(ctx, executor.BuildSpec{ + _, buildErr := mock.Build(ctx, executor.BuildSpec{ TaskID: task.Id, TargetOS: task.TargetOs, BuildImage: task.BuildImage, @@ -143,18 +148,26 @@ func TestExecutorIntegration_ClaimAndExecuteWithMock(t *testing.T) { }, outputCh, errorCh) require.NoError(t, buildErr) - // Channels are closed by Build; drain them. - var outputLines []string + // Channels are closed by Build; drain and stream them. + stream, err := authClient.StreamBuildTaskOutput(ctx) + require.NoError(t, err) + for line := range outputCh { - outputLines = append(outputLines, line) + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Output: line, + })) } - // Submit output to server - _, err = authClient.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ - TaskId: task.Id, - Output: strings.Join(outputLines, "\n"), - }) + // Send final message + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Finished: true, + })) + + resp, err := stream.CloseAndRecv() require.NoError(t, err) + require.NotNil(t, resp) // Verify the task was updated in the database reloaded := graph.BuildTask.GetX(ctx, bt.ID) @@ -206,8 +219,11 @@ func TestExecutorIntegration_ClaimAndExecuteWithMockError(t *testing.T) { bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_LINUX). + SetTargetFormat("BIN"). SetBuildImage("golang:1.21"). SetBuildScript("go build ./..."). + SetCallbackURI("https://callback.example.com"). + SetTransportType(c2pb.Transport_TRANSPORT_GRPC). SetBuilderID(builders[0].ID). SaveX(ctx) @@ -216,8 +232,11 @@ func TestExecutorIntegration_ClaimAndExecuteWithMockError(t *testing.T) { grpc.ChainUnaryInterceptor( builder.NewMTLSAuthInterceptor(caCert, graph), ), + grpc.ChainStreamInterceptor( + builder.NewMTLSStreamAuthInterceptor(caCert, graph), + ), ) - builderSrv := builder.New(graph) + builderSrv := builder.New(graph, "dGVzdC1wdWJrZXk=") builderpb.RegisterBuilderServer(grpcSrv, builderSrv) go func() { @@ -253,17 +272,17 @@ func TestExecutorIntegration_ClaimAndExecuteWithMockError(t *testing.T) { // Execute using mock that fails mock := executor.NewMockExecutor() - mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) error { + mock.BuildFn = func(ctx context.Context, spec executor.BuildSpec, outputCh chan<- string, errorCh chan<- string) (*executor.BuildResult, error) { outputCh <- "Compiling..." errorCh <- "fatal: cannot find package" - return errors.New("exit code 1") + return &executor.BuildResult{}, errors.New("exit code 1") } task := claimResp.Tasks[0] outputCh := make(chan string, 64) errorCh := make(chan string, 64) - buildErr := mock.Build(ctx, executor.BuildSpec{ + _, buildErr := mock.Build(ctx, executor.BuildSpec{ TaskID: task.Id, TargetOS: task.TargetOs, BuildImage: task.BuildImage, @@ -271,24 +290,33 @@ func TestExecutorIntegration_ClaimAndExecuteWithMockError(t *testing.T) { }, outputCh, errorCh) require.Error(t, buildErr) - // Channels are closed by Build; drain them. - var outputLines []string + // Channels are closed by Build; drain and stream them. + stream, err := authClient.StreamBuildTaskOutput(ctx) + require.NoError(t, err) + for line := range outputCh { - outputLines = append(outputLines, line) + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Output: line, + })) } - var errorLines []string for line := range errorCh { - errorLines = append(errorLines, line) + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Error: line, + })) } - // Submit output with error - errMsg := strings.Join(errorLines, "\n") + "\n" + buildErr.Error() - _, err = authClient.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ - TaskId: task.Id, - Output: strings.Join(outputLines, "\n"), - Error: errMsg, - }) + // Send final message with build error + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Error: buildErr.Error(), + Finished: true, + })) + + resp, err := stream.CloseAndRecv() require.NoError(t, err) + require.NotNil(t, resp) // Verify the task was updated reloaded := graph.BuildTask.GetX(ctx, bt.ID) @@ -297,3 +325,399 @@ func TestExecutorIntegration_ClaimAndExecuteWithMockError(t *testing.T) { assert.Contains(t, reloaded.Error, "exit code 1") assert.False(t, reloaded.FinishedAt.IsZero()) } + +func TestExecutorIntegration_StreamBuildOutput(t *testing.T) { + ctx := context.Background() + + graph := enttest.Open(t, "sqlite3", "file:ent_stream_output?mode=memory&cache=shared&_fk=1") + defer graph.Close() + + _, caPrivKey, err := ed25519.GenerateKey(rand.Reader) + require.NoError(t, err) + caCert, err := builder.CreateCA(caPrivKey) + require.NoError(t, err) + + git := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( + tavernhttp.RouteMap{ + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), + }, + tavernhttp.WithAuthenticationBypass(graph), + ) + gqlClient := client.New(srv, client.Path("/graphql")) + + var registerResp struct { + RegisterBuilder struct { + Builder struct{ ID string } + Config string + } + } + err = gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { + registerBuilder(input: $input) { + builder { id } + config + } + }`, ®isterResp, client.Var("input", map[string]any{ + "supportedTargets": []string{"PLATFORM_LINUX"}, + "upstream": "https://tavern.example.com:443", + })) + require.NoError(t, err) + + builders, err := graph.Builder.Query().All(ctx) + require.NoError(t, err) + require.Len(t, builders, 1) + + bt := graph.BuildTask.Create(). + SetTargetOs(c2pb.Host_PLATFORM_LINUX). + SetTargetFormat("BIN"). + SetBuildImage("golang:1.21"). + SetBuildScript("go build ./..."). + SetCallbackURI("https://callback.example.com"). + SetTransportType(c2pb.Transport_TRANSPORT_GRPC). + SetBuilderID(builders[0].ID). + SaveX(ctx) + + lis := bufconn.Listen(1024 * 1024) + grpcSrv := grpc.NewServer( + grpc.ChainUnaryInterceptor( + builder.NewMTLSAuthInterceptor(caCert, graph), + ), + grpc.ChainStreamInterceptor( + builder.NewMTLSStreamAuthInterceptor(caCert, graph), + ), + ) + builderSrv := builder.New(graph, "dGVzdC1wdWJrZXk=") + builderpb.RegisterBuilderServer(grpcSrv, builderSrv) + + go func() { + if err := grpcSrv.Serve(lis); err != nil { + t.Logf("gRPC server exited: %v", err) + } + }() + defer grpcSrv.Stop() + + bufDialer := func(context.Context, string) (net.Conn, error) { + return lis.Dial() + } + + cfg, err := builder.ParseConfigBytes([]byte(registerResp.RegisterBuilder.Config)) + require.NoError(t, err) + + creds, err := builder.NewCredentialsFromConfig(cfg) + require.NoError(t, err) + + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + require.NoError(t, err) + defer conn.Close() + + authClient := builderpb.NewBuilderClient(conn) + + // Claim the task + claimResp, err := authClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) + require.NoError(t, err) + require.Len(t, claimResp.Tasks, 1) + + task := claimResp.Tasks[0] + + // Open stream + stream, err := authClient.StreamBuildTaskOutput(ctx) + require.NoError(t, err) + + // Send output messages + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Output: "Building for linux...", + })) + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Output: "Compiling main.go", + })) + + // Send final message + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Finished: true, + })) + + // Close and receive response + resp, err := stream.CloseAndRecv() + require.NoError(t, err) + require.NotNil(t, resp) + + // Verify DB state + reloaded := graph.BuildTask.GetX(ctx, bt.ID) + assert.Equal(t, "Building for linux...\nCompiling main.go", reloaded.Output) + assert.False(t, reloaded.FinishedAt.IsZero()) + assert.False(t, reloaded.StartedAt.IsZero()) + assert.Empty(t, reloaded.Error) +} + +func TestExecutorIntegration_StreamBuildOutputWithError(t *testing.T) { + ctx := context.Background() + + graph := enttest.Open(t, "sqlite3", "file:ent_stream_output_err?mode=memory&cache=shared&_fk=1") + defer graph.Close() + + _, caPrivKey, err := ed25519.GenerateKey(rand.Reader) + require.NoError(t, err) + caCert, err := builder.CreateCA(caPrivKey) + require.NoError(t, err) + + git := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( + tavernhttp.RouteMap{ + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), + }, + tavernhttp.WithAuthenticationBypass(graph), + ) + gqlClient := client.New(srv, client.Path("/graphql")) + + var registerResp struct { + RegisterBuilder struct { + Builder struct{ ID string } + Config string + } + } + err = gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { + registerBuilder(input: $input) { + builder { id } + config + } + }`, ®isterResp, client.Var("input", map[string]any{ + "supportedTargets": []string{"PLATFORM_LINUX"}, + "upstream": "https://tavern.example.com:443", + })) + require.NoError(t, err) + + builders, err := graph.Builder.Query().All(ctx) + require.NoError(t, err) + require.Len(t, builders, 1) + + bt := graph.BuildTask.Create(). + SetTargetOs(c2pb.Host_PLATFORM_LINUX). + SetTargetFormat("BIN"). + SetBuildImage("golang:1.21"). + SetBuildScript("go build ./..."). + SetCallbackURI("https://callback.example.com"). + SetTransportType(c2pb.Transport_TRANSPORT_GRPC). + SetBuilderID(builders[0].ID). + SaveX(ctx) + + lis := bufconn.Listen(1024 * 1024) + grpcSrv := grpc.NewServer( + grpc.ChainUnaryInterceptor( + builder.NewMTLSAuthInterceptor(caCert, graph), + ), + grpc.ChainStreamInterceptor( + builder.NewMTLSStreamAuthInterceptor(caCert, graph), + ), + ) + builderSrv := builder.New(graph, "dGVzdC1wdWJrZXk=") + builderpb.RegisterBuilderServer(grpcSrv, builderSrv) + + go func() { + if err := grpcSrv.Serve(lis); err != nil { + t.Logf("gRPC server exited: %v", err) + } + }() + defer grpcSrv.Stop() + + bufDialer := func(context.Context, string) (net.Conn, error) { + return lis.Dial() + } + + cfg, err := builder.ParseConfigBytes([]byte(registerResp.RegisterBuilder.Config)) + require.NoError(t, err) + + creds, err := builder.NewCredentialsFromConfig(cfg) + require.NoError(t, err) + + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + require.NoError(t, err) + defer conn.Close() + + authClient := builderpb.NewBuilderClient(conn) + + claimResp, err := authClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) + require.NoError(t, err) + require.Len(t, claimResp.Tasks, 1) + + task := claimResp.Tasks[0] + + // Open stream + stream, err := authClient.StreamBuildTaskOutput(ctx) + require.NoError(t, err) + + // Send output + error lines + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Output: "Compiling...", + })) + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Error: "fatal: cannot find package", + })) + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Error: "exit code 1", + Finished: true, + })) + + resp, err := stream.CloseAndRecv() + require.NoError(t, err) + require.NotNil(t, resp) + + reloaded := graph.BuildTask.GetX(ctx, bt.ID) + assert.Equal(t, "Compiling...", reloaded.Output) + assert.Contains(t, reloaded.Error, "fatal: cannot find package") + assert.Contains(t, reloaded.Error, "exit code 1") + assert.False(t, reloaded.FinishedAt.IsZero()) + assert.False(t, reloaded.StartedAt.IsZero()) +} + +func TestExecutorIntegration_UploadBuildArtifact(t *testing.T) { + ctx := context.Background() + + graph := enttest.Open(t, "sqlite3", "file:ent_upload_artifact?mode=memory&cache=shared&_fk=1") + defer graph.Close() + + _, caPrivKey, err := ed25519.GenerateKey(rand.Reader) + require.NoError(t, err) + caCert, err := builder.CreateCA(caPrivKey) + require.NoError(t, err) + + git := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( + tavernhttp.RouteMap{ + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), + }, + tavernhttp.WithAuthenticationBypass(graph), + ) + gqlClient := client.New(srv, client.Path("/graphql")) + + var registerResp struct { + RegisterBuilder struct { + Builder struct{ ID string } + Config string + } + } + err = gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { + registerBuilder(input: $input) { + builder { id } + config + } + }`, ®isterResp, client.Var("input", map[string]any{ + "supportedTargets": []string{"PLATFORM_LINUX"}, + "upstream": "https://tavern.example.com:443", + })) + require.NoError(t, err) + + builders, err := graph.Builder.Query().All(ctx) + require.NoError(t, err) + require.Len(t, builders, 1) + + graph.BuildTask.Create(). + SetTargetOs(c2pb.Host_PLATFORM_LINUX). + SetTargetFormat("BIN"). + SetBuildImage("golang:1.21"). + SetBuildScript("go build -o /app/output/binary ./..."). + SetCallbackURI("https://callback.example.com"). + SetTransportType(c2pb.Transport_TRANSPORT_GRPC). + SetArtifactPath("/app/output/binary"). + SetBuilderID(builders[0].ID). + SaveX(ctx) + + lis := bufconn.Listen(1024 * 1024) + grpcSrv := grpc.NewServer( + grpc.ChainUnaryInterceptor( + builder.NewMTLSAuthInterceptor(caCert, graph), + ), + grpc.ChainStreamInterceptor( + builder.NewMTLSStreamAuthInterceptor(caCert, graph), + ), + ) + builderSrv := builder.New(graph, "dGVzdC1wdWJrZXk=") + builderpb.RegisterBuilderServer(grpcSrv, builderSrv) + + go func() { + if err := grpcSrv.Serve(lis); err != nil { + t.Logf("gRPC server exited: %v", err) + } + }() + defer grpcSrv.Stop() + + bufDialer := func(context.Context, string) (net.Conn, error) { + return lis.Dial() + } + + cfg, err := builder.ParseConfigBytes([]byte(registerResp.RegisterBuilder.Config)) + require.NoError(t, err) + + creds, err := builder.NewCredentialsFromConfig(cfg) + require.NoError(t, err) + + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + require.NoError(t, err) + defer conn.Close() + + authClient := builderpb.NewBuilderClient(conn) + + // Claim the task + claimResp, err := authClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) + require.NoError(t, err) + require.Len(t, claimResp.Tasks, 1) + assert.Equal(t, "/app/output/binary", claimResp.Tasks[0].ArtifactPath) + + task := claimResp.Tasks[0] + + // Stream build output and finish + stream, err := authClient.StreamBuildTaskOutput(ctx) + require.NoError(t, err) + + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Output: "Build completed", + })) + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: task.Id, + Finished: true, + })) + + _, err = stream.CloseAndRecv() + require.NoError(t, err) + + // Upload artifact + artifactData := []byte("fake-binary-content-for-testing") + artifactStream, err := authClient.UploadBuildArtifact(ctx) + require.NoError(t, err) + + require.NoError(t, artifactStream.Send(&builderpb.UploadBuildArtifactRequest{ + TaskId: task.Id, + ArtifactName: "binary", + Chunk: artifactData, + })) + + artifactResp, err := artifactStream.CloseAndRecv() + require.NoError(t, err) + require.NotNil(t, artifactResp) + assert.Greater(t, artifactResp.AssetId, int64(0)) + + // Verify the asset was created + asset, err := graph.Asset.Get(ctx, int(artifactResp.AssetId)) + require.NoError(t, err) + assert.Contains(t, asset.Name, "build/linux/BIN/imix-") + assert.Equal(t, artifactData, asset.Content) + assert.Equal(t, len(artifactData), asset.Size) +} diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go index 346d554ce..fdd67a7f8 100644 --- a/tavern/internal/builder/integration_test.go +++ b/tavern/internal/builder/integration_test.go @@ -98,8 +98,11 @@ func TestBuilderE2E(t *testing.T) { grpc.ChainUnaryInterceptor( builder.NewMTLSAuthInterceptor(caCert, graph), ), + grpc.ChainStreamInterceptor( + builder.NewMTLSStreamAuthInterceptor(caCert, graph), + ), ) - builderSrv := builder.New(graph) + builderSrv := builder.New(graph, "dGVzdC1wdWJrZXk=") builderpb.RegisterBuilderServer(grpcSrv, builderSrv) go func() { @@ -123,7 +126,7 @@ func TestBuilderE2E(t *testing.T) { defer conn.Close() unauthClient := builderpb.NewBuilderClient(conn) - _, err = unauthClient.Ping(ctx, &builderpb.PingRequest{}) + _, err = unauthClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) require.Error(t, err) assert.Equal(t, codes.Unauthenticated, status.Code(err)) }) @@ -142,9 +145,9 @@ func TestBuilderE2E(t *testing.T) { defer conn.Close() authClient := builderpb.NewBuilderClient(conn) - pingResp, err := authClient.Ping(ctx, &builderpb.PingRequest{}) + claimResp, err := authClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) require.NoError(t, err) - require.NotNil(t, pingResp) + require.NotNil(t, claimResp) }) // 10. Test: ClaimBuildTasks returns unclaimed tasks and marks them as claimed @@ -166,8 +169,12 @@ func TestBuilderE2E(t *testing.T) { // Create a build task assigned to this builder bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_LINUX). + SetTargetFormat("BIN"). SetBuildImage("golang:1.21"). SetBuildScript("echo hello && go build ./..."). + SetCallbackURI("https://callback.example.com"). + SetInterval(10). + SetTransportType(c2pb.Transport_TRANSPORT_GRPC). SetBuilderID(builders[0].ID). SaveX(ctx) @@ -179,6 +186,14 @@ func TestBuilderE2E(t *testing.T) { assert.Equal(t, "golang:1.21", resp.Tasks[0].BuildImage) assert.Equal(t, "echo hello && go build ./...", resp.Tasks[0].BuildScript) + // Verify IMIX_CONFIG env var is set + require.Len(t, resp.Tasks[0].Env, 1) + assert.Contains(t, resp.Tasks[0].Env[0], "IMIX_CONFIG=") + assert.Contains(t, resp.Tasks[0].Env[0], "transports:") + assert.Contains(t, resp.Tasks[0].Env[0], "uri: https://callback.example.com") + assert.Contains(t, resp.Tasks[0].Env[0], "interval: 10") + assert.Contains(t, resp.Tasks[0].Env[0], "type: grpc") + // Verify claimed_at is set reloaded := graph.BuildTask.GetX(ctx, bt.ID) assert.False(t, reloaded.ClaimedAt.IsZero()) @@ -189,8 +204,8 @@ func TestBuilderE2E(t *testing.T) { assert.Empty(t, resp2.Tasks) }) - // 11. Test: SubmitBuildTaskOutput sets output and finished_at - t.Run("SubmitBuildTaskOutput", func(t *testing.T) { + // 11. Test: StreamBuildTaskOutput sets output and finished_at + t.Run("StreamBuildTaskOutput", func(t *testing.T) { creds, err := builder.NewCredentialsFromConfig(cfg) require.NoError(t, err) @@ -207,8 +222,11 @@ func TestBuilderE2E(t *testing.T) { // Create and claim a build task bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_MACOS). + SetTargetFormat("BIN"). SetBuildImage("rust:1.75"). SetBuildScript("cargo build --release"). + SetCallbackURI("https://callback.example.com"). + SetTransportType(c2pb.Transport_TRANSPORT_GRPC). SetBuilderID(builders[0].ID). SaveX(ctx) @@ -217,11 +235,20 @@ func TestBuilderE2E(t *testing.T) { require.NoError(t, err) require.Len(t, claimResp.Tasks, 1) - // Submit output - _, err = authClient.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ + // Stream output + stream, err := authClient.StreamBuildTaskOutput(ctx) + require.NoError(t, err) + + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ TaskId: int64(bt.ID), Output: "build succeeded", - }) + })) + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: int64(bt.ID), + Finished: true, + })) + + _, err = stream.CloseAndRecv() require.NoError(t, err) // Verify the build task was updated @@ -231,8 +258,8 @@ func TestBuilderE2E(t *testing.T) { assert.Empty(t, reloaded.Error) }) - // 12. Test: SubmitBuildTaskOutput with error - t.Run("SubmitBuildTaskOutputWithError", func(t *testing.T) { + // 12. Test: StreamBuildTaskOutput with error + t.Run("StreamBuildTaskOutputWithError", func(t *testing.T) { creds, err := builder.NewCredentialsFromConfig(cfg) require.NoError(t, err) @@ -249,8 +276,11 @@ func TestBuilderE2E(t *testing.T) { // Create and claim a build task bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_LINUX). + SetTargetFormat("BIN"). SetBuildImage("golang:1.21"). SetBuildScript("go build ./..."). + SetCallbackURI("https://callback.example.com"). + SetTransportType(c2pb.Transport_TRANSPORT_GRPC). SetBuilderID(builders[0].ID). SaveX(ctx) @@ -258,12 +288,21 @@ func TestBuilderE2E(t *testing.T) { require.NoError(t, err) require.Len(t, claimResp.Tasks, 1) - // Submit output with error - _, err = authClient.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ + // Stream output with error + stream, err := authClient.StreamBuildTaskOutput(ctx) + require.NoError(t, err) + + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ TaskId: int64(bt.ID), Output: "partial output before failure", - Error: "compilation failed: missing dependency", - }) + })) + require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ + TaskId: int64(bt.ID), + Error: "compilation failed: missing dependency", + Finished: true, + })) + + _, err = stream.CloseAndRecv() require.NoError(t, err) // Verify the build task has both output and error @@ -273,8 +312,8 @@ func TestBuilderE2E(t *testing.T) { assert.False(t, reloaded.FinishedAt.IsZero()) }) - // 13. Test: SubmitBuildTaskOutput for another builder's task is rejected - t.Run("SubmitBuildTaskOutputWrongBuilder", func(t *testing.T) { + // 13. Test: StreamBuildTaskOutput for another builder's task is rejected + t.Run("StreamBuildTaskOutputWrongBuilder", func(t *testing.T) { // Register a second builder var registerResp2 struct { RegisterBuilder struct { @@ -313,12 +352,15 @@ func TestBuilderE2E(t *testing.T) { // Create a build task assigned to the second builder bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_WINDOWS). + SetTargetFormat("BIN"). SetBuildImage("mcr.microsoft.com/windows:ltsc2022"). SetBuildScript("msbuild /t:Build"). + SetCallbackURI("https://callback.example.com"). + SetTransportType(c2pb.Transport_TRANSPORT_GRPC). SetBuilderID(secondBuilder). SaveX(ctx) - // Try to submit output using the FIRST builder's credentials + // Try to stream output using the FIRST builder's credentials creds, err := builder.NewCredentialsFromConfig(cfg) require.NoError(t, err) @@ -332,10 +374,18 @@ func TestBuilderE2E(t *testing.T) { authClient := builderpb.NewBuilderClient(conn) - _, err = authClient.SubmitBuildTaskOutput(ctx, &builderpb.SubmitBuildTaskOutputRequest{ + stream, err := authClient.StreamBuildTaskOutput(ctx) + require.NoError(t, err) + + // Send a message for the wrong builder's task + err = stream.Send(&builderpb.StreamBuildTaskOutputRequest{ TaskId: int64(bt.ID), Output: "should not be allowed", }) + // The send might succeed but the server will reject on recv + if err == nil { + _, err = stream.CloseAndRecv() + } require.Error(t, err) assert.Equal(t, codes.PermissionDenied, status.Code(err)) }) diff --git a/tavern/internal/builder/proto/builder.proto b/tavern/internal/builder/proto/builder.proto index 176ae1b93..134494720 100644 --- a/tavern/internal/builder/proto/builder.proto +++ b/tavern/internal/builder/proto/builder.proto @@ -4,9 +4,6 @@ package builder; option go_package = "realm.pub/tavern/internal/builder/builderpb"; -message PingRequest {} -message PingResponse {} - message ClaimBuildTasksRequest {} message BuildTaskSpec { @@ -14,22 +11,35 @@ message BuildTaskSpec { string target_os = 2; string build_image = 3; string build_script = 4; + string artifact_path = 6; + repeated string env = 7; } message ClaimBuildTasksResponse { repeated BuildTaskSpec tasks = 1; } -message SubmitBuildTaskOutputRequest { +message StreamBuildTaskOutputRequest { int64 task_id = 1; string output = 2; string error = 3; + bool finished = 4; +} + +message StreamBuildTaskOutputResponse {} + +message UploadBuildArtifactRequest { + int64 task_id = 1; + string artifact_name = 2; + bytes chunk = 3; } -message SubmitBuildTaskOutputResponse {} +message UploadBuildArtifactResponse { + int64 asset_id = 1; +} service Builder { - rpc Ping(PingRequest) returns (PingResponse) {} rpc ClaimBuildTasks(ClaimBuildTasksRequest) returns (ClaimBuildTasksResponse) {} - rpc SubmitBuildTaskOutput(SubmitBuildTaskOutputRequest) returns (SubmitBuildTaskOutputResponse) {} + rpc StreamBuildTaskOutput(stream StreamBuildTaskOutputRequest) returns (StreamBuildTaskOutputResponse) {} + rpc UploadBuildArtifact(stream UploadBuildArtifactRequest) returns (UploadBuildArtifactResponse) {} } diff --git a/tavern/internal/builder/server.go b/tavern/internal/builder/server.go index 99beccd5e..818af8219 100644 --- a/tavern/internal/builder/server.go +++ b/tavern/internal/builder/server.go @@ -1,9 +1,14 @@ package builder import ( + "bytes" "context" + "crypto/rand" + "encoding/hex" "fmt" + "io" "log/slog" + "strings" "time" "google.golang.org/grpc/codes" @@ -17,23 +22,20 @@ import ( // Server implements the Builder gRPC service. type Server struct { - graph *ent.Client + graph *ent.Client + serverPubkey string builderpb.UnimplementedBuilderServer } // New creates a new Builder gRPC server. -func New(graph *ent.Client) *Server { +// serverPubkey is the base64-encoded X25519 server public key embedded into agent builds. +func New(graph *ent.Client, serverPubkey string) *Server { return &Server{ - graph: graph, + graph: graph, + serverPubkey: serverPubkey, } } -// Ping is a simple health check endpoint. -func (s *Server) Ping(ctx context.Context, req *builderpb.PingRequest) (*builderpb.PingResponse, error) { - slog.Info("ping!") - return &builderpb.PingResponse{}, nil -} - // ClaimBuildTasks returns unclaimed build tasks assigned to the authenticated builder and marks them as claimed. func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildTasksRequest) (*builderpb.ClaimBuildTasksResponse, error) { now := time.Now() @@ -95,11 +97,31 @@ func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildT if err != nil { return nil, status.Errorf(codes.Internal, "failed to load claimed build task (but it was still claimed) %d: %v", taskID, err) } + + // Derive the IMIX config YAML from the build task's stored fields. + imixCfg := ImixConfig{ + ServerPubkey: s.serverPubkey, + Transports: []ImixTransportConfig{ + { + URI: claimedTask.CallbackURI, + Interval: claimedTask.Interval, + Type: TransportTypeToString(claimedTask.TransportType), + Extra: claimedTask.Extra, + }, + }, + } + imixCfgYAML, err := MarshalImixConfig(imixCfg) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to marshal IMIX config for task %d: %v", taskID, err) + } + resp.Tasks = append(resp.Tasks, &builderpb.BuildTaskSpec{ - Id: int64(claimedTask.ID), - TargetOs: claimedTask.TargetOs.String(), - BuildImage: claimedTask.BuildImage, - BuildScript: claimedTask.BuildScript, + Id: int64(claimedTask.ID), + TargetOs: claimedTask.TargetOs.String(), + BuildImage: claimedTask.BuildImage, + BuildScript: claimedTask.BuildScript, + ArtifactPath: claimedTask.ArtifactPath, + Env: []string{fmt.Sprintf("IMIX_CONFIG=%s", imixCfgYAML)}, }) } @@ -111,56 +133,231 @@ func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildT return resp, nil } -// SubmitBuildTaskOutput records the output of a completed build task. -func (s *Server) SubmitBuildTaskOutput(ctx context.Context, req *builderpb.SubmitBuildTaskOutputRequest) (*builderpb.SubmitBuildTaskOutputResponse, error) { - now := time.Now() +// StreamBuildTaskOutput receives a stream of build output messages from the builder client. +// Each message is flushed to the database immediately. On the final message (finished=true) +// or stream close, the task is finalized. +func (s *Server) StreamBuildTaskOutput(stream builderpb.Builder_StreamBuildTaskOutputServer) error { + ctx := stream.Context() - // 1. Validate the builder is authenticated b, ok := BuilderFromContext(ctx) if !ok { - return nil, status.Error(codes.Unauthenticated, "builder not authenticated") + return status.Error(codes.Unauthenticated, "builder not authenticated") + } + + var ( + taskID int64 + finished bool + ) + + for { + req, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return status.Errorf(codes.Internal, "failed to receive stream message: %v", err) + } + + // First message: validate task ownership and set started_at. + if taskID == 0 { + taskID = req.TaskId + if taskID == 0 { + return status.Error(codes.InvalidArgument, "first message must include task_id") + } + + bt, err := s.graph.BuildTask.Get(ctx, int(taskID)) + if err != nil { + return status.Errorf(codes.NotFound, "build task %d not found: %v", taskID, err) + } + btBuilder, err := bt.QueryBuilder().Only(ctx) + if err != nil { + return status.Errorf(codes.Internal, "failed to query builder for task %d: %v", taskID, err) + } + if btBuilder.ID != b.ID { + return status.Errorf(codes.PermissionDenied, "build task %d is not assigned to this builder", taskID) + } + + // Idempotency: if already finished, return success. + if !bt.FinishedAt.IsZero() { + slog.WarnContext(ctx, "duplicate stream for already-finished build task", + "task_id", taskID, "builder_id", b.ID) + return stream.SendAndClose(&builderpb.StreamBuildTaskOutputResponse{}) + } + + // Set started_at if not already set. + if bt.StartedAt.IsZero() { + if _, err := s.graph.BuildTask.UpdateOne(bt). + SetStartedAt(time.Now()). + Save(ctx); err != nil { + slog.ErrorContext(ctx, "failed to set started_at", + "task_id", taskID, "error", err) + } + } + } + + if req.TaskId != 0 && req.TaskId != taskID { + return status.Errorf(codes.InvalidArgument, "task_id changed mid-stream: got %d, expected %d", req.TaskId, taskID) + } + + if req.Finished { + finished = true + } + + // Flush every message to the database immediately. + if req.Output != "" || req.Error != "" || finished { + if err := s.flushStreamOutput(ctx, int(taskID), req.Output, req.Error, finished); err != nil { + return status.Errorf(codes.Internal, "failed to flush build output for task %d: %v", taskID, err) + } + } + + if finished { + break + } } - // 2. Load the build task and verify it belongs to this builder - bt, err := s.graph.BuildTask.Get(ctx, int(req.TaskId)) + if taskID == 0 { + return status.Error(codes.InvalidArgument, "no messages received") + } + + slog.InfoContext(ctx, "build task stream completed", + "task_id", taskID, + "builder_id", b.ID, + "finished", finished, + ) + + return stream.SendAndClose(&builderpb.StreamBuildTaskOutputResponse{}) +} + +// UploadBuildArtifact receives a chunked binary artifact stream from the builder client +// and creates an Asset entity. +func (s *Server) UploadBuildArtifact(stream builderpb.Builder_UploadBuildArtifactServer) error { + ctx := stream.Context() + + b, ok := BuilderFromContext(ctx) + if !ok { + return status.Error(codes.Unauthenticated, "builder not authenticated") + } + + var ( + taskID int64 + artifactName string + buf bytes.Buffer + ) + + for { + req, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return status.Errorf(codes.Internal, "failed to receive artifact chunk: %v", err) + } + + // First message: validate task ownership. + if taskID == 0 { + taskID = req.TaskId + if taskID == 0 { + return status.Error(codes.InvalidArgument, "first message must include task_id") + } + artifactName = req.ArtifactName + if artifactName == "" { + artifactName = fmt.Sprintf("artifact-%d", taskID) + } + + bt, err := s.graph.BuildTask.Get(ctx, int(taskID)) + if err != nil { + return status.Errorf(codes.NotFound, "build task %d not found: %v", taskID, err) + } + btBuilder, err := bt.QueryBuilder().Only(ctx) + if err != nil { + return status.Errorf(codes.Internal, "failed to query builder for task %d: %v", taskID, err) + } + if btBuilder.ID != b.ID { + return status.Errorf(codes.PermissionDenied, "build task %d is not assigned to this builder", taskID) + } + } + + buf.Write(req.Chunk) + } + + if taskID == 0 { + return status.Error(codes.InvalidArgument, "no messages received") + } + + if buf.Len() == 0 { + return status.Error(codes.InvalidArgument, "empty artifact") + } + + // Load build task to get target_os and target_format for the asset name. + bt, err := s.graph.BuildTask.Get(ctx, int(taskID)) if err != nil { - return nil, status.Errorf(codes.NotFound, "build task %d not found: %v", req.TaskId, err) + return status.Errorf(codes.Internal, "failed to load build task for asset naming: %v", err) } - btBuilder, err := bt.QueryBuilder().Only(ctx) + // Generate 6 random bytes for a unique suffix. + randomBytes := make([]byte, 3) + if _, err := rand.Read(randomBytes); err != nil { + return status.Errorf(codes.Internal, "failed to generate random suffix: %v", err) + } + randomSuffix := hex.EncodeToString(randomBytes) + + osName := strings.ToLower(strings.TrimPrefix(bt.TargetOs.String(), "PLATFORM_")) + assetName := fmt.Sprintf("build/%s/%s/imix-%s", osName, bt.TargetFormat, randomSuffix) + asset, err := s.graph.Asset.Create(). + SetName(assetName). + SetContent(buf.Bytes()). + Save(ctx) if err != nil { - return nil, status.Errorf(codes.Internal, "failed to query builder for task %d: %v", req.TaskId, err) + return status.Errorf(codes.Internal, "failed to create asset: %v", err) } - if btBuilder.ID != b.ID { - return nil, status.Errorf(codes.PermissionDenied, "build task %d is not assigned to this builder", req.TaskId) + + slog.InfoContext(ctx, "build artifact uploaded", + "task_id", taskID, + "builder_id", b.ID, + "asset_id", asset.ID, + "size", buf.Len(), + ) + + return stream.SendAndClose(&builderpb.UploadBuildArtifactResponse{ + AssetId: int64(asset.ID), + }) +} + +// flushStreamOutput appends output and error to the build task in the database. +// If finished is true, it also sets finished_at to mark the task as complete. +func (s *Server) flushStreamOutput(ctx context.Context, taskID int, output string, errMsg string, finished bool) error { + bt, err := s.graph.BuildTask.Get(ctx, taskID) + if err != nil { + return fmt.Errorf("failed to load build task %d: %w", taskID, err) + } + + // Append new content to any existing output already stored from previous flushes. + newOutput := output + if bt.Output != "" && newOutput != "" { + newOutput = bt.Output + "\n" + newOutput + } else if bt.Output != "" { + newOutput = bt.Output } - // 3. Idempotency: if the task is already finished, return success without modification - if !bt.FinishedAt.IsZero() { - slog.WarnContext(ctx, "duplicate build task output submission (already finished)", - "task_id", req.TaskId, - "builder_id", b.ID, - ) - return &builderpb.SubmitBuildTaskOutputResponse{}, nil + newError := errMsg + if bt.Error != "" && newError != "" { + newError = bt.Error + "\n" + newError + } else if bt.Error != "" { + newError = bt.Error } - // 4. Update the build task with output and mark as finished update := s.graph.BuildTask.UpdateOne(bt). - SetFinishedAt(now). - SetOutput(req.Output) - if req.Error != "" { - update = update.SetError(req.Error) + SetOutput(newOutput) + if newError != "" { + update = update.SetError(newError) + } + if finished { + update = update.SetFinishedAt(time.Now()) } if _, err := update.Save(ctx); err != nil { - return nil, status.Errorf(codes.Internal, "failed to update build task %d: %v", req.TaskId, err) + return fmt.Errorf("failed to update build task %d: %w", taskID, err) } - slog.InfoContext(ctx, "build task output submitted", - "task_id", req.TaskId, - "builder_id", b.ID, - "has_error", req.Error != "", - ) - - return &builderpb.SubmitBuildTaskOutputResponse{}, nil + return nil } diff --git a/tavern/internal/ent/buildtask.go b/tavern/internal/ent/buildtask.go index e4592d4de..8b99a4d77 100644 --- a/tavern/internal/ent/buildtask.go +++ b/tavern/internal/ent/buildtask.go @@ -9,7 +9,9 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/buildtask" ) @@ -25,10 +27,20 @@ type BuildTask struct { LastModifiedAt time.Time `json:"last_modified_at,omitempty"` // The target operating system platform for this build. TargetOs c2pb.Host_Platform `json:"target_os,omitempty"` + // The output format for the build (BIN, CDYLIB, WINDOWS_SERVICE). + TargetFormat builderpb.TargetFormat `json:"target_format,omitempty"` // Docker container image name to use for the build. BuildImage string `json:"build_image,omitempty"` - // The script to execute inside the build container. + // The derived script to execute inside the build container. BuildScript string `json:"build_script,omitempty"` + // The callback URI for the IMIX agent to connect to. + CallbackURI string `json:"callback_uri,omitempty"` + // The callback interval in seconds for the IMIX agent. + Interval int `json:"interval,omitempty"` + // The transport type for the IMIX agent. + TransportType c2pb.Transport_Type `json:"transport_type,omitempty"` + // Extra transport configuration for the IMIX agent. + Extra string `json:"extra,omitempty"` // Timestamp of when a builder claimed this task, null if unclaimed. ClaimedAt time.Time `json:"claimed_at,omitempty"` // Timestamp of when the build execution started, null if not yet started. @@ -41,22 +53,29 @@ type BuildTask struct { OutputSize int `json:"output_size,omitempty"` // Error message if the build failed. Error string `json:"error,omitempty"` + // The size of the error in bytes + ErrorSize int `json:"error_size,omitempty"` + // Path inside the container where the build artifact is located. Derived from target_os if not set. + ArtifactPath string `json:"artifact_path,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the BuildTaskQuery when eager-loading is set. - Edges BuildTaskEdges `json:"edges"` - build_task_builder *int - selectValues sql.SelectValues + Edges BuildTaskEdges `json:"edges"` + build_task_builder *int + build_task_artifact *int + selectValues sql.SelectValues } // BuildTaskEdges holds the relations/edges for other nodes in the graph. type BuildTaskEdges struct { // The builder assigned to execute this build task. Builder *Builder `json:"builder,omitempty"` + // The compiled artifact produced by this build task, stored as an Asset. + Artifact *Asset `json:"artifact,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool + loadedTypes [2]bool // totalCount holds the count of the edges above. - totalCount [1]map[string]int + totalCount [2]map[string]int } // BuilderOrErr returns the Builder value or an error if the edge @@ -70,21 +89,38 @@ func (e BuildTaskEdges) BuilderOrErr() (*Builder, error) { return nil, &NotLoadedError{edge: "builder"} } +// ArtifactOrErr returns the Artifact value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e BuildTaskEdges) ArtifactOrErr() (*Asset, error) { + if e.Artifact != nil { + return e.Artifact, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: asset.Label} + } + return nil, &NotLoadedError{edge: "artifact"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*BuildTask) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { + case buildtask.FieldTargetFormat: + values[i] = new(builderpb.TargetFormat) case buildtask.FieldTargetOs: values[i] = new(c2pb.Host_Platform) - case buildtask.FieldID, buildtask.FieldOutputSize: + case buildtask.FieldTransportType: + values[i] = new(c2pb.Transport_Type) + case buildtask.FieldID, buildtask.FieldInterval, buildtask.FieldOutputSize, buildtask.FieldErrorSize: values[i] = new(sql.NullInt64) - case buildtask.FieldBuildImage, buildtask.FieldBuildScript, buildtask.FieldOutput, buildtask.FieldError: + case buildtask.FieldBuildImage, buildtask.FieldBuildScript, buildtask.FieldCallbackURI, buildtask.FieldExtra, buildtask.FieldOutput, buildtask.FieldError, buildtask.FieldArtifactPath: values[i] = new(sql.NullString) case buildtask.FieldCreatedAt, buildtask.FieldLastModifiedAt, buildtask.FieldClaimedAt, buildtask.FieldStartedAt, buildtask.FieldFinishedAt: values[i] = new(sql.NullTime) case buildtask.ForeignKeys[0]: // build_task_builder values[i] = new(sql.NullInt64) + case buildtask.ForeignKeys[1]: // build_task_artifact + values[i] = new(sql.NullInt64) default: values[i] = new(sql.UnknownType) } @@ -124,6 +160,12 @@ func (bt *BuildTask) assignValues(columns []string, values []any) error { } else if value != nil { bt.TargetOs = *value } + case buildtask.FieldTargetFormat: + if value, ok := values[i].(*builderpb.TargetFormat); !ok { + return fmt.Errorf("unexpected type %T for field target_format", values[i]) + } else if value != nil { + bt.TargetFormat = *value + } case buildtask.FieldBuildImage: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field build_image", values[i]) @@ -136,6 +178,30 @@ func (bt *BuildTask) assignValues(columns []string, values []any) error { } else if value.Valid { bt.BuildScript = value.String } + case buildtask.FieldCallbackURI: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field callback_uri", values[i]) + } else if value.Valid { + bt.CallbackURI = value.String + } + case buildtask.FieldInterval: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field interval", values[i]) + } else if value.Valid { + bt.Interval = int(value.Int64) + } + case buildtask.FieldTransportType: + if value, ok := values[i].(*c2pb.Transport_Type); !ok { + return fmt.Errorf("unexpected type %T for field transport_type", values[i]) + } else if value != nil { + bt.TransportType = *value + } + case buildtask.FieldExtra: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field extra", values[i]) + } else if value.Valid { + bt.Extra = value.String + } case buildtask.FieldClaimedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field claimed_at", values[i]) @@ -172,6 +238,18 @@ func (bt *BuildTask) assignValues(columns []string, values []any) error { } else if value.Valid { bt.Error = value.String } + case buildtask.FieldErrorSize: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field error_size", values[i]) + } else if value.Valid { + bt.ErrorSize = int(value.Int64) + } + case buildtask.FieldArtifactPath: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field artifact_path", values[i]) + } else if value.Valid { + bt.ArtifactPath = value.String + } case buildtask.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field build_task_builder", value) @@ -179,6 +257,13 @@ func (bt *BuildTask) assignValues(columns []string, values []any) error { bt.build_task_builder = new(int) *bt.build_task_builder = int(value.Int64) } + case buildtask.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field build_task_artifact", value) + } else if value.Valid { + bt.build_task_artifact = new(int) + *bt.build_task_artifact = int(value.Int64) + } default: bt.selectValues.Set(columns[i], values[i]) } @@ -197,6 +282,11 @@ func (bt *BuildTask) QueryBuilder() *BuilderQuery { return NewBuildTaskClient(bt.config).QueryBuilder(bt) } +// QueryArtifact queries the "artifact" edge of the BuildTask entity. +func (bt *BuildTask) QueryArtifact() *AssetQuery { + return NewBuildTaskClient(bt.config).QueryArtifact(bt) +} + // Update returns a builder for updating this BuildTask. // Note that you need to call BuildTask.Unwrap() before calling this method if this BuildTask // was returned from a transaction, and the transaction was committed or rolled back. @@ -229,12 +319,27 @@ func (bt *BuildTask) String() string { builder.WriteString("target_os=") builder.WriteString(fmt.Sprintf("%v", bt.TargetOs)) builder.WriteString(", ") + builder.WriteString("target_format=") + builder.WriteString(fmt.Sprintf("%v", bt.TargetFormat)) + builder.WriteString(", ") builder.WriteString("build_image=") builder.WriteString(bt.BuildImage) builder.WriteString(", ") builder.WriteString("build_script=") builder.WriteString(bt.BuildScript) builder.WriteString(", ") + builder.WriteString("callback_uri=") + builder.WriteString(bt.CallbackURI) + builder.WriteString(", ") + builder.WriteString("interval=") + builder.WriteString(fmt.Sprintf("%v", bt.Interval)) + builder.WriteString(", ") + builder.WriteString("transport_type=") + builder.WriteString(fmt.Sprintf("%v", bt.TransportType)) + builder.WriteString(", ") + builder.WriteString("extra=") + builder.WriteString(bt.Extra) + builder.WriteString(", ") builder.WriteString("claimed_at=") builder.WriteString(bt.ClaimedAt.Format(time.ANSIC)) builder.WriteString(", ") @@ -252,6 +357,12 @@ func (bt *BuildTask) String() string { builder.WriteString(", ") builder.WriteString("error=") builder.WriteString(bt.Error) + builder.WriteString(", ") + builder.WriteString("error_size=") + builder.WriteString(fmt.Sprintf("%v", bt.ErrorSize)) + builder.WriteString(", ") + builder.WriteString("artifact_path=") + builder.WriteString(bt.ArtifactPath) builder.WriteByte(')') return builder.String() } diff --git a/tavern/internal/ent/buildtask/buildtask.go b/tavern/internal/ent/buildtask/buildtask.go index 64865b5c9..9123d4c91 100644 --- a/tavern/internal/ent/buildtask/buildtask.go +++ b/tavern/internal/ent/buildtask/buildtask.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/99designs/gqlgen/graphql" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2/c2pb" ) @@ -24,10 +25,20 @@ const ( FieldLastModifiedAt = "last_modified_at" // FieldTargetOs holds the string denoting the target_os field in the database. FieldTargetOs = "target_os" + // FieldTargetFormat holds the string denoting the target_format field in the database. + FieldTargetFormat = "target_format" // FieldBuildImage holds the string denoting the build_image field in the database. FieldBuildImage = "build_image" // FieldBuildScript holds the string denoting the build_script field in the database. FieldBuildScript = "build_script" + // FieldCallbackURI holds the string denoting the callback_uri field in the database. + FieldCallbackURI = "callback_uri" + // FieldInterval holds the string denoting the interval field in the database. + FieldInterval = "interval" + // FieldTransportType holds the string denoting the transport_type field in the database. + FieldTransportType = "transport_type" + // FieldExtra holds the string denoting the extra field in the database. + FieldExtra = "extra" // FieldClaimedAt holds the string denoting the claimed_at field in the database. FieldClaimedAt = "claimed_at" // FieldStartedAt holds the string denoting the started_at field in the database. @@ -40,8 +51,14 @@ const ( FieldOutputSize = "output_size" // FieldError holds the string denoting the error field in the database. FieldError = "error" + // FieldErrorSize holds the string denoting the error_size field in the database. + FieldErrorSize = "error_size" + // FieldArtifactPath holds the string denoting the artifact_path field in the database. + FieldArtifactPath = "artifact_path" // EdgeBuilder holds the string denoting the builder edge name in mutations. EdgeBuilder = "builder" + // EdgeArtifact holds the string denoting the artifact edge name in mutations. + EdgeArtifact = "artifact" // Table holds the table name of the buildtask in the database. Table = "build_tasks" // BuilderTable is the table that holds the builder relation/edge. @@ -51,6 +68,13 @@ const ( BuilderInverseTable = "builders" // BuilderColumn is the table column denoting the builder relation/edge. BuilderColumn = "build_task_builder" + // ArtifactTable is the table that holds the artifact relation/edge. + ArtifactTable = "build_tasks" + // ArtifactInverseTable is the table name for the Asset entity. + // It exists in this package in order to avoid circular dependency with the "asset" package. + ArtifactInverseTable = "assets" + // ArtifactColumn is the table column denoting the artifact relation/edge. + ArtifactColumn = "build_task_artifact" ) // Columns holds all SQL columns for buildtask fields. @@ -59,20 +83,28 @@ var Columns = []string{ FieldCreatedAt, FieldLastModifiedAt, FieldTargetOs, + FieldTargetFormat, FieldBuildImage, FieldBuildScript, + FieldCallbackURI, + FieldInterval, + FieldTransportType, + FieldExtra, FieldClaimedAt, FieldStartedAt, FieldFinishedAt, FieldOutput, FieldOutputSize, FieldError, + FieldErrorSize, + FieldArtifactPath, } // ForeignKeys holds the SQL foreign-keys that are owned by the "build_tasks" // table and are not defined as standalone fields in the schema. var ForeignKeys = []string{ "build_task_builder", + "build_task_artifact", } // ValidColumn reports if the column name is valid (part of the table columns). @@ -107,10 +139,18 @@ var ( BuildImageValidator func(string) error // BuildScriptValidator is a validator for the "build_script" field. It is called by the builders before save. BuildScriptValidator func(string) error + // CallbackURIValidator is a validator for the "callback_uri" field. It is called by the builders before save. + CallbackURIValidator func(string) error + // DefaultInterval holds the default value on creation for the "interval" field. + DefaultInterval int // DefaultOutputSize holds the default value on creation for the "output_size" field. DefaultOutputSize int // OutputSizeValidator is a validator for the "output_size" field. It is called by the builders before save. OutputSizeValidator func(int) error + // DefaultErrorSize holds the default value on creation for the "error_size" field. + DefaultErrorSize int + // ErrorSizeValidator is a validator for the "error_size" field. It is called by the builders before save. + ErrorSizeValidator func(int) error ) // TargetOsValidator is a validator for the "target_os" field enum values. It is called by the builders before save. @@ -123,6 +163,26 @@ func TargetOsValidator(to c2pb.Host_Platform) error { } } +// TargetFormatValidator is a validator for the "target_format" field enum values. It is called by the builders before save. +func TargetFormatValidator(tf builderpb.TargetFormat) error { + switch tf { + case "BIN", "CDYLIB", "WINDOWS_SERVICE": + return nil + default: + return fmt.Errorf("buildtask: invalid enum value for target_format field: %q", tf) + } +} + +// TransportTypeValidator is a validator for the "transport_type" field enum values. It is called by the builders before save. +func TransportTypeValidator(tt c2pb.Transport_Type) error { + switch tt.String() { + case "TRANSPORT_DNS", "TRANSPORT_GRPC", "TRANSPORT_HTTP1", "TRANSPORT_UNSPECIFIED": + return nil + default: + return fmt.Errorf("buildtask: invalid enum value for transport_type field: %q", tt) + } +} + // OrderOption defines the ordering options for the BuildTask queries. type OrderOption func(*sql.Selector) @@ -146,6 +206,11 @@ func ByTargetOs(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldTargetOs, opts...).ToFunc() } +// ByTargetFormat orders the results by the target_format field. +func ByTargetFormat(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTargetFormat, opts...).ToFunc() +} + // ByBuildImage orders the results by the build_image field. func ByBuildImage(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldBuildImage, opts...).ToFunc() @@ -156,6 +221,26 @@ func ByBuildScript(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldBuildScript, opts...).ToFunc() } +// ByCallbackURI orders the results by the callback_uri field. +func ByCallbackURI(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCallbackURI, opts...).ToFunc() +} + +// ByInterval orders the results by the interval field. +func ByInterval(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldInterval, opts...).ToFunc() +} + +// ByTransportType orders the results by the transport_type field. +func ByTransportType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTransportType, opts...).ToFunc() +} + +// ByExtra orders the results by the extra field. +func ByExtra(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldExtra, opts...).ToFunc() +} + // ByClaimedAt orders the results by the claimed_at field. func ByClaimedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldClaimedAt, opts...).ToFunc() @@ -186,12 +271,29 @@ func ByError(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldError, opts...).ToFunc() } +// ByErrorSize orders the results by the error_size field. +func ByErrorSize(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldErrorSize, opts...).ToFunc() +} + +// ByArtifactPath orders the results by the artifact_path field. +func ByArtifactPath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldArtifactPath, opts...).ToFunc() +} + // ByBuilderField orders the results by builder field. func ByBuilderField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newBuilderStep(), sql.OrderByField(field, opts...)) } } + +// ByArtifactField orders the results by artifact field. +func ByArtifactField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newArtifactStep(), sql.OrderByField(field, opts...)) + } +} func newBuilderStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -199,6 +301,13 @@ func newBuilderStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2O, false, BuilderTable, BuilderColumn), ) } +func newArtifactStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ArtifactInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ArtifactTable, ArtifactColumn), + ) +} var ( // c2pb.Host_Platform must implement graphql.Marshaler. @@ -206,3 +315,17 @@ var ( // c2pb.Host_Platform must implement graphql.Unmarshaler. _ graphql.Unmarshaler = (*c2pb.Host_Platform)(nil) ) + +var ( + // builderpb.TargetFormat must implement graphql.Marshaler. + _ graphql.Marshaler = (*builderpb.TargetFormat)(nil) + // builderpb.TargetFormat must implement graphql.Unmarshaler. + _ graphql.Unmarshaler = (*builderpb.TargetFormat)(nil) +) + +var ( + // c2pb.Transport_Type must implement graphql.Marshaler. + _ graphql.Marshaler = (*c2pb.Transport_Type)(nil) + // c2pb.Transport_Type must implement graphql.Unmarshaler. + _ graphql.Unmarshaler = (*c2pb.Transport_Type)(nil) +) diff --git a/tavern/internal/ent/buildtask/where.go b/tavern/internal/ent/buildtask/where.go index e4a09ea1a..0b94d561e 100644 --- a/tavern/internal/ent/buildtask/where.go +++ b/tavern/internal/ent/buildtask/where.go @@ -7,6 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent/predicate" ) @@ -76,6 +77,21 @@ func BuildScript(v string) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldBuildScript, v)) } +// CallbackURI applies equality check predicate on the "callback_uri" field. It's identical to CallbackURIEQ. +func CallbackURI(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldCallbackURI, v)) +} + +// Interval applies equality check predicate on the "interval" field. It's identical to IntervalEQ. +func Interval(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldInterval, v)) +} + +// Extra applies equality check predicate on the "extra" field. It's identical to ExtraEQ. +func Extra(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldExtra, v)) +} + // ClaimedAt applies equality check predicate on the "claimed_at" field. It's identical to ClaimedAtEQ. func ClaimedAt(v time.Time) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldClaimedAt, v)) @@ -106,6 +122,16 @@ func Error(v string) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldError, v)) } +// ErrorSize applies equality check predicate on the "error_size" field. It's identical to ErrorSizeEQ. +func ErrorSize(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldErrorSize, v)) +} + +// ArtifactPath applies equality check predicate on the "artifact_path" field. It's identical to ArtifactPathEQ. +func ArtifactPath(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldArtifactPath, v)) +} + // CreatedAtEQ applies the EQ predicate on the "created_at" field. func CreatedAtEQ(v time.Time) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldCreatedAt, v)) @@ -206,6 +232,26 @@ func TargetOsNotIn(vs ...c2pb.Host_Platform) predicate.BuildTask { return predicate.BuildTask(sql.FieldNotIn(FieldTargetOs, vs...)) } +// TargetFormatEQ applies the EQ predicate on the "target_format" field. +func TargetFormatEQ(v builderpb.TargetFormat) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldTargetFormat, v)) +} + +// TargetFormatNEQ applies the NEQ predicate on the "target_format" field. +func TargetFormatNEQ(v builderpb.TargetFormat) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldTargetFormat, v)) +} + +// TargetFormatIn applies the In predicate on the "target_format" field. +func TargetFormatIn(vs ...builderpb.TargetFormat) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldTargetFormat, vs...)) +} + +// TargetFormatNotIn applies the NotIn predicate on the "target_format" field. +func TargetFormatNotIn(vs ...builderpb.TargetFormat) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldTargetFormat, vs...)) +} + // BuildImageEQ applies the EQ predicate on the "build_image" field. func BuildImageEQ(v string) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldBuildImage, v)) @@ -336,6 +382,206 @@ func BuildScriptContainsFold(v string) predicate.BuildTask { return predicate.BuildTask(sql.FieldContainsFold(FieldBuildScript, v)) } +// CallbackURIEQ applies the EQ predicate on the "callback_uri" field. +func CallbackURIEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldCallbackURI, v)) +} + +// CallbackURINEQ applies the NEQ predicate on the "callback_uri" field. +func CallbackURINEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldCallbackURI, v)) +} + +// CallbackURIIn applies the In predicate on the "callback_uri" field. +func CallbackURIIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldCallbackURI, vs...)) +} + +// CallbackURINotIn applies the NotIn predicate on the "callback_uri" field. +func CallbackURINotIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldCallbackURI, vs...)) +} + +// CallbackURIGT applies the GT predicate on the "callback_uri" field. +func CallbackURIGT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldCallbackURI, v)) +} + +// CallbackURIGTE applies the GTE predicate on the "callback_uri" field. +func CallbackURIGTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldCallbackURI, v)) +} + +// CallbackURILT applies the LT predicate on the "callback_uri" field. +func CallbackURILT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldCallbackURI, v)) +} + +// CallbackURILTE applies the LTE predicate on the "callback_uri" field. +func CallbackURILTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldCallbackURI, v)) +} + +// CallbackURIContains applies the Contains predicate on the "callback_uri" field. +func CallbackURIContains(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContains(FieldCallbackURI, v)) +} + +// CallbackURIHasPrefix applies the HasPrefix predicate on the "callback_uri" field. +func CallbackURIHasPrefix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasPrefix(FieldCallbackURI, v)) +} + +// CallbackURIHasSuffix applies the HasSuffix predicate on the "callback_uri" field. +func CallbackURIHasSuffix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasSuffix(FieldCallbackURI, v)) +} + +// CallbackURIEqualFold applies the EqualFold predicate on the "callback_uri" field. +func CallbackURIEqualFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEqualFold(FieldCallbackURI, v)) +} + +// CallbackURIContainsFold applies the ContainsFold predicate on the "callback_uri" field. +func CallbackURIContainsFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContainsFold(FieldCallbackURI, v)) +} + +// IntervalEQ applies the EQ predicate on the "interval" field. +func IntervalEQ(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldInterval, v)) +} + +// IntervalNEQ applies the NEQ predicate on the "interval" field. +func IntervalNEQ(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldInterval, v)) +} + +// IntervalIn applies the In predicate on the "interval" field. +func IntervalIn(vs ...int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldInterval, vs...)) +} + +// IntervalNotIn applies the NotIn predicate on the "interval" field. +func IntervalNotIn(vs ...int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldInterval, vs...)) +} + +// IntervalGT applies the GT predicate on the "interval" field. +func IntervalGT(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldInterval, v)) +} + +// IntervalGTE applies the GTE predicate on the "interval" field. +func IntervalGTE(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldInterval, v)) +} + +// IntervalLT applies the LT predicate on the "interval" field. +func IntervalLT(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldInterval, v)) +} + +// IntervalLTE applies the LTE predicate on the "interval" field. +func IntervalLTE(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldInterval, v)) +} + +// TransportTypeEQ applies the EQ predicate on the "transport_type" field. +func TransportTypeEQ(v c2pb.Transport_Type) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldTransportType, v)) +} + +// TransportTypeNEQ applies the NEQ predicate on the "transport_type" field. +func TransportTypeNEQ(v c2pb.Transport_Type) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldTransportType, v)) +} + +// TransportTypeIn applies the In predicate on the "transport_type" field. +func TransportTypeIn(vs ...c2pb.Transport_Type) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldTransportType, vs...)) +} + +// TransportTypeNotIn applies the NotIn predicate on the "transport_type" field. +func TransportTypeNotIn(vs ...c2pb.Transport_Type) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldTransportType, vs...)) +} + +// ExtraEQ applies the EQ predicate on the "extra" field. +func ExtraEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldExtra, v)) +} + +// ExtraNEQ applies the NEQ predicate on the "extra" field. +func ExtraNEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldExtra, v)) +} + +// ExtraIn applies the In predicate on the "extra" field. +func ExtraIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldExtra, vs...)) +} + +// ExtraNotIn applies the NotIn predicate on the "extra" field. +func ExtraNotIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldExtra, vs...)) +} + +// ExtraGT applies the GT predicate on the "extra" field. +func ExtraGT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldExtra, v)) +} + +// ExtraGTE applies the GTE predicate on the "extra" field. +func ExtraGTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldExtra, v)) +} + +// ExtraLT applies the LT predicate on the "extra" field. +func ExtraLT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldExtra, v)) +} + +// ExtraLTE applies the LTE predicate on the "extra" field. +func ExtraLTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldExtra, v)) +} + +// ExtraContains applies the Contains predicate on the "extra" field. +func ExtraContains(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContains(FieldExtra, v)) +} + +// ExtraHasPrefix applies the HasPrefix predicate on the "extra" field. +func ExtraHasPrefix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasPrefix(FieldExtra, v)) +} + +// ExtraHasSuffix applies the HasSuffix predicate on the "extra" field. +func ExtraHasSuffix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasSuffix(FieldExtra, v)) +} + +// ExtraIsNil applies the IsNil predicate on the "extra" field. +func ExtraIsNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldIsNull(FieldExtra)) +} + +// ExtraNotNil applies the NotNil predicate on the "extra" field. +func ExtraNotNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotNull(FieldExtra)) +} + +// ExtraEqualFold applies the EqualFold predicate on the "extra" field. +func ExtraEqualFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEqualFold(FieldExtra, v)) +} + +// ExtraContainsFold applies the ContainsFold predicate on the "extra" field. +func ExtraContainsFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContainsFold(FieldExtra, v)) +} + // ClaimedAtEQ applies the EQ predicate on the "claimed_at" field. func ClaimedAtEQ(v time.Time) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldClaimedAt, v)) @@ -676,6 +922,121 @@ func ErrorContainsFold(v string) predicate.BuildTask { return predicate.BuildTask(sql.FieldContainsFold(FieldError, v)) } +// ErrorSizeEQ applies the EQ predicate on the "error_size" field. +func ErrorSizeEQ(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldErrorSize, v)) +} + +// ErrorSizeNEQ applies the NEQ predicate on the "error_size" field. +func ErrorSizeNEQ(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldErrorSize, v)) +} + +// ErrorSizeIn applies the In predicate on the "error_size" field. +func ErrorSizeIn(vs ...int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldErrorSize, vs...)) +} + +// ErrorSizeNotIn applies the NotIn predicate on the "error_size" field. +func ErrorSizeNotIn(vs ...int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldErrorSize, vs...)) +} + +// ErrorSizeGT applies the GT predicate on the "error_size" field. +func ErrorSizeGT(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldErrorSize, v)) +} + +// ErrorSizeGTE applies the GTE predicate on the "error_size" field. +func ErrorSizeGTE(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldErrorSize, v)) +} + +// ErrorSizeLT applies the LT predicate on the "error_size" field. +func ErrorSizeLT(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldErrorSize, v)) +} + +// ErrorSizeLTE applies the LTE predicate on the "error_size" field. +func ErrorSizeLTE(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldErrorSize, v)) +} + +// ArtifactPathEQ applies the EQ predicate on the "artifact_path" field. +func ArtifactPathEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldArtifactPath, v)) +} + +// ArtifactPathNEQ applies the NEQ predicate on the "artifact_path" field. +func ArtifactPathNEQ(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldArtifactPath, v)) +} + +// ArtifactPathIn applies the In predicate on the "artifact_path" field. +func ArtifactPathIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldArtifactPath, vs...)) +} + +// ArtifactPathNotIn applies the NotIn predicate on the "artifact_path" field. +func ArtifactPathNotIn(vs ...string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldArtifactPath, vs...)) +} + +// ArtifactPathGT applies the GT predicate on the "artifact_path" field. +func ArtifactPathGT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldArtifactPath, v)) +} + +// ArtifactPathGTE applies the GTE predicate on the "artifact_path" field. +func ArtifactPathGTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldArtifactPath, v)) +} + +// ArtifactPathLT applies the LT predicate on the "artifact_path" field. +func ArtifactPathLT(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldArtifactPath, v)) +} + +// ArtifactPathLTE applies the LTE predicate on the "artifact_path" field. +func ArtifactPathLTE(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldArtifactPath, v)) +} + +// ArtifactPathContains applies the Contains predicate on the "artifact_path" field. +func ArtifactPathContains(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContains(FieldArtifactPath, v)) +} + +// ArtifactPathHasPrefix applies the HasPrefix predicate on the "artifact_path" field. +func ArtifactPathHasPrefix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasPrefix(FieldArtifactPath, v)) +} + +// ArtifactPathHasSuffix applies the HasSuffix predicate on the "artifact_path" field. +func ArtifactPathHasSuffix(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldHasSuffix(FieldArtifactPath, v)) +} + +// ArtifactPathIsNil applies the IsNil predicate on the "artifact_path" field. +func ArtifactPathIsNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldIsNull(FieldArtifactPath)) +} + +// ArtifactPathNotNil applies the NotNil predicate on the "artifact_path" field. +func ArtifactPathNotNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotNull(FieldArtifactPath)) +} + +// ArtifactPathEqualFold applies the EqualFold predicate on the "artifact_path" field. +func ArtifactPathEqualFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEqualFold(FieldArtifactPath, v)) +} + +// ArtifactPathContainsFold applies the ContainsFold predicate on the "artifact_path" field. +func ArtifactPathContainsFold(v string) predicate.BuildTask { + return predicate.BuildTask(sql.FieldContainsFold(FieldArtifactPath, v)) +} + // HasBuilder applies the HasEdge predicate on the "builder" edge. func HasBuilder() predicate.BuildTask { return predicate.BuildTask(func(s *sql.Selector) { @@ -699,6 +1060,29 @@ func HasBuilderWith(preds ...predicate.Builder) predicate.BuildTask { }) } +// HasArtifact applies the HasEdge predicate on the "artifact" edge. +func HasArtifact() predicate.BuildTask { + return predicate.BuildTask(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ArtifactTable, ArtifactColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasArtifactWith applies the HasEdge predicate on the "artifact" edge with a given conditions (other predicates). +func HasArtifactWith(preds ...predicate.Asset) predicate.BuildTask { + return predicate.BuildTask(func(s *sql.Selector) { + step := newArtifactStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.BuildTask) predicate.BuildTask { return predicate.BuildTask(sql.AndPredicates(predicates...)) diff --git a/tavern/internal/ent/buildtask_create.go b/tavern/internal/ent/buildtask_create.go index eed3ae246..8f5ab001b 100644 --- a/tavern/internal/ent/buildtask_create.go +++ b/tavern/internal/ent/buildtask_create.go @@ -11,7 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/buildtask" ) @@ -58,6 +60,12 @@ func (btc *BuildTaskCreate) SetTargetOs(cp c2pb.Host_Platform) *BuildTaskCreate return btc } +// SetTargetFormat sets the "target_format" field. +func (btc *BuildTaskCreate) SetTargetFormat(bf builderpb.TargetFormat) *BuildTaskCreate { + btc.mutation.SetTargetFormat(bf) + return btc +} + // SetBuildImage sets the "build_image" field. func (btc *BuildTaskCreate) SetBuildImage(s string) *BuildTaskCreate { btc.mutation.SetBuildImage(s) @@ -70,6 +78,46 @@ func (btc *BuildTaskCreate) SetBuildScript(s string) *BuildTaskCreate { return btc } +// SetCallbackURI sets the "callback_uri" field. +func (btc *BuildTaskCreate) SetCallbackURI(s string) *BuildTaskCreate { + btc.mutation.SetCallbackURI(s) + return btc +} + +// SetInterval sets the "interval" field. +func (btc *BuildTaskCreate) SetInterval(i int) *BuildTaskCreate { + btc.mutation.SetInterval(i) + return btc +} + +// SetNillableInterval sets the "interval" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableInterval(i *int) *BuildTaskCreate { + if i != nil { + btc.SetInterval(*i) + } + return btc +} + +// SetTransportType sets the "transport_type" field. +func (btc *BuildTaskCreate) SetTransportType(ct c2pb.Transport_Type) *BuildTaskCreate { + btc.mutation.SetTransportType(ct) + return btc +} + +// SetExtra sets the "extra" field. +func (btc *BuildTaskCreate) SetExtra(s string) *BuildTaskCreate { + btc.mutation.SetExtra(s) + return btc +} + +// SetNillableExtra sets the "extra" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableExtra(s *string) *BuildTaskCreate { + if s != nil { + btc.SetExtra(*s) + } + return btc +} + // SetClaimedAt sets the "claimed_at" field. func (btc *BuildTaskCreate) SetClaimedAt(t time.Time) *BuildTaskCreate { btc.mutation.SetClaimedAt(t) @@ -154,6 +202,34 @@ func (btc *BuildTaskCreate) SetNillableError(s *string) *BuildTaskCreate { return btc } +// SetErrorSize sets the "error_size" field. +func (btc *BuildTaskCreate) SetErrorSize(i int) *BuildTaskCreate { + btc.mutation.SetErrorSize(i) + return btc +} + +// SetNillableErrorSize sets the "error_size" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableErrorSize(i *int) *BuildTaskCreate { + if i != nil { + btc.SetErrorSize(*i) + } + return btc +} + +// SetArtifactPath sets the "artifact_path" field. +func (btc *BuildTaskCreate) SetArtifactPath(s string) *BuildTaskCreate { + btc.mutation.SetArtifactPath(s) + return btc +} + +// SetNillableArtifactPath sets the "artifact_path" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableArtifactPath(s *string) *BuildTaskCreate { + if s != nil { + btc.SetArtifactPath(*s) + } + return btc +} + // SetBuilderID sets the "builder" edge to the Builder entity by ID. func (btc *BuildTaskCreate) SetBuilderID(id int) *BuildTaskCreate { btc.mutation.SetBuilderID(id) @@ -165,6 +241,25 @@ func (btc *BuildTaskCreate) SetBuilder(b *Builder) *BuildTaskCreate { return btc.SetBuilderID(b.ID) } +// SetArtifactID sets the "artifact" edge to the Asset entity by ID. +func (btc *BuildTaskCreate) SetArtifactID(id int) *BuildTaskCreate { + btc.mutation.SetArtifactID(id) + return btc +} + +// SetNillableArtifactID sets the "artifact" edge to the Asset entity by ID if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableArtifactID(id *int) *BuildTaskCreate { + if id != nil { + btc = btc.SetArtifactID(*id) + } + return btc +} + +// SetArtifact sets the "artifact" edge to the Asset entity. +func (btc *BuildTaskCreate) SetArtifact(a *Asset) *BuildTaskCreate { + return btc.SetArtifactID(a.ID) +} + // Mutation returns the BuildTaskMutation object of the builder. func (btc *BuildTaskCreate) Mutation() *BuildTaskMutation { return btc.mutation @@ -216,10 +311,18 @@ func (btc *BuildTaskCreate) defaults() error { v := buildtask.DefaultLastModifiedAt() btc.mutation.SetLastModifiedAt(v) } + if _, ok := btc.mutation.Interval(); !ok { + v := buildtask.DefaultInterval + btc.mutation.SetInterval(v) + } if _, ok := btc.mutation.OutputSize(); !ok { v := buildtask.DefaultOutputSize btc.mutation.SetOutputSize(v) } + if _, ok := btc.mutation.ErrorSize(); !ok { + v := buildtask.DefaultErrorSize + btc.mutation.SetErrorSize(v) + } return nil } @@ -239,6 +342,14 @@ func (btc *BuildTaskCreate) check() error { return &ValidationError{Name: "target_os", err: fmt.Errorf(`ent: validator failed for field "BuildTask.target_os": %w`, err)} } } + if _, ok := btc.mutation.TargetFormat(); !ok { + return &ValidationError{Name: "target_format", err: errors.New(`ent: missing required field "BuildTask.target_format"`)} + } + if v, ok := btc.mutation.TargetFormat(); ok { + if err := buildtask.TargetFormatValidator(v); err != nil { + return &ValidationError{Name: "target_format", err: fmt.Errorf(`ent: validator failed for field "BuildTask.target_format": %w`, err)} + } + } if _, ok := btc.mutation.BuildImage(); !ok { return &ValidationError{Name: "build_image", err: errors.New(`ent: missing required field "BuildTask.build_image"`)} } @@ -255,6 +366,25 @@ func (btc *BuildTaskCreate) check() error { return &ValidationError{Name: "build_script", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_script": %w`, err)} } } + if _, ok := btc.mutation.CallbackURI(); !ok { + return &ValidationError{Name: "callback_uri", err: errors.New(`ent: missing required field "BuildTask.callback_uri"`)} + } + if v, ok := btc.mutation.CallbackURI(); ok { + if err := buildtask.CallbackURIValidator(v); err != nil { + return &ValidationError{Name: "callback_uri", err: fmt.Errorf(`ent: validator failed for field "BuildTask.callback_uri": %w`, err)} + } + } + if _, ok := btc.mutation.Interval(); !ok { + return &ValidationError{Name: "interval", err: errors.New(`ent: missing required field "BuildTask.interval"`)} + } + if _, ok := btc.mutation.TransportType(); !ok { + return &ValidationError{Name: "transport_type", err: errors.New(`ent: missing required field "BuildTask.transport_type"`)} + } + if v, ok := btc.mutation.TransportType(); ok { + if err := buildtask.TransportTypeValidator(v); err != nil { + return &ValidationError{Name: "transport_type", err: fmt.Errorf(`ent: validator failed for field "BuildTask.transport_type": %w`, err)} + } + } if _, ok := btc.mutation.OutputSize(); !ok { return &ValidationError{Name: "output_size", err: errors.New(`ent: missing required field "BuildTask.output_size"`)} } @@ -263,6 +393,14 @@ func (btc *BuildTaskCreate) check() error { return &ValidationError{Name: "output_size", err: fmt.Errorf(`ent: validator failed for field "BuildTask.output_size": %w`, err)} } } + if _, ok := btc.mutation.ErrorSize(); !ok { + return &ValidationError{Name: "error_size", err: errors.New(`ent: missing required field "BuildTask.error_size"`)} + } + if v, ok := btc.mutation.ErrorSize(); ok { + if err := buildtask.ErrorSizeValidator(v); err != nil { + return &ValidationError{Name: "error_size", err: fmt.Errorf(`ent: validator failed for field "BuildTask.error_size": %w`, err)} + } + } if len(btc.mutation.BuilderIDs()) == 0 { return &ValidationError{Name: "builder", err: errors.New(`ent: missing required edge "BuildTask.builder"`)} } @@ -305,6 +443,10 @@ func (btc *BuildTaskCreate) createSpec() (*BuildTask, *sqlgraph.CreateSpec) { _spec.SetField(buildtask.FieldTargetOs, field.TypeEnum, value) _node.TargetOs = value } + if value, ok := btc.mutation.TargetFormat(); ok { + _spec.SetField(buildtask.FieldTargetFormat, field.TypeEnum, value) + _node.TargetFormat = value + } if value, ok := btc.mutation.BuildImage(); ok { _spec.SetField(buildtask.FieldBuildImage, field.TypeString, value) _node.BuildImage = value @@ -313,6 +455,22 @@ func (btc *BuildTaskCreate) createSpec() (*BuildTask, *sqlgraph.CreateSpec) { _spec.SetField(buildtask.FieldBuildScript, field.TypeString, value) _node.BuildScript = value } + if value, ok := btc.mutation.CallbackURI(); ok { + _spec.SetField(buildtask.FieldCallbackURI, field.TypeString, value) + _node.CallbackURI = value + } + if value, ok := btc.mutation.Interval(); ok { + _spec.SetField(buildtask.FieldInterval, field.TypeInt, value) + _node.Interval = value + } + if value, ok := btc.mutation.TransportType(); ok { + _spec.SetField(buildtask.FieldTransportType, field.TypeEnum, value) + _node.TransportType = value + } + if value, ok := btc.mutation.Extra(); ok { + _spec.SetField(buildtask.FieldExtra, field.TypeString, value) + _node.Extra = value + } if value, ok := btc.mutation.ClaimedAt(); ok { _spec.SetField(buildtask.FieldClaimedAt, field.TypeTime, value) _node.ClaimedAt = value @@ -337,6 +495,14 @@ func (btc *BuildTaskCreate) createSpec() (*BuildTask, *sqlgraph.CreateSpec) { _spec.SetField(buildtask.FieldError, field.TypeString, value) _node.Error = value } + if value, ok := btc.mutation.ErrorSize(); ok { + _spec.SetField(buildtask.FieldErrorSize, field.TypeInt, value) + _node.ErrorSize = value + } + if value, ok := btc.mutation.ArtifactPath(); ok { + _spec.SetField(buildtask.FieldArtifactPath, field.TypeString, value) + _node.ArtifactPath = value + } if nodes := btc.mutation.BuilderIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -354,6 +520,23 @@ func (btc *BuildTaskCreate) createSpec() (*BuildTask, *sqlgraph.CreateSpec) { _node.build_task_builder = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } + if nodes := btc.mutation.ArtifactIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: buildtask.ArtifactTable, + Columns: []string{buildtask.ArtifactColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.build_task_artifact = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } @@ -430,6 +613,18 @@ func (u *BuildTaskUpsert) UpdateTargetOs() *BuildTaskUpsert { return u } +// SetTargetFormat sets the "target_format" field. +func (u *BuildTaskUpsert) SetTargetFormat(v builderpb.TargetFormat) *BuildTaskUpsert { + u.Set(buildtask.FieldTargetFormat, v) + return u +} + +// UpdateTargetFormat sets the "target_format" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateTargetFormat() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldTargetFormat) + return u +} + // SetBuildImage sets the "build_image" field. func (u *BuildTaskUpsert) SetBuildImage(v string) *BuildTaskUpsert { u.Set(buildtask.FieldBuildImage, v) @@ -454,6 +649,66 @@ func (u *BuildTaskUpsert) UpdateBuildScript() *BuildTaskUpsert { return u } +// SetCallbackURI sets the "callback_uri" field. +func (u *BuildTaskUpsert) SetCallbackURI(v string) *BuildTaskUpsert { + u.Set(buildtask.FieldCallbackURI, v) + return u +} + +// UpdateCallbackURI sets the "callback_uri" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateCallbackURI() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldCallbackURI) + return u +} + +// SetInterval sets the "interval" field. +func (u *BuildTaskUpsert) SetInterval(v int) *BuildTaskUpsert { + u.Set(buildtask.FieldInterval, v) + return u +} + +// UpdateInterval sets the "interval" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateInterval() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldInterval) + return u +} + +// AddInterval adds v to the "interval" field. +func (u *BuildTaskUpsert) AddInterval(v int) *BuildTaskUpsert { + u.Add(buildtask.FieldInterval, v) + return u +} + +// SetTransportType sets the "transport_type" field. +func (u *BuildTaskUpsert) SetTransportType(v c2pb.Transport_Type) *BuildTaskUpsert { + u.Set(buildtask.FieldTransportType, v) + return u +} + +// UpdateTransportType sets the "transport_type" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateTransportType() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldTransportType) + return u +} + +// SetExtra sets the "extra" field. +func (u *BuildTaskUpsert) SetExtra(v string) *BuildTaskUpsert { + u.Set(buildtask.FieldExtra, v) + return u +} + +// UpdateExtra sets the "extra" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateExtra() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldExtra) + return u +} + +// ClearExtra clears the value of the "extra" field. +func (u *BuildTaskUpsert) ClearExtra() *BuildTaskUpsert { + u.SetNull(buildtask.FieldExtra) + return u +} + // SetClaimedAt sets the "claimed_at" field. func (u *BuildTaskUpsert) SetClaimedAt(v time.Time) *BuildTaskUpsert { u.Set(buildtask.FieldClaimedAt, v) @@ -562,6 +817,42 @@ func (u *BuildTaskUpsert) ClearError() *BuildTaskUpsert { return u } +// SetErrorSize sets the "error_size" field. +func (u *BuildTaskUpsert) SetErrorSize(v int) *BuildTaskUpsert { + u.Set(buildtask.FieldErrorSize, v) + return u +} + +// UpdateErrorSize sets the "error_size" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateErrorSize() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldErrorSize) + return u +} + +// AddErrorSize adds v to the "error_size" field. +func (u *BuildTaskUpsert) AddErrorSize(v int) *BuildTaskUpsert { + u.Add(buildtask.FieldErrorSize, v) + return u +} + +// SetArtifactPath sets the "artifact_path" field. +func (u *BuildTaskUpsert) SetArtifactPath(v string) *BuildTaskUpsert { + u.Set(buildtask.FieldArtifactPath, v) + return u +} + +// UpdateArtifactPath sets the "artifact_path" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateArtifactPath() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldArtifactPath) + return u +} + +// ClearArtifactPath clears the value of the "artifact_path" field. +func (u *BuildTaskUpsert) ClearArtifactPath() *BuildTaskUpsert { + u.SetNull(buildtask.FieldArtifactPath) + return u +} + // UpdateNewValues updates the mutable fields using the new values that were set on create. // Using this option is equivalent to using: // @@ -635,6 +926,20 @@ func (u *BuildTaskUpsertOne) UpdateTargetOs() *BuildTaskUpsertOne { }) } +// SetTargetFormat sets the "target_format" field. +func (u *BuildTaskUpsertOne) SetTargetFormat(v builderpb.TargetFormat) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetTargetFormat(v) + }) +} + +// UpdateTargetFormat sets the "target_format" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateTargetFormat() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateTargetFormat() + }) +} + // SetBuildImage sets the "build_image" field. func (u *BuildTaskUpsertOne) SetBuildImage(v string) *BuildTaskUpsertOne { return u.Update(func(s *BuildTaskUpsert) { @@ -663,6 +968,76 @@ func (u *BuildTaskUpsertOne) UpdateBuildScript() *BuildTaskUpsertOne { }) } +// SetCallbackURI sets the "callback_uri" field. +func (u *BuildTaskUpsertOne) SetCallbackURI(v string) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetCallbackURI(v) + }) +} + +// UpdateCallbackURI sets the "callback_uri" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateCallbackURI() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateCallbackURI() + }) +} + +// SetInterval sets the "interval" field. +func (u *BuildTaskUpsertOne) SetInterval(v int) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetInterval(v) + }) +} + +// AddInterval adds v to the "interval" field. +func (u *BuildTaskUpsertOne) AddInterval(v int) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.AddInterval(v) + }) +} + +// UpdateInterval sets the "interval" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateInterval() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateInterval() + }) +} + +// SetTransportType sets the "transport_type" field. +func (u *BuildTaskUpsertOne) SetTransportType(v c2pb.Transport_Type) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetTransportType(v) + }) +} + +// UpdateTransportType sets the "transport_type" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateTransportType() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateTransportType() + }) +} + +// SetExtra sets the "extra" field. +func (u *BuildTaskUpsertOne) SetExtra(v string) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetExtra(v) + }) +} + +// UpdateExtra sets the "extra" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateExtra() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateExtra() + }) +} + +// ClearExtra clears the value of the "extra" field. +func (u *BuildTaskUpsertOne) ClearExtra() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearExtra() + }) +} + // SetClaimedAt sets the "claimed_at" field. func (u *BuildTaskUpsertOne) SetClaimedAt(v time.Time) *BuildTaskUpsertOne { return u.Update(func(s *BuildTaskUpsert) { @@ -789,6 +1164,48 @@ func (u *BuildTaskUpsertOne) ClearError() *BuildTaskUpsertOne { }) } +// SetErrorSize sets the "error_size" field. +func (u *BuildTaskUpsertOne) SetErrorSize(v int) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetErrorSize(v) + }) +} + +// AddErrorSize adds v to the "error_size" field. +func (u *BuildTaskUpsertOne) AddErrorSize(v int) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.AddErrorSize(v) + }) +} + +// UpdateErrorSize sets the "error_size" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateErrorSize() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateErrorSize() + }) +} + +// SetArtifactPath sets the "artifact_path" field. +func (u *BuildTaskUpsertOne) SetArtifactPath(v string) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetArtifactPath(v) + }) +} + +// UpdateArtifactPath sets the "artifact_path" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateArtifactPath() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateArtifactPath() + }) +} + +// ClearArtifactPath clears the value of the "artifact_path" field. +func (u *BuildTaskUpsertOne) ClearArtifactPath() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearArtifactPath() + }) +} + // Exec executes the query. func (u *BuildTaskUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -1028,6 +1445,20 @@ func (u *BuildTaskUpsertBulk) UpdateTargetOs() *BuildTaskUpsertBulk { }) } +// SetTargetFormat sets the "target_format" field. +func (u *BuildTaskUpsertBulk) SetTargetFormat(v builderpb.TargetFormat) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetTargetFormat(v) + }) +} + +// UpdateTargetFormat sets the "target_format" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateTargetFormat() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateTargetFormat() + }) +} + // SetBuildImage sets the "build_image" field. func (u *BuildTaskUpsertBulk) SetBuildImage(v string) *BuildTaskUpsertBulk { return u.Update(func(s *BuildTaskUpsert) { @@ -1056,6 +1487,76 @@ func (u *BuildTaskUpsertBulk) UpdateBuildScript() *BuildTaskUpsertBulk { }) } +// SetCallbackURI sets the "callback_uri" field. +func (u *BuildTaskUpsertBulk) SetCallbackURI(v string) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetCallbackURI(v) + }) +} + +// UpdateCallbackURI sets the "callback_uri" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateCallbackURI() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateCallbackURI() + }) +} + +// SetInterval sets the "interval" field. +func (u *BuildTaskUpsertBulk) SetInterval(v int) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetInterval(v) + }) +} + +// AddInterval adds v to the "interval" field. +func (u *BuildTaskUpsertBulk) AddInterval(v int) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.AddInterval(v) + }) +} + +// UpdateInterval sets the "interval" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateInterval() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateInterval() + }) +} + +// SetTransportType sets the "transport_type" field. +func (u *BuildTaskUpsertBulk) SetTransportType(v c2pb.Transport_Type) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetTransportType(v) + }) +} + +// UpdateTransportType sets the "transport_type" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateTransportType() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateTransportType() + }) +} + +// SetExtra sets the "extra" field. +func (u *BuildTaskUpsertBulk) SetExtra(v string) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetExtra(v) + }) +} + +// UpdateExtra sets the "extra" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateExtra() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateExtra() + }) +} + +// ClearExtra clears the value of the "extra" field. +func (u *BuildTaskUpsertBulk) ClearExtra() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearExtra() + }) +} + // SetClaimedAt sets the "claimed_at" field. func (u *BuildTaskUpsertBulk) SetClaimedAt(v time.Time) *BuildTaskUpsertBulk { return u.Update(func(s *BuildTaskUpsert) { @@ -1182,6 +1683,48 @@ func (u *BuildTaskUpsertBulk) ClearError() *BuildTaskUpsertBulk { }) } +// SetErrorSize sets the "error_size" field. +func (u *BuildTaskUpsertBulk) SetErrorSize(v int) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetErrorSize(v) + }) +} + +// AddErrorSize adds v to the "error_size" field. +func (u *BuildTaskUpsertBulk) AddErrorSize(v int) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.AddErrorSize(v) + }) +} + +// UpdateErrorSize sets the "error_size" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateErrorSize() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateErrorSize() + }) +} + +// SetArtifactPath sets the "artifact_path" field. +func (u *BuildTaskUpsertBulk) SetArtifactPath(v string) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetArtifactPath(v) + }) +} + +// UpdateArtifactPath sets the "artifact_path" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateArtifactPath() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateArtifactPath() + }) +} + +// ClearArtifactPath clears the value of the "artifact_path" field. +func (u *BuildTaskUpsertBulk) ClearArtifactPath() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearArtifactPath() + }) +} + // Exec executes the query. func (u *BuildTaskUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/tavern/internal/ent/buildtask_query.go b/tavern/internal/ent/buildtask_query.go index 071eb3eb6..5fb34e8b4 100644 --- a/tavern/internal/ent/buildtask_query.go +++ b/tavern/internal/ent/buildtask_query.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/predicate" @@ -19,14 +20,15 @@ import ( // BuildTaskQuery is the builder for querying BuildTask entities. type BuildTaskQuery struct { config - ctx *QueryContext - order []buildtask.OrderOption - inters []Interceptor - predicates []predicate.BuildTask - withBuilder *BuilderQuery - withFKs bool - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*BuildTask) error + ctx *QueryContext + order []buildtask.OrderOption + inters []Interceptor + predicates []predicate.BuildTask + withBuilder *BuilderQuery + withArtifact *AssetQuery + withFKs bool + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*BuildTask) error // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -85,6 +87,28 @@ func (btq *BuildTaskQuery) QueryBuilder() *BuilderQuery { return query } +// QueryArtifact chains the current query on the "artifact" edge. +func (btq *BuildTaskQuery) QueryArtifact() *AssetQuery { + query := (&AssetClient{config: btq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := btq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := btq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(buildtask.Table, buildtask.FieldID, selector), + sqlgraph.To(asset.Table, asset.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, buildtask.ArtifactTable, buildtask.ArtifactColumn), + ) + fromU = sqlgraph.SetNeighbors(btq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first BuildTask entity from the query. // Returns a *NotFoundError when no BuildTask was found. func (btq *BuildTaskQuery) First(ctx context.Context) (*BuildTask, error) { @@ -272,12 +296,13 @@ func (btq *BuildTaskQuery) Clone() *BuildTaskQuery { return nil } return &BuildTaskQuery{ - config: btq.config, - ctx: btq.ctx.Clone(), - order: append([]buildtask.OrderOption{}, btq.order...), - inters: append([]Interceptor{}, btq.inters...), - predicates: append([]predicate.BuildTask{}, btq.predicates...), - withBuilder: btq.withBuilder.Clone(), + config: btq.config, + ctx: btq.ctx.Clone(), + order: append([]buildtask.OrderOption{}, btq.order...), + inters: append([]Interceptor{}, btq.inters...), + predicates: append([]predicate.BuildTask{}, btq.predicates...), + withBuilder: btq.withBuilder.Clone(), + withArtifact: btq.withArtifact.Clone(), // clone intermediate query. sql: btq.sql.Clone(), path: btq.path, @@ -295,6 +320,17 @@ func (btq *BuildTaskQuery) WithBuilder(opts ...func(*BuilderQuery)) *BuildTaskQu return btq } +// WithArtifact tells the query-builder to eager-load the nodes that are connected to +// the "artifact" edge. The optional arguments are used to configure the query builder of the edge. +func (btq *BuildTaskQuery) WithArtifact(opts ...func(*AssetQuery)) *BuildTaskQuery { + query := (&AssetClient{config: btq.config}).Query() + for _, opt := range opts { + opt(query) + } + btq.withArtifact = query + return btq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -374,11 +410,12 @@ func (btq *BuildTaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*B nodes = []*BuildTask{} withFKs = btq.withFKs _spec = btq.querySpec() - loadedTypes = [1]bool{ + loadedTypes = [2]bool{ btq.withBuilder != nil, + btq.withArtifact != nil, } ) - if btq.withBuilder != nil { + if btq.withBuilder != nil || btq.withArtifact != nil { withFKs = true } if withFKs { @@ -411,6 +448,12 @@ func (btq *BuildTaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*B return nil, err } } + if query := btq.withArtifact; query != nil { + if err := btq.loadArtifact(ctx, query, nodes, nil, + func(n *BuildTask, e *Asset) { n.Edges.Artifact = e }); err != nil { + return nil, err + } + } for i := range btq.loadTotal { if err := btq.loadTotal[i](ctx, nodes); err != nil { return nil, err @@ -451,6 +494,38 @@ func (btq *BuildTaskQuery) loadBuilder(ctx context.Context, query *BuilderQuery, } return nil } +func (btq *BuildTaskQuery) loadArtifact(ctx context.Context, query *AssetQuery, nodes []*BuildTask, init func(*BuildTask), assign func(*BuildTask, *Asset)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*BuildTask) + for i := range nodes { + if nodes[i].build_task_artifact == nil { + continue + } + fk := *nodes[i].build_task_artifact + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(asset.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "build_task_artifact" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} func (btq *BuildTaskQuery) sqlCount(ctx context.Context) (int, error) { _spec := btq.querySpec() diff --git a/tavern/internal/ent/buildtask_update.go b/tavern/internal/ent/buildtask_update.go index d2b4327c8..7b3a5e181 100644 --- a/tavern/internal/ent/buildtask_update.go +++ b/tavern/internal/ent/buildtask_update.go @@ -11,7 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/buildtask" "realm.pub/tavern/internal/ent/predicate" @@ -50,6 +52,20 @@ func (btu *BuildTaskUpdate) SetNillableTargetOs(cp *c2pb.Host_Platform) *BuildTa return btu } +// SetTargetFormat sets the "target_format" field. +func (btu *BuildTaskUpdate) SetTargetFormat(bf builderpb.TargetFormat) *BuildTaskUpdate { + btu.mutation.SetTargetFormat(bf) + return btu +} + +// SetNillableTargetFormat sets the "target_format" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableTargetFormat(bf *builderpb.TargetFormat) *BuildTaskUpdate { + if bf != nil { + btu.SetTargetFormat(*bf) + } + return btu +} + // SetBuildImage sets the "build_image" field. func (btu *BuildTaskUpdate) SetBuildImage(s string) *BuildTaskUpdate { btu.mutation.SetBuildImage(s) @@ -78,6 +94,75 @@ func (btu *BuildTaskUpdate) SetNillableBuildScript(s *string) *BuildTaskUpdate { return btu } +// SetCallbackURI sets the "callback_uri" field. +func (btu *BuildTaskUpdate) SetCallbackURI(s string) *BuildTaskUpdate { + btu.mutation.SetCallbackURI(s) + return btu +} + +// SetNillableCallbackURI sets the "callback_uri" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableCallbackURI(s *string) *BuildTaskUpdate { + if s != nil { + btu.SetCallbackURI(*s) + } + return btu +} + +// SetInterval sets the "interval" field. +func (btu *BuildTaskUpdate) SetInterval(i int) *BuildTaskUpdate { + btu.mutation.ResetInterval() + btu.mutation.SetInterval(i) + return btu +} + +// SetNillableInterval sets the "interval" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableInterval(i *int) *BuildTaskUpdate { + if i != nil { + btu.SetInterval(*i) + } + return btu +} + +// AddInterval adds i to the "interval" field. +func (btu *BuildTaskUpdate) AddInterval(i int) *BuildTaskUpdate { + btu.mutation.AddInterval(i) + return btu +} + +// SetTransportType sets the "transport_type" field. +func (btu *BuildTaskUpdate) SetTransportType(ct c2pb.Transport_Type) *BuildTaskUpdate { + btu.mutation.SetTransportType(ct) + return btu +} + +// SetNillableTransportType sets the "transport_type" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableTransportType(ct *c2pb.Transport_Type) *BuildTaskUpdate { + if ct != nil { + btu.SetTransportType(*ct) + } + return btu +} + +// SetExtra sets the "extra" field. +func (btu *BuildTaskUpdate) SetExtra(s string) *BuildTaskUpdate { + btu.mutation.SetExtra(s) + return btu +} + +// SetNillableExtra sets the "extra" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableExtra(s *string) *BuildTaskUpdate { + if s != nil { + btu.SetExtra(*s) + } + return btu +} + +// ClearExtra clears the value of the "extra" field. +func (btu *BuildTaskUpdate) ClearExtra() *BuildTaskUpdate { + btu.mutation.ClearExtra() + return btu +} + // SetClaimedAt sets the "claimed_at" field. func (btu *BuildTaskUpdate) SetClaimedAt(t time.Time) *BuildTaskUpdate { btu.mutation.SetClaimedAt(t) @@ -199,6 +284,47 @@ func (btu *BuildTaskUpdate) ClearError() *BuildTaskUpdate { return btu } +// SetErrorSize sets the "error_size" field. +func (btu *BuildTaskUpdate) SetErrorSize(i int) *BuildTaskUpdate { + btu.mutation.ResetErrorSize() + btu.mutation.SetErrorSize(i) + return btu +} + +// SetNillableErrorSize sets the "error_size" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableErrorSize(i *int) *BuildTaskUpdate { + if i != nil { + btu.SetErrorSize(*i) + } + return btu +} + +// AddErrorSize adds i to the "error_size" field. +func (btu *BuildTaskUpdate) AddErrorSize(i int) *BuildTaskUpdate { + btu.mutation.AddErrorSize(i) + return btu +} + +// SetArtifactPath sets the "artifact_path" field. +func (btu *BuildTaskUpdate) SetArtifactPath(s string) *BuildTaskUpdate { + btu.mutation.SetArtifactPath(s) + return btu +} + +// SetNillableArtifactPath sets the "artifact_path" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableArtifactPath(s *string) *BuildTaskUpdate { + if s != nil { + btu.SetArtifactPath(*s) + } + return btu +} + +// ClearArtifactPath clears the value of the "artifact_path" field. +func (btu *BuildTaskUpdate) ClearArtifactPath() *BuildTaskUpdate { + btu.mutation.ClearArtifactPath() + return btu +} + // SetBuilderID sets the "builder" edge to the Builder entity by ID. func (btu *BuildTaskUpdate) SetBuilderID(id int) *BuildTaskUpdate { btu.mutation.SetBuilderID(id) @@ -210,6 +336,25 @@ func (btu *BuildTaskUpdate) SetBuilder(b *Builder) *BuildTaskUpdate { return btu.SetBuilderID(b.ID) } +// SetArtifactID sets the "artifact" edge to the Asset entity by ID. +func (btu *BuildTaskUpdate) SetArtifactID(id int) *BuildTaskUpdate { + btu.mutation.SetArtifactID(id) + return btu +} + +// SetNillableArtifactID sets the "artifact" edge to the Asset entity by ID if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableArtifactID(id *int) *BuildTaskUpdate { + if id != nil { + btu = btu.SetArtifactID(*id) + } + return btu +} + +// SetArtifact sets the "artifact" edge to the Asset entity. +func (btu *BuildTaskUpdate) SetArtifact(a *Asset) *BuildTaskUpdate { + return btu.SetArtifactID(a.ID) +} + // Mutation returns the BuildTaskMutation object of the builder. func (btu *BuildTaskUpdate) Mutation() *BuildTaskMutation { return btu.mutation @@ -221,6 +366,12 @@ func (btu *BuildTaskUpdate) ClearBuilder() *BuildTaskUpdate { return btu } +// ClearArtifact clears the "artifact" edge to the Asset entity. +func (btu *BuildTaskUpdate) ClearArtifact() *BuildTaskUpdate { + btu.mutation.ClearArtifact() + return btu +} + // Save executes the query and returns the number of nodes affected by the update operation. func (btu *BuildTaskUpdate) Save(ctx context.Context) (int, error) { if err := btu.defaults(); err != nil { @@ -270,6 +421,11 @@ func (btu *BuildTaskUpdate) check() error { return &ValidationError{Name: "target_os", err: fmt.Errorf(`ent: validator failed for field "BuildTask.target_os": %w`, err)} } } + if v, ok := btu.mutation.TargetFormat(); ok { + if err := buildtask.TargetFormatValidator(v); err != nil { + return &ValidationError{Name: "target_format", err: fmt.Errorf(`ent: validator failed for field "BuildTask.target_format": %w`, err)} + } + } if v, ok := btu.mutation.BuildImage(); ok { if err := buildtask.BuildImageValidator(v); err != nil { return &ValidationError{Name: "build_image", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_image": %w`, err)} @@ -280,11 +436,26 @@ func (btu *BuildTaskUpdate) check() error { return &ValidationError{Name: "build_script", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_script": %w`, err)} } } + if v, ok := btu.mutation.CallbackURI(); ok { + if err := buildtask.CallbackURIValidator(v); err != nil { + return &ValidationError{Name: "callback_uri", err: fmt.Errorf(`ent: validator failed for field "BuildTask.callback_uri": %w`, err)} + } + } + if v, ok := btu.mutation.TransportType(); ok { + if err := buildtask.TransportTypeValidator(v); err != nil { + return &ValidationError{Name: "transport_type", err: fmt.Errorf(`ent: validator failed for field "BuildTask.transport_type": %w`, err)} + } + } if v, ok := btu.mutation.OutputSize(); ok { if err := buildtask.OutputSizeValidator(v); err != nil { return &ValidationError{Name: "output_size", err: fmt.Errorf(`ent: validator failed for field "BuildTask.output_size": %w`, err)} } } + if v, ok := btu.mutation.ErrorSize(); ok { + if err := buildtask.ErrorSizeValidator(v); err != nil { + return &ValidationError{Name: "error_size", err: fmt.Errorf(`ent: validator failed for field "BuildTask.error_size": %w`, err)} + } + } if btu.mutation.BuilderCleared() && len(btu.mutation.BuilderIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "BuildTask.builder"`) } @@ -309,12 +480,33 @@ func (btu *BuildTaskUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := btu.mutation.TargetOs(); ok { _spec.SetField(buildtask.FieldTargetOs, field.TypeEnum, value) } + if value, ok := btu.mutation.TargetFormat(); ok { + _spec.SetField(buildtask.FieldTargetFormat, field.TypeEnum, value) + } if value, ok := btu.mutation.BuildImage(); ok { _spec.SetField(buildtask.FieldBuildImage, field.TypeString, value) } if value, ok := btu.mutation.BuildScript(); ok { _spec.SetField(buildtask.FieldBuildScript, field.TypeString, value) } + if value, ok := btu.mutation.CallbackURI(); ok { + _spec.SetField(buildtask.FieldCallbackURI, field.TypeString, value) + } + if value, ok := btu.mutation.Interval(); ok { + _spec.SetField(buildtask.FieldInterval, field.TypeInt, value) + } + if value, ok := btu.mutation.AddedInterval(); ok { + _spec.AddField(buildtask.FieldInterval, field.TypeInt, value) + } + if value, ok := btu.mutation.TransportType(); ok { + _spec.SetField(buildtask.FieldTransportType, field.TypeEnum, value) + } + if value, ok := btu.mutation.Extra(); ok { + _spec.SetField(buildtask.FieldExtra, field.TypeString, value) + } + if btu.mutation.ExtraCleared() { + _spec.ClearField(buildtask.FieldExtra, field.TypeString) + } if value, ok := btu.mutation.ClaimedAt(); ok { _spec.SetField(buildtask.FieldClaimedAt, field.TypeTime, value) } @@ -351,6 +543,18 @@ func (btu *BuildTaskUpdate) sqlSave(ctx context.Context) (n int, err error) { if btu.mutation.ErrorCleared() { _spec.ClearField(buildtask.FieldError, field.TypeString) } + if value, ok := btu.mutation.ErrorSize(); ok { + _spec.SetField(buildtask.FieldErrorSize, field.TypeInt, value) + } + if value, ok := btu.mutation.AddedErrorSize(); ok { + _spec.AddField(buildtask.FieldErrorSize, field.TypeInt, value) + } + if value, ok := btu.mutation.ArtifactPath(); ok { + _spec.SetField(buildtask.FieldArtifactPath, field.TypeString, value) + } + if btu.mutation.ArtifactPathCleared() { + _spec.ClearField(buildtask.FieldArtifactPath, field.TypeString) + } if btu.mutation.BuilderCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -380,6 +584,35 @@ func (btu *BuildTaskUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if btu.mutation.ArtifactCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: buildtask.ArtifactTable, + Columns: []string{buildtask.ArtifactColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := btu.mutation.ArtifactIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: buildtask.ArtifactTable, + Columns: []string{buildtask.ArtifactColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, btu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{buildtask.Label} @@ -420,6 +653,20 @@ func (btuo *BuildTaskUpdateOne) SetNillableTargetOs(cp *c2pb.Host_Platform) *Bui return btuo } +// SetTargetFormat sets the "target_format" field. +func (btuo *BuildTaskUpdateOne) SetTargetFormat(bf builderpb.TargetFormat) *BuildTaskUpdateOne { + btuo.mutation.SetTargetFormat(bf) + return btuo +} + +// SetNillableTargetFormat sets the "target_format" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableTargetFormat(bf *builderpb.TargetFormat) *BuildTaskUpdateOne { + if bf != nil { + btuo.SetTargetFormat(*bf) + } + return btuo +} + // SetBuildImage sets the "build_image" field. func (btuo *BuildTaskUpdateOne) SetBuildImage(s string) *BuildTaskUpdateOne { btuo.mutation.SetBuildImage(s) @@ -448,6 +695,75 @@ func (btuo *BuildTaskUpdateOne) SetNillableBuildScript(s *string) *BuildTaskUpda return btuo } +// SetCallbackURI sets the "callback_uri" field. +func (btuo *BuildTaskUpdateOne) SetCallbackURI(s string) *BuildTaskUpdateOne { + btuo.mutation.SetCallbackURI(s) + return btuo +} + +// SetNillableCallbackURI sets the "callback_uri" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableCallbackURI(s *string) *BuildTaskUpdateOne { + if s != nil { + btuo.SetCallbackURI(*s) + } + return btuo +} + +// SetInterval sets the "interval" field. +func (btuo *BuildTaskUpdateOne) SetInterval(i int) *BuildTaskUpdateOne { + btuo.mutation.ResetInterval() + btuo.mutation.SetInterval(i) + return btuo +} + +// SetNillableInterval sets the "interval" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableInterval(i *int) *BuildTaskUpdateOne { + if i != nil { + btuo.SetInterval(*i) + } + return btuo +} + +// AddInterval adds i to the "interval" field. +func (btuo *BuildTaskUpdateOne) AddInterval(i int) *BuildTaskUpdateOne { + btuo.mutation.AddInterval(i) + return btuo +} + +// SetTransportType sets the "transport_type" field. +func (btuo *BuildTaskUpdateOne) SetTransportType(ct c2pb.Transport_Type) *BuildTaskUpdateOne { + btuo.mutation.SetTransportType(ct) + return btuo +} + +// SetNillableTransportType sets the "transport_type" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableTransportType(ct *c2pb.Transport_Type) *BuildTaskUpdateOne { + if ct != nil { + btuo.SetTransportType(*ct) + } + return btuo +} + +// SetExtra sets the "extra" field. +func (btuo *BuildTaskUpdateOne) SetExtra(s string) *BuildTaskUpdateOne { + btuo.mutation.SetExtra(s) + return btuo +} + +// SetNillableExtra sets the "extra" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableExtra(s *string) *BuildTaskUpdateOne { + if s != nil { + btuo.SetExtra(*s) + } + return btuo +} + +// ClearExtra clears the value of the "extra" field. +func (btuo *BuildTaskUpdateOne) ClearExtra() *BuildTaskUpdateOne { + btuo.mutation.ClearExtra() + return btuo +} + // SetClaimedAt sets the "claimed_at" field. func (btuo *BuildTaskUpdateOne) SetClaimedAt(t time.Time) *BuildTaskUpdateOne { btuo.mutation.SetClaimedAt(t) @@ -569,6 +885,47 @@ func (btuo *BuildTaskUpdateOne) ClearError() *BuildTaskUpdateOne { return btuo } +// SetErrorSize sets the "error_size" field. +func (btuo *BuildTaskUpdateOne) SetErrorSize(i int) *BuildTaskUpdateOne { + btuo.mutation.ResetErrorSize() + btuo.mutation.SetErrorSize(i) + return btuo +} + +// SetNillableErrorSize sets the "error_size" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableErrorSize(i *int) *BuildTaskUpdateOne { + if i != nil { + btuo.SetErrorSize(*i) + } + return btuo +} + +// AddErrorSize adds i to the "error_size" field. +func (btuo *BuildTaskUpdateOne) AddErrorSize(i int) *BuildTaskUpdateOne { + btuo.mutation.AddErrorSize(i) + return btuo +} + +// SetArtifactPath sets the "artifact_path" field. +func (btuo *BuildTaskUpdateOne) SetArtifactPath(s string) *BuildTaskUpdateOne { + btuo.mutation.SetArtifactPath(s) + return btuo +} + +// SetNillableArtifactPath sets the "artifact_path" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableArtifactPath(s *string) *BuildTaskUpdateOne { + if s != nil { + btuo.SetArtifactPath(*s) + } + return btuo +} + +// ClearArtifactPath clears the value of the "artifact_path" field. +func (btuo *BuildTaskUpdateOne) ClearArtifactPath() *BuildTaskUpdateOne { + btuo.mutation.ClearArtifactPath() + return btuo +} + // SetBuilderID sets the "builder" edge to the Builder entity by ID. func (btuo *BuildTaskUpdateOne) SetBuilderID(id int) *BuildTaskUpdateOne { btuo.mutation.SetBuilderID(id) @@ -580,6 +937,25 @@ func (btuo *BuildTaskUpdateOne) SetBuilder(b *Builder) *BuildTaskUpdateOne { return btuo.SetBuilderID(b.ID) } +// SetArtifactID sets the "artifact" edge to the Asset entity by ID. +func (btuo *BuildTaskUpdateOne) SetArtifactID(id int) *BuildTaskUpdateOne { + btuo.mutation.SetArtifactID(id) + return btuo +} + +// SetNillableArtifactID sets the "artifact" edge to the Asset entity by ID if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableArtifactID(id *int) *BuildTaskUpdateOne { + if id != nil { + btuo = btuo.SetArtifactID(*id) + } + return btuo +} + +// SetArtifact sets the "artifact" edge to the Asset entity. +func (btuo *BuildTaskUpdateOne) SetArtifact(a *Asset) *BuildTaskUpdateOne { + return btuo.SetArtifactID(a.ID) +} + // Mutation returns the BuildTaskMutation object of the builder. func (btuo *BuildTaskUpdateOne) Mutation() *BuildTaskMutation { return btuo.mutation @@ -591,6 +967,12 @@ func (btuo *BuildTaskUpdateOne) ClearBuilder() *BuildTaskUpdateOne { return btuo } +// ClearArtifact clears the "artifact" edge to the Asset entity. +func (btuo *BuildTaskUpdateOne) ClearArtifact() *BuildTaskUpdateOne { + btuo.mutation.ClearArtifact() + return btuo +} + // Where appends a list predicates to the BuildTaskUpdate builder. func (btuo *BuildTaskUpdateOne) Where(ps ...predicate.BuildTask) *BuildTaskUpdateOne { btuo.mutation.Where(ps...) @@ -653,6 +1035,11 @@ func (btuo *BuildTaskUpdateOne) check() error { return &ValidationError{Name: "target_os", err: fmt.Errorf(`ent: validator failed for field "BuildTask.target_os": %w`, err)} } } + if v, ok := btuo.mutation.TargetFormat(); ok { + if err := buildtask.TargetFormatValidator(v); err != nil { + return &ValidationError{Name: "target_format", err: fmt.Errorf(`ent: validator failed for field "BuildTask.target_format": %w`, err)} + } + } if v, ok := btuo.mutation.BuildImage(); ok { if err := buildtask.BuildImageValidator(v); err != nil { return &ValidationError{Name: "build_image", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_image": %w`, err)} @@ -663,11 +1050,26 @@ func (btuo *BuildTaskUpdateOne) check() error { return &ValidationError{Name: "build_script", err: fmt.Errorf(`ent: validator failed for field "BuildTask.build_script": %w`, err)} } } + if v, ok := btuo.mutation.CallbackURI(); ok { + if err := buildtask.CallbackURIValidator(v); err != nil { + return &ValidationError{Name: "callback_uri", err: fmt.Errorf(`ent: validator failed for field "BuildTask.callback_uri": %w`, err)} + } + } + if v, ok := btuo.mutation.TransportType(); ok { + if err := buildtask.TransportTypeValidator(v); err != nil { + return &ValidationError{Name: "transport_type", err: fmt.Errorf(`ent: validator failed for field "BuildTask.transport_type": %w`, err)} + } + } if v, ok := btuo.mutation.OutputSize(); ok { if err := buildtask.OutputSizeValidator(v); err != nil { return &ValidationError{Name: "output_size", err: fmt.Errorf(`ent: validator failed for field "BuildTask.output_size": %w`, err)} } } + if v, ok := btuo.mutation.ErrorSize(); ok { + if err := buildtask.ErrorSizeValidator(v); err != nil { + return &ValidationError{Name: "error_size", err: fmt.Errorf(`ent: validator failed for field "BuildTask.error_size": %w`, err)} + } + } if btuo.mutation.BuilderCleared() && len(btuo.mutation.BuilderIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "BuildTask.builder"`) } @@ -709,12 +1111,33 @@ func (btuo *BuildTaskUpdateOne) sqlSave(ctx context.Context) (_node *BuildTask, if value, ok := btuo.mutation.TargetOs(); ok { _spec.SetField(buildtask.FieldTargetOs, field.TypeEnum, value) } + if value, ok := btuo.mutation.TargetFormat(); ok { + _spec.SetField(buildtask.FieldTargetFormat, field.TypeEnum, value) + } if value, ok := btuo.mutation.BuildImage(); ok { _spec.SetField(buildtask.FieldBuildImage, field.TypeString, value) } if value, ok := btuo.mutation.BuildScript(); ok { _spec.SetField(buildtask.FieldBuildScript, field.TypeString, value) } + if value, ok := btuo.mutation.CallbackURI(); ok { + _spec.SetField(buildtask.FieldCallbackURI, field.TypeString, value) + } + if value, ok := btuo.mutation.Interval(); ok { + _spec.SetField(buildtask.FieldInterval, field.TypeInt, value) + } + if value, ok := btuo.mutation.AddedInterval(); ok { + _spec.AddField(buildtask.FieldInterval, field.TypeInt, value) + } + if value, ok := btuo.mutation.TransportType(); ok { + _spec.SetField(buildtask.FieldTransportType, field.TypeEnum, value) + } + if value, ok := btuo.mutation.Extra(); ok { + _spec.SetField(buildtask.FieldExtra, field.TypeString, value) + } + if btuo.mutation.ExtraCleared() { + _spec.ClearField(buildtask.FieldExtra, field.TypeString) + } if value, ok := btuo.mutation.ClaimedAt(); ok { _spec.SetField(buildtask.FieldClaimedAt, field.TypeTime, value) } @@ -751,6 +1174,18 @@ func (btuo *BuildTaskUpdateOne) sqlSave(ctx context.Context) (_node *BuildTask, if btuo.mutation.ErrorCleared() { _spec.ClearField(buildtask.FieldError, field.TypeString) } + if value, ok := btuo.mutation.ErrorSize(); ok { + _spec.SetField(buildtask.FieldErrorSize, field.TypeInt, value) + } + if value, ok := btuo.mutation.AddedErrorSize(); ok { + _spec.AddField(buildtask.FieldErrorSize, field.TypeInt, value) + } + if value, ok := btuo.mutation.ArtifactPath(); ok { + _spec.SetField(buildtask.FieldArtifactPath, field.TypeString, value) + } + if btuo.mutation.ArtifactPathCleared() { + _spec.ClearField(buildtask.FieldArtifactPath, field.TypeString) + } if btuo.mutation.BuilderCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -780,6 +1215,35 @@ func (btuo *BuildTaskUpdateOne) sqlSave(ctx context.Context) (_node *BuildTask, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if btuo.mutation.ArtifactCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: buildtask.ArtifactTable, + Columns: []string{buildtask.ArtifactColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := btuo.mutation.ArtifactIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: buildtask.ArtifactTable, + Columns: []string{buildtask.ArtifactColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &BuildTask{config: btuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/tavern/internal/ent/client.go b/tavern/internal/ent/client.go index d18289462..fc8a9e5b2 100644 --- a/tavern/internal/ent/client.go +++ b/tavern/internal/ent/client.go @@ -826,6 +826,22 @@ func (c *BuildTaskClient) QueryBuilder(bt *BuildTask) *BuilderQuery { return query } +// QueryArtifact queries the artifact edge of a BuildTask. +func (c *BuildTaskClient) QueryArtifact(bt *BuildTask) *AssetQuery { + query := (&AssetClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := bt.ID + step := sqlgraph.NewStep( + sqlgraph.From(buildtask.Table, buildtask.FieldID, id), + sqlgraph.To(asset.Table, asset.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, buildtask.ArtifactTable, buildtask.ArtifactColumn), + ) + fromV = sqlgraph.Neighbors(bt.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *BuildTaskClient) Hooks() []Hook { hooks := c.hooks.BuildTask diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index 37b75099a..d4e5f3790 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -698,6 +698,17 @@ func (bt *BuildTaskQuery) collectField(ctx context.Context, oneNode bool, opCtx return err } bt.withBuilder = query + + case "artifact": + var ( + alias = field.Alias + path = append(path, alias) + query = (&AssetClient{config: bt.config}).Query() + ) + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, assetImplementors)...); err != nil { + return err + } + bt.withArtifact = query case "createdAt": if _, ok := fieldSeen[buildtask.FieldCreatedAt]; !ok { selectedFields = append(selectedFields, buildtask.FieldCreatedAt) @@ -713,6 +724,11 @@ func (bt *BuildTaskQuery) collectField(ctx context.Context, oneNode bool, opCtx selectedFields = append(selectedFields, buildtask.FieldTargetOs) fieldSeen[buildtask.FieldTargetOs] = struct{}{} } + case "targetFormat": + if _, ok := fieldSeen[buildtask.FieldTargetFormat]; !ok { + selectedFields = append(selectedFields, buildtask.FieldTargetFormat) + fieldSeen[buildtask.FieldTargetFormat] = struct{}{} + } case "buildImage": if _, ok := fieldSeen[buildtask.FieldBuildImage]; !ok { selectedFields = append(selectedFields, buildtask.FieldBuildImage) @@ -723,6 +739,26 @@ func (bt *BuildTaskQuery) collectField(ctx context.Context, oneNode bool, opCtx selectedFields = append(selectedFields, buildtask.FieldBuildScript) fieldSeen[buildtask.FieldBuildScript] = struct{}{} } + case "callbackURI": + if _, ok := fieldSeen[buildtask.FieldCallbackURI]; !ok { + selectedFields = append(selectedFields, buildtask.FieldCallbackURI) + fieldSeen[buildtask.FieldCallbackURI] = struct{}{} + } + case "interval": + if _, ok := fieldSeen[buildtask.FieldInterval]; !ok { + selectedFields = append(selectedFields, buildtask.FieldInterval) + fieldSeen[buildtask.FieldInterval] = struct{}{} + } + case "transportType": + if _, ok := fieldSeen[buildtask.FieldTransportType]; !ok { + selectedFields = append(selectedFields, buildtask.FieldTransportType) + fieldSeen[buildtask.FieldTransportType] = struct{}{} + } + case "extra": + if _, ok := fieldSeen[buildtask.FieldExtra]; !ok { + selectedFields = append(selectedFields, buildtask.FieldExtra) + fieldSeen[buildtask.FieldExtra] = struct{}{} + } case "claimedAt": if _, ok := fieldSeen[buildtask.FieldClaimedAt]; !ok { selectedFields = append(selectedFields, buildtask.FieldClaimedAt) @@ -753,6 +789,16 @@ func (bt *BuildTaskQuery) collectField(ctx context.Context, oneNode bool, opCtx selectedFields = append(selectedFields, buildtask.FieldError) fieldSeen[buildtask.FieldError] = struct{}{} } + case "errorSize": + if _, ok := fieldSeen[buildtask.FieldErrorSize]; !ok { + selectedFields = append(selectedFields, buildtask.FieldErrorSize) + fieldSeen[buildtask.FieldErrorSize] = struct{}{} + } + case "artifactPath": + if _, ok := fieldSeen[buildtask.FieldArtifactPath]; !ok { + selectedFields = append(selectedFields, buildtask.FieldArtifactPath) + fieldSeen[buildtask.FieldArtifactPath] = struct{}{} + } case "id": case "__typename": default: diff --git a/tavern/internal/ent/gql_edge.go b/tavern/internal/ent/gql_edge.go index cfd48244f..878089783 100644 --- a/tavern/internal/ent/gql_edge.go +++ b/tavern/internal/ent/gql_edge.go @@ -116,6 +116,14 @@ func (bt *BuildTask) Builder(ctx context.Context) (*Builder, error) { return result, err } +func (bt *BuildTask) Artifact(ctx context.Context) (*Asset, error) { + result, err := bt.Edges.ArtifactOrErr() + if IsNotLoaded(err) { + result, err = bt.QueryArtifact().Only(ctx) + } + return result, MaskNotFound(err) +} + func (b *Builder) BuildTasks( ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, orderBy []*BuildTaskOrder, where *BuildTaskWhereInput, ) (*BuildTaskConnection, error) { diff --git a/tavern/internal/ent/gql_pagination.go b/tavern/internal/ent/gql_pagination.go index a8362e608..1890fe36b 100644 --- a/tavern/internal/ent/gql_pagination.go +++ b/tavern/internal/ent/gql_pagination.go @@ -1247,6 +1247,20 @@ var ( } }, } + // BuildTaskOrderFieldErrorSize orders BuildTask by error_size. + BuildTaskOrderFieldErrorSize = &BuildTaskOrderField{ + Value: func(bt *BuildTask) (ent.Value, error) { + return bt.ErrorSize, nil + }, + column: buildtask.FieldErrorSize, + toTerm: buildtask.ByErrorSize, + toCursor: func(bt *BuildTask) Cursor { + return Cursor{ + ID: bt.ID, + Value: bt.ErrorSize, + } + }, + } ) // String implement fmt.Stringer interface. @@ -1267,6 +1281,8 @@ func (f BuildTaskOrderField) String() string { str = "FINISHED_AT" case BuildTaskOrderFieldOutputSize.column: str = "OUTPUT_SIZE" + case BuildTaskOrderFieldErrorSize.column: + str = "ERROR_SIZE" } return str } @@ -1297,6 +1313,8 @@ func (f *BuildTaskOrderField) UnmarshalGQL(v interface{}) error { *f = *BuildTaskOrderFieldFinishedAt case "OUTPUT_SIZE": *f = *BuildTaskOrderFieldOutputSize + case "ERROR_SIZE": + *f = *BuildTaskOrderFieldErrorSize default: return fmt.Errorf("%s is not a valid BuildTaskOrderField", str) } diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index 71903bc07..9bf9254f0 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -7,6 +7,7 @@ import ( "fmt" "time" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/c2/epb" "realm.pub/tavern/internal/ent/asset" @@ -1106,6 +1107,12 @@ type BuildTaskWhereInput struct { TargetOsIn []c2pb.Host_Platform `json:"targetOsIn,omitempty"` TargetOsNotIn []c2pb.Host_Platform `json:"targetOsNotIn,omitempty"` + // "target_format" field predicates. + TargetFormat *builderpb.TargetFormat `json:"targetFormat,omitempty"` + TargetFormatNEQ *builderpb.TargetFormat `json:"targetFormatNEQ,omitempty"` + TargetFormatIn []builderpb.TargetFormat `json:"targetFormatIn,omitempty"` + TargetFormatNotIn []builderpb.TargetFormat `json:"targetFormatNotIn,omitempty"` + // "build_image" field predicates. BuildImage *string `json:"buildImage,omitempty"` BuildImageNEQ *string `json:"buildImageNEQ,omitempty"` @@ -1136,6 +1143,54 @@ type BuildTaskWhereInput struct { BuildScriptEqualFold *string `json:"buildScriptEqualFold,omitempty"` BuildScriptContainsFold *string `json:"buildScriptContainsFold,omitempty"` + // "callback_uri" field predicates. + CallbackURI *string `json:"callbackURI,omitempty"` + CallbackURINEQ *string `json:"callbackURINEQ,omitempty"` + CallbackURIIn []string `json:"callbackURIIn,omitempty"` + CallbackURINotIn []string `json:"callbackURINotIn,omitempty"` + CallbackURIGT *string `json:"callbackURIGT,omitempty"` + CallbackURIGTE *string `json:"callbackURIGTE,omitempty"` + CallbackURILT *string `json:"callbackURILT,omitempty"` + CallbackURILTE *string `json:"callbackURILTE,omitempty"` + CallbackURIContains *string `json:"callbackURIContains,omitempty"` + CallbackURIHasPrefix *string `json:"callbackURIHasPrefix,omitempty"` + CallbackURIHasSuffix *string `json:"callbackURIHasSuffix,omitempty"` + CallbackURIEqualFold *string `json:"callbackURIEqualFold,omitempty"` + CallbackURIContainsFold *string `json:"callbackURIContainsFold,omitempty"` + + // "interval" field predicates. + Interval *int `json:"interval,omitempty"` + IntervalNEQ *int `json:"intervalNEQ,omitempty"` + IntervalIn []int `json:"intervalIn,omitempty"` + IntervalNotIn []int `json:"intervalNotIn,omitempty"` + IntervalGT *int `json:"intervalGT,omitempty"` + IntervalGTE *int `json:"intervalGTE,omitempty"` + IntervalLT *int `json:"intervalLT,omitempty"` + IntervalLTE *int `json:"intervalLTE,omitempty"` + + // "transport_type" field predicates. + TransportType *c2pb.Transport_Type `json:"transportType,omitempty"` + TransportTypeNEQ *c2pb.Transport_Type `json:"transportTypeNEQ,omitempty"` + TransportTypeIn []c2pb.Transport_Type `json:"transportTypeIn,omitempty"` + TransportTypeNotIn []c2pb.Transport_Type `json:"transportTypeNotIn,omitempty"` + + // "extra" field predicates. + Extra *string `json:"extra,omitempty"` + ExtraNEQ *string `json:"extraNEQ,omitempty"` + ExtraIn []string `json:"extraIn,omitempty"` + ExtraNotIn []string `json:"extraNotIn,omitempty"` + ExtraGT *string `json:"extraGT,omitempty"` + ExtraGTE *string `json:"extraGTE,omitempty"` + ExtraLT *string `json:"extraLT,omitempty"` + ExtraLTE *string `json:"extraLTE,omitempty"` + ExtraContains *string `json:"extraContains,omitempty"` + ExtraHasPrefix *string `json:"extraHasPrefix,omitempty"` + ExtraHasSuffix *string `json:"extraHasSuffix,omitempty"` + ExtraIsNil bool `json:"extraIsNil,omitempty"` + ExtraNotNil bool `json:"extraNotNil,omitempty"` + ExtraEqualFold *string `json:"extraEqualFold,omitempty"` + ExtraContainsFold *string `json:"extraContainsFold,omitempty"` + // "claimed_at" field predicates. ClaimedAt *time.Time `json:"claimedAt,omitempty"` ClaimedAtNEQ *time.Time `json:"claimedAtNEQ,omitempty"` @@ -1216,9 +1271,40 @@ type BuildTaskWhereInput struct { ErrorEqualFold *string `json:"errorEqualFold,omitempty"` ErrorContainsFold *string `json:"errorContainsFold,omitempty"` + // "error_size" field predicates. + ErrorSize *int `json:"errorSize,omitempty"` + ErrorSizeNEQ *int `json:"errorSizeNEQ,omitempty"` + ErrorSizeIn []int `json:"errorSizeIn,omitempty"` + ErrorSizeNotIn []int `json:"errorSizeNotIn,omitempty"` + ErrorSizeGT *int `json:"errorSizeGT,omitempty"` + ErrorSizeGTE *int `json:"errorSizeGTE,omitempty"` + ErrorSizeLT *int `json:"errorSizeLT,omitempty"` + ErrorSizeLTE *int `json:"errorSizeLTE,omitempty"` + + // "artifact_path" field predicates. + ArtifactPath *string `json:"artifactPath,omitempty"` + ArtifactPathNEQ *string `json:"artifactPathNEQ,omitempty"` + ArtifactPathIn []string `json:"artifactPathIn,omitempty"` + ArtifactPathNotIn []string `json:"artifactPathNotIn,omitempty"` + ArtifactPathGT *string `json:"artifactPathGT,omitempty"` + ArtifactPathGTE *string `json:"artifactPathGTE,omitempty"` + ArtifactPathLT *string `json:"artifactPathLT,omitempty"` + ArtifactPathLTE *string `json:"artifactPathLTE,omitempty"` + ArtifactPathContains *string `json:"artifactPathContains,omitempty"` + ArtifactPathHasPrefix *string `json:"artifactPathHasPrefix,omitempty"` + ArtifactPathHasSuffix *string `json:"artifactPathHasSuffix,omitempty"` + ArtifactPathIsNil bool `json:"artifactPathIsNil,omitempty"` + ArtifactPathNotNil bool `json:"artifactPathNotNil,omitempty"` + ArtifactPathEqualFold *string `json:"artifactPathEqualFold,omitempty"` + ArtifactPathContainsFold *string `json:"artifactPathContainsFold,omitempty"` + // "builder" edge predicates. HasBuilder *bool `json:"hasBuilder,omitempty"` HasBuilderWith []*BuilderWhereInput `json:"hasBuilderWith,omitempty"` + + // "artifact" edge predicates. + HasArtifact *bool `json:"hasArtifact,omitempty"` + HasArtifactWith []*AssetWhereInput `json:"hasArtifactWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -1376,6 +1462,18 @@ func (i *BuildTaskWhereInput) P() (predicate.BuildTask, error) { if len(i.TargetOsNotIn) > 0 { predicates = append(predicates, buildtask.TargetOsNotIn(i.TargetOsNotIn...)) } + if i.TargetFormat != nil { + predicates = append(predicates, buildtask.TargetFormatEQ(*i.TargetFormat)) + } + if i.TargetFormatNEQ != nil { + predicates = append(predicates, buildtask.TargetFormatNEQ(*i.TargetFormatNEQ)) + } + if len(i.TargetFormatIn) > 0 { + predicates = append(predicates, buildtask.TargetFormatIn(i.TargetFormatIn...)) + } + if len(i.TargetFormatNotIn) > 0 { + predicates = append(predicates, buildtask.TargetFormatNotIn(i.TargetFormatNotIn...)) + } if i.BuildImage != nil { predicates = append(predicates, buildtask.BuildImageEQ(*i.BuildImage)) } @@ -1454,6 +1552,126 @@ func (i *BuildTaskWhereInput) P() (predicate.BuildTask, error) { if i.BuildScriptContainsFold != nil { predicates = append(predicates, buildtask.BuildScriptContainsFold(*i.BuildScriptContainsFold)) } + if i.CallbackURI != nil { + predicates = append(predicates, buildtask.CallbackURIEQ(*i.CallbackURI)) + } + if i.CallbackURINEQ != nil { + predicates = append(predicates, buildtask.CallbackURINEQ(*i.CallbackURINEQ)) + } + if len(i.CallbackURIIn) > 0 { + predicates = append(predicates, buildtask.CallbackURIIn(i.CallbackURIIn...)) + } + if len(i.CallbackURINotIn) > 0 { + predicates = append(predicates, buildtask.CallbackURINotIn(i.CallbackURINotIn...)) + } + if i.CallbackURIGT != nil { + predicates = append(predicates, buildtask.CallbackURIGT(*i.CallbackURIGT)) + } + if i.CallbackURIGTE != nil { + predicates = append(predicates, buildtask.CallbackURIGTE(*i.CallbackURIGTE)) + } + if i.CallbackURILT != nil { + predicates = append(predicates, buildtask.CallbackURILT(*i.CallbackURILT)) + } + if i.CallbackURILTE != nil { + predicates = append(predicates, buildtask.CallbackURILTE(*i.CallbackURILTE)) + } + if i.CallbackURIContains != nil { + predicates = append(predicates, buildtask.CallbackURIContains(*i.CallbackURIContains)) + } + if i.CallbackURIHasPrefix != nil { + predicates = append(predicates, buildtask.CallbackURIHasPrefix(*i.CallbackURIHasPrefix)) + } + if i.CallbackURIHasSuffix != nil { + predicates = append(predicates, buildtask.CallbackURIHasSuffix(*i.CallbackURIHasSuffix)) + } + if i.CallbackURIEqualFold != nil { + predicates = append(predicates, buildtask.CallbackURIEqualFold(*i.CallbackURIEqualFold)) + } + if i.CallbackURIContainsFold != nil { + predicates = append(predicates, buildtask.CallbackURIContainsFold(*i.CallbackURIContainsFold)) + } + if i.Interval != nil { + predicates = append(predicates, buildtask.IntervalEQ(*i.Interval)) + } + if i.IntervalNEQ != nil { + predicates = append(predicates, buildtask.IntervalNEQ(*i.IntervalNEQ)) + } + if len(i.IntervalIn) > 0 { + predicates = append(predicates, buildtask.IntervalIn(i.IntervalIn...)) + } + if len(i.IntervalNotIn) > 0 { + predicates = append(predicates, buildtask.IntervalNotIn(i.IntervalNotIn...)) + } + if i.IntervalGT != nil { + predicates = append(predicates, buildtask.IntervalGT(*i.IntervalGT)) + } + if i.IntervalGTE != nil { + predicates = append(predicates, buildtask.IntervalGTE(*i.IntervalGTE)) + } + if i.IntervalLT != nil { + predicates = append(predicates, buildtask.IntervalLT(*i.IntervalLT)) + } + if i.IntervalLTE != nil { + predicates = append(predicates, buildtask.IntervalLTE(*i.IntervalLTE)) + } + if i.TransportType != nil { + predicates = append(predicates, buildtask.TransportTypeEQ(*i.TransportType)) + } + if i.TransportTypeNEQ != nil { + predicates = append(predicates, buildtask.TransportTypeNEQ(*i.TransportTypeNEQ)) + } + if len(i.TransportTypeIn) > 0 { + predicates = append(predicates, buildtask.TransportTypeIn(i.TransportTypeIn...)) + } + if len(i.TransportTypeNotIn) > 0 { + predicates = append(predicates, buildtask.TransportTypeNotIn(i.TransportTypeNotIn...)) + } + if i.Extra != nil { + predicates = append(predicates, buildtask.ExtraEQ(*i.Extra)) + } + if i.ExtraNEQ != nil { + predicates = append(predicates, buildtask.ExtraNEQ(*i.ExtraNEQ)) + } + if len(i.ExtraIn) > 0 { + predicates = append(predicates, buildtask.ExtraIn(i.ExtraIn...)) + } + if len(i.ExtraNotIn) > 0 { + predicates = append(predicates, buildtask.ExtraNotIn(i.ExtraNotIn...)) + } + if i.ExtraGT != nil { + predicates = append(predicates, buildtask.ExtraGT(*i.ExtraGT)) + } + if i.ExtraGTE != nil { + predicates = append(predicates, buildtask.ExtraGTE(*i.ExtraGTE)) + } + if i.ExtraLT != nil { + predicates = append(predicates, buildtask.ExtraLT(*i.ExtraLT)) + } + if i.ExtraLTE != nil { + predicates = append(predicates, buildtask.ExtraLTE(*i.ExtraLTE)) + } + if i.ExtraContains != nil { + predicates = append(predicates, buildtask.ExtraContains(*i.ExtraContains)) + } + if i.ExtraHasPrefix != nil { + predicates = append(predicates, buildtask.ExtraHasPrefix(*i.ExtraHasPrefix)) + } + if i.ExtraHasSuffix != nil { + predicates = append(predicates, buildtask.ExtraHasSuffix(*i.ExtraHasSuffix)) + } + if i.ExtraIsNil { + predicates = append(predicates, buildtask.ExtraIsNil()) + } + if i.ExtraNotNil { + predicates = append(predicates, buildtask.ExtraNotNil()) + } + if i.ExtraEqualFold != nil { + predicates = append(predicates, buildtask.ExtraEqualFold(*i.ExtraEqualFold)) + } + if i.ExtraContainsFold != nil { + predicates = append(predicates, buildtask.ExtraContainsFold(*i.ExtraContainsFold)) + } if i.ClaimedAt != nil { predicates = append(predicates, buildtask.ClaimedAtEQ(*i.ClaimedAt)) } @@ -1658,6 +1876,75 @@ func (i *BuildTaskWhereInput) P() (predicate.BuildTask, error) { if i.ErrorContainsFold != nil { predicates = append(predicates, buildtask.ErrorContainsFold(*i.ErrorContainsFold)) } + if i.ErrorSize != nil { + predicates = append(predicates, buildtask.ErrorSizeEQ(*i.ErrorSize)) + } + if i.ErrorSizeNEQ != nil { + predicates = append(predicates, buildtask.ErrorSizeNEQ(*i.ErrorSizeNEQ)) + } + if len(i.ErrorSizeIn) > 0 { + predicates = append(predicates, buildtask.ErrorSizeIn(i.ErrorSizeIn...)) + } + if len(i.ErrorSizeNotIn) > 0 { + predicates = append(predicates, buildtask.ErrorSizeNotIn(i.ErrorSizeNotIn...)) + } + if i.ErrorSizeGT != nil { + predicates = append(predicates, buildtask.ErrorSizeGT(*i.ErrorSizeGT)) + } + if i.ErrorSizeGTE != nil { + predicates = append(predicates, buildtask.ErrorSizeGTE(*i.ErrorSizeGTE)) + } + if i.ErrorSizeLT != nil { + predicates = append(predicates, buildtask.ErrorSizeLT(*i.ErrorSizeLT)) + } + if i.ErrorSizeLTE != nil { + predicates = append(predicates, buildtask.ErrorSizeLTE(*i.ErrorSizeLTE)) + } + if i.ArtifactPath != nil { + predicates = append(predicates, buildtask.ArtifactPathEQ(*i.ArtifactPath)) + } + if i.ArtifactPathNEQ != nil { + predicates = append(predicates, buildtask.ArtifactPathNEQ(*i.ArtifactPathNEQ)) + } + if len(i.ArtifactPathIn) > 0 { + predicates = append(predicates, buildtask.ArtifactPathIn(i.ArtifactPathIn...)) + } + if len(i.ArtifactPathNotIn) > 0 { + predicates = append(predicates, buildtask.ArtifactPathNotIn(i.ArtifactPathNotIn...)) + } + if i.ArtifactPathGT != nil { + predicates = append(predicates, buildtask.ArtifactPathGT(*i.ArtifactPathGT)) + } + if i.ArtifactPathGTE != nil { + predicates = append(predicates, buildtask.ArtifactPathGTE(*i.ArtifactPathGTE)) + } + if i.ArtifactPathLT != nil { + predicates = append(predicates, buildtask.ArtifactPathLT(*i.ArtifactPathLT)) + } + if i.ArtifactPathLTE != nil { + predicates = append(predicates, buildtask.ArtifactPathLTE(*i.ArtifactPathLTE)) + } + if i.ArtifactPathContains != nil { + predicates = append(predicates, buildtask.ArtifactPathContains(*i.ArtifactPathContains)) + } + if i.ArtifactPathHasPrefix != nil { + predicates = append(predicates, buildtask.ArtifactPathHasPrefix(*i.ArtifactPathHasPrefix)) + } + if i.ArtifactPathHasSuffix != nil { + predicates = append(predicates, buildtask.ArtifactPathHasSuffix(*i.ArtifactPathHasSuffix)) + } + if i.ArtifactPathIsNil { + predicates = append(predicates, buildtask.ArtifactPathIsNil()) + } + if i.ArtifactPathNotNil { + predicates = append(predicates, buildtask.ArtifactPathNotNil()) + } + if i.ArtifactPathEqualFold != nil { + predicates = append(predicates, buildtask.ArtifactPathEqualFold(*i.ArtifactPathEqualFold)) + } + if i.ArtifactPathContainsFold != nil { + predicates = append(predicates, buildtask.ArtifactPathContainsFold(*i.ArtifactPathContainsFold)) + } if i.HasBuilder != nil { p := buildtask.HasBuilder() @@ -1677,6 +1964,24 @@ func (i *BuildTaskWhereInput) P() (predicate.BuildTask, error) { } predicates = append(predicates, buildtask.HasBuilderWith(with...)) } + if i.HasArtifact != nil { + p := buildtask.HasArtifact() + if !*i.HasArtifact { + p = buildtask.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasArtifactWith) > 0 { + with := make([]predicate.Asset, 0, len(i.HasArtifactWith)) + for _, w := range i.HasArtifactWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasArtifactWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, buildtask.HasArtifactWith(with...)) + } switch len(predicates) { case 0: return nil, ErrEmptyBuildTaskWhereInput diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index 9582d40ad..a839893fd 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -69,15 +69,23 @@ var ( {Name: "created_at", Type: field.TypeTime}, {Name: "last_modified_at", Type: field.TypeTime}, {Name: "target_os", Type: field.TypeEnum, Enums: []string{"PLATFORM_BSD", "PLATFORM_LINUX", "PLATFORM_MACOS", "PLATFORM_UNSPECIFIED", "PLATFORM_WINDOWS"}}, + {Name: "target_format", Type: field.TypeEnum, Enums: []string{"BIN", "CDYLIB", "WINDOWS_SERVICE"}}, {Name: "build_image", Type: field.TypeString}, {Name: "build_script", Type: field.TypeString, Size: 2147483647, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, + {Name: "callback_uri", Type: field.TypeString}, + {Name: "interval", Type: field.TypeInt, Default: 5}, + {Name: "transport_type", Type: field.TypeEnum, Enums: []string{"TRANSPORT_DNS", "TRANSPORT_GRPC", "TRANSPORT_HTTP1", "TRANSPORT_UNSPECIFIED"}}, + {Name: "extra", Type: field.TypeString, Nullable: true}, {Name: "claimed_at", Type: field.TypeTime, Nullable: true}, {Name: "started_at", Type: field.TypeTime, Nullable: true}, {Name: "finished_at", Type: field.TypeTime, Nullable: true}, {Name: "output", Type: field.TypeString, Nullable: true, Size: 2147483647, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, {Name: "output_size", Type: field.TypeInt, Default: 0}, {Name: "error", Type: field.TypeString, Nullable: true, Size: 2147483647, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, + {Name: "error_size", Type: field.TypeInt, Default: 0}, + {Name: "artifact_path", Type: field.TypeString, Nullable: true}, {Name: "build_task_builder", Type: field.TypeInt}, + {Name: "build_task_artifact", Type: field.TypeInt, Nullable: true}, } // BuildTasksTable holds the schema information for the "build_tasks" table. BuildTasksTable = &schema.Table{ @@ -87,10 +95,16 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "build_tasks_builders_builder", - Columns: []*schema.Column{BuildTasksColumns[12]}, + Columns: []*schema.Column{BuildTasksColumns[19]}, RefColumns: []*schema.Column{BuildersColumns[0]}, OnDelete: schema.Cascade, }, + { + Symbol: "build_tasks_assets_artifact", + Columns: []*schema.Column{BuildTasksColumns[20]}, + RefColumns: []*schema.Column{AssetsColumns[0]}, + OnDelete: schema.SetNull, + }, }, } // BuildersColumns holds the columns for the "builders" table. @@ -643,6 +657,7 @@ func init() { Collation: "utf8mb4_general_ci", } BuildTasksTable.ForeignKeys[0].RefTable = BuildersTable + BuildTasksTable.ForeignKeys[1].RefTable = AssetsTable BuildTasksTable.Annotation = &entsql.Annotation{ Collation: "utf8mb4_general_ci", } diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index 3d4757b66..8cdee4da7 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/c2/epb" "realm.pub/tavern/internal/ent/asset" @@ -2119,8 +2120,14 @@ type BuildTaskMutation struct { created_at *time.Time last_modified_at *time.Time target_os *c2pb.Host_Platform + target_format *builderpb.TargetFormat build_image *string build_script *string + callback_uri *string + interval *int + addinterval *int + transport_type *c2pb.Transport_Type + extra *string claimed_at *time.Time started_at *time.Time finished_at *time.Time @@ -2128,9 +2135,14 @@ type BuildTaskMutation struct { output_size *int addoutput_size *int error *string + error_size *int + adderror_size *int + artifact_path *string clearedFields map[string]struct{} builder *int clearedbuilder bool + artifact *int + clearedartifact bool done bool oldValue func(context.Context) (*BuildTask, error) predicates []predicate.BuildTask @@ -2342,6 +2354,42 @@ func (m *BuildTaskMutation) ResetTargetOs() { m.target_os = nil } +// SetTargetFormat sets the "target_format" field. +func (m *BuildTaskMutation) SetTargetFormat(bf builderpb.TargetFormat) { + m.target_format = &bf +} + +// TargetFormat returns the value of the "target_format" field in the mutation. +func (m *BuildTaskMutation) TargetFormat() (r builderpb.TargetFormat, exists bool) { + v := m.target_format + if v == nil { + return + } + return *v, true +} + +// OldTargetFormat returns the old "target_format" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldTargetFormat(ctx context.Context) (v builderpb.TargetFormat, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTargetFormat is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTargetFormat requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTargetFormat: %w", err) + } + return oldValue.TargetFormat, nil +} + +// ResetTargetFormat resets all changes to the "target_format" field. +func (m *BuildTaskMutation) ResetTargetFormat() { + m.target_format = nil +} + // SetBuildImage sets the "build_image" field. func (m *BuildTaskMutation) SetBuildImage(s string) { m.build_image = &s @@ -2414,6 +2462,183 @@ func (m *BuildTaskMutation) ResetBuildScript() { m.build_script = nil } +// SetCallbackURI sets the "callback_uri" field. +func (m *BuildTaskMutation) SetCallbackURI(s string) { + m.callback_uri = &s +} + +// CallbackURI returns the value of the "callback_uri" field in the mutation. +func (m *BuildTaskMutation) CallbackURI() (r string, exists bool) { + v := m.callback_uri + if v == nil { + return + } + return *v, true +} + +// OldCallbackURI returns the old "callback_uri" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldCallbackURI(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCallbackURI is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCallbackURI requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCallbackURI: %w", err) + } + return oldValue.CallbackURI, nil +} + +// ResetCallbackURI resets all changes to the "callback_uri" field. +func (m *BuildTaskMutation) ResetCallbackURI() { + m.callback_uri = nil +} + +// SetInterval sets the "interval" field. +func (m *BuildTaskMutation) SetInterval(i int) { + m.interval = &i + m.addinterval = nil +} + +// Interval returns the value of the "interval" field in the mutation. +func (m *BuildTaskMutation) Interval() (r int, exists bool) { + v := m.interval + if v == nil { + return + } + return *v, true +} + +// OldInterval returns the old "interval" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldInterval(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInterval is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInterval requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInterval: %w", err) + } + return oldValue.Interval, nil +} + +// AddInterval adds i to the "interval" field. +func (m *BuildTaskMutation) AddInterval(i int) { + if m.addinterval != nil { + *m.addinterval += i + } else { + m.addinterval = &i + } +} + +// AddedInterval returns the value that was added to the "interval" field in this mutation. +func (m *BuildTaskMutation) AddedInterval() (r int, exists bool) { + v := m.addinterval + if v == nil { + return + } + return *v, true +} + +// ResetInterval resets all changes to the "interval" field. +func (m *BuildTaskMutation) ResetInterval() { + m.interval = nil + m.addinterval = nil +} + +// SetTransportType sets the "transport_type" field. +func (m *BuildTaskMutation) SetTransportType(ct c2pb.Transport_Type) { + m.transport_type = &ct +} + +// TransportType returns the value of the "transport_type" field in the mutation. +func (m *BuildTaskMutation) TransportType() (r c2pb.Transport_Type, exists bool) { + v := m.transport_type + if v == nil { + return + } + return *v, true +} + +// OldTransportType returns the old "transport_type" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldTransportType(ctx context.Context) (v c2pb.Transport_Type, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTransportType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTransportType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTransportType: %w", err) + } + return oldValue.TransportType, nil +} + +// ResetTransportType resets all changes to the "transport_type" field. +func (m *BuildTaskMutation) ResetTransportType() { + m.transport_type = nil +} + +// SetExtra sets the "extra" field. +func (m *BuildTaskMutation) SetExtra(s string) { + m.extra = &s +} + +// Extra returns the value of the "extra" field in the mutation. +func (m *BuildTaskMutation) Extra() (r string, exists bool) { + v := m.extra + if v == nil { + return + } + return *v, true +} + +// OldExtra returns the old "extra" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldExtra(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExtra is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExtra requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExtra: %w", err) + } + return oldValue.Extra, nil +} + +// ClearExtra clears the value of the "extra" field. +func (m *BuildTaskMutation) ClearExtra() { + m.extra = nil + m.clearedFields[buildtask.FieldExtra] = struct{}{} +} + +// ExtraCleared returns if the "extra" field was cleared in this mutation. +func (m *BuildTaskMutation) ExtraCleared() bool { + _, ok := m.clearedFields[buildtask.FieldExtra] + return ok +} + +// ResetExtra resets all changes to the "extra" field. +func (m *BuildTaskMutation) ResetExtra() { + m.extra = nil + delete(m.clearedFields, buildtask.FieldExtra) +} + // SetClaimedAt sets the "claimed_at" field. func (m *BuildTaskMutation) SetClaimedAt(t time.Time) { m.claimed_at = &t @@ -2715,6 +2940,111 @@ func (m *BuildTaskMutation) ResetError() { delete(m.clearedFields, buildtask.FieldError) } +// SetErrorSize sets the "error_size" field. +func (m *BuildTaskMutation) SetErrorSize(i int) { + m.error_size = &i + m.adderror_size = nil +} + +// ErrorSize returns the value of the "error_size" field in the mutation. +func (m *BuildTaskMutation) ErrorSize() (r int, exists bool) { + v := m.error_size + if v == nil { + return + } + return *v, true +} + +// OldErrorSize returns the old "error_size" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldErrorSize(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldErrorSize is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldErrorSize requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldErrorSize: %w", err) + } + return oldValue.ErrorSize, nil +} + +// AddErrorSize adds i to the "error_size" field. +func (m *BuildTaskMutation) AddErrorSize(i int) { + if m.adderror_size != nil { + *m.adderror_size += i + } else { + m.adderror_size = &i + } +} + +// AddedErrorSize returns the value that was added to the "error_size" field in this mutation. +func (m *BuildTaskMutation) AddedErrorSize() (r int, exists bool) { + v := m.adderror_size + if v == nil { + return + } + return *v, true +} + +// ResetErrorSize resets all changes to the "error_size" field. +func (m *BuildTaskMutation) ResetErrorSize() { + m.error_size = nil + m.adderror_size = nil +} + +// SetArtifactPath sets the "artifact_path" field. +func (m *BuildTaskMutation) SetArtifactPath(s string) { + m.artifact_path = &s +} + +// ArtifactPath returns the value of the "artifact_path" field in the mutation. +func (m *BuildTaskMutation) ArtifactPath() (r string, exists bool) { + v := m.artifact_path + if v == nil { + return + } + return *v, true +} + +// OldArtifactPath returns the old "artifact_path" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldArtifactPath(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArtifactPath is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArtifactPath requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArtifactPath: %w", err) + } + return oldValue.ArtifactPath, nil +} + +// ClearArtifactPath clears the value of the "artifact_path" field. +func (m *BuildTaskMutation) ClearArtifactPath() { + m.artifact_path = nil + m.clearedFields[buildtask.FieldArtifactPath] = struct{}{} +} + +// ArtifactPathCleared returns if the "artifact_path" field was cleared in this mutation. +func (m *BuildTaskMutation) ArtifactPathCleared() bool { + _, ok := m.clearedFields[buildtask.FieldArtifactPath] + return ok +} + +// ResetArtifactPath resets all changes to the "artifact_path" field. +func (m *BuildTaskMutation) ResetArtifactPath() { + m.artifact_path = nil + delete(m.clearedFields, buildtask.FieldArtifactPath) +} + // SetBuilderID sets the "builder" edge to the Builder entity by id. func (m *BuildTaskMutation) SetBuilderID(id int) { m.builder = &id @@ -2754,6 +3084,45 @@ func (m *BuildTaskMutation) ResetBuilder() { m.clearedbuilder = false } +// SetArtifactID sets the "artifact" edge to the Asset entity by id. +func (m *BuildTaskMutation) SetArtifactID(id int) { + m.artifact = &id +} + +// ClearArtifact clears the "artifact" edge to the Asset entity. +func (m *BuildTaskMutation) ClearArtifact() { + m.clearedartifact = true +} + +// ArtifactCleared reports if the "artifact" edge to the Asset entity was cleared. +func (m *BuildTaskMutation) ArtifactCleared() bool { + return m.clearedartifact +} + +// ArtifactID returns the "artifact" edge ID in the mutation. +func (m *BuildTaskMutation) ArtifactID() (id int, exists bool) { + if m.artifact != nil { + return *m.artifact, true + } + return +} + +// ArtifactIDs returns the "artifact" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ArtifactID instead. It exists only for internal usage by the builders. +func (m *BuildTaskMutation) ArtifactIDs() (ids []int) { + if id := m.artifact; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetArtifact resets all changes to the "artifact" edge. +func (m *BuildTaskMutation) ResetArtifact() { + m.artifact = nil + m.clearedartifact = false +} + // Where appends a list predicates to the BuildTaskMutation builder. func (m *BuildTaskMutation) Where(ps ...predicate.BuildTask) { m.predicates = append(m.predicates, ps...) @@ -2788,7 +3157,7 @@ func (m *BuildTaskMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BuildTaskMutation) Fields() []string { - fields := make([]string, 0, 11) + fields := make([]string, 0, 18) if m.created_at != nil { fields = append(fields, buildtask.FieldCreatedAt) } @@ -2798,12 +3167,27 @@ func (m *BuildTaskMutation) Fields() []string { if m.target_os != nil { fields = append(fields, buildtask.FieldTargetOs) } + if m.target_format != nil { + fields = append(fields, buildtask.FieldTargetFormat) + } if m.build_image != nil { fields = append(fields, buildtask.FieldBuildImage) } if m.build_script != nil { fields = append(fields, buildtask.FieldBuildScript) } + if m.callback_uri != nil { + fields = append(fields, buildtask.FieldCallbackURI) + } + if m.interval != nil { + fields = append(fields, buildtask.FieldInterval) + } + if m.transport_type != nil { + fields = append(fields, buildtask.FieldTransportType) + } + if m.extra != nil { + fields = append(fields, buildtask.FieldExtra) + } if m.claimed_at != nil { fields = append(fields, buildtask.FieldClaimedAt) } @@ -2822,6 +3206,12 @@ func (m *BuildTaskMutation) Fields() []string { if m.error != nil { fields = append(fields, buildtask.FieldError) } + if m.error_size != nil { + fields = append(fields, buildtask.FieldErrorSize) + } + if m.artifact_path != nil { + fields = append(fields, buildtask.FieldArtifactPath) + } return fields } @@ -2836,10 +3226,20 @@ func (m *BuildTaskMutation) Field(name string) (ent.Value, bool) { return m.LastModifiedAt() case buildtask.FieldTargetOs: return m.TargetOs() + case buildtask.FieldTargetFormat: + return m.TargetFormat() case buildtask.FieldBuildImage: return m.BuildImage() case buildtask.FieldBuildScript: return m.BuildScript() + case buildtask.FieldCallbackURI: + return m.CallbackURI() + case buildtask.FieldInterval: + return m.Interval() + case buildtask.FieldTransportType: + return m.TransportType() + case buildtask.FieldExtra: + return m.Extra() case buildtask.FieldClaimedAt: return m.ClaimedAt() case buildtask.FieldStartedAt: @@ -2852,6 +3252,10 @@ func (m *BuildTaskMutation) Field(name string) (ent.Value, bool) { return m.OutputSize() case buildtask.FieldError: return m.Error() + case buildtask.FieldErrorSize: + return m.ErrorSize() + case buildtask.FieldArtifactPath: + return m.ArtifactPath() } return nil, false } @@ -2867,10 +3271,20 @@ func (m *BuildTaskMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldLastModifiedAt(ctx) case buildtask.FieldTargetOs: return m.OldTargetOs(ctx) + case buildtask.FieldTargetFormat: + return m.OldTargetFormat(ctx) case buildtask.FieldBuildImage: return m.OldBuildImage(ctx) case buildtask.FieldBuildScript: return m.OldBuildScript(ctx) + case buildtask.FieldCallbackURI: + return m.OldCallbackURI(ctx) + case buildtask.FieldInterval: + return m.OldInterval(ctx) + case buildtask.FieldTransportType: + return m.OldTransportType(ctx) + case buildtask.FieldExtra: + return m.OldExtra(ctx) case buildtask.FieldClaimedAt: return m.OldClaimedAt(ctx) case buildtask.FieldStartedAt: @@ -2883,6 +3297,10 @@ func (m *BuildTaskMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldOutputSize(ctx) case buildtask.FieldError: return m.OldError(ctx) + case buildtask.FieldErrorSize: + return m.OldErrorSize(ctx) + case buildtask.FieldArtifactPath: + return m.OldArtifactPath(ctx) } return nil, fmt.Errorf("unknown BuildTask field %s", name) } @@ -2913,6 +3331,13 @@ func (m *BuildTaskMutation) SetField(name string, value ent.Value) error { } m.SetTargetOs(v) return nil + case buildtask.FieldTargetFormat: + v, ok := value.(builderpb.TargetFormat) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTargetFormat(v) + return nil case buildtask.FieldBuildImage: v, ok := value.(string) if !ok { @@ -2927,6 +3352,34 @@ func (m *BuildTaskMutation) SetField(name string, value ent.Value) error { } m.SetBuildScript(v) return nil + case buildtask.FieldCallbackURI: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCallbackURI(v) + return nil + case buildtask.FieldInterval: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInterval(v) + return nil + case buildtask.FieldTransportType: + v, ok := value.(c2pb.Transport_Type) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTransportType(v) + return nil + case buildtask.FieldExtra: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExtra(v) + return nil case buildtask.FieldClaimedAt: v, ok := value.(time.Time) if !ok { @@ -2969,6 +3422,20 @@ func (m *BuildTaskMutation) SetField(name string, value ent.Value) error { } m.SetError(v) return nil + case buildtask.FieldErrorSize: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetErrorSize(v) + return nil + case buildtask.FieldArtifactPath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArtifactPath(v) + return nil } return fmt.Errorf("unknown BuildTask field %s", name) } @@ -2977,9 +3444,15 @@ func (m *BuildTaskMutation) SetField(name string, value ent.Value) error { // this mutation. func (m *BuildTaskMutation) AddedFields() []string { var fields []string + if m.addinterval != nil { + fields = append(fields, buildtask.FieldInterval) + } if m.addoutput_size != nil { fields = append(fields, buildtask.FieldOutputSize) } + if m.adderror_size != nil { + fields = append(fields, buildtask.FieldErrorSize) + } return fields } @@ -2988,8 +3461,12 @@ func (m *BuildTaskMutation) AddedFields() []string { // was not set, or was not defined in the schema. func (m *BuildTaskMutation) AddedField(name string) (ent.Value, bool) { switch name { + case buildtask.FieldInterval: + return m.AddedInterval() case buildtask.FieldOutputSize: return m.AddedOutputSize() + case buildtask.FieldErrorSize: + return m.AddedErrorSize() } return nil, false } @@ -2999,6 +3476,13 @@ func (m *BuildTaskMutation) AddedField(name string) (ent.Value, bool) { // type. func (m *BuildTaskMutation) AddField(name string, value ent.Value) error { switch name { + case buildtask.FieldInterval: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddInterval(v) + return nil case buildtask.FieldOutputSize: v, ok := value.(int) if !ok { @@ -3006,6 +3490,13 @@ func (m *BuildTaskMutation) AddField(name string, value ent.Value) error { } m.AddOutputSize(v) return nil + case buildtask.FieldErrorSize: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddErrorSize(v) + return nil } return fmt.Errorf("unknown BuildTask numeric field %s", name) } @@ -3014,6 +3505,9 @@ func (m *BuildTaskMutation) AddField(name string, value ent.Value) error { // mutation. func (m *BuildTaskMutation) ClearedFields() []string { var fields []string + if m.FieldCleared(buildtask.FieldExtra) { + fields = append(fields, buildtask.FieldExtra) + } if m.FieldCleared(buildtask.FieldClaimedAt) { fields = append(fields, buildtask.FieldClaimedAt) } @@ -3029,6 +3523,9 @@ func (m *BuildTaskMutation) ClearedFields() []string { if m.FieldCleared(buildtask.FieldError) { fields = append(fields, buildtask.FieldError) } + if m.FieldCleared(buildtask.FieldArtifactPath) { + fields = append(fields, buildtask.FieldArtifactPath) + } return fields } @@ -3043,6 +3540,9 @@ func (m *BuildTaskMutation) FieldCleared(name string) bool { // error if the field is not defined in the schema. func (m *BuildTaskMutation) ClearField(name string) error { switch name { + case buildtask.FieldExtra: + m.ClearExtra() + return nil case buildtask.FieldClaimedAt: m.ClearClaimedAt() return nil @@ -3058,6 +3558,9 @@ func (m *BuildTaskMutation) ClearField(name string) error { case buildtask.FieldError: m.ClearError() return nil + case buildtask.FieldArtifactPath: + m.ClearArtifactPath() + return nil } return fmt.Errorf("unknown BuildTask nullable field %s", name) } @@ -3075,12 +3578,27 @@ func (m *BuildTaskMutation) ResetField(name string) error { case buildtask.FieldTargetOs: m.ResetTargetOs() return nil + case buildtask.FieldTargetFormat: + m.ResetTargetFormat() + return nil case buildtask.FieldBuildImage: m.ResetBuildImage() return nil case buildtask.FieldBuildScript: m.ResetBuildScript() return nil + case buildtask.FieldCallbackURI: + m.ResetCallbackURI() + return nil + case buildtask.FieldInterval: + m.ResetInterval() + return nil + case buildtask.FieldTransportType: + m.ResetTransportType() + return nil + case buildtask.FieldExtra: + m.ResetExtra() + return nil case buildtask.FieldClaimedAt: m.ResetClaimedAt() return nil @@ -3099,16 +3617,25 @@ func (m *BuildTaskMutation) ResetField(name string) error { case buildtask.FieldError: m.ResetError() return nil + case buildtask.FieldErrorSize: + m.ResetErrorSize() + return nil + case buildtask.FieldArtifactPath: + m.ResetArtifactPath() + return nil } return fmt.Errorf("unknown BuildTask field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *BuildTaskMutation) AddedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) if m.builder != nil { edges = append(edges, buildtask.EdgeBuilder) } + if m.artifact != nil { + edges = append(edges, buildtask.EdgeArtifact) + } return edges } @@ -3120,13 +3647,17 @@ func (m *BuildTaskMutation) AddedIDs(name string) []ent.Value { if id := m.builder; id != nil { return []ent.Value{*id} } + case buildtask.EdgeArtifact: + if id := m.artifact; id != nil { + return []ent.Value{*id} + } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *BuildTaskMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) return edges } @@ -3138,10 +3669,13 @@ func (m *BuildTaskMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *BuildTaskMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) if m.clearedbuilder { edges = append(edges, buildtask.EdgeBuilder) } + if m.clearedartifact { + edges = append(edges, buildtask.EdgeArtifact) + } return edges } @@ -3151,6 +3685,8 @@ func (m *BuildTaskMutation) EdgeCleared(name string) bool { switch name { case buildtask.EdgeBuilder: return m.clearedbuilder + case buildtask.EdgeArtifact: + return m.clearedartifact } return false } @@ -3162,6 +3698,9 @@ func (m *BuildTaskMutation) ClearEdge(name string) error { case buildtask.EdgeBuilder: m.ClearBuilder() return nil + case buildtask.EdgeArtifact: + m.ClearArtifact() + return nil } return fmt.Errorf("unknown BuildTask unique edge %s", name) } @@ -3173,6 +3712,9 @@ func (m *BuildTaskMutation) ResetEdge(name string) error { case buildtask.EdgeBuilder: m.ResetBuilder() return nil + case buildtask.EdgeArtifact: + m.ResetArtifact() + return nil } return fmt.Errorf("unknown BuildTask edge %s", name) } diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index 33159771c..cec37f06c 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -113,19 +113,33 @@ func init() { // buildtask.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. buildtask.UpdateDefaultLastModifiedAt = buildtaskDescLastModifiedAt.UpdateDefault.(func() time.Time) // buildtaskDescBuildImage is the schema descriptor for build_image field. - buildtaskDescBuildImage := buildtaskFields[1].Descriptor() + buildtaskDescBuildImage := buildtaskFields[2].Descriptor() // buildtask.BuildImageValidator is a validator for the "build_image" field. It is called by the builders before save. buildtask.BuildImageValidator = buildtaskDescBuildImage.Validators[0].(func(string) error) // buildtaskDescBuildScript is the schema descriptor for build_script field. - buildtaskDescBuildScript := buildtaskFields[2].Descriptor() + buildtaskDescBuildScript := buildtaskFields[3].Descriptor() // buildtask.BuildScriptValidator is a validator for the "build_script" field. It is called by the builders before save. buildtask.BuildScriptValidator = buildtaskDescBuildScript.Validators[0].(func(string) error) + // buildtaskDescCallbackURI is the schema descriptor for callback_uri field. + buildtaskDescCallbackURI := buildtaskFields[4].Descriptor() + // buildtask.CallbackURIValidator is a validator for the "callback_uri" field. It is called by the builders before save. + buildtask.CallbackURIValidator = buildtaskDescCallbackURI.Validators[0].(func(string) error) + // buildtaskDescInterval is the schema descriptor for interval field. + buildtaskDescInterval := buildtaskFields[5].Descriptor() + // buildtask.DefaultInterval holds the default value on creation for the interval field. + buildtask.DefaultInterval = buildtaskDescInterval.Default.(int) // buildtaskDescOutputSize is the schema descriptor for output_size field. - buildtaskDescOutputSize := buildtaskFields[7].Descriptor() + buildtaskDescOutputSize := buildtaskFields[12].Descriptor() // buildtask.DefaultOutputSize holds the default value on creation for the output_size field. buildtask.DefaultOutputSize = buildtaskDescOutputSize.Default.(int) // buildtask.OutputSizeValidator is a validator for the "output_size" field. It is called by the builders before save. buildtask.OutputSizeValidator = buildtaskDescOutputSize.Validators[0].(func(int) error) + // buildtaskDescErrorSize is the schema descriptor for error_size field. + buildtaskDescErrorSize := buildtaskFields[14].Descriptor() + // buildtask.DefaultErrorSize holds the default value on creation for the error_size field. + buildtask.DefaultErrorSize = buildtaskDescErrorSize.Default.(int) + // buildtask.ErrorSizeValidator is a validator for the "error_size" field. It is called by the builders before save. + buildtask.ErrorSizeValidator = buildtaskDescErrorSize.Validators[0].(func(int) error) builderMixin := schema.Builder{}.Mixin() builderMixinFields0 := builderMixin[0].Fields() _ = builderMixinFields0 diff --git a/tavern/internal/ent/schema/build_task.go b/tavern/internal/ent/schema/build_task.go index 652e54cde..bbb948690 100644 --- a/tavern/internal/ent/schema/build_task.go +++ b/tavern/internal/ent/schema/build_task.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent/hook" ) @@ -30,6 +31,12 @@ func (BuildTask) Fields() []ent.Field { entgql.OrderField("TARGET_OS"), ). Comment("The target operating system platform for this build."), + field.Enum("target_format"). + GoType(builderpb.TargetFormat("")). + Annotations( + entgql.Type("BuildTaskTargetFormat"), + ). + Comment("The output format for the build (BIN, CDYLIB, WINDOWS_SERVICE)."), field.String("build_image"). NotEmpty(). Comment("Docker container image name to use for the build."), @@ -38,7 +45,25 @@ func (BuildTask) Fields() []ent.Field { SchemaType(map[string]string{ dialect.MySQL: "LONGTEXT", }). - Comment("The script to execute inside the build container."), + Annotations( + entgql.Skip(entgql.SkipMutationCreateInput), + ). + Comment("The derived script to execute inside the build container."), + field.String("callback_uri"). + NotEmpty(). + Comment("The callback URI for the IMIX agent to connect to."), + field.Int("interval"). + Default(builderpb.DefaultInterval). + Comment("The callback interval in seconds for the IMIX agent."), + field.Enum("transport_type"). + GoType(c2pb.Transport_Type(0)). + Annotations( + entgql.Type("BeaconTransport_Type"), + ). + Comment("The transport type for the IMIX agent."), + field.String("extra"). + Optional(). + Comment("Extra transport configuration for the IMIX agent."), field.Time("claimed_at"). Optional(). Annotations( @@ -76,6 +101,19 @@ func (BuildTask) Fields() []ent.Field { dialect.MySQL: "LONGTEXT", }). Comment("Error message if the build failed."), + field.Int("error_size"). + Default(0). + Min(0). + Annotations( + entgql.OrderField("ERROR_SIZE"), + ). + Comment("The size of the error in bytes"), + field.String("artifact_path"). + Optional(). + Annotations( + entgql.Skip(entgql.SkipMutationCreateInput), + ). + Comment("Path inside the container where the build artifact is located. Derived from target_os if not set."), } } @@ -89,6 +127,9 @@ func (BuildTask) Edges() []ent.Edge { Required(). Unique(). Comment("The builder assigned to execute this build task."), + edge.To("artifact", Asset.Type). + Unique(). + Comment("The compiled artifact produced by this build task, stored as an Asset."), } } @@ -117,11 +158,13 @@ func (BuildTask) Hooks() []ent.Hook { } } -// HookDeriveBuildTaskInfo will update build task info (e.g. output_size) whenever it is mutated. +// HookDeriveBuildTaskInfo will update build task info (e.g. output_size, error_size) whenever it is mutated. func HookDeriveBuildTaskInfo() ent.Hook { type btMutation interface { Output() (string, bool) SetOutputSize(i int) + Error() (string, bool) + SetErrorSize(i int) } return func(next ent.Mutator) ent.Mutator { @@ -134,6 +177,9 @@ func HookDeriveBuildTaskInfo() ent.Hook { output, _ := bt.Output() bt.SetOutputSize(len([]byte(output))) + errStr, _ := bt.Error() + bt.SetErrorSize(len([]byte(errStr))) + return next.Mutate(ctx, m) }) } diff --git a/tavern/internal/graphql/build_task_test.go b/tavern/internal/graphql/build_task_test.go index 92d2d712d..39ac1dd54 100644 --- a/tavern/internal/graphql/build_task_test.go +++ b/tavern/internal/graphql/build_task_test.go @@ -34,8 +34,13 @@ func TestCreateBuildTask(t *testing.T) { createBuildTask(input: $input) { id targetOs + targetFormat buildImage buildScript + callbackURI + interval + transportType + artifactPath builder { id } } }` @@ -52,9 +57,10 @@ func TestCreateBuildTask(t *testing.T) { } } err := gqlClient.Post(mutIDOnly, &resp, client.Var("input", map[string]any{ - "targetOS": "PLATFORM_LINUX", - "buildImage": "golang:1.21", - "buildScript": "go build ./...", + "targetOS": "PLATFORM_LINUX", + "targetFormat": "BIN", + "buildImage": "golang:1.21", + "callbackURI": "https://callback.example.com", })) require.Error(t, err) assert.Contains(t, err.Error(), "no builder available") @@ -73,9 +79,10 @@ func TestCreateBuildTask(t *testing.T) { } } err := gqlClient.Post(mutIDOnly, &resp, client.Var("input", map[string]any{ - "targetOS": "PLATFORM_LINUX", - "buildImage": "golang:1.21", - "buildScript": "go build ./...", + "targetOS": "PLATFORM_LINUX", + "targetFormat": "BIN", + "buildImage": "golang:1.21", + "callbackURI": "https://callback.example.com", })) require.Error(t, err) assert.Contains(t, err.Error(), "no builder available") @@ -93,25 +100,36 @@ func TestCreateBuildTask(t *testing.T) { var resp struct { CreateBuildTask struct { - ID string - TargetOs string - BuildImage string - BuildScript string - Builder struct { + ID string + TargetOs string + TargetFormat string + BuildImage string + BuildScript string + CallbackURI string + Interval int + TransportType string + ArtifactPath string + Builder struct { ID string } } } err := gqlClient.Post(mutFull, &resp, client.Var("input", map[string]any{ - "targetOS": "PLATFORM_LINUX", - "buildImage": "golang:1.21", - "buildScript": "go build ./...", + "targetOS": "PLATFORM_LINUX", + "targetFormat": "BIN", + "buildImage": "golang:1.21", + "callbackURI": "https://callback.example.com", })) require.NoError(t, err) require.NotEmpty(t, resp.CreateBuildTask.ID) assert.Equal(t, "PLATFORM_LINUX", resp.CreateBuildTask.TargetOs) + assert.Equal(t, "BIN", resp.CreateBuildTask.TargetFormat) assert.Equal(t, "golang:1.21", resp.CreateBuildTask.BuildImage) - assert.Equal(t, "go build ./...", resp.CreateBuildTask.BuildScript) + assert.Contains(t, resp.CreateBuildTask.BuildScript, "cargo build") + assert.Equal(t, "https://callback.example.com", resp.CreateBuildTask.CallbackURI) + assert.Equal(t, 5, resp.CreateBuildTask.Interval) + assert.Equal(t, "TRANSPORT_GRPC", resp.CreateBuildTask.TransportType) + assert.Contains(t, resp.CreateBuildTask.ArtifactPath, "x86_64-unknown-linux-musl") // Verify the builder edge bt := graph.BuildTask.GetX(ctx, convertID(resp.CreateBuildTask.ID)) @@ -119,6 +137,77 @@ func TestCreateBuildTask(t *testing.T) { assert.Equal(t, linuxBuilder.ID, assignedBuilder.ID) }) + t.Run("DefaultsApplied", func(t *testing.T) { + // Clean up + graph.BuildTask.Delete().ExecX(ctx) + graph.Builder.Delete().ExecX(ctx) + + graph.Builder.Create(). + SetSupportedTargets([]c2pb.Host_Platform{c2pb.Host_PLATFORM_LINUX}). + SetUpstream("https://example.com"). + SaveX(ctx) + + var resp struct { + CreateBuildTask struct { + ID string + CallbackURI string + Interval int + TransportType string + ArtifactPath string + } + } + // Only specify required fields; callbackURI, transportType, and artifactPath should get defaults. + err := gqlClient.Post(`mutation createBuildTask($input: CreateBuildTaskInput!) { + createBuildTask(input: $input) { + id + callbackURI + interval + transportType + artifactPath + } + }`, &resp, client.Var("input", map[string]any{ + "targetOS": "PLATFORM_LINUX", + "targetFormat": "BIN", + "buildImage": "golang:1.21", + })) + require.NoError(t, err) + assert.Equal(t, "http://127.0.0.1:8000", resp.CreateBuildTask.CallbackURI) + assert.Equal(t, 5, resp.CreateBuildTask.Interval) + assert.Equal(t, "TRANSPORT_GRPC", resp.CreateBuildTask.TransportType) + assert.Contains(t, resp.CreateBuildTask.ArtifactPath, "x86_64-unknown-linux-musl") + }) + + t.Run("CustomArtifactPath", func(t *testing.T) { + // Clean up + graph.BuildTask.Delete().ExecX(ctx) + graph.Builder.Delete().ExecX(ctx) + + graph.Builder.Create(). + SetSupportedTargets([]c2pb.Host_Platform{c2pb.Host_PLATFORM_LINUX}). + SetUpstream("https://example.com"). + SaveX(ctx) + + var resp struct { + CreateBuildTask struct { + ID string + ArtifactPath string + } + } + err := gqlClient.Post(`mutation createBuildTask($input: CreateBuildTaskInput!) { + createBuildTask(input: $input) { + id + artifactPath + } + }`, &resp, client.Var("input", map[string]any{ + "targetOS": "PLATFORM_LINUX", + "targetFormat": "BIN", + "buildImage": "golang:1.21", + "artifactPath": "/custom/path/to/binary", + })) + require.NoError(t, err) + assert.Equal(t, "/custom/path/to/binary", resp.CreateBuildTask.ArtifactPath) + }) + t.Run("MultipleMatchingBuilders", func(t *testing.T) { // Clean up graph.BuildTask.Delete().ExecX(ctx) @@ -143,9 +232,10 @@ func TestCreateBuildTask(t *testing.T) { } } err := gqlClient.Post(mutIDOnly, &resp, client.Var("input", map[string]any{ - "targetOS": "PLATFORM_LINUX", - "buildImage": "golang:1.21", - "buildScript": "go build ./...", + "targetOS": "PLATFORM_LINUX", + "targetFormat": "BIN", + "buildImage": "golang:1.21", + "callbackURI": "https://callback.example.com", })) require.NoError(t, err) @@ -158,4 +248,64 @@ func TestCreateBuildTask(t *testing.T) { // With 3 builders and 20 attempts, we should see at least 2 different builders selected assert.Greater(t, len(selectedBuilders), 1, "expected random selection across multiple builders") }) + + t.Run("InvalidTargetFormat", func(t *testing.T) { + // Clean up + graph.BuildTask.Delete().ExecX(ctx) + graph.Builder.Delete().ExecX(ctx) + + graph.Builder.Create(). + SetSupportedTargets([]c2pb.Host_Platform{c2pb.Host_PLATFORM_LINUX}). + SetUpstream("https://example.com"). + SaveX(ctx) + + var resp struct { + CreateBuildTask struct { + ID string + } + } + // cdylib is not supported on Linux + err := gqlClient.Post(mutIDOnly, &resp, client.Var("input", map[string]any{ + "targetOS": "PLATFORM_LINUX", + "targetFormat": "CDYLIB", + "buildImage": "golang:1.21", + "callbackURI": "https://callback.example.com", + })) + require.Error(t, err) + assert.Contains(t, err.Error(), "not supported") + }) + + t.Run("WindowsServiceFormat", func(t *testing.T) { + // Clean up + graph.BuildTask.Delete().ExecX(ctx) + graph.Builder.Delete().ExecX(ctx) + + graph.Builder.Create(). + SetSupportedTargets([]c2pb.Host_Platform{c2pb.Host_PLATFORM_WINDOWS}). + SetUpstream("https://example.com"). + SaveX(ctx) + + var resp struct { + CreateBuildTask struct { + ID string + TargetFormat string + BuildScript string + } + } + err := gqlClient.Post(`mutation createBuildTask($input: CreateBuildTaskInput!) { + createBuildTask(input: $input) { + id + targetFormat + buildScript + } + }`, &resp, client.Var("input", map[string]any{ + "targetOS": "PLATFORM_WINDOWS", + "targetFormat": "WINDOWS_SERVICE", + "buildImage": "golang:1.21", + "callbackURI": "https://callback.example.com", + })) + require.NoError(t, err) + assert.Equal(t, "WINDOWS_SERVICE", resp.CreateBuildTask.TargetFormat) + assert.Contains(t, resp.CreateBuildTask.BuildScript, "win_service") + }) } diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index da17aacd6..1d24236d4 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -13,6 +13,7 @@ import ( "entgo.io/contrib/entgql" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/c2/epb" "realm.pub/tavern/internal/ent" @@ -2628,6 +2629,35 @@ func (ec *executionContext) fieldContext_BuildTask_targetOs(_ context.Context, f return fc, nil } +func (ec *executionContext) _BuildTask_targetFormat(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_BuildTask_targetFormat, + func(ctx context.Context) (any, error) { + return obj.TargetFormat, nil + }, + nil, + ec.marshalNBuildTaskTargetFormat2realmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_BuildTask_targetFormat(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuildTask", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type BuildTaskTargetFormat does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _BuildTask_buildImage(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -2686,6 +2716,122 @@ func (ec *executionContext) fieldContext_BuildTask_buildScript(_ context.Context return fc, nil } +func (ec *executionContext) _BuildTask_callbackURI(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_BuildTask_callbackURI, + func(ctx context.Context) (any, error) { + return obj.CallbackURI, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_BuildTask_callbackURI(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuildTask", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _BuildTask_interval(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_BuildTask_interval, + func(ctx context.Context) (any, error) { + return obj.Interval, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_BuildTask_interval(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuildTask", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _BuildTask_transportType(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_BuildTask_transportType, + func(ctx context.Context) (any, error) { + return obj.TransportType, nil + }, + nil, + ec.marshalNBeaconTransport_Type2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_BuildTask_transportType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuildTask", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type BeaconTransport_Type does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _BuildTask_extra(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_BuildTask_extra, + func(ctx context.Context) (any, error) { + return obj.Extra, nil + }, + nil, + ec.marshalOString2string, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_BuildTask_extra(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuildTask", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _BuildTask_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -2860,6 +3006,64 @@ func (ec *executionContext) fieldContext_BuildTask_error(_ context.Context, fiel return fc, nil } +func (ec *executionContext) _BuildTask_errorSize(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_BuildTask_errorSize, + func(ctx context.Context) (any, error) { + return obj.ErrorSize, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_BuildTask_errorSize(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuildTask", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _BuildTask_artifactPath(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_BuildTask_artifactPath, + func(ctx context.Context) (any, error) { + return obj.ArtifactPath, nil + }, + nil, + ec.marshalOString2string, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_BuildTask_artifactPath(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuildTask", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _BuildTask_builder(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -2905,6 +3109,55 @@ func (ec *executionContext) fieldContext_BuildTask_builder(_ context.Context, fi return fc, nil } +func (ec *executionContext) _BuildTask_artifact(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_BuildTask_artifact, + func(ctx context.Context) (any, error) { + return obj.Artifact(ctx) + }, + nil, + ec.marshalOAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_BuildTask_artifact(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuildTask", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Asset_id(ctx, field) + case "createdAt": + return ec.fieldContext_Asset_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Asset_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Asset_name(ctx, field) + case "size": + return ec.fieldContext_Asset_size(ctx, field) + case "hash": + return ec.fieldContext_Asset_hash(ctx, field) + case "tomes": + return ec.fieldContext_Asset_tomes(ctx, field) + case "links": + return ec.fieldContext_Asset_links(ctx, field) + case "creator": + return ec.fieldContext_Asset_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _BuildTaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -3040,10 +3293,20 @@ func (ec *executionContext) fieldContext_BuildTaskEdge_node(_ context.Context, f return ec.fieldContext_BuildTask_lastModifiedAt(ctx, field) case "targetOs": return ec.fieldContext_BuildTask_targetOs(ctx, field) + case "targetFormat": + return ec.fieldContext_BuildTask_targetFormat(ctx, field) case "buildImage": return ec.fieldContext_BuildTask_buildImage(ctx, field) case "buildScript": return ec.fieldContext_BuildTask_buildScript(ctx, field) + case "callbackURI": + return ec.fieldContext_BuildTask_callbackURI(ctx, field) + case "interval": + return ec.fieldContext_BuildTask_interval(ctx, field) + case "transportType": + return ec.fieldContext_BuildTask_transportType(ctx, field) + case "extra": + return ec.fieldContext_BuildTask_extra(ctx, field) case "claimedAt": return ec.fieldContext_BuildTask_claimedAt(ctx, field) case "startedAt": @@ -3056,8 +3319,14 @@ func (ec *executionContext) fieldContext_BuildTaskEdge_node(_ context.Context, f return ec.fieldContext_BuildTask_outputSize(ctx, field) case "error": return ec.fieldContext_BuildTask_error(ctx, field) + case "errorSize": + return ec.fieldContext_BuildTask_errorSize(ctx, field) + case "artifactPath": + return ec.fieldContext_BuildTask_artifactPath(ctx, field) case "builder": return ec.fieldContext_BuildTask_builder(ctx, field) + case "artifact": + return ec.fieldContext_BuildTask_artifact(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type BuildTask", field.Name) }, @@ -13368,7 +13637,7 @@ func (ec *executionContext) unmarshalInputBuildTaskWhereInput(ctx context.Contex asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "targetOs", "targetOsNEQ", "targetOsIn", "targetOsNotIn", "buildImage", "buildImageNEQ", "buildImageIn", "buildImageNotIn", "buildImageGT", "buildImageGTE", "buildImageLT", "buildImageLTE", "buildImageContains", "buildImageHasPrefix", "buildImageHasSuffix", "buildImageEqualFold", "buildImageContainsFold", "buildScript", "buildScriptNEQ", "buildScriptIn", "buildScriptNotIn", "buildScriptGT", "buildScriptGTE", "buildScriptLT", "buildScriptLTE", "buildScriptContains", "buildScriptHasPrefix", "buildScriptHasSuffix", "buildScriptEqualFold", "buildScriptContainsFold", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "startedAt", "startedAtNEQ", "startedAtIn", "startedAtNotIn", "startedAtGT", "startedAtGTE", "startedAtLT", "startedAtLTE", "startedAtIsNil", "startedAtNotNil", "finishedAt", "finishedAtNEQ", "finishedAtIn", "finishedAtNotIn", "finishedAtGT", "finishedAtGTE", "finishedAtLT", "finishedAtLTE", "finishedAtIsNil", "finishedAtNotNil", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "outputSize", "outputSizeNEQ", "outputSizeIn", "outputSizeNotIn", "outputSizeGT", "outputSizeGTE", "outputSizeLT", "outputSizeLTE", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "hasBuilder", "hasBuilderWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "targetOs", "targetOsNEQ", "targetOsIn", "targetOsNotIn", "targetFormat", "targetFormatNEQ", "targetFormatIn", "targetFormatNotIn", "buildImage", "buildImageNEQ", "buildImageIn", "buildImageNotIn", "buildImageGT", "buildImageGTE", "buildImageLT", "buildImageLTE", "buildImageContains", "buildImageHasPrefix", "buildImageHasSuffix", "buildImageEqualFold", "buildImageContainsFold", "buildScript", "buildScriptNEQ", "buildScriptIn", "buildScriptNotIn", "buildScriptGT", "buildScriptGTE", "buildScriptLT", "buildScriptLTE", "buildScriptContains", "buildScriptHasPrefix", "buildScriptHasSuffix", "buildScriptEqualFold", "buildScriptContainsFold", "callbackURI", "callbackURINEQ", "callbackURIIn", "callbackURINotIn", "callbackURIGT", "callbackURIGTE", "callbackURILT", "callbackURILTE", "callbackURIContains", "callbackURIHasPrefix", "callbackURIHasSuffix", "callbackURIEqualFold", "callbackURIContainsFold", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "transportType", "transportTypeNEQ", "transportTypeIn", "transportTypeNotIn", "extra", "extraNEQ", "extraIn", "extraNotIn", "extraGT", "extraGTE", "extraLT", "extraLTE", "extraContains", "extraHasPrefix", "extraHasSuffix", "extraIsNil", "extraNotNil", "extraEqualFold", "extraContainsFold", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "startedAt", "startedAtNEQ", "startedAtIn", "startedAtNotIn", "startedAtGT", "startedAtGTE", "startedAtLT", "startedAtLTE", "startedAtIsNil", "startedAtNotNil", "finishedAt", "finishedAtNEQ", "finishedAtIn", "finishedAtNotIn", "finishedAtGT", "finishedAtGTE", "finishedAtLT", "finishedAtLTE", "finishedAtIsNil", "finishedAtNotNil", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "outputSize", "outputSizeNEQ", "outputSizeIn", "outputSizeNotIn", "outputSizeGT", "outputSizeGTE", "outputSizeLT", "outputSizeLTE", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "errorSize", "errorSizeNEQ", "errorSizeIn", "errorSizeNotIn", "errorSizeGT", "errorSizeGTE", "errorSizeLT", "errorSizeLTE", "artifactPath", "artifactPathNEQ", "artifactPathIn", "artifactPathNotIn", "artifactPathGT", "artifactPathGTE", "artifactPathLT", "artifactPathLTE", "artifactPathContains", "artifactPathHasPrefix", "artifactPathHasSuffix", "artifactPathIsNil", "artifactPathNotNil", "artifactPathEqualFold", "artifactPathContainsFold", "hasBuilder", "hasBuilderWith", "hasArtifact", "hasArtifactWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -13592,6 +13861,34 @@ func (ec *executionContext) unmarshalInputBuildTaskWhereInput(ctx context.Contex return it, err } it.TargetOsNotIn = data + case "targetFormat": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetFormat")) + data, err := ec.unmarshalOBuildTaskTargetFormat2ᚖrealmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat(ctx, v) + if err != nil { + return it, err + } + it.TargetFormat = data + case "targetFormatNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetFormatNEQ")) + data, err := ec.unmarshalOBuildTaskTargetFormat2ᚖrealmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat(ctx, v) + if err != nil { + return it, err + } + it.TargetFormatNEQ = data + case "targetFormatIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetFormatIn")) + data, err := ec.unmarshalOBuildTaskTargetFormat2ᚕrealmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormatᚄ(ctx, v) + if err != nil { + return it, err + } + it.TargetFormatIn = data + case "targetFormatNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetFormatNotIn")) + data, err := ec.unmarshalOBuildTaskTargetFormat2ᚕrealmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormatᚄ(ctx, v) + if err != nil { + return it, err + } + it.TargetFormatNotIn = data case "buildImage": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImage")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) @@ -13717,63 +14014,343 @@ func (ec *executionContext) unmarshalInputBuildTaskWhereInput(ctx context.Contex if err != nil { return it, err } - it.BuildScriptGT = data - case "buildScriptGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptGTE")) + it.BuildScriptGT = data + case "buildScriptGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.BuildScriptGTE = data + case "buildScriptLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.BuildScriptLT = data + case "buildScriptLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.BuildScriptLTE = data + case "buildScriptContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.BuildScriptContains = data + case "buildScriptHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.BuildScriptHasPrefix = data + case "buildScriptHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.BuildScriptHasSuffix = data + case "buildScriptEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.BuildScriptEqualFold = data + case "buildScriptContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.BuildScriptContainsFold = data + case "callbackURI": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURI")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURI = data + case "callbackURINEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURINEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURINEQ = data + case "callbackURIIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURIIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.CallbackURIIn = data + case "callbackURINotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURINotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.CallbackURINotIn = data + case "callbackURIGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURIGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURIGT = data + case "callbackURIGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURIGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURIGTE = data + case "callbackURILT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURILT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURILT = data + case "callbackURILTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURILTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURILTE = data + case "callbackURIContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURIContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURIContains = data + case "callbackURIHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURIHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURIHasPrefix = data + case "callbackURIHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURIHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURIHasSuffix = data + case "callbackURIEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURIEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURIEqualFold = data + case "callbackURIContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURIContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURIContainsFold = data + case "interval": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.Interval = data + case "intervalNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IntervalNEQ = data + case "intervalIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IntervalIn = data + case "intervalNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IntervalNotIn = data + case "intervalGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IntervalGT = data + case "intervalGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IntervalGTE = data + case "intervalLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IntervalLT = data + case "intervalLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IntervalLTE = data + case "transportType": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportType")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) + if err != nil { + return it, err + } + it.TransportType = data + case "transportTypeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportTypeNEQ")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) + if err != nil { + return it, err + } + it.TransportTypeNEQ = data + case "transportTypeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportTypeIn")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) + if err != nil { + return it, err + } + it.TransportTypeIn = data + case "transportTypeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportTypeNotIn")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) + if err != nil { + return it, err + } + it.TransportTypeNotIn = data + case "extra": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extra")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Extra = data + case "extraNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ExtraNEQ = data + case "extraIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ExtraIn = data + case "extraNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ExtraNotIn = data + case "extraGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ExtraGT = data + case "extraGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ExtraGTE = data + case "extraLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ExtraLT = data + case "extraLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.BuildScriptGTE = data - case "buildScriptLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptLT")) + it.ExtraLTE = data + case "extraContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.BuildScriptLT = data - case "buildScriptLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptLTE")) + it.ExtraContains = data + case "extraHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.BuildScriptLTE = data - case "buildScriptContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptContains")) + it.ExtraHasPrefix = data + case "extraHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.BuildScriptContains = data - case "buildScriptHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.ExtraHasSuffix = data + case "extraIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.BuildScriptHasPrefix = data - case "buildScriptHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.ExtraIsNil = data + case "extraNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.BuildScriptHasSuffix = data - case "buildScriptEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptEqualFold")) + it.ExtraNotNil = data + case "extraEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.BuildScriptEqualFold = data - case "buildScriptContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScriptContainsFold")) + it.ExtraEqualFold = data + case "extraContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.BuildScriptContainsFold = data + it.ExtraContainsFold = data case "claimedAt": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("claimedAt")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) @@ -14250,6 +14827,167 @@ func (ec *executionContext) unmarshalInputBuildTaskWhereInput(ctx context.Contex return it, err } it.ErrorContainsFold = data + case "errorSize": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorSize")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ErrorSize = data + case "errorSizeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorSizeNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ErrorSizeNEQ = data + case "errorSizeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorSizeIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.ErrorSizeIn = data + case "errorSizeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorSizeNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.ErrorSizeNotIn = data + case "errorSizeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorSizeGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ErrorSizeGT = data + case "errorSizeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorSizeGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ErrorSizeGTE = data + case "errorSizeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorSizeLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ErrorSizeLT = data + case "errorSizeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("errorSizeLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ErrorSizeLTE = data + case "artifactPath": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPath")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPath = data + case "artifactPathNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathNEQ = data + case "artifactPathIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathIn = data + case "artifactPathNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathNotIn = data + case "artifactPathGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathGT = data + case "artifactPathGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathGTE = data + case "artifactPathLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathLT = data + case "artifactPathLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathLTE = data + case "artifactPathContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathContains = data + case "artifactPathHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathHasPrefix = data + case "artifactPathHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathHasSuffix = data + case "artifactPathIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathIsNil = data + case "artifactPathNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathNotNil = data + case "artifactPathEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathEqualFold = data + case "artifactPathContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPathContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactPathContainsFold = data case "hasBuilder": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBuilder")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) @@ -14264,6 +15002,20 @@ func (ec *executionContext) unmarshalInputBuildTaskWhereInput(ctx context.Contex return it, err } it.HasBuilderWith = data + case "hasArtifact": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasArtifact")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasArtifact = data + case "hasArtifactWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasArtifactWith")) + data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasArtifactWith = data } } @@ -24446,6 +25198,11 @@ func (ec *executionContext) _BuildTask(ctx context.Context, sel ast.SelectionSet if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "targetFormat": + out.Values[i] = ec._BuildTask_targetFormat(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "buildImage": out.Values[i] = ec._BuildTask_buildImage(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -24456,6 +25213,23 @@ func (ec *executionContext) _BuildTask(ctx context.Context, sel ast.SelectionSet if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "callbackURI": + out.Values[i] = ec._BuildTask_callbackURI(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "interval": + out.Values[i] = ec._BuildTask_interval(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "transportType": + out.Values[i] = ec._BuildTask_transportType(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "extra": + out.Values[i] = ec._BuildTask_extra(ctx, field, obj) case "claimedAt": out.Values[i] = ec._BuildTask_claimedAt(ctx, field, obj) case "startedAt": @@ -24471,6 +25245,13 @@ func (ec *executionContext) _BuildTask(ctx context.Context, sel ast.SelectionSet } case "error": out.Values[i] = ec._BuildTask_error(ctx, field, obj) + case "errorSize": + out.Values[i] = ec._BuildTask_errorSize(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "artifactPath": + out.Values[i] = ec._BuildTask_artifactPath(ctx, field, obj) case "builder": field := field @@ -24506,6 +25287,39 @@ func (ec *executionContext) _BuildTask(ctx context.Context, sel ast.SelectionSet continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "artifact": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._BuildTask_artifact(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) @@ -28785,6 +29599,16 @@ func (ec *executionContext) marshalNBuildTaskOrderField2ᚖrealmᚗpubᚋtavern return v } +func (ec *executionContext) unmarshalNBuildTaskTargetFormat2realmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat(ctx context.Context, v any) (builderpb.TargetFormat, error) { + var res builderpb.TargetFormat + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNBuildTaskTargetFormat2realmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat(ctx context.Context, sel ast.SelectionSet, v builderpb.TargetFormat) graphql.Marshaler { + return v +} + func (ec *executionContext) unmarshalNBuildTaskWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInput(ctx context.Context, v any) (*ent.BuildTaskWhereInput, error) { res, err := ec.unmarshalInputBuildTaskWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -30041,6 +30865,87 @@ func (ec *executionContext) unmarshalOBuildTaskOrder2ᚕᚖrealmᚗpubᚋtavern return res, nil } +func (ec *executionContext) unmarshalOBuildTaskTargetFormat2ᚕrealmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormatᚄ(ctx context.Context, v any) ([]builderpb.TargetFormat, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]builderpb.TargetFormat, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNBuildTaskTargetFormat2realmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOBuildTaskTargetFormat2ᚕrealmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormatᚄ(ctx context.Context, sel ast.SelectionSet, v []builderpb.TargetFormat) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNBuildTaskTargetFormat2realmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOBuildTaskTargetFormat2ᚖrealmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat(ctx context.Context, v any) (*builderpb.TargetFormat, error) { + if v == nil { + return nil, nil + } + var res = new(builderpb.TargetFormat) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOBuildTaskTargetFormat2ᚖrealmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat(ctx context.Context, sel ast.SelectionSet, v *builderpb.TargetFormat) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + func (ec *executionContext) unmarshalOBuildTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuildTaskWhereInputᚄ(ctx context.Context, v any) ([]*ent.BuildTaskWhereInput, error) { if v == nil { return nil, nil diff --git a/tavern/internal/graphql/generated/inputs.generated.go b/tavern/internal/graphql/generated/inputs.generated.go index fedacaeff..066ffb11b 100644 --- a/tavern/internal/graphql/generated/inputs.generated.go +++ b/tavern/internal/graphql/generated/inputs.generated.go @@ -211,7 +211,11 @@ func (ec *executionContext) unmarshalInputCreateBuildTaskInput(ctx context.Conte asMap[k] = v } - fieldsInOrder := [...]string{"targetOS", "buildImage", "buildScript"} + if _, present := asMap["interval"]; !present { + asMap["interval"] = 5 + } + + fieldsInOrder := [...]string{"targetOS", "targetFormat", "buildImage", "callbackURI", "interval", "transportType", "extra", "artifactPath"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -225,6 +229,13 @@ func (ec *executionContext) unmarshalInputCreateBuildTaskInput(ctx context.Conte return it, err } it.TargetOs = data + case "targetFormat": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetFormat")) + data, err := ec.unmarshalNBuildTaskTargetFormat2realmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat(ctx, v) + if err != nil { + return it, err + } + it.TargetFormat = data case "buildImage": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImage")) data, err := ec.unmarshalNString2string(ctx, v) @@ -232,13 +243,41 @@ func (ec *executionContext) unmarshalInputCreateBuildTaskInput(ctx context.Conte return it, err } it.BuildImage = data - case "buildScript": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildScript")) - data, err := ec.unmarshalNString2string(ctx, v) + case "callbackURI": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callbackURI")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CallbackURI = data + case "interval": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.Interval = data + case "transportType": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportType")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) + if err != nil { + return it, err + } + it.TransportType = data + case "extra": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extra")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Extra = data + case "artifactPath": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPath")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.BuildScript = data + it.ArtifactPath = data } } diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index 8c3574078..d10e9bcea 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -1635,10 +1635,20 @@ func (ec *executionContext) fieldContext_Mutation_createBuildTask(ctx context.Co return ec.fieldContext_BuildTask_lastModifiedAt(ctx, field) case "targetOs": return ec.fieldContext_BuildTask_targetOs(ctx, field) + case "targetFormat": + return ec.fieldContext_BuildTask_targetFormat(ctx, field) case "buildImage": return ec.fieldContext_BuildTask_buildImage(ctx, field) case "buildScript": return ec.fieldContext_BuildTask_buildScript(ctx, field) + case "callbackURI": + return ec.fieldContext_BuildTask_callbackURI(ctx, field) + case "interval": + return ec.fieldContext_BuildTask_interval(ctx, field) + case "transportType": + return ec.fieldContext_BuildTask_transportType(ctx, field) + case "extra": + return ec.fieldContext_BuildTask_extra(ctx, field) case "claimedAt": return ec.fieldContext_BuildTask_claimedAt(ctx, field) case "startedAt": @@ -1651,8 +1661,14 @@ func (ec *executionContext) fieldContext_Mutation_createBuildTask(ctx context.Co return ec.fieldContext_BuildTask_outputSize(ctx, field) case "error": return ec.fieldContext_BuildTask_error(ctx, field) + case "errorSize": + return ec.fieldContext_BuildTask_errorSize(ctx, field) + case "artifactPath": + return ec.fieldContext_BuildTask_artifactPath(ctx, field) case "builder": return ec.fieldContext_BuildTask_builder(ctx, field) + case "artifact": + return ec.fieldContext_BuildTask_artifact(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type BuildTask", field.Name) }, diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 01b8342e0..54f034f52 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -96,19 +96,27 @@ type ComplexityRoot struct { } BuildTask struct { + Artifact func(childComplexity int) int + ArtifactPath func(childComplexity int) int BuildImage func(childComplexity int) int BuildScript func(childComplexity int) int Builder func(childComplexity int) int + CallbackURI func(childComplexity int) int ClaimedAt func(childComplexity int) int CreatedAt func(childComplexity int) int Error func(childComplexity int) int + ErrorSize func(childComplexity int) int + Extra func(childComplexity int) int FinishedAt func(childComplexity int) int ID func(childComplexity int) int + Interval func(childComplexity int) int LastModifiedAt func(childComplexity int) int Output func(childComplexity int) int OutputSize func(childComplexity int) int StartedAt func(childComplexity int) int + TargetFormat func(childComplexity int) int TargetOs func(childComplexity int) int + TransportType func(childComplexity int) int } BuildTaskConnection struct { @@ -783,6 +791,20 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.BeaconEdge.Node(childComplexity), true + case "BuildTask.artifact": + if e.complexity.BuildTask.Artifact == nil { + break + } + + return e.complexity.BuildTask.Artifact(childComplexity), true + + case "BuildTask.artifactPath": + if e.complexity.BuildTask.ArtifactPath == nil { + break + } + + return e.complexity.BuildTask.ArtifactPath(childComplexity), true + case "BuildTask.buildImage": if e.complexity.BuildTask.BuildImage == nil { break @@ -804,6 +826,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.BuildTask.Builder(childComplexity), true + case "BuildTask.callbackURI": + if e.complexity.BuildTask.CallbackURI == nil { + break + } + + return e.complexity.BuildTask.CallbackURI(childComplexity), true + case "BuildTask.claimedAt": if e.complexity.BuildTask.ClaimedAt == nil { break @@ -825,6 +854,20 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.BuildTask.Error(childComplexity), true + case "BuildTask.errorSize": + if e.complexity.BuildTask.ErrorSize == nil { + break + } + + return e.complexity.BuildTask.ErrorSize(childComplexity), true + + case "BuildTask.extra": + if e.complexity.BuildTask.Extra == nil { + break + } + + return e.complexity.BuildTask.Extra(childComplexity), true + case "BuildTask.finishedAt": if e.complexity.BuildTask.FinishedAt == nil { break @@ -839,6 +882,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.BuildTask.ID(childComplexity), true + case "BuildTask.interval": + if e.complexity.BuildTask.Interval == nil { + break + } + + return e.complexity.BuildTask.Interval(childComplexity), true + case "BuildTask.lastModifiedAt": if e.complexity.BuildTask.LastModifiedAt == nil { break @@ -867,6 +917,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.BuildTask.StartedAt(childComplexity), true + case "BuildTask.targetFormat": + if e.complexity.BuildTask.TargetFormat == nil { + break + } + + return e.complexity.BuildTask.TargetFormat(childComplexity), true + case "BuildTask.targetOs": if e.complexity.BuildTask.TargetOs == nil { break @@ -874,6 +931,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.BuildTask.TargetOs(childComplexity), true + case "BuildTask.transportType": + if e.complexity.BuildTask.TransportType == nil { + break + } + + return e.complexity.BuildTask.TransportType(childComplexity), true + case "BuildTaskConnection.edges": if e.complexity.BuildTaskConnection.Edges == nil { break @@ -3685,14 +3749,34 @@ type BuildTask implements Node { """ targetOs: HostPlatform! """ + The output format for the build (BIN, CDYLIB, WINDOWS_SERVICE). + """ + targetFormat: BuildTaskTargetFormat! + """ Docker container image name to use for the build. """ buildImage: String! """ - The script to execute inside the build container. + The derived script to execute inside the build container. """ buildScript: String! """ + The callback URI for the IMIX agent to connect to. + """ + callbackURI: String! + """ + The callback interval in seconds for the IMIX agent. + """ + interval: Int! + """ + The transport type for the IMIX agent. + """ + transportType: BeaconTransport_Type! + """ + Extra transport configuration for the IMIX agent. + """ + extra: String + """ Timestamp of when a builder claimed this task, null if unclaimed. """ claimedAt: Time @@ -3717,9 +3801,21 @@ type BuildTask implements Node { """ error: String """ + The size of the error in bytes + """ + errorSize: Int! + """ + Path inside the container where the build artifact is located. Derived from target_os if not set. + """ + artifactPath: String + """ The builder assigned to execute this build task. """ builder: Builder! + """ + The compiled artifact produced by this build task, stored as an Asset. + """ + artifact: Asset } """ A connection to a list of items. @@ -3775,6 +3871,15 @@ enum BuildTaskOrderField { STARTED_AT FINISHED_AT OUTPUT_SIZE + ERROR_SIZE +} +""" +BuildTaskTargetFormat is enum for the field target_format +""" +enum BuildTaskTargetFormat @goModel(model: "realm.pub/tavern/internal/builder/builderpb.TargetFormat") { + BIN + CDYLIB + WINDOWS_SERVICE } """ BuildTaskWhereInput is used for filtering BuildTask objects. @@ -3825,6 +3930,13 @@ input BuildTaskWhereInput { targetOsIn: [HostPlatform!] targetOsNotIn: [HostPlatform!] """ + target_format field predicates + """ + targetFormat: BuildTaskTargetFormat + targetFormatNEQ: BuildTaskTargetFormat + targetFormatIn: [BuildTaskTargetFormat!] + targetFormatNotIn: [BuildTaskTargetFormat!] + """ build_image field predicates """ buildImage: String @@ -3857,6 +3969,58 @@ input BuildTaskWhereInput { buildScriptEqualFold: String buildScriptContainsFold: String """ + callback_uri field predicates + """ + callbackURI: String + callbackURINEQ: String + callbackURIIn: [String!] + callbackURINotIn: [String!] + callbackURIGT: String + callbackURIGTE: String + callbackURILT: String + callbackURILTE: String + callbackURIContains: String + callbackURIHasPrefix: String + callbackURIHasSuffix: String + callbackURIEqualFold: String + callbackURIContainsFold: String + """ + interval field predicates + """ + interval: Int + intervalNEQ: Int + intervalIn: [Int!] + intervalNotIn: [Int!] + intervalGT: Int + intervalGTE: Int + intervalLT: Int + intervalLTE: Int + """ + transport_type field predicates + """ + transportType: BeaconTransport_Type + transportTypeNEQ: BeaconTransport_Type + transportTypeIn: [BeaconTransport_Type!] + transportTypeNotIn: [BeaconTransport_Type!] + """ + extra field predicates + """ + extra: String + extraNEQ: String + extraIn: [String!] + extraNotIn: [String!] + extraGT: String + extraGTE: String + extraLT: String + extraLTE: String + extraContains: String + extraHasPrefix: String + extraHasSuffix: String + extraIsNil: Boolean + extraNotNil: Boolean + extraEqualFold: String + extraContainsFold: String + """ claimed_at field predicates """ claimedAt: Time @@ -3943,10 +4107,44 @@ input BuildTaskWhereInput { errorEqualFold: String errorContainsFold: String """ + error_size field predicates + """ + errorSize: Int + errorSizeNEQ: Int + errorSizeIn: [Int!] + errorSizeNotIn: [Int!] + errorSizeGT: Int + errorSizeGTE: Int + errorSizeLT: Int + errorSizeLTE: Int + """ + artifact_path field predicates + """ + artifactPath: String + artifactPathNEQ: String + artifactPathIn: [String!] + artifactPathNotIn: [String!] + artifactPathGT: String + artifactPathGTE: String + artifactPathLT: String + artifactPathLTE: String + artifactPathContains: String + artifactPathHasPrefix: String + artifactPathHasSuffix: String + artifactPathIsNil: Boolean + artifactPathNotNil: Boolean + artifactPathEqualFold: String + artifactPathContainsFold: String + """ builder edge predicates """ hasBuilder: Boolean hasBuilderWith: [BuilderWhereInput!] + """ + artifact edge predicates + """ + hasArtifact: Boolean + hasArtifactWith: [AssetWhereInput!] } type Builder implements Node { id: ID! @@ -8168,11 +8366,26 @@ input CreateBuildTaskInput { """The target operating system for the build.""" targetOS: HostPlatform! + """The output format for the build.""" + targetFormat: BuildTaskTargetFormat! + """Docker container image name to use for the build.""" buildImage: String! - """The script to execute inside the build container.""" - buildScript: String! + """The callback URI for the IMIX agent to connect to. Defaults to http://127.0.0.1:8000.""" + callbackURI: String + + """The callback interval in seconds for the IMIX agent.""" + interval: Int = 5 + + """The transport type for the IMIX agent. Defaults to TRANSPORT_GRPC.""" + transportType: BeaconTransport_Type + + """Extra transport configuration for the IMIX agent.""" + extra: String + + """Path inside the build container to extract the artifact from. Defaults to the derived path based on target OS.""" + artifactPath: String } """Output returned when registering a new builder.""" diff --git a/tavern/internal/graphql/gqlgen.yml b/tavern/internal/graphql/gqlgen.yml index 2c0f1970f..513417e3f 100644 --- a/tavern/internal/graphql/gqlgen.yml +++ b/tavern/internal/graphql/gqlgen.yml @@ -63,3 +63,6 @@ models: Status: model: - realm.pub/tavern/internal/c2/epb.Process_Status + BuildTaskTargetFormat: + model: + - realm.pub/tavern/internal/builder/builderpb.TargetFormat diff --git a/tavern/internal/graphql/models/gqlgen_models.go b/tavern/internal/graphql/models/gqlgen_models.go index 93952b4aa..66515a36a 100644 --- a/tavern/internal/graphql/models/gqlgen_models.go +++ b/tavern/internal/graphql/models/gqlgen_models.go @@ -9,6 +9,7 @@ import ( "strconv" "time" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent" ) @@ -34,10 +35,20 @@ type ClaimTasksInput struct { type CreateBuildTaskInput struct { // The target operating system for the build. TargetOs c2pb.Host_Platform `json:"targetOS"` + // The output format for the build. + TargetFormat builderpb.TargetFormat `json:"targetFormat"` // Docker container image name to use for the build. BuildImage string `json:"buildImage"` - // The script to execute inside the build container. - BuildScript string `json:"buildScript"` + // The callback URI for the IMIX agent to connect to. Defaults to http://127.0.0.1:8000. + CallbackURI *string `json:"callbackURI,omitempty"` + // The callback interval in seconds for the IMIX agent. + Interval *int `json:"interval,omitempty"` + // The transport type for the IMIX agent. Defaults to TRANSPORT_GRPC. + TransportType *c2pb.Transport_Type `json:"transportType,omitempty"` + // Extra transport configuration for the IMIX agent. + Extra *string `json:"extra,omitempty"` + // Path inside the build container to extract the artifact from. Defaults to the derived path based on target OS. + ArtifactPath *string `json:"artifactPath,omitempty"` } type ImportRepositoryInput struct { diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index e3c4ffc60..09a8c586f 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -341,13 +341,45 @@ func (r *mutationResolver) RegisterBuilder(ctx context.Context, input ent.Create // CreateBuildTask is the resolver for the createBuildTask field. func (r *mutationResolver) CreateBuildTask(ctx context.Context, input models.CreateBuildTaskInput) (*ent.BuildTask, error) { - // 1. Query all builders + // 1. Validate target format for the given OS + if err := builder.ValidateTargetFormat(input.TargetOs, input.TargetFormat); err != nil { + return nil, err + } + + // 2. Resolve defaults for optional fields + interval := builder.DefaultInterval + if input.Interval != nil { + interval = *input.Interval + } + + callbackURI := builder.DefaultCallbackURI + if input.CallbackURI != nil { + callbackURI = *input.CallbackURI + } + + transportType := builder.DefaultTransportType + if input.TransportType != nil { + transportType = *input.TransportType + } + + artifactPath := builder.DeriveArtifactPath(input.TargetOs) + if input.ArtifactPath != nil { + artifactPath = *input.ArtifactPath + } + + // 3. Derive the build script from configuration + buildScript, err := builder.GenerateBuildScript(input.TargetOs, input.TargetFormat) + if err != nil { + return nil, fmt.Errorf("failed to generate build script: %w", err) + } + + // 4. Query all builders allBuilders, err := r.client.Builder.Query().All(ctx) if err != nil { return nil, fmt.Errorf("failed to query builders: %w", err) } - // 2. Filter builders that support the target OS + // 5. Filter builders that support the target OS var candidates []*ent.Builder for _, b := range allBuilders { for _, target := range b.SupportedTargets { @@ -362,16 +394,26 @@ func (r *mutationResolver) CreateBuildTask(ctx context.Context, input models.Cre return nil, fmt.Errorf("no builder available that supports target %s", input.TargetOs.String()) } - // 3. Randomly select one builder + // 6. Randomly select one builder selected := candidates[rand.Intn(len(candidates))] - // 4. Create the build task - bt, err := r.client.BuildTask.Create(). + // 7. Create the build task + create := r.client.BuildTask.Create(). SetTargetOs(input.TargetOs). + SetTargetFormat(input.TargetFormat). SetBuildImage(input.BuildImage). - SetBuildScript(input.BuildScript). - SetBuilder(selected). - Save(ctx) + SetBuildScript(buildScript). + SetCallbackURI(callbackURI). + SetInterval(interval). + SetTransportType(transportType). + SetArtifactPath(artifactPath). + SetBuilder(selected) + + if input.Extra != nil { + create = create.SetExtra(*input.Extra) + } + + bt, err := create.Save(ctx) if err != nil { return nil, fmt.Errorf("failed to create build task: %w", err) } diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index f0d40fa1a..377b16557 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -603,14 +603,34 @@ type BuildTask implements Node { """ targetOs: HostPlatform! """ + The output format for the build (BIN, CDYLIB, WINDOWS_SERVICE). + """ + targetFormat: BuildTaskTargetFormat! + """ Docker container image name to use for the build. """ buildImage: String! """ - The script to execute inside the build container. + The derived script to execute inside the build container. """ buildScript: String! """ + The callback URI for the IMIX agent to connect to. + """ + callbackURI: String! + """ + The callback interval in seconds for the IMIX agent. + """ + interval: Int! + """ + The transport type for the IMIX agent. + """ + transportType: BeaconTransport_Type! + """ + Extra transport configuration for the IMIX agent. + """ + extra: String + """ Timestamp of when a builder claimed this task, null if unclaimed. """ claimedAt: Time @@ -635,9 +655,21 @@ type BuildTask implements Node { """ error: String """ + The size of the error in bytes + """ + errorSize: Int! + """ + Path inside the container where the build artifact is located. Derived from target_os if not set. + """ + artifactPath: String + """ The builder assigned to execute this build task. """ builder: Builder! + """ + The compiled artifact produced by this build task, stored as an Asset. + """ + artifact: Asset } """ A connection to a list of items. @@ -693,6 +725,15 @@ enum BuildTaskOrderField { STARTED_AT FINISHED_AT OUTPUT_SIZE + ERROR_SIZE +} +""" +BuildTaskTargetFormat is enum for the field target_format +""" +enum BuildTaskTargetFormat @goModel(model: "realm.pub/tavern/internal/builder/builderpb.TargetFormat") { + BIN + CDYLIB + WINDOWS_SERVICE } """ BuildTaskWhereInput is used for filtering BuildTask objects. @@ -743,6 +784,13 @@ input BuildTaskWhereInput { targetOsIn: [HostPlatform!] targetOsNotIn: [HostPlatform!] """ + target_format field predicates + """ + targetFormat: BuildTaskTargetFormat + targetFormatNEQ: BuildTaskTargetFormat + targetFormatIn: [BuildTaskTargetFormat!] + targetFormatNotIn: [BuildTaskTargetFormat!] + """ build_image field predicates """ buildImage: String @@ -775,6 +823,58 @@ input BuildTaskWhereInput { buildScriptEqualFold: String buildScriptContainsFold: String """ + callback_uri field predicates + """ + callbackURI: String + callbackURINEQ: String + callbackURIIn: [String!] + callbackURINotIn: [String!] + callbackURIGT: String + callbackURIGTE: String + callbackURILT: String + callbackURILTE: String + callbackURIContains: String + callbackURIHasPrefix: String + callbackURIHasSuffix: String + callbackURIEqualFold: String + callbackURIContainsFold: String + """ + interval field predicates + """ + interval: Int + intervalNEQ: Int + intervalIn: [Int!] + intervalNotIn: [Int!] + intervalGT: Int + intervalGTE: Int + intervalLT: Int + intervalLTE: Int + """ + transport_type field predicates + """ + transportType: BeaconTransport_Type + transportTypeNEQ: BeaconTransport_Type + transportTypeIn: [BeaconTransport_Type!] + transportTypeNotIn: [BeaconTransport_Type!] + """ + extra field predicates + """ + extra: String + extraNEQ: String + extraIn: [String!] + extraNotIn: [String!] + extraGT: String + extraGTE: String + extraLT: String + extraLTE: String + extraContains: String + extraHasPrefix: String + extraHasSuffix: String + extraIsNil: Boolean + extraNotNil: Boolean + extraEqualFold: String + extraContainsFold: String + """ claimed_at field predicates """ claimedAt: Time @@ -861,10 +961,44 @@ input BuildTaskWhereInput { errorEqualFold: String errorContainsFold: String """ + error_size field predicates + """ + errorSize: Int + errorSizeNEQ: Int + errorSizeIn: [Int!] + errorSizeNotIn: [Int!] + errorSizeGT: Int + errorSizeGTE: Int + errorSizeLT: Int + errorSizeLTE: Int + """ + artifact_path field predicates + """ + artifactPath: String + artifactPathNEQ: String + artifactPathIn: [String!] + artifactPathNotIn: [String!] + artifactPathGT: String + artifactPathGTE: String + artifactPathLT: String + artifactPathLTE: String + artifactPathContains: String + artifactPathHasPrefix: String + artifactPathHasSuffix: String + artifactPathIsNil: Boolean + artifactPathNotNil: Boolean + artifactPathEqualFold: String + artifactPathContainsFold: String + """ builder edge predicates """ hasBuilder: Boolean hasBuilderWith: [BuilderWhereInput!] + """ + artifact edge predicates + """ + hasArtifact: Boolean + hasArtifactWith: [AssetWhereInput!] } type Builder implements Node { id: ID! @@ -4782,11 +4916,26 @@ input CreateBuildTaskInput { """The target operating system for the build.""" targetOS: HostPlatform! + """The output format for the build.""" + targetFormat: BuildTaskTargetFormat! + """Docker container image name to use for the build.""" buildImage: String! - """The script to execute inside the build container.""" - buildScript: String! + """The callback URI for the IMIX agent to connect to. Defaults to http://127.0.0.1:8000.""" + callbackURI: String + + """The callback interval in seconds for the IMIX agent.""" + interval: Int = 5 + + """The transport type for the IMIX agent. Defaults to TRANSPORT_GRPC.""" + transportType: BeaconTransport_Type + + """Extra transport configuration for the IMIX agent.""" + extra: String + + """Path inside the build container to extract the artifact from. Defaults to the derived path based on target OS.""" + artifactPath: String } """Output returned when registering a new builder.""" diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index 85f0b6ebe..f92beb153 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -598,14 +598,34 @@ type BuildTask implements Node { """ targetOs: HostPlatform! """ + The output format for the build (BIN, CDYLIB, WINDOWS_SERVICE). + """ + targetFormat: BuildTaskTargetFormat! + """ Docker container image name to use for the build. """ buildImage: String! """ - The script to execute inside the build container. + The derived script to execute inside the build container. """ buildScript: String! """ + The callback URI for the IMIX agent to connect to. + """ + callbackURI: String! + """ + The callback interval in seconds for the IMIX agent. + """ + interval: Int! + """ + The transport type for the IMIX agent. + """ + transportType: BeaconTransport_Type! + """ + Extra transport configuration for the IMIX agent. + """ + extra: String + """ Timestamp of when a builder claimed this task, null if unclaimed. """ claimedAt: Time @@ -630,9 +650,21 @@ type BuildTask implements Node { """ error: String """ + The size of the error in bytes + """ + errorSize: Int! + """ + Path inside the container where the build artifact is located. Derived from target_os if not set. + """ + artifactPath: String + """ The builder assigned to execute this build task. """ builder: Builder! + """ + The compiled artifact produced by this build task, stored as an Asset. + """ + artifact: Asset } """ A connection to a list of items. @@ -688,6 +720,15 @@ enum BuildTaskOrderField { STARTED_AT FINISHED_AT OUTPUT_SIZE + ERROR_SIZE +} +""" +BuildTaskTargetFormat is enum for the field target_format +""" +enum BuildTaskTargetFormat @goModel(model: "realm.pub/tavern/internal/builder/builderpb.TargetFormat") { + BIN + CDYLIB + WINDOWS_SERVICE } """ BuildTaskWhereInput is used for filtering BuildTask objects. @@ -738,6 +779,13 @@ input BuildTaskWhereInput { targetOsIn: [HostPlatform!] targetOsNotIn: [HostPlatform!] """ + target_format field predicates + """ + targetFormat: BuildTaskTargetFormat + targetFormatNEQ: BuildTaskTargetFormat + targetFormatIn: [BuildTaskTargetFormat!] + targetFormatNotIn: [BuildTaskTargetFormat!] + """ build_image field predicates """ buildImage: String @@ -770,6 +818,58 @@ input BuildTaskWhereInput { buildScriptEqualFold: String buildScriptContainsFold: String """ + callback_uri field predicates + """ + callbackURI: String + callbackURINEQ: String + callbackURIIn: [String!] + callbackURINotIn: [String!] + callbackURIGT: String + callbackURIGTE: String + callbackURILT: String + callbackURILTE: String + callbackURIContains: String + callbackURIHasPrefix: String + callbackURIHasSuffix: String + callbackURIEqualFold: String + callbackURIContainsFold: String + """ + interval field predicates + """ + interval: Int + intervalNEQ: Int + intervalIn: [Int!] + intervalNotIn: [Int!] + intervalGT: Int + intervalGTE: Int + intervalLT: Int + intervalLTE: Int + """ + transport_type field predicates + """ + transportType: BeaconTransport_Type + transportTypeNEQ: BeaconTransport_Type + transportTypeIn: [BeaconTransport_Type!] + transportTypeNotIn: [BeaconTransport_Type!] + """ + extra field predicates + """ + extra: String + extraNEQ: String + extraIn: [String!] + extraNotIn: [String!] + extraGT: String + extraGTE: String + extraLT: String + extraLTE: String + extraContains: String + extraHasPrefix: String + extraHasSuffix: String + extraIsNil: Boolean + extraNotNil: Boolean + extraEqualFold: String + extraContainsFold: String + """ claimed_at field predicates """ claimedAt: Time @@ -856,10 +956,44 @@ input BuildTaskWhereInput { errorEqualFold: String errorContainsFold: String """ + error_size field predicates + """ + errorSize: Int + errorSizeNEQ: Int + errorSizeIn: [Int!] + errorSizeNotIn: [Int!] + errorSizeGT: Int + errorSizeGTE: Int + errorSizeLT: Int + errorSizeLTE: Int + """ + artifact_path field predicates + """ + artifactPath: String + artifactPathNEQ: String + artifactPathIn: [String!] + artifactPathNotIn: [String!] + artifactPathGT: String + artifactPathGTE: String + artifactPathLT: String + artifactPathLTE: String + artifactPathContains: String + artifactPathHasPrefix: String + artifactPathHasSuffix: String + artifactPathIsNil: Boolean + artifactPathNotNil: Boolean + artifactPathEqualFold: String + artifactPathContainsFold: String + """ builder edge predicates """ hasBuilder: Boolean hasBuilderWith: [BuilderWhereInput!] + """ + artifact edge predicates + """ + hasArtifact: Boolean + hasArtifactWith: [AssetWhereInput!] } type Builder implements Node { id: ID! diff --git a/tavern/internal/graphql/schema/inputs.graphql b/tavern/internal/graphql/schema/inputs.graphql index 39df200df..382de6a7d 100644 --- a/tavern/internal/graphql/schema/inputs.graphql +++ b/tavern/internal/graphql/schema/inputs.graphql @@ -53,11 +53,26 @@ input CreateBuildTaskInput { """The target operating system for the build.""" targetOS: HostPlatform! + """The output format for the build.""" + targetFormat: BuildTaskTargetFormat! + """Docker container image name to use for the build.""" buildImage: String! - """The script to execute inside the build container.""" - buildScript: String! + """The callback URI for the IMIX agent to connect to. Defaults to http://127.0.0.1:8000.""" + callbackURI: String + + """The callback interval in seconds for the IMIX agent.""" + interval: Int = 5 + + """The transport type for the IMIX agent. Defaults to TRANSPORT_GRPC.""" + transportType: BeaconTransport_Type + + """Extra transport configuration for the IMIX agent.""" + extra: String + + """Path inside the build container to extract the artifact from. Defaults to the derived path based on target OS.""" + artifactPath: String } """Output returned when registering a new builder.""" diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index f0d40fa1a..377b16557 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -603,14 +603,34 @@ type BuildTask implements Node { """ targetOs: HostPlatform! """ + The output format for the build (BIN, CDYLIB, WINDOWS_SERVICE). + """ + targetFormat: BuildTaskTargetFormat! + """ Docker container image name to use for the build. """ buildImage: String! """ - The script to execute inside the build container. + The derived script to execute inside the build container. """ buildScript: String! """ + The callback URI for the IMIX agent to connect to. + """ + callbackURI: String! + """ + The callback interval in seconds for the IMIX agent. + """ + interval: Int! + """ + The transport type for the IMIX agent. + """ + transportType: BeaconTransport_Type! + """ + Extra transport configuration for the IMIX agent. + """ + extra: String + """ Timestamp of when a builder claimed this task, null if unclaimed. """ claimedAt: Time @@ -635,9 +655,21 @@ type BuildTask implements Node { """ error: String """ + The size of the error in bytes + """ + errorSize: Int! + """ + Path inside the container where the build artifact is located. Derived from target_os if not set. + """ + artifactPath: String + """ The builder assigned to execute this build task. """ builder: Builder! + """ + The compiled artifact produced by this build task, stored as an Asset. + """ + artifact: Asset } """ A connection to a list of items. @@ -693,6 +725,15 @@ enum BuildTaskOrderField { STARTED_AT FINISHED_AT OUTPUT_SIZE + ERROR_SIZE +} +""" +BuildTaskTargetFormat is enum for the field target_format +""" +enum BuildTaskTargetFormat @goModel(model: "realm.pub/tavern/internal/builder/builderpb.TargetFormat") { + BIN + CDYLIB + WINDOWS_SERVICE } """ BuildTaskWhereInput is used for filtering BuildTask objects. @@ -743,6 +784,13 @@ input BuildTaskWhereInput { targetOsIn: [HostPlatform!] targetOsNotIn: [HostPlatform!] """ + target_format field predicates + """ + targetFormat: BuildTaskTargetFormat + targetFormatNEQ: BuildTaskTargetFormat + targetFormatIn: [BuildTaskTargetFormat!] + targetFormatNotIn: [BuildTaskTargetFormat!] + """ build_image field predicates """ buildImage: String @@ -775,6 +823,58 @@ input BuildTaskWhereInput { buildScriptEqualFold: String buildScriptContainsFold: String """ + callback_uri field predicates + """ + callbackURI: String + callbackURINEQ: String + callbackURIIn: [String!] + callbackURINotIn: [String!] + callbackURIGT: String + callbackURIGTE: String + callbackURILT: String + callbackURILTE: String + callbackURIContains: String + callbackURIHasPrefix: String + callbackURIHasSuffix: String + callbackURIEqualFold: String + callbackURIContainsFold: String + """ + interval field predicates + """ + interval: Int + intervalNEQ: Int + intervalIn: [Int!] + intervalNotIn: [Int!] + intervalGT: Int + intervalGTE: Int + intervalLT: Int + intervalLTE: Int + """ + transport_type field predicates + """ + transportType: BeaconTransport_Type + transportTypeNEQ: BeaconTransport_Type + transportTypeIn: [BeaconTransport_Type!] + transportTypeNotIn: [BeaconTransport_Type!] + """ + extra field predicates + """ + extra: String + extraNEQ: String + extraIn: [String!] + extraNotIn: [String!] + extraGT: String + extraGTE: String + extraLT: String + extraLTE: String + extraContains: String + extraHasPrefix: String + extraHasSuffix: String + extraIsNil: Boolean + extraNotNil: Boolean + extraEqualFold: String + extraContainsFold: String + """ claimed_at field predicates """ claimedAt: Time @@ -861,10 +961,44 @@ input BuildTaskWhereInput { errorEqualFold: String errorContainsFold: String """ + error_size field predicates + """ + errorSize: Int + errorSizeNEQ: Int + errorSizeIn: [Int!] + errorSizeNotIn: [Int!] + errorSizeGT: Int + errorSizeGTE: Int + errorSizeLT: Int + errorSizeLTE: Int + """ + artifact_path field predicates + """ + artifactPath: String + artifactPathNEQ: String + artifactPathIn: [String!] + artifactPathNotIn: [String!] + artifactPathGT: String + artifactPathGTE: String + artifactPathLT: String + artifactPathLTE: String + artifactPathContains: String + artifactPathHasPrefix: String + artifactPathHasSuffix: String + artifactPathIsNil: Boolean + artifactPathNotNil: Boolean + artifactPathEqualFold: String + artifactPathContainsFold: String + """ builder edge predicates """ hasBuilder: Boolean hasBuilderWith: [BuilderWhereInput!] + """ + artifact edge predicates + """ + hasArtifact: Boolean + hasArtifactWith: [AssetWhereInput!] } type Builder implements Node { id: ID! @@ -4782,11 +4916,26 @@ input CreateBuildTaskInput { """The target operating system for the build.""" targetOS: HostPlatform! + """The output format for the build.""" + targetFormat: BuildTaskTargetFormat! + """Docker container image name to use for the build.""" buildImage: String! - """The script to execute inside the build container.""" - buildScript: String! + """The callback URI for the IMIX agent to connect to. Defaults to http://127.0.0.1:8000.""" + callbackURI: String + + """The callback interval in seconds for the IMIX agent.""" + interval: Int = 5 + + """The transport type for the IMIX agent. Defaults to TRANSPORT_GRPC.""" + transportType: BeaconTransport_Type + + """Extra transport configuration for the IMIX agent.""" + extra: String + + """Path inside the build container to extract the artifact from. Defaults to the derived path based on target OS.""" + artifactPath: String } """Output returned when registering a new builder.""" From ef15bbc2fdb6ee488e6281a67035a8c42459e955 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Wed, 11 Feb 2026 23:51:39 +0000 Subject: [PATCH 14/19] Cleanup and builder management --- tavern/internal/builder/README.md | 67 ++-- tavern/internal/builder/build_config.go | 6 + .../internal/builder/builderpb/builder.pb.go | 83 ++-- tavern/internal/builder/client.go | 3 + tavern/internal/builder/integration_test.go | 13 +- tavern/internal/builder/proto/builder.proto | 1 + tavern/internal/builder/server.go | 17 +- tavern/internal/ent/builder.go | 16 +- tavern/internal/ent/builder/builder.go | 8 + tavern/internal/ent/builder/where.go | 55 +++ tavern/internal/ent/builder_create.go | 78 ++++ tavern/internal/ent/builder_update.go | 52 +++ tavern/internal/ent/buildtask.go | 16 +- tavern/internal/ent/buildtask/buildtask.go | 8 + tavern/internal/ent/buildtask/where.go | 55 +++ tavern/internal/ent/buildtask_create.go | 98 +++++ tavern/internal/ent/buildtask_update.go | 72 ++++ tavern/internal/ent/gql_collection.go | 10 + tavern/internal/ent/gql_pagination.go | 36 ++ tavern/internal/ent/gql_where_input.go | 84 ++++ tavern/internal/ent/migrate/schema.go | 6 +- tavern/internal/ent/mutation.go | 189 ++++++++- tavern/internal/ent/schema/build_task.go | 7 + tavern/internal/ent/schema/builder.go | 8 + tavern/internal/graphql/build_task_test.go | 12 +- .../graphql/generated/ent.generated.go | 375 +++++++++++++++++- .../graphql/generated/inputs.generated.go | 6 +- .../graphql/generated/mutation.generated.go | 80 ++++ .../graphql/generated/root_.generated.go | 106 ++++- .../internal/graphql/models/gqlgen_models.go | 8 +- tavern/internal/graphql/mutation.resolvers.go | 32 +- tavern/internal/graphql/query.resolvers.go | 16 + tavern/internal/graphql/schema.graphql | 64 ++- tavern/internal/graphql/schema/ent.graphql | 36 ++ tavern/internal/graphql/schema/inputs.graphql | 8 +- .../internal/graphql/schema/mutation.graphql | 1 + tavern/internal/graphql/schema/query.graphql | 19 + tavern/internal/www/schema.graphql | 64 ++- 38 files changed, 1699 insertions(+), 116 deletions(-) diff --git a/tavern/internal/builder/README.md b/tavern/internal/builder/README.md index 356d2963f..cfc6e6e06 100644 --- a/tavern/internal/builder/README.md +++ b/tavern/internal/builder/README.md @@ -6,7 +6,8 @@ The builder package orchestrates agent compilation for target platforms. It conn - **Registration**: Builders register with Tavern via the `registerBuilder` GraphQL mutation, which returns an mTLS certificate signed by the Tavern Builder CA and a YAML configuration file. - **mTLS Authentication**: All gRPC requests are authenticated using application-level mTLS. The builder presents its CA-signed certificate and a signed timestamp in gRPC metadata on each request. The server verifies the certificate chain, proof of private key possession, and looks up the builder by the identifier embedded in the certificate CN. -- **gRPC API**: Builders communicate with Tavern over gRPC at the `/builder.Builder/` route. Supports `Ping` (health check), `ClaimBuildTasks` (poll for unclaimed tasks), `StreamBuildTaskOutput` (stream build output incrementally), and `UploadBuildArtifact` (upload compiled binaries). +- **gRPC API**: Builders communicate with Tavern over gRPC at the `/builder.Builder/` route. Supports `ClaimBuildTasks` (poll for unclaimed tasks), `StreamBuildTaskOutput` (stream build output and exit code incrementally), and `UploadBuildArtifact` (upload compiled binaries). +- **Builder Management**: Builders are queryable via the `builders` GraphQL query (paginated, filterable, orderable by `LAST_SEEN_AT`) and removable via `deleteBuilder`. Deleting a builder cascade-deletes its build tasks. The `last_seen_at` field is updated on each `ClaimBuildTasks` call. - **Executor**: Build tasks are executed via the `executor.Executor` interface. The `DockerExecutor` runs builds inside Docker containers; the `MockExecutor` is used in tests. - **CLI**: Run a builder using the `builder` subcommand with a `--config` flag pointing to a YAML configuration file. @@ -59,42 +60,41 @@ go run ./tavern builder --config /path/to/builder-config.yaml The `StreamBuildTaskOutput` RPC uses client-streaming to send build output incrementally. The builder sends one message per output/error line as the executor produces them, and each -message is flushed to the database immediately. The final message sets `finished=true` to -signal completion. The `started_at` timestamp is set when the first message is received. -If the stream is interrupted before `finished=true`, partial output is preserved but -`finished_at` is not set. +message is flushed to the database immediately. The final message sets `finished=true` and +includes the container's `exit_code` to signal completion. The server persists both +`finished_at` and `exit_code` on the build task. The `started_at` timestamp is set when +the first message is received. If the stream is interrupted before `finished=true`, partial +output is preserved but `finished_at` and `exit_code` are not set. + +## Build Task Defaults + +The `createBuildTask` mutation requires only `targetOS`. All other fields have sensible +defaults resolved server-side: + +| Field | Default | Notes | +|-------|---------|-------| +| `targetFormat` | `BIN` | Can also be `CDYLIB` or `WINDOWS_SERVICE` (Windows only) | +| `buildImage` | `spellshift/devcontainer:main` | Docker image for the build container | +| `callbackURI` | `http://127.0.0.1:8000` | IMIX agent callback address | +| `interval` | `5` | Callback interval in seconds | +| `transportType` | `TRANSPORT_GRPC` | IMIX agent transport | +| `artifactPath` | Derived from `targetOS` | Path inside the container to extract the compiled binary | ## Artifact Extraction Build tasks can specify an `artifact_path` field — the path inside the container where the -compiled binary or output file is written. When the build finishes successfully, the -`DockerExecutor` copies the file from the stopped container using Docker's `CopyFromContainer` -API (which returns a tar archive), extracts the first regular file, and returns the bytes in -`BuildResult`. The builder client then streams the artifact to Tavern via the -`UploadBuildArtifact` RPC in 1 MB chunks. The server creates an `Asset` entity. -The artifact is downloadable via the existing CDN endpoint at `GET /assets/download/{name}`. - - -### Easy -- Add exitCode to the buildTask ent update executor and build client with build exitCode. -- Builder management - - Add a remove builder mutation - - Add Builder as a queryable type - - Add a last seen at field to builder ent that's updated on each `ClaimBuildTask` call -- Defaults - - Add default bulidImage: `spellshift/devcontainer:main` - - Add default target format: `BIN` - - 'buildImage' should be optional in the mutation and default to `spellshift/devcontainer:main` - - `artifactPath` should be an optional param to the createBuildTask mutation. - - `artifactPath` should default to the derived path only if no other path is specified. Use the same pattern as interval: - ``` - interval := builder.DefaultInterval - if input.Interval != nil { - interval = *input.Interval - } - ``` +compiled binary or output file is written. If not specified, it is derived from the target +OS (e.g. `/home/vscode/realm/implants/target/x86_64-unknown-linux-musl/release/imix` for +Linux). When the build finishes successfully, the `DockerExecutor` copies the file from +the stopped container using Docker's `CopyFromContainer` API (which returns a tar archive), +extracts the first regular file, and returns the bytes in `BuildResult`. The builder client +then streams the artifact to Tavern via the `UploadBuildArtifact` RPC in 1 MB chunks. The +server creates an `Asset` entity. The artifact is downloadable via the existing CDN endpoint +at `GET /assets/download/{name}`. +### Fix +- Debug why the second job in a parallel set of builds never finished ### Architectural - Add a way for the server to interrupt and cancel a build. @@ -110,6 +110,8 @@ The artifact is downloadable via the existing CDN endpoint at `GET /assets/downl ### Planning +- Change exit Code to a bool and rename to errored to make API querying easier +- Change exit Code to a bool and rename to errored to - Where should realm source code be pulled? - which version'd copy of the code to checkout - Can we automatically determine which version / main,edge the server is and pass that ot the build script. @@ -130,10 +132,11 @@ The artifact is downloadable via the existing CDN endpoint at `GET /assets/downl | File | Purpose | |------|---------| | `auth.go` | gRPC unary and stream interceptors for mTLS authentication | +| `build_config.go` | Build defaults, target formats, IMIX config, build script generation | | `ca.go` | Builder CA generation, persistence, and certificate signing | | `client.go` | Builder client: mTLS credentials, polling loop, task execution | | `config.go` | YAML configuration parsing and validation | -| `server.go` | gRPC server: `Ping`, `ClaimBuildTasks`, `StreamBuildTaskOutput`, `UploadBuildArtifact` | +| `server.go` | gRPC server: `ClaimBuildTasks`, `StreamBuildTaskOutput`, `UploadBuildArtifact` | | `rollback.go` | Transaction rollback helper (matches c2 pattern) | | `executor/executor.go` | `Executor` interface, `BuildSpec`, and `BuildResult` definitions | | `executor/docker.go` | `DockerExecutor`: runs builds in Docker containers | diff --git a/tavern/internal/builder/build_config.go b/tavern/internal/builder/build_config.go index 37ae682b4..9823f0800 100644 --- a/tavern/internal/builder/build_config.go +++ b/tavern/internal/builder/build_config.go @@ -23,6 +23,12 @@ const ( // DefaultTransportType is the default transport type for the IMIX agent, // derived from the IMIX default behavior for http:// URIs. DefaultTransportType = c2pb.Transport_TRANSPORT_GRPC + + // DefaultBuildImage is the default Docker image for building agents. + DefaultBuildImage = "spellshift/devcontainer:main" + + // DefaultTargetFormat is the default output format for builds. + DefaultTargetFormat = builderpb.TargetFormatBin ) // TargetFormat is an alias for builderpb.TargetFormat. diff --git a/tavern/internal/builder/builderpb/builder.pb.go b/tavern/internal/builder/builderpb/builder.pb.go index 227fad4bd..321e95bd5 100644 --- a/tavern/internal/builder/builderpb/builder.pb.go +++ b/tavern/internal/builder/builderpb/builder.pb.go @@ -191,6 +191,7 @@ type StreamBuildTaskOutputRequest struct { Output string `protobuf:"bytes,2,opt,name=output,proto3" json:"output,omitempty"` Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` Finished bool `protobuf:"varint,4,opt,name=finished,proto3" json:"finished,omitempty"` + ExitCode int64 `protobuf:"varint,5,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -253,6 +254,13 @@ func (x *StreamBuildTaskOutputRequest) GetFinished() bool { return false } +func (x *StreamBuildTaskOutputRequest) GetExitCode() int64 { + if x != nil { + return x.ExitCode + } + return 0 +} + type StreamBuildTaskOutputResponse struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -415,7 +423,7 @@ var file_builder_proto_rawDesc = string([]byte{ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x53, 0x70, 0x65, 0x63, 0x52, 0x05, - 0x74, 0x61, 0x73, 0x6b, 0x73, 0x22, 0x81, 0x01, 0x0a, 0x1c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x74, 0x61, 0x73, 0x6b, 0x73, 0x22, 0x9e, 0x01, 0x0a, 0x1c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, @@ -423,43 +431,44 @@ var file_builder_proto_rawDesc = string([]byte{ 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x22, 0x1f, 0x0a, 0x1d, 0x53, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, - 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x70, 0x0a, 0x1a, 0x55, 0x70, - 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, - 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, - 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x22, 0x38, 0x0a, 0x1b, - 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, - 0x61, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x61, - 0x73, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, - 0x73, 0x73, 0x65, 0x74, 0x49, 0x64, 0x32, 0xb3, 0x02, 0x0a, 0x07, 0x42, 0x75, 0x69, 0x6c, 0x64, - 0x65, 0x72, 0x12, 0x56, 0x0a, 0x0f, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, - 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x1f, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, - 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, - 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6a, 0x0a, 0x15, 0x53, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, - 0x70, 0x75, 0x74, 0x12, 0x25, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, - 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x62, 0x75, 0x69, - 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, - 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x64, 0x0a, 0x13, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, - 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x23, 0x2e, - 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, - 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x6c, + 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x78, 0x69, + 0x74, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x65, 0x78, + 0x69, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x1f, 0x0a, 0x1d, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x70, 0x0a, 0x1a, 0x55, 0x70, 0x6c, 0x6f, 0x61, + 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x23, + 0x0a, 0x0d, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x22, 0x38, 0x0a, 0x1b, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x42, 0x2d, 0x5a, 0x2b, - 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, 0x6e, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, - 0x72, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x73, 0x73, 0x65, + 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, 0x73, 0x73, 0x65, + 0x74, 0x49, 0x64, 0x32, 0xb3, 0x02, 0x0a, 0x07, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x12, + 0x56, 0x0a, 0x0f, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, + 0x6b, 0x73, 0x12, 0x1f, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x61, + 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x6c, + 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6a, 0x0a, 0x15, 0x53, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, + 0x12, 0x25, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, + 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, + 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x28, 0x01, 0x12, 0x64, 0x0a, 0x13, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, + 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x23, 0x2e, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x24, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, + 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x42, 0x2d, 0x5a, 0x2b, 0x72, 0x65, 0x61, + 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, 0x6e, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2f, 0x62, + 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, }) var ( diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index 31de0176f..3227c57b3 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -257,6 +257,9 @@ func executeTask(ctx context.Context, client builderpb.BuilderClient, exec execu TaskId: task.Id, Finished: true, } + if result != nil { + finalMsg.ExitCode = result.ExitCode + } if buildErr != nil { finalMsg.Error = buildErr.Error() slog.ErrorContext(ctx, "build task failed", diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go index fdd67a7f8..288cbb8fe 100644 --- a/tavern/internal/builder/integration_test.go +++ b/tavern/internal/builder/integration_test.go @@ -190,7 +190,7 @@ func TestBuilderE2E(t *testing.T) { require.Len(t, resp.Tasks[0].Env, 1) assert.Contains(t, resp.Tasks[0].Env[0], "IMIX_CONFIG=") assert.Contains(t, resp.Tasks[0].Env[0], "transports:") - assert.Contains(t, resp.Tasks[0].Env[0], "uri: https://callback.example.com") + assert.Contains(t, resp.Tasks[0].Env[0], "URI: https://callback.example.com") assert.Contains(t, resp.Tasks[0].Env[0], "interval: 10") assert.Contains(t, resp.Tasks[0].Env[0], "type: grpc") @@ -198,6 +198,11 @@ func TestBuilderE2E(t *testing.T) { reloaded := graph.BuildTask.GetX(ctx, bt.ID) assert.False(t, reloaded.ClaimedAt.IsZero()) + // Verify builder's last_seen_at was updated + reloadedBuilder := graph.Builder.GetX(ctx, builders[0].ID) + require.NotNil(t, reloadedBuilder.LastSeenAt) + assert.False(t, reloadedBuilder.LastSeenAt.IsZero()) + // Claim again -> should return empty (already claimed) resp2, err := authClient.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) require.NoError(t, err) @@ -246,6 +251,7 @@ func TestBuilderE2E(t *testing.T) { require.NoError(t, stream.Send(&builderpb.StreamBuildTaskOutputRequest{ TaskId: int64(bt.ID), Finished: true, + ExitCode: 0, })) _, err = stream.CloseAndRecv() @@ -256,6 +262,8 @@ func TestBuilderE2E(t *testing.T) { assert.Equal(t, "build succeeded", reloaded.Output) assert.False(t, reloaded.FinishedAt.IsZero()) assert.Empty(t, reloaded.Error) + require.NotNil(t, reloaded.ExitCode) + assert.Equal(t, 0, *reloaded.ExitCode) }) // 12. Test: StreamBuildTaskOutput with error @@ -300,6 +308,7 @@ func TestBuilderE2E(t *testing.T) { TaskId: int64(bt.ID), Error: "compilation failed: missing dependency", Finished: true, + ExitCode: 1, })) _, err = stream.CloseAndRecv() @@ -310,6 +319,8 @@ func TestBuilderE2E(t *testing.T) { assert.Equal(t, "partial output before failure", reloaded.Output) assert.Equal(t, "compilation failed: missing dependency", reloaded.Error) assert.False(t, reloaded.FinishedAt.IsZero()) + require.NotNil(t, reloaded.ExitCode) + assert.Equal(t, 1, *reloaded.ExitCode) }) // 13. Test: StreamBuildTaskOutput for another builder's task is rejected diff --git a/tavern/internal/builder/proto/builder.proto b/tavern/internal/builder/proto/builder.proto index 134494720..3712265d2 100644 --- a/tavern/internal/builder/proto/builder.proto +++ b/tavern/internal/builder/proto/builder.proto @@ -24,6 +24,7 @@ message StreamBuildTaskOutputRequest { string output = 2; string error = 3; bool finished = 4; + int64 exit_code = 5; } message StreamBuildTaskOutputResponse {} diff --git a/tavern/internal/builder/server.go b/tavern/internal/builder/server.go index 818af8219..565ddd9b5 100644 --- a/tavern/internal/builder/server.go +++ b/tavern/internal/builder/server.go @@ -46,6 +46,14 @@ func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildT return nil, status.Error(codes.Unauthenticated, "builder not authenticated") } + // Update builder's last_seen_at timestamp + if _, err := s.graph.Builder.UpdateOne(b). + SetLastSeenAt(now). + Save(ctx); err != nil { + slog.ErrorContext(ctx, "failed to update builder last_seen_at", + "builder_id", b.ID, "error", err) + } + // Load unclaimed build tasks assigned to this builder tasks, err := s.graph.BuildTask.Query(). Where( @@ -205,7 +213,7 @@ func (s *Server) StreamBuildTaskOutput(stream builderpb.Builder_StreamBuildTaskO // Flush every message to the database immediately. if req.Output != "" || req.Error != "" || finished { - if err := s.flushStreamOutput(ctx, int(taskID), req.Output, req.Error, finished); err != nil { + if err := s.flushStreamOutput(ctx, int(taskID), req.Output, req.Error, finished, req.ExitCode); err != nil { return status.Errorf(codes.Internal, "failed to flush build output for task %d: %v", taskID, err) } } @@ -324,8 +332,8 @@ func (s *Server) UploadBuildArtifact(stream builderpb.Builder_UploadBuildArtifac } // flushStreamOutput appends output and error to the build task in the database. -// If finished is true, it also sets finished_at to mark the task as complete. -func (s *Server) flushStreamOutput(ctx context.Context, taskID int, output string, errMsg string, finished bool) error { +// If finished is true, it also sets finished_at and exit_code to mark the task as complete. +func (s *Server) flushStreamOutput(ctx context.Context, taskID int, output string, errMsg string, finished bool, exitCode int64) error { bt, err := s.graph.BuildTask.Get(ctx, taskID) if err != nil { return fmt.Errorf("failed to load build task %d: %w", taskID, err) @@ -352,7 +360,8 @@ func (s *Server) flushStreamOutput(ctx context.Context, taskID int, output strin update = update.SetError(newError) } if finished { - update = update.SetFinishedAt(time.Now()) + update = update.SetFinishedAt(time.Now()). + SetExitCode(int(exitCode)) } if _, err := update.Save(ctx); err != nil { diff --git a/tavern/internal/ent/builder.go b/tavern/internal/ent/builder.go index d116f7de3..8baf8c211 100644 --- a/tavern/internal/ent/builder.go +++ b/tavern/internal/ent/builder.go @@ -29,6 +29,8 @@ type Builder struct { SupportedTargets []c2pb.Host_Platform `json:"supported_targets,omitempty"` // The server address that the builder should connect to. Upstream string `json:"upstream,omitempty"` + // Timestamp of the builder's last ClaimBuildTasks call. Null if never seen. + LastSeenAt *time.Time `json:"last_seen_at,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the BuilderQuery when eager-loading is set. Edges BuilderEdges `json:"edges"` @@ -68,7 +70,7 @@ func (*Builder) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case builder.FieldIdentifier, builder.FieldUpstream: values[i] = new(sql.NullString) - case builder.FieldCreatedAt, builder.FieldLastModifiedAt: + case builder.FieldCreatedAt, builder.FieldLastModifiedAt, builder.FieldLastSeenAt: values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) @@ -123,6 +125,13 @@ func (b *Builder) assignValues(columns []string, values []any) error { } else if value.Valid { b.Upstream = value.String } + case builder.FieldLastSeenAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_seen_at", values[i]) + } else if value.Valid { + b.LastSeenAt = new(time.Time) + *b.LastSeenAt = value.Time + } default: b.selectValues.Set(columns[i], values[i]) } @@ -178,6 +187,11 @@ func (b *Builder) String() string { builder.WriteString(", ") builder.WriteString("upstream=") builder.WriteString(b.Upstream) + builder.WriteString(", ") + if v := b.LastSeenAt; v != nil { + builder.WriteString("last_seen_at=") + builder.WriteString(v.Format(time.ANSIC)) + } builder.WriteByte(')') return builder.String() } diff --git a/tavern/internal/ent/builder/builder.go b/tavern/internal/ent/builder/builder.go index 86c6268c1..eff483ea6 100644 --- a/tavern/internal/ent/builder/builder.go +++ b/tavern/internal/ent/builder/builder.go @@ -24,6 +24,8 @@ const ( FieldSupportedTargets = "supported_targets" // FieldUpstream holds the string denoting the upstream field in the database. FieldUpstream = "upstream" + // FieldLastSeenAt holds the string denoting the last_seen_at field in the database. + FieldLastSeenAt = "last_seen_at" // EdgeBuildTasks holds the string denoting the build_tasks edge name in mutations. EdgeBuildTasks = "build_tasks" // Table holds the table name of the builder in the database. @@ -45,6 +47,7 @@ var Columns = []string{ FieldIdentifier, FieldSupportedTargets, FieldUpstream, + FieldLastSeenAt, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -98,6 +101,11 @@ func ByUpstream(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUpstream, opts...).ToFunc() } +// ByLastSeenAt orders the results by the last_seen_at field. +func ByLastSeenAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastSeenAt, opts...).ToFunc() +} + // ByBuildTasksCount orders the results by build_tasks count. func ByBuildTasksCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/tavern/internal/ent/builder/where.go b/tavern/internal/ent/builder/where.go index a2f85e99c..bf18a5e59 100644 --- a/tavern/internal/ent/builder/where.go +++ b/tavern/internal/ent/builder/where.go @@ -75,6 +75,11 @@ func Upstream(v string) predicate.Builder { return predicate.Builder(sql.FieldEQ(FieldUpstream, v)) } +// LastSeenAt applies equality check predicate on the "last_seen_at" field. It's identical to LastSeenAtEQ. +func LastSeenAt(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldLastSeenAt, v)) +} + // CreatedAtEQ applies the EQ predicate on the "created_at" field. func CreatedAtEQ(v time.Time) predicate.Builder { return predicate.Builder(sql.FieldEQ(FieldCreatedAt, v)) @@ -285,6 +290,56 @@ func UpstreamContainsFold(v string) predicate.Builder { return predicate.Builder(sql.FieldContainsFold(FieldUpstream, v)) } +// LastSeenAtEQ applies the EQ predicate on the "last_seen_at" field. +func LastSeenAtEQ(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldLastSeenAt, v)) +} + +// LastSeenAtNEQ applies the NEQ predicate on the "last_seen_at" field. +func LastSeenAtNEQ(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldNEQ(FieldLastSeenAt, v)) +} + +// LastSeenAtIn applies the In predicate on the "last_seen_at" field. +func LastSeenAtIn(vs ...time.Time) predicate.Builder { + return predicate.Builder(sql.FieldIn(FieldLastSeenAt, vs...)) +} + +// LastSeenAtNotIn applies the NotIn predicate on the "last_seen_at" field. +func LastSeenAtNotIn(vs ...time.Time) predicate.Builder { + return predicate.Builder(sql.FieldNotIn(FieldLastSeenAt, vs...)) +} + +// LastSeenAtGT applies the GT predicate on the "last_seen_at" field. +func LastSeenAtGT(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldGT(FieldLastSeenAt, v)) +} + +// LastSeenAtGTE applies the GTE predicate on the "last_seen_at" field. +func LastSeenAtGTE(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldGTE(FieldLastSeenAt, v)) +} + +// LastSeenAtLT applies the LT predicate on the "last_seen_at" field. +func LastSeenAtLT(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldLT(FieldLastSeenAt, v)) +} + +// LastSeenAtLTE applies the LTE predicate on the "last_seen_at" field. +func LastSeenAtLTE(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldLTE(FieldLastSeenAt, v)) +} + +// LastSeenAtIsNil applies the IsNil predicate on the "last_seen_at" field. +func LastSeenAtIsNil() predicate.Builder { + return predicate.Builder(sql.FieldIsNull(FieldLastSeenAt)) +} + +// LastSeenAtNotNil applies the NotNil predicate on the "last_seen_at" field. +func LastSeenAtNotNil() predicate.Builder { + return predicate.Builder(sql.FieldNotNull(FieldLastSeenAt)) +} + // HasBuildTasks applies the HasEdge predicate on the "build_tasks" edge. func HasBuildTasks() predicate.Builder { return predicate.Builder(func(s *sql.Selector) { diff --git a/tavern/internal/ent/builder_create.go b/tavern/internal/ent/builder_create.go index 9a85f8ba9..035cd8fa7 100644 --- a/tavern/internal/ent/builder_create.go +++ b/tavern/internal/ent/builder_create.go @@ -78,6 +78,20 @@ func (bc *BuilderCreate) SetUpstream(s string) *BuilderCreate { return bc } +// SetLastSeenAt sets the "last_seen_at" field. +func (bc *BuilderCreate) SetLastSeenAt(t time.Time) *BuilderCreate { + bc.mutation.SetLastSeenAt(t) + return bc +} + +// SetNillableLastSeenAt sets the "last_seen_at" field if the given value is not nil. +func (bc *BuilderCreate) SetNillableLastSeenAt(t *time.Time) *BuilderCreate { + if t != nil { + bc.SetLastSeenAt(*t) + } + return bc +} + // AddBuildTaskIDs adds the "build_tasks" edge to the BuildTask entity by IDs. func (bc *BuilderCreate) AddBuildTaskIDs(ids ...int) *BuilderCreate { bc.mutation.AddBuildTaskIDs(ids...) @@ -211,6 +225,10 @@ func (bc *BuilderCreate) createSpec() (*Builder, *sqlgraph.CreateSpec) { _spec.SetField(builder.FieldUpstream, field.TypeString, value) _node.Upstream = value } + if value, ok := bc.mutation.LastSeenAt(); ok { + _spec.SetField(builder.FieldLastSeenAt, field.TypeTime, value) + _node.LastSeenAt = &value + } if nodes := bc.mutation.BuildTasksIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -315,6 +333,24 @@ func (u *BuilderUpsert) UpdateUpstream() *BuilderUpsert { return u } +// SetLastSeenAt sets the "last_seen_at" field. +func (u *BuilderUpsert) SetLastSeenAt(v time.Time) *BuilderUpsert { + u.Set(builder.FieldLastSeenAt, v) + return u +} + +// UpdateLastSeenAt sets the "last_seen_at" field to the value that was provided on create. +func (u *BuilderUpsert) UpdateLastSeenAt() *BuilderUpsert { + u.SetExcluded(builder.FieldLastSeenAt) + return u +} + +// ClearLastSeenAt clears the value of the "last_seen_at" field. +func (u *BuilderUpsert) ClearLastSeenAt() *BuilderUpsert { + u.SetNull(builder.FieldLastSeenAt) + return u +} + // UpdateNewValues updates the mutable fields using the new values that were set on create. // Using this option is equivalent to using: // @@ -405,6 +441,27 @@ func (u *BuilderUpsertOne) UpdateUpstream() *BuilderUpsertOne { }) } +// SetLastSeenAt sets the "last_seen_at" field. +func (u *BuilderUpsertOne) SetLastSeenAt(v time.Time) *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.SetLastSeenAt(v) + }) +} + +// UpdateLastSeenAt sets the "last_seen_at" field to the value that was provided on create. +func (u *BuilderUpsertOne) UpdateLastSeenAt() *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.UpdateLastSeenAt() + }) +} + +// ClearLastSeenAt clears the value of the "last_seen_at" field. +func (u *BuilderUpsertOne) ClearLastSeenAt() *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.ClearLastSeenAt() + }) +} + // Exec executes the query. func (u *BuilderUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -661,6 +718,27 @@ func (u *BuilderUpsertBulk) UpdateUpstream() *BuilderUpsertBulk { }) } +// SetLastSeenAt sets the "last_seen_at" field. +func (u *BuilderUpsertBulk) SetLastSeenAt(v time.Time) *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.SetLastSeenAt(v) + }) +} + +// UpdateLastSeenAt sets the "last_seen_at" field to the value that was provided on create. +func (u *BuilderUpsertBulk) UpdateLastSeenAt() *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.UpdateLastSeenAt() + }) +} + +// ClearLastSeenAt clears the value of the "last_seen_at" field. +func (u *BuilderUpsertBulk) ClearLastSeenAt() *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.ClearLastSeenAt() + }) +} + // Exec executes the query. func (u *BuilderUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/tavern/internal/ent/builder_update.go b/tavern/internal/ent/builder_update.go index fd4fefe9a..64eb1b847 100644 --- a/tavern/internal/ent/builder_update.go +++ b/tavern/internal/ent/builder_update.go @@ -63,6 +63,26 @@ func (bu *BuilderUpdate) SetNillableUpstream(s *string) *BuilderUpdate { return bu } +// SetLastSeenAt sets the "last_seen_at" field. +func (bu *BuilderUpdate) SetLastSeenAt(t time.Time) *BuilderUpdate { + bu.mutation.SetLastSeenAt(t) + return bu +} + +// SetNillableLastSeenAt sets the "last_seen_at" field if the given value is not nil. +func (bu *BuilderUpdate) SetNillableLastSeenAt(t *time.Time) *BuilderUpdate { + if t != nil { + bu.SetLastSeenAt(*t) + } + return bu +} + +// ClearLastSeenAt clears the value of the "last_seen_at" field. +func (bu *BuilderUpdate) ClearLastSeenAt() *BuilderUpdate { + bu.mutation.ClearLastSeenAt() + return bu +} + // AddBuildTaskIDs adds the "build_tasks" edge to the BuildTask entity by IDs. func (bu *BuilderUpdate) AddBuildTaskIDs(ids ...int) *BuilderUpdate { bu.mutation.AddBuildTaskIDs(ids...) @@ -163,6 +183,12 @@ func (bu *BuilderUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := bu.mutation.Upstream(); ok { _spec.SetField(builder.FieldUpstream, field.TypeString, value) } + if value, ok := bu.mutation.LastSeenAt(); ok { + _spec.SetField(builder.FieldLastSeenAt, field.TypeTime, value) + } + if bu.mutation.LastSeenAtCleared() { + _spec.ClearField(builder.FieldLastSeenAt, field.TypeTime) + } if bu.mutation.BuildTasksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -260,6 +286,26 @@ func (buo *BuilderUpdateOne) SetNillableUpstream(s *string) *BuilderUpdateOne { return buo } +// SetLastSeenAt sets the "last_seen_at" field. +func (buo *BuilderUpdateOne) SetLastSeenAt(t time.Time) *BuilderUpdateOne { + buo.mutation.SetLastSeenAt(t) + return buo +} + +// SetNillableLastSeenAt sets the "last_seen_at" field if the given value is not nil. +func (buo *BuilderUpdateOne) SetNillableLastSeenAt(t *time.Time) *BuilderUpdateOne { + if t != nil { + buo.SetLastSeenAt(*t) + } + return buo +} + +// ClearLastSeenAt clears the value of the "last_seen_at" field. +func (buo *BuilderUpdateOne) ClearLastSeenAt() *BuilderUpdateOne { + buo.mutation.ClearLastSeenAt() + return buo +} + // AddBuildTaskIDs adds the "build_tasks" edge to the BuildTask entity by IDs. func (buo *BuilderUpdateOne) AddBuildTaskIDs(ids ...int) *BuilderUpdateOne { buo.mutation.AddBuildTaskIDs(ids...) @@ -390,6 +436,12 @@ func (buo *BuilderUpdateOne) sqlSave(ctx context.Context) (_node *Builder, err e if value, ok := buo.mutation.Upstream(); ok { _spec.SetField(builder.FieldUpstream, field.TypeString, value) } + if value, ok := buo.mutation.LastSeenAt(); ok { + _spec.SetField(builder.FieldLastSeenAt, field.TypeTime, value) + } + if buo.mutation.LastSeenAtCleared() { + _spec.ClearField(builder.FieldLastSeenAt, field.TypeTime) + } if buo.mutation.BuildTasksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/tavern/internal/ent/buildtask.go b/tavern/internal/ent/buildtask.go index 8b99a4d77..20e24af5c 100644 --- a/tavern/internal/ent/buildtask.go +++ b/tavern/internal/ent/buildtask.go @@ -55,6 +55,8 @@ type BuildTask struct { Error string `json:"error,omitempty"` // The size of the error in bytes ErrorSize int `json:"error_size,omitempty"` + // Exit code from the build container process. Null if the build has not finished. + ExitCode *int `json:"exit_code,omitempty"` // Path inside the container where the build artifact is located. Derived from target_os if not set. ArtifactPath string `json:"artifact_path,omitempty"` // Edges holds the relations/edges for other nodes in the graph. @@ -111,7 +113,7 @@ func (*BuildTask) scanValues(columns []string) ([]any, error) { values[i] = new(c2pb.Host_Platform) case buildtask.FieldTransportType: values[i] = new(c2pb.Transport_Type) - case buildtask.FieldID, buildtask.FieldInterval, buildtask.FieldOutputSize, buildtask.FieldErrorSize: + case buildtask.FieldID, buildtask.FieldInterval, buildtask.FieldOutputSize, buildtask.FieldErrorSize, buildtask.FieldExitCode: values[i] = new(sql.NullInt64) case buildtask.FieldBuildImage, buildtask.FieldBuildScript, buildtask.FieldCallbackURI, buildtask.FieldExtra, buildtask.FieldOutput, buildtask.FieldError, buildtask.FieldArtifactPath: values[i] = new(sql.NullString) @@ -244,6 +246,13 @@ func (bt *BuildTask) assignValues(columns []string, values []any) error { } else if value.Valid { bt.ErrorSize = int(value.Int64) } + case buildtask.FieldExitCode: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field exit_code", values[i]) + } else if value.Valid { + bt.ExitCode = new(int) + *bt.ExitCode = int(value.Int64) + } case buildtask.FieldArtifactPath: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field artifact_path", values[i]) @@ -361,6 +370,11 @@ func (bt *BuildTask) String() string { builder.WriteString("error_size=") builder.WriteString(fmt.Sprintf("%v", bt.ErrorSize)) builder.WriteString(", ") + if v := bt.ExitCode; v != nil { + builder.WriteString("exit_code=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") builder.WriteString("artifact_path=") builder.WriteString(bt.ArtifactPath) builder.WriteByte(')') diff --git a/tavern/internal/ent/buildtask/buildtask.go b/tavern/internal/ent/buildtask/buildtask.go index 9123d4c91..1d43332c9 100644 --- a/tavern/internal/ent/buildtask/buildtask.go +++ b/tavern/internal/ent/buildtask/buildtask.go @@ -53,6 +53,8 @@ const ( FieldError = "error" // FieldErrorSize holds the string denoting the error_size field in the database. FieldErrorSize = "error_size" + // FieldExitCode holds the string denoting the exit_code field in the database. + FieldExitCode = "exit_code" // FieldArtifactPath holds the string denoting the artifact_path field in the database. FieldArtifactPath = "artifact_path" // EdgeBuilder holds the string denoting the builder edge name in mutations. @@ -97,6 +99,7 @@ var Columns = []string{ FieldOutputSize, FieldError, FieldErrorSize, + FieldExitCode, FieldArtifactPath, } @@ -276,6 +279,11 @@ func ByErrorSize(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldErrorSize, opts...).ToFunc() } +// ByExitCode orders the results by the exit_code field. +func ByExitCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldExitCode, opts...).ToFunc() +} + // ByArtifactPath orders the results by the artifact_path field. func ByArtifactPath(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldArtifactPath, opts...).ToFunc() diff --git a/tavern/internal/ent/buildtask/where.go b/tavern/internal/ent/buildtask/where.go index 0b94d561e..2dae145c2 100644 --- a/tavern/internal/ent/buildtask/where.go +++ b/tavern/internal/ent/buildtask/where.go @@ -127,6 +127,11 @@ func ErrorSize(v int) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldErrorSize, v)) } +// ExitCode applies equality check predicate on the "exit_code" field. It's identical to ExitCodeEQ. +func ExitCode(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldExitCode, v)) +} + // ArtifactPath applies equality check predicate on the "artifact_path" field. It's identical to ArtifactPathEQ. func ArtifactPath(v string) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldArtifactPath, v)) @@ -962,6 +967,56 @@ func ErrorSizeLTE(v int) predicate.BuildTask { return predicate.BuildTask(sql.FieldLTE(FieldErrorSize, v)) } +// ExitCodeEQ applies the EQ predicate on the "exit_code" field. +func ExitCodeEQ(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldEQ(FieldExitCode, v)) +} + +// ExitCodeNEQ applies the NEQ predicate on the "exit_code" field. +func ExitCodeNEQ(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNEQ(FieldExitCode, v)) +} + +// ExitCodeIn applies the In predicate on the "exit_code" field. +func ExitCodeIn(vs ...int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldIn(FieldExitCode, vs...)) +} + +// ExitCodeNotIn applies the NotIn predicate on the "exit_code" field. +func ExitCodeNotIn(vs ...int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotIn(FieldExitCode, vs...)) +} + +// ExitCodeGT applies the GT predicate on the "exit_code" field. +func ExitCodeGT(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGT(FieldExitCode, v)) +} + +// ExitCodeGTE applies the GTE predicate on the "exit_code" field. +func ExitCodeGTE(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldGTE(FieldExitCode, v)) +} + +// ExitCodeLT applies the LT predicate on the "exit_code" field. +func ExitCodeLT(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLT(FieldExitCode, v)) +} + +// ExitCodeLTE applies the LTE predicate on the "exit_code" field. +func ExitCodeLTE(v int) predicate.BuildTask { + return predicate.BuildTask(sql.FieldLTE(FieldExitCode, v)) +} + +// ExitCodeIsNil applies the IsNil predicate on the "exit_code" field. +func ExitCodeIsNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldIsNull(FieldExitCode)) +} + +// ExitCodeNotNil applies the NotNil predicate on the "exit_code" field. +func ExitCodeNotNil() predicate.BuildTask { + return predicate.BuildTask(sql.FieldNotNull(FieldExitCode)) +} + // ArtifactPathEQ applies the EQ predicate on the "artifact_path" field. func ArtifactPathEQ(v string) predicate.BuildTask { return predicate.BuildTask(sql.FieldEQ(FieldArtifactPath, v)) diff --git a/tavern/internal/ent/buildtask_create.go b/tavern/internal/ent/buildtask_create.go index 8f5ab001b..b582b38f2 100644 --- a/tavern/internal/ent/buildtask_create.go +++ b/tavern/internal/ent/buildtask_create.go @@ -216,6 +216,20 @@ func (btc *BuildTaskCreate) SetNillableErrorSize(i *int) *BuildTaskCreate { return btc } +// SetExitCode sets the "exit_code" field. +func (btc *BuildTaskCreate) SetExitCode(i int) *BuildTaskCreate { + btc.mutation.SetExitCode(i) + return btc +} + +// SetNillableExitCode sets the "exit_code" field if the given value is not nil. +func (btc *BuildTaskCreate) SetNillableExitCode(i *int) *BuildTaskCreate { + if i != nil { + btc.SetExitCode(*i) + } + return btc +} + // SetArtifactPath sets the "artifact_path" field. func (btc *BuildTaskCreate) SetArtifactPath(s string) *BuildTaskCreate { btc.mutation.SetArtifactPath(s) @@ -499,6 +513,10 @@ func (btc *BuildTaskCreate) createSpec() (*BuildTask, *sqlgraph.CreateSpec) { _spec.SetField(buildtask.FieldErrorSize, field.TypeInt, value) _node.ErrorSize = value } + if value, ok := btc.mutation.ExitCode(); ok { + _spec.SetField(buildtask.FieldExitCode, field.TypeInt, value) + _node.ExitCode = &value + } if value, ok := btc.mutation.ArtifactPath(); ok { _spec.SetField(buildtask.FieldArtifactPath, field.TypeString, value) _node.ArtifactPath = value @@ -835,6 +853,30 @@ func (u *BuildTaskUpsert) AddErrorSize(v int) *BuildTaskUpsert { return u } +// SetExitCode sets the "exit_code" field. +func (u *BuildTaskUpsert) SetExitCode(v int) *BuildTaskUpsert { + u.Set(buildtask.FieldExitCode, v) + return u +} + +// UpdateExitCode sets the "exit_code" field to the value that was provided on create. +func (u *BuildTaskUpsert) UpdateExitCode() *BuildTaskUpsert { + u.SetExcluded(buildtask.FieldExitCode) + return u +} + +// AddExitCode adds v to the "exit_code" field. +func (u *BuildTaskUpsert) AddExitCode(v int) *BuildTaskUpsert { + u.Add(buildtask.FieldExitCode, v) + return u +} + +// ClearExitCode clears the value of the "exit_code" field. +func (u *BuildTaskUpsert) ClearExitCode() *BuildTaskUpsert { + u.SetNull(buildtask.FieldExitCode) + return u +} + // SetArtifactPath sets the "artifact_path" field. func (u *BuildTaskUpsert) SetArtifactPath(v string) *BuildTaskUpsert { u.Set(buildtask.FieldArtifactPath, v) @@ -1185,6 +1227,34 @@ func (u *BuildTaskUpsertOne) UpdateErrorSize() *BuildTaskUpsertOne { }) } +// SetExitCode sets the "exit_code" field. +func (u *BuildTaskUpsertOne) SetExitCode(v int) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.SetExitCode(v) + }) +} + +// AddExitCode adds v to the "exit_code" field. +func (u *BuildTaskUpsertOne) AddExitCode(v int) *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.AddExitCode(v) + }) +} + +// UpdateExitCode sets the "exit_code" field to the value that was provided on create. +func (u *BuildTaskUpsertOne) UpdateExitCode() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateExitCode() + }) +} + +// ClearExitCode clears the value of the "exit_code" field. +func (u *BuildTaskUpsertOne) ClearExitCode() *BuildTaskUpsertOne { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearExitCode() + }) +} + // SetArtifactPath sets the "artifact_path" field. func (u *BuildTaskUpsertOne) SetArtifactPath(v string) *BuildTaskUpsertOne { return u.Update(func(s *BuildTaskUpsert) { @@ -1704,6 +1774,34 @@ func (u *BuildTaskUpsertBulk) UpdateErrorSize() *BuildTaskUpsertBulk { }) } +// SetExitCode sets the "exit_code" field. +func (u *BuildTaskUpsertBulk) SetExitCode(v int) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.SetExitCode(v) + }) +} + +// AddExitCode adds v to the "exit_code" field. +func (u *BuildTaskUpsertBulk) AddExitCode(v int) *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.AddExitCode(v) + }) +} + +// UpdateExitCode sets the "exit_code" field to the value that was provided on create. +func (u *BuildTaskUpsertBulk) UpdateExitCode() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.UpdateExitCode() + }) +} + +// ClearExitCode clears the value of the "exit_code" field. +func (u *BuildTaskUpsertBulk) ClearExitCode() *BuildTaskUpsertBulk { + return u.Update(func(s *BuildTaskUpsert) { + s.ClearExitCode() + }) +} + // SetArtifactPath sets the "artifact_path" field. func (u *BuildTaskUpsertBulk) SetArtifactPath(v string) *BuildTaskUpsertBulk { return u.Update(func(s *BuildTaskUpsert) { diff --git a/tavern/internal/ent/buildtask_update.go b/tavern/internal/ent/buildtask_update.go index 7b3a5e181..c87e1211e 100644 --- a/tavern/internal/ent/buildtask_update.go +++ b/tavern/internal/ent/buildtask_update.go @@ -305,6 +305,33 @@ func (btu *BuildTaskUpdate) AddErrorSize(i int) *BuildTaskUpdate { return btu } +// SetExitCode sets the "exit_code" field. +func (btu *BuildTaskUpdate) SetExitCode(i int) *BuildTaskUpdate { + btu.mutation.ResetExitCode() + btu.mutation.SetExitCode(i) + return btu +} + +// SetNillableExitCode sets the "exit_code" field if the given value is not nil. +func (btu *BuildTaskUpdate) SetNillableExitCode(i *int) *BuildTaskUpdate { + if i != nil { + btu.SetExitCode(*i) + } + return btu +} + +// AddExitCode adds i to the "exit_code" field. +func (btu *BuildTaskUpdate) AddExitCode(i int) *BuildTaskUpdate { + btu.mutation.AddExitCode(i) + return btu +} + +// ClearExitCode clears the value of the "exit_code" field. +func (btu *BuildTaskUpdate) ClearExitCode() *BuildTaskUpdate { + btu.mutation.ClearExitCode() + return btu +} + // SetArtifactPath sets the "artifact_path" field. func (btu *BuildTaskUpdate) SetArtifactPath(s string) *BuildTaskUpdate { btu.mutation.SetArtifactPath(s) @@ -549,6 +576,15 @@ func (btu *BuildTaskUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := btu.mutation.AddedErrorSize(); ok { _spec.AddField(buildtask.FieldErrorSize, field.TypeInt, value) } + if value, ok := btu.mutation.ExitCode(); ok { + _spec.SetField(buildtask.FieldExitCode, field.TypeInt, value) + } + if value, ok := btu.mutation.AddedExitCode(); ok { + _spec.AddField(buildtask.FieldExitCode, field.TypeInt, value) + } + if btu.mutation.ExitCodeCleared() { + _spec.ClearField(buildtask.FieldExitCode, field.TypeInt) + } if value, ok := btu.mutation.ArtifactPath(); ok { _spec.SetField(buildtask.FieldArtifactPath, field.TypeString, value) } @@ -906,6 +942,33 @@ func (btuo *BuildTaskUpdateOne) AddErrorSize(i int) *BuildTaskUpdateOne { return btuo } +// SetExitCode sets the "exit_code" field. +func (btuo *BuildTaskUpdateOne) SetExitCode(i int) *BuildTaskUpdateOne { + btuo.mutation.ResetExitCode() + btuo.mutation.SetExitCode(i) + return btuo +} + +// SetNillableExitCode sets the "exit_code" field if the given value is not nil. +func (btuo *BuildTaskUpdateOne) SetNillableExitCode(i *int) *BuildTaskUpdateOne { + if i != nil { + btuo.SetExitCode(*i) + } + return btuo +} + +// AddExitCode adds i to the "exit_code" field. +func (btuo *BuildTaskUpdateOne) AddExitCode(i int) *BuildTaskUpdateOne { + btuo.mutation.AddExitCode(i) + return btuo +} + +// ClearExitCode clears the value of the "exit_code" field. +func (btuo *BuildTaskUpdateOne) ClearExitCode() *BuildTaskUpdateOne { + btuo.mutation.ClearExitCode() + return btuo +} + // SetArtifactPath sets the "artifact_path" field. func (btuo *BuildTaskUpdateOne) SetArtifactPath(s string) *BuildTaskUpdateOne { btuo.mutation.SetArtifactPath(s) @@ -1180,6 +1243,15 @@ func (btuo *BuildTaskUpdateOne) sqlSave(ctx context.Context) (_node *BuildTask, if value, ok := btuo.mutation.AddedErrorSize(); ok { _spec.AddField(buildtask.FieldErrorSize, field.TypeInt, value) } + if value, ok := btuo.mutation.ExitCode(); ok { + _spec.SetField(buildtask.FieldExitCode, field.TypeInt, value) + } + if value, ok := btuo.mutation.AddedExitCode(); ok { + _spec.AddField(buildtask.FieldExitCode, field.TypeInt, value) + } + if btuo.mutation.ExitCodeCleared() { + _spec.ClearField(buildtask.FieldExitCode, field.TypeInt) + } if value, ok := btuo.mutation.ArtifactPath(); ok { _spec.SetField(buildtask.FieldArtifactPath, field.TypeString, value) } diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index d4e5f3790..ba6a8cce7 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -794,6 +794,11 @@ func (bt *BuildTaskQuery) collectField(ctx context.Context, oneNode bool, opCtx selectedFields = append(selectedFields, buildtask.FieldErrorSize) fieldSeen[buildtask.FieldErrorSize] = struct{}{} } + case "exitCode": + if _, ok := fieldSeen[buildtask.FieldExitCode]; !ok { + selectedFields = append(selectedFields, buildtask.FieldExitCode) + fieldSeen[buildtask.FieldExitCode] = struct{}{} + } case "artifactPath": if _, ok := fieldSeen[buildtask.FieldArtifactPath]; !ok { selectedFields = append(selectedFields, buildtask.FieldArtifactPath) @@ -1003,6 +1008,11 @@ func (b *BuilderQuery) collectField(ctx context.Context, oneNode bool, opCtx *gr selectedFields = append(selectedFields, builder.FieldUpstream) fieldSeen[builder.FieldUpstream] = struct{}{} } + case "lastSeenAt": + if _, ok := fieldSeen[builder.FieldLastSeenAt]; !ok { + selectedFields = append(selectedFields, builder.FieldLastSeenAt) + fieldSeen[builder.FieldLastSeenAt] = struct{}{} + } case "id": case "__typename": default: diff --git a/tavern/internal/ent/gql_pagination.go b/tavern/internal/ent/gql_pagination.go index 1890fe36b..dfa0c413e 100644 --- a/tavern/internal/ent/gql_pagination.go +++ b/tavern/internal/ent/gql_pagination.go @@ -1261,6 +1261,20 @@ var ( } }, } + // BuildTaskOrderFieldExitCode orders BuildTask by exit_code. + BuildTaskOrderFieldExitCode = &BuildTaskOrderField{ + Value: func(bt *BuildTask) (ent.Value, error) { + return bt.ExitCode, nil + }, + column: buildtask.FieldExitCode, + toTerm: buildtask.ByExitCode, + toCursor: func(bt *BuildTask) Cursor { + return Cursor{ + ID: bt.ID, + Value: bt.ExitCode, + } + }, + } ) // String implement fmt.Stringer interface. @@ -1283,6 +1297,8 @@ func (f BuildTaskOrderField) String() string { str = "OUTPUT_SIZE" case BuildTaskOrderFieldErrorSize.column: str = "ERROR_SIZE" + case BuildTaskOrderFieldExitCode.column: + str = "EXIT_CODE" } return str } @@ -1315,6 +1331,8 @@ func (f *BuildTaskOrderField) UnmarshalGQL(v interface{}) error { *f = *BuildTaskOrderFieldOutputSize case "ERROR_SIZE": *f = *BuildTaskOrderFieldErrorSize + case "EXIT_CODE": + *f = *BuildTaskOrderFieldExitCode default: return fmt.Errorf("%s is not a valid BuildTaskOrderField", str) } @@ -1635,6 +1653,20 @@ var ( } }, } + // BuilderOrderFieldLastSeenAt orders Builder by last_seen_at. + BuilderOrderFieldLastSeenAt = &BuilderOrderField{ + Value: func(b *Builder) (ent.Value, error) { + return b.LastSeenAt, nil + }, + column: builder.FieldLastSeenAt, + toTerm: builder.ByLastSeenAt, + toCursor: func(b *Builder) Cursor { + return Cursor{ + ID: b.ID, + Value: b.LastSeenAt, + } + }, + } ) // String implement fmt.Stringer interface. @@ -1645,6 +1677,8 @@ func (f BuilderOrderField) String() string { str = "CREATED_AT" case BuilderOrderFieldLastModifiedAt.column: str = "LAST_MODIFIED_AT" + case BuilderOrderFieldLastSeenAt.column: + str = "LAST_SEEN_AT" } return str } @@ -1665,6 +1699,8 @@ func (f *BuilderOrderField) UnmarshalGQL(v interface{}) error { *f = *BuilderOrderFieldCreatedAt case "LAST_MODIFIED_AT": *f = *BuilderOrderFieldLastModifiedAt + case "LAST_SEEN_AT": + *f = *BuilderOrderFieldLastSeenAt default: return fmt.Errorf("%s is not a valid BuilderOrderField", str) } diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index 9bf9254f0..46cd7f7d1 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -1281,6 +1281,18 @@ type BuildTaskWhereInput struct { ErrorSizeLT *int `json:"errorSizeLT,omitempty"` ErrorSizeLTE *int `json:"errorSizeLTE,omitempty"` + // "exit_code" field predicates. + ExitCode *int `json:"exitCode,omitempty"` + ExitCodeNEQ *int `json:"exitCodeNEQ,omitempty"` + ExitCodeIn []int `json:"exitCodeIn,omitempty"` + ExitCodeNotIn []int `json:"exitCodeNotIn,omitempty"` + ExitCodeGT *int `json:"exitCodeGT,omitempty"` + ExitCodeGTE *int `json:"exitCodeGTE,omitempty"` + ExitCodeLT *int `json:"exitCodeLT,omitempty"` + ExitCodeLTE *int `json:"exitCodeLTE,omitempty"` + ExitCodeIsNil bool `json:"exitCodeIsNil,omitempty"` + ExitCodeNotNil bool `json:"exitCodeNotNil,omitempty"` + // "artifact_path" field predicates. ArtifactPath *string `json:"artifactPath,omitempty"` ArtifactPathNEQ *string `json:"artifactPathNEQ,omitempty"` @@ -1900,6 +1912,36 @@ func (i *BuildTaskWhereInput) P() (predicate.BuildTask, error) { if i.ErrorSizeLTE != nil { predicates = append(predicates, buildtask.ErrorSizeLTE(*i.ErrorSizeLTE)) } + if i.ExitCode != nil { + predicates = append(predicates, buildtask.ExitCodeEQ(*i.ExitCode)) + } + if i.ExitCodeNEQ != nil { + predicates = append(predicates, buildtask.ExitCodeNEQ(*i.ExitCodeNEQ)) + } + if len(i.ExitCodeIn) > 0 { + predicates = append(predicates, buildtask.ExitCodeIn(i.ExitCodeIn...)) + } + if len(i.ExitCodeNotIn) > 0 { + predicates = append(predicates, buildtask.ExitCodeNotIn(i.ExitCodeNotIn...)) + } + if i.ExitCodeGT != nil { + predicates = append(predicates, buildtask.ExitCodeGT(*i.ExitCodeGT)) + } + if i.ExitCodeGTE != nil { + predicates = append(predicates, buildtask.ExitCodeGTE(*i.ExitCodeGTE)) + } + if i.ExitCodeLT != nil { + predicates = append(predicates, buildtask.ExitCodeLT(*i.ExitCodeLT)) + } + if i.ExitCodeLTE != nil { + predicates = append(predicates, buildtask.ExitCodeLTE(*i.ExitCodeLTE)) + } + if i.ExitCodeIsNil { + predicates = append(predicates, buildtask.ExitCodeIsNil()) + } + if i.ExitCodeNotNil { + predicates = append(predicates, buildtask.ExitCodeNotNil()) + } if i.ArtifactPath != nil { predicates = append(predicates, buildtask.ArtifactPathEQ(*i.ArtifactPath)) } @@ -2059,6 +2101,18 @@ type BuilderWhereInput struct { UpstreamEqualFold *string `json:"upstreamEqualFold,omitempty"` UpstreamContainsFold *string `json:"upstreamContainsFold,omitempty"` + // "last_seen_at" field predicates. + LastSeenAt *time.Time `json:"lastSeenAt,omitempty"` + LastSeenAtNEQ *time.Time `json:"lastSeenAtNEQ,omitempty"` + LastSeenAtIn []time.Time `json:"lastSeenAtIn,omitempty"` + LastSeenAtNotIn []time.Time `json:"lastSeenAtNotIn,omitempty"` + LastSeenAtGT *time.Time `json:"lastSeenAtGT,omitempty"` + LastSeenAtGTE *time.Time `json:"lastSeenAtGTE,omitempty"` + LastSeenAtLT *time.Time `json:"lastSeenAtLT,omitempty"` + LastSeenAtLTE *time.Time `json:"lastSeenAtLTE,omitempty"` + LastSeenAtIsNil bool `json:"lastSeenAtIsNil,omitempty"` + LastSeenAtNotNil bool `json:"lastSeenAtNotNil,omitempty"` + // "build_tasks" edge predicates. HasBuildTasks *bool `json:"hasBuildTasks,omitempty"` HasBuildTasksWith []*BuildTaskWhereInput `json:"hasBuildTasksWith,omitempty"` @@ -2285,6 +2339,36 @@ func (i *BuilderWhereInput) P() (predicate.Builder, error) { if i.UpstreamContainsFold != nil { predicates = append(predicates, builder.UpstreamContainsFold(*i.UpstreamContainsFold)) } + if i.LastSeenAt != nil { + predicates = append(predicates, builder.LastSeenAtEQ(*i.LastSeenAt)) + } + if i.LastSeenAtNEQ != nil { + predicates = append(predicates, builder.LastSeenAtNEQ(*i.LastSeenAtNEQ)) + } + if len(i.LastSeenAtIn) > 0 { + predicates = append(predicates, builder.LastSeenAtIn(i.LastSeenAtIn...)) + } + if len(i.LastSeenAtNotIn) > 0 { + predicates = append(predicates, builder.LastSeenAtNotIn(i.LastSeenAtNotIn...)) + } + if i.LastSeenAtGT != nil { + predicates = append(predicates, builder.LastSeenAtGT(*i.LastSeenAtGT)) + } + if i.LastSeenAtGTE != nil { + predicates = append(predicates, builder.LastSeenAtGTE(*i.LastSeenAtGTE)) + } + if i.LastSeenAtLT != nil { + predicates = append(predicates, builder.LastSeenAtLT(*i.LastSeenAtLT)) + } + if i.LastSeenAtLTE != nil { + predicates = append(predicates, builder.LastSeenAtLTE(*i.LastSeenAtLTE)) + } + if i.LastSeenAtIsNil { + predicates = append(predicates, builder.LastSeenAtIsNil()) + } + if i.LastSeenAtNotNil { + predicates = append(predicates, builder.LastSeenAtNotNil()) + } if i.HasBuildTasks != nil { p := builder.HasBuildTasks() diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index a839893fd..aa4757ab2 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -83,6 +83,7 @@ var ( {Name: "output_size", Type: field.TypeInt, Default: 0}, {Name: "error", Type: field.TypeString, Nullable: true, Size: 2147483647, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, {Name: "error_size", Type: field.TypeInt, Default: 0}, + {Name: "exit_code", Type: field.TypeInt, Nullable: true}, {Name: "artifact_path", Type: field.TypeString, Nullable: true}, {Name: "build_task_builder", Type: field.TypeInt}, {Name: "build_task_artifact", Type: field.TypeInt, Nullable: true}, @@ -95,13 +96,13 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "build_tasks_builders_builder", - Columns: []*schema.Column{BuildTasksColumns[19]}, + Columns: []*schema.Column{BuildTasksColumns[20]}, RefColumns: []*schema.Column{BuildersColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "build_tasks_assets_artifact", - Columns: []*schema.Column{BuildTasksColumns[20]}, + Columns: []*schema.Column{BuildTasksColumns[21]}, RefColumns: []*schema.Column{AssetsColumns[0]}, OnDelete: schema.SetNull, }, @@ -115,6 +116,7 @@ var ( {Name: "identifier", Type: field.TypeString, Unique: true}, {Name: "supported_targets", Type: field.TypeJSON}, {Name: "upstream", Type: field.TypeString}, + {Name: "last_seen_at", Type: field.TypeTime, Nullable: true}, } // BuildersTable holds the schema information for the "builders" table. BuildersTable = &schema.Table{ diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index 8cdee4da7..5fab9f704 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -2137,6 +2137,8 @@ type BuildTaskMutation struct { error *string error_size *int adderror_size *int + exit_code *int + addexit_code *int artifact_path *string clearedFields map[string]struct{} builder *int @@ -2996,6 +2998,76 @@ func (m *BuildTaskMutation) ResetErrorSize() { m.adderror_size = nil } +// SetExitCode sets the "exit_code" field. +func (m *BuildTaskMutation) SetExitCode(i int) { + m.exit_code = &i + m.addexit_code = nil +} + +// ExitCode returns the value of the "exit_code" field in the mutation. +func (m *BuildTaskMutation) ExitCode() (r int, exists bool) { + v := m.exit_code + if v == nil { + return + } + return *v, true +} + +// OldExitCode returns the old "exit_code" field's value of the BuildTask entity. +// If the BuildTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuildTaskMutation) OldExitCode(ctx context.Context) (v *int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExitCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExitCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExitCode: %w", err) + } + return oldValue.ExitCode, nil +} + +// AddExitCode adds i to the "exit_code" field. +func (m *BuildTaskMutation) AddExitCode(i int) { + if m.addexit_code != nil { + *m.addexit_code += i + } else { + m.addexit_code = &i + } +} + +// AddedExitCode returns the value that was added to the "exit_code" field in this mutation. +func (m *BuildTaskMutation) AddedExitCode() (r int, exists bool) { + v := m.addexit_code + if v == nil { + return + } + return *v, true +} + +// ClearExitCode clears the value of the "exit_code" field. +func (m *BuildTaskMutation) ClearExitCode() { + m.exit_code = nil + m.addexit_code = nil + m.clearedFields[buildtask.FieldExitCode] = struct{}{} +} + +// ExitCodeCleared returns if the "exit_code" field was cleared in this mutation. +func (m *BuildTaskMutation) ExitCodeCleared() bool { + _, ok := m.clearedFields[buildtask.FieldExitCode] + return ok +} + +// ResetExitCode resets all changes to the "exit_code" field. +func (m *BuildTaskMutation) ResetExitCode() { + m.exit_code = nil + m.addexit_code = nil + delete(m.clearedFields, buildtask.FieldExitCode) +} + // SetArtifactPath sets the "artifact_path" field. func (m *BuildTaskMutation) SetArtifactPath(s string) { m.artifact_path = &s @@ -3157,7 +3229,7 @@ func (m *BuildTaskMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BuildTaskMutation) Fields() []string { - fields := make([]string, 0, 18) + fields := make([]string, 0, 19) if m.created_at != nil { fields = append(fields, buildtask.FieldCreatedAt) } @@ -3209,6 +3281,9 @@ func (m *BuildTaskMutation) Fields() []string { if m.error_size != nil { fields = append(fields, buildtask.FieldErrorSize) } + if m.exit_code != nil { + fields = append(fields, buildtask.FieldExitCode) + } if m.artifact_path != nil { fields = append(fields, buildtask.FieldArtifactPath) } @@ -3254,6 +3329,8 @@ func (m *BuildTaskMutation) Field(name string) (ent.Value, bool) { return m.Error() case buildtask.FieldErrorSize: return m.ErrorSize() + case buildtask.FieldExitCode: + return m.ExitCode() case buildtask.FieldArtifactPath: return m.ArtifactPath() } @@ -3299,6 +3376,8 @@ func (m *BuildTaskMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldError(ctx) case buildtask.FieldErrorSize: return m.OldErrorSize(ctx) + case buildtask.FieldExitCode: + return m.OldExitCode(ctx) case buildtask.FieldArtifactPath: return m.OldArtifactPath(ctx) } @@ -3429,6 +3508,13 @@ func (m *BuildTaskMutation) SetField(name string, value ent.Value) error { } m.SetErrorSize(v) return nil + case buildtask.FieldExitCode: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExitCode(v) + return nil case buildtask.FieldArtifactPath: v, ok := value.(string) if !ok { @@ -3453,6 +3539,9 @@ func (m *BuildTaskMutation) AddedFields() []string { if m.adderror_size != nil { fields = append(fields, buildtask.FieldErrorSize) } + if m.addexit_code != nil { + fields = append(fields, buildtask.FieldExitCode) + } return fields } @@ -3467,6 +3556,8 @@ func (m *BuildTaskMutation) AddedField(name string) (ent.Value, bool) { return m.AddedOutputSize() case buildtask.FieldErrorSize: return m.AddedErrorSize() + case buildtask.FieldExitCode: + return m.AddedExitCode() } return nil, false } @@ -3497,6 +3588,13 @@ func (m *BuildTaskMutation) AddField(name string, value ent.Value) error { } m.AddErrorSize(v) return nil + case buildtask.FieldExitCode: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddExitCode(v) + return nil } return fmt.Errorf("unknown BuildTask numeric field %s", name) } @@ -3523,6 +3621,9 @@ func (m *BuildTaskMutation) ClearedFields() []string { if m.FieldCleared(buildtask.FieldError) { fields = append(fields, buildtask.FieldError) } + if m.FieldCleared(buildtask.FieldExitCode) { + fields = append(fields, buildtask.FieldExitCode) + } if m.FieldCleared(buildtask.FieldArtifactPath) { fields = append(fields, buildtask.FieldArtifactPath) } @@ -3558,6 +3659,9 @@ func (m *BuildTaskMutation) ClearField(name string) error { case buildtask.FieldError: m.ClearError() return nil + case buildtask.FieldExitCode: + m.ClearExitCode() + return nil case buildtask.FieldArtifactPath: m.ClearArtifactPath() return nil @@ -3620,6 +3724,9 @@ func (m *BuildTaskMutation) ResetField(name string) error { case buildtask.FieldErrorSize: m.ResetErrorSize() return nil + case buildtask.FieldExitCode: + m.ResetExitCode() + return nil case buildtask.FieldArtifactPath: m.ResetArtifactPath() return nil @@ -3731,6 +3838,7 @@ type BuilderMutation struct { supported_targets *[]c2pb.Host_Platform appendsupported_targets []c2pb.Host_Platform upstream *string + last_seen_at *time.Time clearedFields map[string]struct{} build_tasks map[int]struct{} removedbuild_tasks map[int]struct{} @@ -4033,6 +4141,55 @@ func (m *BuilderMutation) ResetUpstream() { m.upstream = nil } +// SetLastSeenAt sets the "last_seen_at" field. +func (m *BuilderMutation) SetLastSeenAt(t time.Time) { + m.last_seen_at = &t +} + +// LastSeenAt returns the value of the "last_seen_at" field in the mutation. +func (m *BuilderMutation) LastSeenAt() (r time.Time, exists bool) { + v := m.last_seen_at + if v == nil { + return + } + return *v, true +} + +// OldLastSeenAt returns the old "last_seen_at" field's value of the Builder entity. +// If the Builder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BuilderMutation) OldLastSeenAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastSeenAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastSeenAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastSeenAt: %w", err) + } + return oldValue.LastSeenAt, nil +} + +// ClearLastSeenAt clears the value of the "last_seen_at" field. +func (m *BuilderMutation) ClearLastSeenAt() { + m.last_seen_at = nil + m.clearedFields[builder.FieldLastSeenAt] = struct{}{} +} + +// LastSeenAtCleared returns if the "last_seen_at" field was cleared in this mutation. +func (m *BuilderMutation) LastSeenAtCleared() bool { + _, ok := m.clearedFields[builder.FieldLastSeenAt] + return ok +} + +// ResetLastSeenAt resets all changes to the "last_seen_at" field. +func (m *BuilderMutation) ResetLastSeenAt() { + m.last_seen_at = nil + delete(m.clearedFields, builder.FieldLastSeenAt) +} + // AddBuildTaskIDs adds the "build_tasks" edge to the BuildTask entity by ids. func (m *BuilderMutation) AddBuildTaskIDs(ids ...int) { if m.build_tasks == nil { @@ -4121,7 +4278,7 @@ func (m *BuilderMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BuilderMutation) Fields() []string { - fields := make([]string, 0, 5) + fields := make([]string, 0, 6) if m.created_at != nil { fields = append(fields, builder.FieldCreatedAt) } @@ -4137,6 +4294,9 @@ func (m *BuilderMutation) Fields() []string { if m.upstream != nil { fields = append(fields, builder.FieldUpstream) } + if m.last_seen_at != nil { + fields = append(fields, builder.FieldLastSeenAt) + } return fields } @@ -4155,6 +4315,8 @@ func (m *BuilderMutation) Field(name string) (ent.Value, bool) { return m.SupportedTargets() case builder.FieldUpstream: return m.Upstream() + case builder.FieldLastSeenAt: + return m.LastSeenAt() } return nil, false } @@ -4174,6 +4336,8 @@ func (m *BuilderMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldSupportedTargets(ctx) case builder.FieldUpstream: return m.OldUpstream(ctx) + case builder.FieldLastSeenAt: + return m.OldLastSeenAt(ctx) } return nil, fmt.Errorf("unknown Builder field %s", name) } @@ -4218,6 +4382,13 @@ func (m *BuilderMutation) SetField(name string, value ent.Value) error { } m.SetUpstream(v) return nil + case builder.FieldLastSeenAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastSeenAt(v) + return nil } return fmt.Errorf("unknown Builder field %s", name) } @@ -4247,7 +4418,11 @@ func (m *BuilderMutation) AddField(name string, value ent.Value) error { // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *BuilderMutation) ClearedFields() []string { - return nil + var fields []string + if m.FieldCleared(builder.FieldLastSeenAt) { + fields = append(fields, builder.FieldLastSeenAt) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was @@ -4260,6 +4435,11 @@ func (m *BuilderMutation) FieldCleared(name string) bool { // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. func (m *BuilderMutation) ClearField(name string) error { + switch name { + case builder.FieldLastSeenAt: + m.ClearLastSeenAt() + return nil + } return fmt.Errorf("unknown Builder nullable field %s", name) } @@ -4282,6 +4462,9 @@ func (m *BuilderMutation) ResetField(name string) error { case builder.FieldUpstream: m.ResetUpstream() return nil + case builder.FieldLastSeenAt: + m.ResetLastSeenAt() + return nil } return fmt.Errorf("unknown Builder field %s", name) } diff --git a/tavern/internal/ent/schema/build_task.go b/tavern/internal/ent/schema/build_task.go index bbb948690..476024e74 100644 --- a/tavern/internal/ent/schema/build_task.go +++ b/tavern/internal/ent/schema/build_task.go @@ -108,6 +108,13 @@ func (BuildTask) Fields() []ent.Field { entgql.OrderField("ERROR_SIZE"), ). Comment("The size of the error in bytes"), + field.Int("exit_code"). + Optional(). + Nillable(). + Annotations( + entgql.OrderField("EXIT_CODE"), + ). + Comment("Exit code from the build container process. Null if the build has not finished."), field.String("artifact_path"). Optional(). Annotations( diff --git a/tavern/internal/ent/schema/builder.go b/tavern/internal/ent/schema/builder.go index 497a704bc..8a495fe59 100644 --- a/tavern/internal/ent/schema/builder.go +++ b/tavern/internal/ent/schema/builder.go @@ -36,6 +36,14 @@ func (Builder) Fields() []ent.Field { Comment("The platforms this builder can build agents for."), field.String("upstream"). Comment("The server address that the builder should connect to."), + field.Time("last_seen_at"). + Optional(). + Nillable(). + Annotations( + entgql.OrderField("LAST_SEEN_AT"), + entgql.Skip(entgql.SkipMutationCreateInput), + ). + Comment("Timestamp of the builder's last ClaimBuildTasks call. Null if never seen."), } } diff --git a/tavern/internal/graphql/build_task_test.go b/tavern/internal/graphql/build_task_test.go index 39ac1dd54..d98d5acce 100644 --- a/tavern/internal/graphql/build_task_test.go +++ b/tavern/internal/graphql/build_task_test.go @@ -150,27 +150,31 @@ func TestCreateBuildTask(t *testing.T) { var resp struct { CreateBuildTask struct { ID string + TargetFormat string + BuildImage string CallbackURI string Interval int TransportType string ArtifactPath string } } - // Only specify required fields; callbackURI, transportType, and artifactPath should get defaults. + // Only specify targetOS; all other fields should get defaults. err := gqlClient.Post(`mutation createBuildTask($input: CreateBuildTaskInput!) { createBuildTask(input: $input) { id + targetFormat + buildImage callbackURI interval transportType artifactPath } }`, &resp, client.Var("input", map[string]any{ - "targetOS": "PLATFORM_LINUX", - "targetFormat": "BIN", - "buildImage": "golang:1.21", + "targetOS": "PLATFORM_LINUX", })) require.NoError(t, err) + assert.Equal(t, "BIN", resp.CreateBuildTask.TargetFormat) + assert.Equal(t, "spellshift/devcontainer:main", resp.CreateBuildTask.BuildImage) assert.Equal(t, "http://127.0.0.1:8000", resp.CreateBuildTask.CallbackURI) assert.Equal(t, 5, resp.CreateBuildTask.Interval) assert.Equal(t, "TRANSPORT_GRPC", resp.CreateBuildTask.TransportType) diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index 1d24236d4..e95a1f73e 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -38,6 +38,7 @@ type QueryResolver interface { Portals(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.PortalOrder, where *ent.PortalWhereInput) (*ent.PortalConnection, error) Shells(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.ShellOrder, where *ent.ShellWhereInput) (*ent.ShellConnection, error) BuildTasks(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BuildTaskOrder, where *ent.BuildTaskWhereInput) (*ent.BuildTaskConnection, error) + Builders(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BuilderOrder, where *ent.BuilderWhereInput) (*ent.BuilderConnection, error) Me(ctx context.Context) (*ent.User, error) } @@ -560,6 +561,42 @@ func (ec *executionContext) field_Query_buildTasks_args(ctx context.Context, raw return args, nil } +func (ec *executionContext) field_Query_builders_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor) + if err != nil { + return nil, err + } + args["after"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) + if err != nil { + return nil, err + } + args["first"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "before", ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor) + if err != nil { + return nil, err + } + args["before"] = arg2 + arg3, err := graphql.ProcessArgField(ctx, rawArgs, "last", ec.unmarshalOInt2ᚖint) + if err != nil { + return nil, err + } + args["last"] = arg3 + arg4, err := graphql.ProcessArgField(ctx, rawArgs, "orderBy", ec.unmarshalOBuilderOrder2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderOrderᚄ) + if err != nil { + return nil, err + } + args["orderBy"] = arg4 + arg5, err := graphql.ProcessArgField(ctx, rawArgs, "where", ec.unmarshalOBuilderWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInput) + if err != nil { + return nil, err + } + args["where"] = arg5 + return args, nil +} + func (ec *executionContext) field_Query_hosts_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -3035,6 +3072,35 @@ func (ec *executionContext) fieldContext_BuildTask_errorSize(_ context.Context, return fc, nil } +func (ec *executionContext) _BuildTask_exitCode(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_BuildTask_exitCode, + func(ctx context.Context) (any, error) { + return obj.ExitCode, nil + }, + nil, + ec.marshalOInt2ᚖint, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_BuildTask_exitCode(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuildTask", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _BuildTask_artifactPath(ctx context.Context, field graphql.CollectedField, obj *ent.BuildTask) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -3100,6 +3166,8 @@ func (ec *executionContext) fieldContext_BuildTask_builder(_ context.Context, fi return ec.fieldContext_Builder_supportedTargets(ctx, field) case "upstream": return ec.fieldContext_Builder_upstream(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Builder_lastSeenAt(ctx, field) case "buildTasks": return ec.fieldContext_Builder_buildTasks(ctx, field) } @@ -3321,6 +3389,8 @@ func (ec *executionContext) fieldContext_BuildTaskEdge_node(_ context.Context, f return ec.fieldContext_BuildTask_error(ctx, field) case "errorSize": return ec.fieldContext_BuildTask_errorSize(ctx, field) + case "exitCode": + return ec.fieldContext_BuildTask_exitCode(ctx, field) case "artifactPath": return ec.fieldContext_BuildTask_artifactPath(ctx, field) case "builder": @@ -3537,6 +3607,35 @@ func (ec *executionContext) fieldContext_Builder_upstream(_ context.Context, fie return fc, nil } +func (ec *executionContext) _Builder_lastSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Builder_lastSeenAt, + func(ctx context.Context) (any, error) { + return obj.LastSeenAt, nil + }, + nil, + ec.marshalOTime2ᚖtimeᚐTime, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Builder_lastSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Builder", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Builder_buildTasks(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -3725,6 +3824,8 @@ func (ec *executionContext) fieldContext_BuilderEdge_node(_ context.Context, fie return ec.fieldContext_Builder_supportedTargets(ctx, field) case "upstream": return ec.fieldContext_Builder_upstream(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Builder_lastSeenAt(ctx, field) case "buildTasks": return ec.fieldContext_Builder_buildTasks(ctx, field) } @@ -8184,6 +8285,73 @@ func (ec *executionContext) fieldContext_Query_buildTasks(ctx context.Context, f return fc, nil } +func (ec *executionContext) _Query_builders(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query_builders, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Builders(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BuilderOrder), fc.Args["where"].(*ent.BuilderWhereInput)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "ADMIN") + if err != nil { + var zeroVal *ent.BuilderConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.BuilderConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNBuilderConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Query_builders(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_BuilderConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_BuilderConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_BuilderConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BuilderConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_builders_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -13637,7 +13805,7 @@ func (ec *executionContext) unmarshalInputBuildTaskWhereInput(ctx context.Contex asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "targetOs", "targetOsNEQ", "targetOsIn", "targetOsNotIn", "targetFormat", "targetFormatNEQ", "targetFormatIn", "targetFormatNotIn", "buildImage", "buildImageNEQ", "buildImageIn", "buildImageNotIn", "buildImageGT", "buildImageGTE", "buildImageLT", "buildImageLTE", "buildImageContains", "buildImageHasPrefix", "buildImageHasSuffix", "buildImageEqualFold", "buildImageContainsFold", "buildScript", "buildScriptNEQ", "buildScriptIn", "buildScriptNotIn", "buildScriptGT", "buildScriptGTE", "buildScriptLT", "buildScriptLTE", "buildScriptContains", "buildScriptHasPrefix", "buildScriptHasSuffix", "buildScriptEqualFold", "buildScriptContainsFold", "callbackURI", "callbackURINEQ", "callbackURIIn", "callbackURINotIn", "callbackURIGT", "callbackURIGTE", "callbackURILT", "callbackURILTE", "callbackURIContains", "callbackURIHasPrefix", "callbackURIHasSuffix", "callbackURIEqualFold", "callbackURIContainsFold", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "transportType", "transportTypeNEQ", "transportTypeIn", "transportTypeNotIn", "extra", "extraNEQ", "extraIn", "extraNotIn", "extraGT", "extraGTE", "extraLT", "extraLTE", "extraContains", "extraHasPrefix", "extraHasSuffix", "extraIsNil", "extraNotNil", "extraEqualFold", "extraContainsFold", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "startedAt", "startedAtNEQ", "startedAtIn", "startedAtNotIn", "startedAtGT", "startedAtGTE", "startedAtLT", "startedAtLTE", "startedAtIsNil", "startedAtNotNil", "finishedAt", "finishedAtNEQ", "finishedAtIn", "finishedAtNotIn", "finishedAtGT", "finishedAtGTE", "finishedAtLT", "finishedAtLTE", "finishedAtIsNil", "finishedAtNotNil", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "outputSize", "outputSizeNEQ", "outputSizeIn", "outputSizeNotIn", "outputSizeGT", "outputSizeGTE", "outputSizeLT", "outputSizeLTE", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "errorSize", "errorSizeNEQ", "errorSizeIn", "errorSizeNotIn", "errorSizeGT", "errorSizeGTE", "errorSizeLT", "errorSizeLTE", "artifactPath", "artifactPathNEQ", "artifactPathIn", "artifactPathNotIn", "artifactPathGT", "artifactPathGTE", "artifactPathLT", "artifactPathLTE", "artifactPathContains", "artifactPathHasPrefix", "artifactPathHasSuffix", "artifactPathIsNil", "artifactPathNotNil", "artifactPathEqualFold", "artifactPathContainsFold", "hasBuilder", "hasBuilderWith", "hasArtifact", "hasArtifactWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "targetOs", "targetOsNEQ", "targetOsIn", "targetOsNotIn", "targetFormat", "targetFormatNEQ", "targetFormatIn", "targetFormatNotIn", "buildImage", "buildImageNEQ", "buildImageIn", "buildImageNotIn", "buildImageGT", "buildImageGTE", "buildImageLT", "buildImageLTE", "buildImageContains", "buildImageHasPrefix", "buildImageHasSuffix", "buildImageEqualFold", "buildImageContainsFold", "buildScript", "buildScriptNEQ", "buildScriptIn", "buildScriptNotIn", "buildScriptGT", "buildScriptGTE", "buildScriptLT", "buildScriptLTE", "buildScriptContains", "buildScriptHasPrefix", "buildScriptHasSuffix", "buildScriptEqualFold", "buildScriptContainsFold", "callbackURI", "callbackURINEQ", "callbackURIIn", "callbackURINotIn", "callbackURIGT", "callbackURIGTE", "callbackURILT", "callbackURILTE", "callbackURIContains", "callbackURIHasPrefix", "callbackURIHasSuffix", "callbackURIEqualFold", "callbackURIContainsFold", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "transportType", "transportTypeNEQ", "transportTypeIn", "transportTypeNotIn", "extra", "extraNEQ", "extraIn", "extraNotIn", "extraGT", "extraGTE", "extraLT", "extraLTE", "extraContains", "extraHasPrefix", "extraHasSuffix", "extraIsNil", "extraNotNil", "extraEqualFold", "extraContainsFold", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "startedAt", "startedAtNEQ", "startedAtIn", "startedAtNotIn", "startedAtGT", "startedAtGTE", "startedAtLT", "startedAtLTE", "startedAtIsNil", "startedAtNotNil", "finishedAt", "finishedAtNEQ", "finishedAtIn", "finishedAtNotIn", "finishedAtGT", "finishedAtGTE", "finishedAtLT", "finishedAtLTE", "finishedAtIsNil", "finishedAtNotNil", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "outputSize", "outputSizeNEQ", "outputSizeIn", "outputSizeNotIn", "outputSizeGT", "outputSizeGTE", "outputSizeLT", "outputSizeLTE", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "errorSize", "errorSizeNEQ", "errorSizeIn", "errorSizeNotIn", "errorSizeGT", "errorSizeGTE", "errorSizeLT", "errorSizeLTE", "exitCode", "exitCodeNEQ", "exitCodeIn", "exitCodeNotIn", "exitCodeGT", "exitCodeGTE", "exitCodeLT", "exitCodeLTE", "exitCodeIsNil", "exitCodeNotNil", "artifactPath", "artifactPathNEQ", "artifactPathIn", "artifactPathNotIn", "artifactPathGT", "artifactPathGTE", "artifactPathLT", "artifactPathLTE", "artifactPathContains", "artifactPathHasPrefix", "artifactPathHasSuffix", "artifactPathIsNil", "artifactPathNotNil", "artifactPathEqualFold", "artifactPathContainsFold", "hasBuilder", "hasBuilderWith", "hasArtifact", "hasArtifactWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -14883,6 +15051,76 @@ func (ec *executionContext) unmarshalInputBuildTaskWhereInput(ctx context.Contex return it, err } it.ErrorSizeLTE = data + case "exitCode": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("exitCode")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ExitCode = data + case "exitCodeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("exitCodeNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ExitCodeNEQ = data + case "exitCodeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("exitCodeIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.ExitCodeIn = data + case "exitCodeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("exitCodeNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.ExitCodeNotIn = data + case "exitCodeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("exitCodeGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ExitCodeGT = data + case "exitCodeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("exitCodeGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ExitCodeGTE = data + case "exitCodeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("exitCodeLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ExitCodeLT = data + case "exitCodeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("exitCodeLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ExitCodeLTE = data + case "exitCodeIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("exitCodeIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ExitCodeIsNil = data + case "exitCodeNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("exitCodeNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ExitCodeNotNil = data case "artifactPath": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactPath")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) @@ -15067,7 +15305,7 @@ func (ec *executionContext) unmarshalInputBuilderWhereInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "upstream", "upstreamNEQ", "upstreamIn", "upstreamNotIn", "upstreamGT", "upstreamGTE", "upstreamLT", "upstreamLTE", "upstreamContains", "upstreamHasPrefix", "upstreamHasSuffix", "upstreamEqualFold", "upstreamContainsFold", "hasBuildTasks", "hasBuildTasksWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "upstream", "upstreamNEQ", "upstreamIn", "upstreamNotIn", "upstreamGT", "upstreamGTE", "upstreamLT", "upstreamLTE", "upstreamContains", "upstreamHasPrefix", "upstreamHasSuffix", "upstreamEqualFold", "upstreamContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "hasBuildTasks", "hasBuildTasksWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -15445,6 +15683,76 @@ func (ec *executionContext) unmarshalInputBuilderWhereInput(ctx context.Context, return it, err } it.UpstreamContainsFold = data + case "lastSeenAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAt = data + case "lastSeenAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtNEQ = data + case "lastSeenAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtIn = data + case "lastSeenAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtNotIn = data + case "lastSeenAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtGT = data + case "lastSeenAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtGTE = data + case "lastSeenAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtLT = data + case "lastSeenAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtLTE = data + case "lastSeenAtIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtIsNil = data + case "lastSeenAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtNotNil = data case "hasBuildTasks": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBuildTasks")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) @@ -25250,6 +25558,8 @@ func (ec *executionContext) _BuildTask(ctx context.Context, sel ast.SelectionSet if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "exitCode": + out.Values[i] = ec._BuildTask_exitCode(ctx, field, obj) case "artifactPath": out.Values[i] = ec._BuildTask_artifactPath(ctx, field, obj) case "builder": @@ -25472,6 +25782,8 @@ func (ec *executionContext) _Builder(ctx context.Context, sel ast.SelectionSet, if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "lastSeenAt": + out.Values[i] = ec._Builder_lastSeenAt(ctx, field, obj) case "buildTasks": field := field @@ -27516,6 +27828,28 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "builders": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_builders(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "me": field := field @@ -29624,6 +29958,25 @@ func (ec *executionContext) marshalNBuilder2ᚖrealmᚗpubᚋtavernᚋinternal return ec._Builder(ctx, sel, v) } +func (ec *executionContext) marshalNBuilderConnection2realmᚗpubᚋtavernᚋinternalᚋentᚐBuilderConnection(ctx context.Context, sel ast.SelectionSet, v ent.BuilderConnection) graphql.Marshaler { + return ec._BuilderConnection(ctx, sel, &v) +} + +func (ec *executionContext) marshalNBuilderConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderConnection(ctx context.Context, sel ast.SelectionSet, v *ent.BuilderConnection) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._BuilderConnection(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNBuilderOrder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderOrder(ctx context.Context, v any) (*ent.BuilderOrder, error) { + res, err := ec.unmarshalInputBuilderOrder(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNBuilderOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderOrderField(ctx context.Context, v any) (*ent.BuilderOrderField, error) { var res = new(ent.BuilderOrderField) err := res.UnmarshalGQL(v) @@ -31027,6 +31380,24 @@ func (ec *executionContext) marshalOBuilderEdge2ᚖrealmᚗpubᚋtavernᚋintern return ec._BuilderEdge(ctx, sel, v) } +func (ec *executionContext) unmarshalOBuilderOrder2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderOrderᚄ(ctx context.Context, v any) ([]*ent.BuilderOrder, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]*ent.BuilderOrder, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNBuilderOrder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderOrder(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + func (ec *executionContext) unmarshalOBuilderWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInputᚄ(ctx context.Context, v any) ([]*ent.BuilderWhereInput, error) { if v == nil { return nil, nil diff --git a/tavern/internal/graphql/generated/inputs.generated.go b/tavern/internal/graphql/generated/inputs.generated.go index 066ffb11b..917159715 100644 --- a/tavern/internal/graphql/generated/inputs.generated.go +++ b/tavern/internal/graphql/generated/inputs.generated.go @@ -64,6 +64,8 @@ func (ec *executionContext) fieldContext_RegisterBuilderOutput_builder(_ context return ec.fieldContext_Builder_supportedTargets(ctx, field) case "upstream": return ec.fieldContext_Builder_upstream(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Builder_lastSeenAt(ctx, field) case "buildTasks": return ec.fieldContext_Builder_buildTasks(ctx, field) } @@ -231,14 +233,14 @@ func (ec *executionContext) unmarshalInputCreateBuildTaskInput(ctx context.Conte it.TargetOs = data case "targetFormat": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetFormat")) - data, err := ec.unmarshalNBuildTaskTargetFormat2realmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat(ctx, v) + data, err := ec.unmarshalOBuildTaskTargetFormat2ᚖrealmᚗpubᚋtavernᚋinternalᚋbuilderᚋbuilderpbᚐTargetFormat(ctx, v) if err != nil { return it, err } it.TargetFormat = data case "buildImage": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("buildImage")) - data, err := ec.unmarshalNString2string(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index d10e9bcea..0bc3be874 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -35,6 +35,7 @@ type MutationResolver interface { UpdateLink(ctx context.Context, linkID int, input ent.UpdateLinkInput) (*ent.Link, error) DisableLink(ctx context.Context, linkID int) (*ent.Link, error) RegisterBuilder(ctx context.Context, input ent.CreateBuilderInput) (*models.RegisterBuilderOutput, error) + DeleteBuilder(ctx context.Context, builderID int) (int, error) CreateBuildTask(ctx context.Context, input models.CreateBuildTaskInput) (*ent.BuildTask, error) } @@ -124,6 +125,17 @@ func (ec *executionContext) field_Mutation_createTome_args(ctx context.Context, return args, nil } +func (ec *executionContext) field_Mutation_deleteBuilder_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "builderID", ec.unmarshalNID2int) + if err != nil { + return nil, err + } + args["builderID"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation_deleteTome_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -1584,6 +1596,65 @@ func (ec *executionContext) fieldContext_Mutation_registerBuilder(ctx context.Co return fc, nil } +func (ec *executionContext) _Mutation_deleteBuilder(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Mutation_deleteBuilder, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Mutation().DeleteBuilder(ctx, fc.Args["builderID"].(int)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "ADMIN") + if err != nil { + var zeroVal int + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal int + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNID2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Mutation_deleteBuilder(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_deleteBuilder_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Mutation_createBuildTask(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -1663,6 +1734,8 @@ func (ec *executionContext) fieldContext_Mutation_createBuildTask(ctx context.Co return ec.fieldContext_BuildTask_error(ctx, field) case "errorSize": return ec.fieldContext_BuildTask_errorSize(ctx, field) + case "exitCode": + return ec.fieldContext_BuildTask_exitCode(ctx, field) case "artifactPath": return ec.fieldContext_BuildTask_artifactPath(ctx, field) case "builder": @@ -1831,6 +1904,13 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "deleteBuilder": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteBuilder(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "createBuildTask": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createBuildTask(ctx, field) diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 54f034f52..6c987303c 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -106,6 +106,7 @@ type ComplexityRoot struct { CreatedAt func(childComplexity int) int Error func(childComplexity int) int ErrorSize func(childComplexity int) int + ExitCode func(childComplexity int) int Extra func(childComplexity int) int FinishedAt func(childComplexity int) int ID func(childComplexity int) int @@ -136,6 +137,7 @@ type ComplexityRoot struct { ID func(childComplexity int) int Identifier func(childComplexity int) int LastModifiedAt func(childComplexity int) int + LastSeenAt func(childComplexity int) int SupportedTargets func(childComplexity int) int Upstream func(childComplexity int) int } @@ -286,6 +288,7 @@ type ComplexityRoot struct { CreateRepository func(childComplexity int, input ent.CreateRepositoryInput) int CreateTag func(childComplexity int, input ent.CreateTagInput) int CreateTome func(childComplexity int, input ent.CreateTomeInput) int + DeleteBuilder func(childComplexity int, builderID int) int DeleteTome func(childComplexity int, tomeID int) int DisableLink func(childComplexity int, linkID int) int DropAllData func(childComplexity int) int @@ -332,6 +335,7 @@ type ComplexityRoot struct { Assets func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.AssetOrder, where *ent.AssetWhereInput) int Beacons func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BeaconOrder, where *ent.BeaconWhereInput) int BuildTasks func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BuildTaskOrder, where *ent.BuildTaskWhereInput) int + Builders func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BuilderOrder, where *ent.BuilderWhereInput) int Hosts func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.HostOrder, where *ent.HostWhereInput) int Me func(childComplexity int) int Node func(childComplexity int, id int) int @@ -861,6 +865,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.BuildTask.ErrorSize(childComplexity), true + case "BuildTask.exitCode": + if e.complexity.BuildTask.ExitCode == nil { + break + } + + return e.complexity.BuildTask.ExitCode(childComplexity), true + case "BuildTask.extra": if e.complexity.BuildTask.Extra == nil { break @@ -1013,6 +1024,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Builder.LastModifiedAt(childComplexity), true + case "Builder.lastSeenAt": + if e.complexity.Builder.LastSeenAt == nil { + break + } + + return e.complexity.Builder.LastSeenAt(childComplexity), true + case "Builder.supportedTargets": if e.complexity.Builder.SupportedTargets == nil { break @@ -1745,6 +1763,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Mutation.CreateTome(childComplexity, args["input"].(ent.CreateTomeInput)), true + case "Mutation.deleteBuilder": + if e.complexity.Mutation.DeleteBuilder == nil { + break + } + + args, err := ec.field_Mutation_deleteBuilder_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteBuilder(childComplexity, args["builderID"].(int)), true + case "Mutation.deleteTome": if e.complexity.Mutation.DeleteTome == nil { break @@ -2032,6 +2062,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Query.BuildTasks(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].([]*ent.BuildTaskOrder), args["where"].(*ent.BuildTaskWhereInput)), true + case "Query.builders": + if e.complexity.Query.Builders == nil { + break + } + + args, err := ec.field_Query_builders_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Builders(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].([]*ent.BuilderOrder), args["where"].(*ent.BuilderWhereInput)), true + case "Query.hosts": if e.complexity.Query.Hosts == nil { break @@ -3805,6 +3847,10 @@ type BuildTask implements Node { """ errorSize: Int! """ + Exit code from the build container process. Null if the build has not finished. + """ + exitCode: Int + """ Path inside the container where the build artifact is located. Derived from target_os if not set. """ artifactPath: String @@ -3872,6 +3918,7 @@ enum BuildTaskOrderField { FINISHED_AT OUTPUT_SIZE ERROR_SIZE + EXIT_CODE } """ BuildTaskTargetFormat is enum for the field target_format @@ -4118,6 +4165,19 @@ input BuildTaskWhereInput { errorSizeLT: Int errorSizeLTE: Int """ + exit_code field predicates + """ + exitCode: Int + exitCodeNEQ: Int + exitCodeIn: [Int!] + exitCodeNotIn: [Int!] + exitCodeGT: Int + exitCodeGTE: Int + exitCodeLT: Int + exitCodeLTE: Int + exitCodeIsNil: Boolean + exitCodeNotNil: Boolean + """ artifact_path field predicates """ artifactPath: String @@ -4168,6 +4228,10 @@ type Builder implements Node { The server address that the builder should connect to. """ upstream: String! + """ + Timestamp of the builder's last ClaimBuildTasks call. Null if never seen. + """ + lastSeenAt: Time buildTasks( """ Returns the elements in the list that come after the specified cursor. @@ -4249,6 +4313,7 @@ Properties by which Builder connections can be ordered. enum BuilderOrderField { CREATED_AT LAST_MODIFIED_AT + LAST_SEEN_AT } """ BuilderWhereInput is used for filtering Builder objects. @@ -4324,6 +4389,19 @@ input BuilderWhereInput { upstreamEqualFold: String upstreamContainsFold: String """ + last_seen_at field predicates + """ + lastSeenAt: Time + lastSeenAtNEQ: Time + lastSeenAtIn: [Time!] + lastSeenAtNotIn: [Time!] + lastSeenAtGT: Time + lastSeenAtGTE: Time + lastSeenAtLT: Time + lastSeenAtLTE: Time + lastSeenAtIsNil: Boolean + lastSeenAtNotNil: Boolean + """ build_tasks edge predicates """ hasBuildTasks: Boolean @@ -8240,6 +8318,25 @@ scalar Uint64 """Filtering options for BuildTasks returned from the connection.""" where: BuildTaskWhereInput ): BuildTaskConnection! @requireRole(role: USER) + builders( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for Builders returned from the connection.""" + orderBy: [BuilderOrder!] + + """Filtering options for Builders returned from the connection.""" + where: BuilderWhereInput + ): BuilderConnection! @requireRole(role: ADMIN) me: User! } `, BuiltIn: false}, @@ -8304,6 +8401,7 @@ scalar Uint64 # Builder ### registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) + deleteBuilder(builderID: ID!): ID! @requireRole(role: ADMIN) ### # BuildTask @@ -8366,11 +8464,11 @@ input CreateBuildTaskInput { """The target operating system for the build.""" targetOS: HostPlatform! - """The output format for the build.""" - targetFormat: BuildTaskTargetFormat! + """The output format for the build. Defaults to BIN.""" + targetFormat: BuildTaskTargetFormat - """Docker container image name to use for the build.""" - buildImage: String! + """Docker container image name to use for the build. Defaults to spellshift/devcontainer:main.""" + buildImage: String """The callback URI for the IMIX agent to connect to. Defaults to http://127.0.0.1:8000.""" callbackURI: String diff --git a/tavern/internal/graphql/models/gqlgen_models.go b/tavern/internal/graphql/models/gqlgen_models.go index 66515a36a..cbadd0298 100644 --- a/tavern/internal/graphql/models/gqlgen_models.go +++ b/tavern/internal/graphql/models/gqlgen_models.go @@ -35,10 +35,10 @@ type ClaimTasksInput struct { type CreateBuildTaskInput struct { // The target operating system for the build. TargetOs c2pb.Host_Platform `json:"targetOS"` - // The output format for the build. - TargetFormat builderpb.TargetFormat `json:"targetFormat"` - // Docker container image name to use for the build. - BuildImage string `json:"buildImage"` + // The output format for the build. Defaults to BIN. + TargetFormat *builderpb.TargetFormat `json:"targetFormat,omitempty"` + // Docker container image name to use for the build. Defaults to spellshift/devcontainer:main. + BuildImage *string `json:"buildImage,omitempty"` // The callback URI for the IMIX agent to connect to. Defaults to http://127.0.0.1:8000. CallbackURI *string `json:"callbackURI,omitempty"` // The callback interval in seconds for the IMIX agent. diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index 09a8c586f..6e17e4463 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -339,14 +339,27 @@ func (r *mutationResolver) RegisterBuilder(ctx context.Context, input ent.Create }, nil } +// DeleteBuilder is the resolver for the deleteBuilder field. +func (r *mutationResolver) DeleteBuilder(ctx context.Context, builderID int) (int, error) { + if err := r.client.Builder.DeleteOneID(builderID).Exec(ctx); err != nil { + return 0, err + } + return builderID, nil +} + // CreateBuildTask is the resolver for the createBuildTask field. func (r *mutationResolver) CreateBuildTask(ctx context.Context, input models.CreateBuildTaskInput) (*ent.BuildTask, error) { - // 1. Validate target format for the given OS - if err := builder.ValidateTargetFormat(input.TargetOs, input.TargetFormat); err != nil { - return nil, err + // 1. Resolve defaults for optional fields + targetFormat := builder.DefaultTargetFormat + if input.TargetFormat != nil { + targetFormat = *input.TargetFormat + } + + buildImage := builder.DefaultBuildImage + if input.BuildImage != nil { + buildImage = *input.BuildImage } - // 2. Resolve defaults for optional fields interval := builder.DefaultInterval if input.Interval != nil { interval = *input.Interval @@ -367,8 +380,13 @@ func (r *mutationResolver) CreateBuildTask(ctx context.Context, input models.Cre artifactPath = *input.ArtifactPath } + // 2. Validate target format for the given OS + if err := builder.ValidateTargetFormat(input.TargetOs, targetFormat); err != nil { + return nil, err + } + // 3. Derive the build script from configuration - buildScript, err := builder.GenerateBuildScript(input.TargetOs, input.TargetFormat) + buildScript, err := builder.GenerateBuildScript(input.TargetOs, targetFormat) if err != nil { return nil, fmt.Errorf("failed to generate build script: %w", err) } @@ -400,8 +418,8 @@ func (r *mutationResolver) CreateBuildTask(ctx context.Context, input models.Cre // 7. Create the build task create := r.client.BuildTask.Create(). SetTargetOs(input.TargetOs). - SetTargetFormat(input.TargetFormat). - SetBuildImage(input.BuildImage). + SetTargetFormat(targetFormat). + SetBuildImage(buildImage). SetBuildScript(buildScript). SetCallbackURI(callbackURI). SetInterval(interval). diff --git a/tavern/internal/graphql/query.resolvers.go b/tavern/internal/graphql/query.resolvers.go index c2498e9af..b14f1724e 100644 --- a/tavern/internal/graphql/query.resolvers.go +++ b/tavern/internal/graphql/query.resolvers.go @@ -206,6 +206,22 @@ func (r *queryResolver) BuildTasks(ctx context.Context, after *entgql.Cursor[int return query.Paginate(ctx, after, first, before, last, ent.WithBuildTaskOrder(orderBy)) } +// Builders is the resolver for the builders field. +func (r *queryResolver) Builders(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BuilderOrder, where *ent.BuilderWhereInput) (*ent.BuilderConnection, error) { + query, err := r.client.Builder.Query().CollectFields(ctx) + if err != nil { + return nil, fmt.Errorf("failed to collect fields: %w", err) + } + if where != nil { + query, err := where.Filter(query) + if err != nil { + return nil, fmt.Errorf("failed to apply filter: %w", err) + } + return query.Paginate(ctx, after, first, before, last, ent.WithBuilderOrder(orderBy)) + } + return query.Paginate(ctx, after, first, before, last, ent.WithBuilderOrder(orderBy)) +} + // Me is the resolver for the me field. func (r *queryResolver) Me(ctx context.Context) (*ent.User, error) { if authUser := auth.UserFromContext(ctx); authUser != nil { diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index 377b16557..7b519a0fb 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -659,6 +659,10 @@ type BuildTask implements Node { """ errorSize: Int! """ + Exit code from the build container process. Null if the build has not finished. + """ + exitCode: Int + """ Path inside the container where the build artifact is located. Derived from target_os if not set. """ artifactPath: String @@ -726,6 +730,7 @@ enum BuildTaskOrderField { FINISHED_AT OUTPUT_SIZE ERROR_SIZE + EXIT_CODE } """ BuildTaskTargetFormat is enum for the field target_format @@ -972,6 +977,19 @@ input BuildTaskWhereInput { errorSizeLT: Int errorSizeLTE: Int """ + exit_code field predicates + """ + exitCode: Int + exitCodeNEQ: Int + exitCodeIn: [Int!] + exitCodeNotIn: [Int!] + exitCodeGT: Int + exitCodeGTE: Int + exitCodeLT: Int + exitCodeLTE: Int + exitCodeIsNil: Boolean + exitCodeNotNil: Boolean + """ artifact_path field predicates """ artifactPath: String @@ -1022,6 +1040,10 @@ type Builder implements Node { The server address that the builder should connect to. """ upstream: String! + """ + Timestamp of the builder's last ClaimBuildTasks call. Null if never seen. + """ + lastSeenAt: Time buildTasks( """ Returns the elements in the list that come after the specified cursor. @@ -1103,6 +1125,7 @@ Properties by which Builder connections can be ordered. enum BuilderOrderField { CREATED_AT LAST_MODIFIED_AT + LAST_SEEN_AT } """ BuilderWhereInput is used for filtering Builder objects. @@ -1178,6 +1201,19 @@ input BuilderWhereInput { upstreamEqualFold: String upstreamContainsFold: String """ + last_seen_at field predicates + """ + lastSeenAt: Time + lastSeenAtNEQ: Time + lastSeenAtIn: [Time!] + lastSeenAtNotIn: [Time!] + lastSeenAtGT: Time + lastSeenAtGTE: Time + lastSeenAtLT: Time + lastSeenAtLTE: Time + lastSeenAtIsNil: Boolean + lastSeenAtNotNil: Boolean + """ build_tasks edge predicates """ hasBuildTasks: Boolean @@ -4916,11 +4952,11 @@ input CreateBuildTaskInput { """The target operating system for the build.""" targetOS: HostPlatform! - """The output format for the build.""" - targetFormat: BuildTaskTargetFormat! + """The output format for the build. Defaults to BIN.""" + targetFormat: BuildTaskTargetFormat - """Docker container image name to use for the build.""" - buildImage: String! + """Docker container image name to use for the build. Defaults to spellshift/devcontainer:main.""" + buildImage: String """The callback URI for the IMIX agent to connect to. Defaults to http://127.0.0.1:8000.""" callbackURI: String @@ -5010,6 +5046,7 @@ type Mutation { # Builder ### registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) + deleteBuilder(builderID: ID!): ID! @requireRole(role: ADMIN) ### # BuildTask @@ -5245,6 +5282,25 @@ extend type Query { """Filtering options for BuildTasks returned from the connection.""" where: BuildTaskWhereInput ): BuildTaskConnection! @requireRole(role: USER) + builders( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for Builders returned from the connection.""" + orderBy: [BuilderOrder!] + + """Filtering options for Builders returned from the connection.""" + where: BuilderWhereInput + ): BuilderConnection! @requireRole(role: ADMIN) me: User! } scalar Time diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index f92beb153..459ab0578 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -654,6 +654,10 @@ type BuildTask implements Node { """ errorSize: Int! """ + Exit code from the build container process. Null if the build has not finished. + """ + exitCode: Int + """ Path inside the container where the build artifact is located. Derived from target_os if not set. """ artifactPath: String @@ -721,6 +725,7 @@ enum BuildTaskOrderField { FINISHED_AT OUTPUT_SIZE ERROR_SIZE + EXIT_CODE } """ BuildTaskTargetFormat is enum for the field target_format @@ -967,6 +972,19 @@ input BuildTaskWhereInput { errorSizeLT: Int errorSizeLTE: Int """ + exit_code field predicates + """ + exitCode: Int + exitCodeNEQ: Int + exitCodeIn: [Int!] + exitCodeNotIn: [Int!] + exitCodeGT: Int + exitCodeGTE: Int + exitCodeLT: Int + exitCodeLTE: Int + exitCodeIsNil: Boolean + exitCodeNotNil: Boolean + """ artifact_path field predicates """ artifactPath: String @@ -1017,6 +1035,10 @@ type Builder implements Node { The server address that the builder should connect to. """ upstream: String! + """ + Timestamp of the builder's last ClaimBuildTasks call. Null if never seen. + """ + lastSeenAt: Time buildTasks( """ Returns the elements in the list that come after the specified cursor. @@ -1098,6 +1120,7 @@ Properties by which Builder connections can be ordered. enum BuilderOrderField { CREATED_AT LAST_MODIFIED_AT + LAST_SEEN_AT } """ BuilderWhereInput is used for filtering Builder objects. @@ -1173,6 +1196,19 @@ input BuilderWhereInput { upstreamEqualFold: String upstreamContainsFold: String """ + last_seen_at field predicates + """ + lastSeenAt: Time + lastSeenAtNEQ: Time + lastSeenAtIn: [Time!] + lastSeenAtNotIn: [Time!] + lastSeenAtGT: Time + lastSeenAtGTE: Time + lastSeenAtLT: Time + lastSeenAtLTE: Time + lastSeenAtIsNil: Boolean + lastSeenAtNotNil: Boolean + """ build_tasks edge predicates """ hasBuildTasks: Boolean diff --git a/tavern/internal/graphql/schema/inputs.graphql b/tavern/internal/graphql/schema/inputs.graphql index 382de6a7d..8fa2b987f 100644 --- a/tavern/internal/graphql/schema/inputs.graphql +++ b/tavern/internal/graphql/schema/inputs.graphql @@ -53,11 +53,11 @@ input CreateBuildTaskInput { """The target operating system for the build.""" targetOS: HostPlatform! - """The output format for the build.""" - targetFormat: BuildTaskTargetFormat! + """The output format for the build. Defaults to BIN.""" + targetFormat: BuildTaskTargetFormat - """Docker container image name to use for the build.""" - buildImage: String! + """Docker container image name to use for the build. Defaults to spellshift/devcontainer:main.""" + buildImage: String """The callback URI for the IMIX agent to connect to. Defaults to http://127.0.0.1:8000.""" callbackURI: String diff --git a/tavern/internal/graphql/schema/mutation.graphql b/tavern/internal/graphql/schema/mutation.graphql index f9b0ee09e..08b2851aa 100644 --- a/tavern/internal/graphql/schema/mutation.graphql +++ b/tavern/internal/graphql/schema/mutation.graphql @@ -59,6 +59,7 @@ type Mutation { # Builder ### registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) + deleteBuilder(builderID: ID!): ID! @requireRole(role: ADMIN) ### # BuildTask diff --git a/tavern/internal/graphql/schema/query.graphql b/tavern/internal/graphql/schema/query.graphql index e720a1a2d..baff5adca 100644 --- a/tavern/internal/graphql/schema/query.graphql +++ b/tavern/internal/graphql/schema/query.graphql @@ -227,5 +227,24 @@ extend type Query { """Filtering options for BuildTasks returned from the connection.""" where: BuildTaskWhereInput ): BuildTaskConnection! @requireRole(role: USER) + builders( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for Builders returned from the connection.""" + orderBy: [BuilderOrder!] + + """Filtering options for Builders returned from the connection.""" + where: BuilderWhereInput + ): BuilderConnection! @requireRole(role: ADMIN) me: User! } diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index 377b16557..7b519a0fb 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -659,6 +659,10 @@ type BuildTask implements Node { """ errorSize: Int! """ + Exit code from the build container process. Null if the build has not finished. + """ + exitCode: Int + """ Path inside the container where the build artifact is located. Derived from target_os if not set. """ artifactPath: String @@ -726,6 +730,7 @@ enum BuildTaskOrderField { FINISHED_AT OUTPUT_SIZE ERROR_SIZE + EXIT_CODE } """ BuildTaskTargetFormat is enum for the field target_format @@ -972,6 +977,19 @@ input BuildTaskWhereInput { errorSizeLT: Int errorSizeLTE: Int """ + exit_code field predicates + """ + exitCode: Int + exitCodeNEQ: Int + exitCodeIn: [Int!] + exitCodeNotIn: [Int!] + exitCodeGT: Int + exitCodeGTE: Int + exitCodeLT: Int + exitCodeLTE: Int + exitCodeIsNil: Boolean + exitCodeNotNil: Boolean + """ artifact_path field predicates """ artifactPath: String @@ -1022,6 +1040,10 @@ type Builder implements Node { The server address that the builder should connect to. """ upstream: String! + """ + Timestamp of the builder's last ClaimBuildTasks call. Null if never seen. + """ + lastSeenAt: Time buildTasks( """ Returns the elements in the list that come after the specified cursor. @@ -1103,6 +1125,7 @@ Properties by which Builder connections can be ordered. enum BuilderOrderField { CREATED_AT LAST_MODIFIED_AT + LAST_SEEN_AT } """ BuilderWhereInput is used for filtering Builder objects. @@ -1178,6 +1201,19 @@ input BuilderWhereInput { upstreamEqualFold: String upstreamContainsFold: String """ + last_seen_at field predicates + """ + lastSeenAt: Time + lastSeenAtNEQ: Time + lastSeenAtIn: [Time!] + lastSeenAtNotIn: [Time!] + lastSeenAtGT: Time + lastSeenAtGTE: Time + lastSeenAtLT: Time + lastSeenAtLTE: Time + lastSeenAtIsNil: Boolean + lastSeenAtNotNil: Boolean + """ build_tasks edge predicates """ hasBuildTasks: Boolean @@ -4916,11 +4952,11 @@ input CreateBuildTaskInput { """The target operating system for the build.""" targetOS: HostPlatform! - """The output format for the build.""" - targetFormat: BuildTaskTargetFormat! + """The output format for the build. Defaults to BIN.""" + targetFormat: BuildTaskTargetFormat - """Docker container image name to use for the build.""" - buildImage: String! + """Docker container image name to use for the build. Defaults to spellshift/devcontainer:main.""" + buildImage: String """The callback URI for the IMIX agent to connect to. Defaults to http://127.0.0.1:8000.""" callbackURI: String @@ -5010,6 +5046,7 @@ type Mutation { # Builder ### registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) + deleteBuilder(builderID: ID!): ID! @requireRole(role: ADMIN) ### # BuildTask @@ -5245,6 +5282,25 @@ extend type Query { """Filtering options for BuildTasks returned from the connection.""" where: BuildTaskWhereInput ): BuildTaskConnection! @requireRole(role: USER) + builders( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for Builders returned from the connection.""" + orderBy: [BuilderOrder!] + + """Filtering options for Builders returned from the connection.""" + where: BuilderWhereInput + ): BuilderConnection! @requireRole(role: ADMIN) me: User! } scalar Time From decc997d64adf3b0388cfb3fa65d1792f5749006 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Thu, 12 Feb 2026 01:02:44 +0000 Subject: [PATCH 15/19] Resolve feedback --- tavern/internal/builder/build_config.go | 18 +-- .../internal/builder/builderpb/builder.pb.go | 140 +++++++++++++----- .../builder/builderpb/enum_target_format.go | 64 ++++++++ .../builder/builderpb/target_format.go | 89 ----------- tavern/internal/builder/executor/docker.go | 41 ++--- .../builder/executor_integration_test.go | 12 +- tavern/internal/builder/integration_test.go | 8 +- tavern/internal/builder/proto/builder.proto | 7 + tavern/internal/builder/server.go | 3 +- tavern/internal/ent/buildtask/buildtask.go | 4 +- tavern/internal/ent/migrate/schema.go | 2 +- tavern/internal/ent/schema/build_task.go | 4 +- tavern/internal/graphql/build_task_test.go | 39 ++--- .../graphql/generated/root_.generated.go | 7 +- tavern/internal/graphql/schema.graphql | 7 +- tavern/internal/graphql/schema/ent.graphql | 7 +- tavern/internal/www/schema.graphql | 7 +- 17 files changed, 249 insertions(+), 210 deletions(-) create mode 100644 tavern/internal/builder/builderpb/enum_target_format.go delete mode 100644 tavern/internal/builder/builderpb/target_format.go diff --git a/tavern/internal/builder/build_config.go b/tavern/internal/builder/build_config.go index 9823f0800..18adcdf7c 100644 --- a/tavern/internal/builder/build_config.go +++ b/tavern/internal/builder/build_config.go @@ -13,8 +13,8 @@ const ( // RealmRepoURL is the default git repository URL for building realm agents. RealmRepoURL = "https://github.com/spellshift/realm.git" - // DefaultInterval is re-exported from builderpb for convenience. - DefaultInterval = builderpb.DefaultInterval + // DefaultInterval is the default callback interval in seconds for the IMIX agent. + DefaultInterval = 5 // DefaultCallbackURI is the default callback URI for the IMIX agent, // derived from the IMIX compile-time default (IMIX_CALLBACK_URI). @@ -28,16 +28,16 @@ const ( DefaultBuildImage = "spellshift/devcontainer:main" // DefaultTargetFormat is the default output format for builds. - DefaultTargetFormat = builderpb.TargetFormatBin + DefaultTargetFormat = builderpb.TargetFormat_TARGET_FORMAT_BIN ) // TargetFormat is an alias for builderpb.TargetFormat. type TargetFormat = builderpb.TargetFormat const ( - TargetFormatBin = builderpb.TargetFormatBin - TargetFormatCdylib = builderpb.TargetFormatCdylib - TargetFormatWindowsService = builderpb.TargetFormatWindowsService + TargetFormatBin = builderpb.TargetFormat_TARGET_FORMAT_BIN + TargetFormatCdylib = builderpb.TargetFormat_TARGET_FORMAT_CDYLIB + TargetFormatWindowsService = builderpb.TargetFormat_TARGET_FORMAT_WINDOWS_SERVICE ) // SupportedFormats maps each target OS to its supported output formats. @@ -81,16 +81,16 @@ func ValidateTargetFormat(os c2pb.Host_Platform, format TargetFormat) error { } supported := make([]string, len(formats)) for i, f := range formats { - supported[i] = string(f) + supported[i] = f.String() } - return fmt.Errorf("target format %q is not supported for %s (supported: %s)", format, os.String(), strings.Join(supported, ", ")) + return fmt.Errorf("target format %q is not supported for %s (supported: %s)", format.String(), os.String(), strings.Join(supported, ", ")) } // BuildCommand returns the cargo build command for the given OS and format. func BuildCommand(os c2pb.Host_Platform, format TargetFormat) (string, error) { cmd, ok := buildCommands[buildKey{os, format}] if !ok { - return "", fmt.Errorf("no build command for %s + %s", os.String(), format) + return "", fmt.Errorf("no build command for %s + %s", os.String(), format.String()) } return cmd, nil } diff --git a/tavern/internal/builder/builderpb/builder.pb.go b/tavern/internal/builder/builderpb/builder.pb.go index 321e95bd5..9b043509a 100644 --- a/tavern/internal/builder/builderpb/builder.pb.go +++ b/tavern/internal/builder/builderpb/builder.pb.go @@ -21,6 +21,58 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type TargetFormat int32 + +const ( + TargetFormat_TARGET_FORMAT_UNSPECIFIED TargetFormat = 0 + TargetFormat_TARGET_FORMAT_BIN TargetFormat = 1 + TargetFormat_TARGET_FORMAT_CDYLIB TargetFormat = 2 + TargetFormat_TARGET_FORMAT_WINDOWS_SERVICE TargetFormat = 3 +) + +// Enum value maps for TargetFormat. +var ( + TargetFormat_name = map[int32]string{ + 0: "TARGET_FORMAT_UNSPECIFIED", + 1: "TARGET_FORMAT_BIN", + 2: "TARGET_FORMAT_CDYLIB", + 3: "TARGET_FORMAT_WINDOWS_SERVICE", + } + TargetFormat_value = map[string]int32{ + "TARGET_FORMAT_UNSPECIFIED": 0, + "TARGET_FORMAT_BIN": 1, + "TARGET_FORMAT_CDYLIB": 2, + "TARGET_FORMAT_WINDOWS_SERVICE": 3, + } +) + +func (x TargetFormat) Enum() *TargetFormat { + p := new(TargetFormat) + *p = x + return p +} + +func (x TargetFormat) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (TargetFormat) Descriptor() protoreflect.EnumDescriptor { + return file_builder_proto_enumTypes[0].Descriptor() +} + +func (TargetFormat) Type() protoreflect.EnumType { + return &file_builder_proto_enumTypes[0] +} + +func (x TargetFormat) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use TargetFormat.Descriptor instead. +func (TargetFormat) EnumDescriptor() ([]byte, []int) { + return file_builder_proto_rawDescGZIP(), []int{0} +} + type ClaimBuildTasksRequest struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -446,29 +498,38 @@ var file_builder_proto_rawDesc = string([]byte{ 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x73, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, 0x73, 0x73, 0x65, - 0x74, 0x49, 0x64, 0x32, 0xb3, 0x02, 0x0a, 0x07, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x12, - 0x56, 0x0a, 0x0f, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, - 0x6b, 0x73, 0x12, 0x1f, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x61, - 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x6c, - 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6a, 0x0a, 0x15, 0x53, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, - 0x12, 0x25, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, - 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, - 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x28, 0x01, 0x12, 0x64, 0x0a, 0x13, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, - 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x23, 0x2e, 0x62, 0x75, 0x69, - 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, - 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x24, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, - 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x42, 0x2d, 0x5a, 0x2b, 0x72, 0x65, 0x61, - 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, 0x6e, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2f, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x49, 0x64, 0x2a, 0x81, 0x01, 0x0a, 0x0c, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x46, 0x6f, + 0x72, 0x6d, 0x61, 0x74, 0x12, 0x1d, 0x0a, 0x19, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x46, + 0x4f, 0x52, 0x4d, 0x41, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x46, 0x4f, + 0x52, 0x4d, 0x41, 0x54, 0x5f, 0x42, 0x49, 0x4e, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x54, 0x41, + 0x52, 0x47, 0x45, 0x54, 0x5f, 0x46, 0x4f, 0x52, 0x4d, 0x41, 0x54, 0x5f, 0x43, 0x44, 0x59, 0x4c, + 0x49, 0x42, 0x10, 0x02, 0x12, 0x21, 0x0a, 0x1d, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x46, + 0x4f, 0x52, 0x4d, 0x41, 0x54, 0x5f, 0x57, 0x49, 0x4e, 0x44, 0x4f, 0x57, 0x53, 0x5f, 0x53, 0x45, + 0x52, 0x56, 0x49, 0x43, 0x45, 0x10, 0x03, 0x32, 0xb3, 0x02, 0x0a, 0x07, 0x42, 0x75, 0x69, 0x6c, + 0x64, 0x65, 0x72, 0x12, 0x56, 0x0a, 0x0f, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, + 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x1f, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, + 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, + 0x72, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6a, 0x0a, 0x15, 0x53, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, + 0x74, 0x70, 0x75, 0x74, 0x12, 0x25, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x53, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, + 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x62, 0x75, + 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x75, 0x69, 0x6c, + 0x64, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x64, 0x0a, 0x13, 0x55, 0x70, 0x6c, 0x6f, 0x61, + 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x23, + 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, + 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x55, 0x70, + 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x42, 0x2d, 0x5a, + 0x2b, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, + 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, + 0x65, 0x72, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, }) var ( @@ -483,24 +544,26 @@ func file_builder_proto_rawDescGZIP() []byte { return file_builder_proto_rawDescData } +var file_builder_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_builder_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_builder_proto_goTypes = []any{ - (*ClaimBuildTasksRequest)(nil), // 0: builder.ClaimBuildTasksRequest - (*BuildTaskSpec)(nil), // 1: builder.BuildTaskSpec - (*ClaimBuildTasksResponse)(nil), // 2: builder.ClaimBuildTasksResponse - (*StreamBuildTaskOutputRequest)(nil), // 3: builder.StreamBuildTaskOutputRequest - (*StreamBuildTaskOutputResponse)(nil), // 4: builder.StreamBuildTaskOutputResponse - (*UploadBuildArtifactRequest)(nil), // 5: builder.UploadBuildArtifactRequest - (*UploadBuildArtifactResponse)(nil), // 6: builder.UploadBuildArtifactResponse + (TargetFormat)(0), // 0: builder.TargetFormat + (*ClaimBuildTasksRequest)(nil), // 1: builder.ClaimBuildTasksRequest + (*BuildTaskSpec)(nil), // 2: builder.BuildTaskSpec + (*ClaimBuildTasksResponse)(nil), // 3: builder.ClaimBuildTasksResponse + (*StreamBuildTaskOutputRequest)(nil), // 4: builder.StreamBuildTaskOutputRequest + (*StreamBuildTaskOutputResponse)(nil), // 5: builder.StreamBuildTaskOutputResponse + (*UploadBuildArtifactRequest)(nil), // 6: builder.UploadBuildArtifactRequest + (*UploadBuildArtifactResponse)(nil), // 7: builder.UploadBuildArtifactResponse } var file_builder_proto_depIdxs = []int32{ - 1, // 0: builder.ClaimBuildTasksResponse.tasks:type_name -> builder.BuildTaskSpec - 0, // 1: builder.Builder.ClaimBuildTasks:input_type -> builder.ClaimBuildTasksRequest - 3, // 2: builder.Builder.StreamBuildTaskOutput:input_type -> builder.StreamBuildTaskOutputRequest - 5, // 3: builder.Builder.UploadBuildArtifact:input_type -> builder.UploadBuildArtifactRequest - 2, // 4: builder.Builder.ClaimBuildTasks:output_type -> builder.ClaimBuildTasksResponse - 4, // 5: builder.Builder.StreamBuildTaskOutput:output_type -> builder.StreamBuildTaskOutputResponse - 6, // 6: builder.Builder.UploadBuildArtifact:output_type -> builder.UploadBuildArtifactResponse + 2, // 0: builder.ClaimBuildTasksResponse.tasks:type_name -> builder.BuildTaskSpec + 1, // 1: builder.Builder.ClaimBuildTasks:input_type -> builder.ClaimBuildTasksRequest + 4, // 2: builder.Builder.StreamBuildTaskOutput:input_type -> builder.StreamBuildTaskOutputRequest + 6, // 3: builder.Builder.UploadBuildArtifact:input_type -> builder.UploadBuildArtifactRequest + 3, // 4: builder.Builder.ClaimBuildTasks:output_type -> builder.ClaimBuildTasksResponse + 5, // 5: builder.Builder.StreamBuildTaskOutput:output_type -> builder.StreamBuildTaskOutputResponse + 7, // 6: builder.Builder.UploadBuildArtifact:output_type -> builder.UploadBuildArtifactResponse 4, // [4:7] is the sub-list for method output_type 1, // [1:4] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -518,13 +581,14 @@ func file_builder_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_builder_proto_rawDesc), len(file_builder_proto_rawDesc)), - NumEnums: 0, + NumEnums: 1, NumMessages: 7, NumExtensions: 0, NumServices: 1, }, GoTypes: file_builder_proto_goTypes, DependencyIndexes: file_builder_proto_depIdxs, + EnumInfos: file_builder_proto_enumTypes, MessageInfos: file_builder_proto_msgTypes, }.Build() File_builder_proto = out.File diff --git a/tavern/internal/builder/builderpb/enum_target_format.go b/tavern/internal/builder/builderpb/enum_target_format.go new file mode 100644 index 000000000..a21c49a2c --- /dev/null +++ b/tavern/internal/builder/builderpb/enum_target_format.go @@ -0,0 +1,64 @@ +package builderpb + +import ( + "database/sql/driver" + "io" + "sort" + + "github.com/99designs/gqlgen/graphql" +) + +// Values provides list valid values for Enum. +func (TargetFormat) Values() []string { + values := make([]string, 0, len(TargetFormat_name)) + for _, name := range TargetFormat_name { + values = append(values, name) + } + sort.Strings(values) + return values +} + +// Value provides the DB a string from int. +func (f TargetFormat) Value() (driver.Value, error) { + return f.String(), nil +} + +// Scan tells our code how to read the enum into our type. +func (f *TargetFormat) Scan(val any) error { + var name string + switch v := val.(type) { + case nil: + return nil + case string: + name = v + case []uint8: + name = string(v) + default: + *f = TargetFormat_TARGET_FORMAT_UNSPECIFIED + return nil + } + + status, ok := TargetFormat_value[name] + if !ok { + *f = TargetFormat_TARGET_FORMAT_UNSPECIFIED + return nil + } + *f = TargetFormat(status) + + return nil +} + +// MarshalGQL writes a formatted string value for GraphQL. +func (f TargetFormat) MarshalGQL(w io.Writer) { + graphql.MarshalString(f.String()).MarshalGQL(w) +} + +// UnmarshalGQL parses a GraphQL string representation into the enum. +func (f *TargetFormat) UnmarshalGQL(v interface{}) error { + str, err := graphql.UnmarshalString(v) + if err != nil { + return err + } + + return f.Scan(str) +} diff --git a/tavern/internal/builder/builderpb/target_format.go b/tavern/internal/builder/builderpb/target_format.go deleted file mode 100644 index b50477bf3..000000000 --- a/tavern/internal/builder/builderpb/target_format.go +++ /dev/null @@ -1,89 +0,0 @@ -package builderpb - -import ( - "database/sql/driver" - "fmt" - "io" - "sort" - - "github.com/99designs/gqlgen/graphql" -) - -const ( - // DefaultInterval is the default callback interval in seconds for the IMIX agent. - DefaultInterval = 5 -) - -// TargetFormat represents the output format for a build. -type TargetFormat string - -const ( - TargetFormatBin TargetFormat = "BIN" - TargetFormatCdylib TargetFormat = "CDYLIB" - TargetFormatWindowsService TargetFormat = "WINDOWS_SERVICE" -) - -// targetFormatName maps each TargetFormat to its string representation. -var targetFormatName = map[TargetFormat]string{ - TargetFormatBin: "BIN", - TargetFormatCdylib: "CDYLIB", - TargetFormatWindowsService: "WINDOWS_SERVICE", -} - -// targetFormatValue maps string names to TargetFormat values. -var targetFormatValue = map[string]TargetFormat{ - "BIN": TargetFormatBin, - "CDYLIB": TargetFormatCdylib, - "WINDOWS_SERVICE": TargetFormatWindowsService, -} - -// Values provides list of valid values for the ent enum interface. -func (TargetFormat) Values() []string { - values := make([]string, 0, len(targetFormatName)) - for _, name := range targetFormatName { - values = append(values, name) - } - sort.Strings(values) - return values -} - -// Value provides the DB a string from the enum (implements driver.Valuer). -func (f TargetFormat) Value() (driver.Value, error) { - return string(f), nil -} - -// Scan tells our code how to read the enum from the database (implements sql.Scanner). -func (f *TargetFormat) Scan(val any) error { - var name string - switch v := val.(type) { - case nil: - return nil - case string: - name = v - case []uint8: - name = string(v) - default: - return fmt.Errorf("unsupported type for TargetFormat: %T", val) - } - - tf, ok := targetFormatValue[name] - if !ok { - return fmt.Errorf("invalid TargetFormat value: %q", name) - } - *f = tf - return nil -} - -// MarshalGQL writes a formatted string value for GraphQL. -func (f TargetFormat) MarshalGQL(w io.Writer) { - graphql.MarshalString(string(f)).MarshalGQL(w) -} - -// UnmarshalGQL parses a GraphQL string representation into the enum. -func (f *TargetFormat) UnmarshalGQL(v interface{}) error { - str, err := graphql.UnmarshalString(v) - if err != nil { - return err - } - return f.Scan(str) -} diff --git a/tavern/internal/builder/executor/docker.go b/tavern/internal/builder/executor/docker.go index c12ffef14..66af03492 100644 --- a/tavern/internal/builder/executor/docker.go +++ b/tavern/internal/builder/executor/docker.go @@ -146,23 +146,27 @@ func (d *DockerExecutor) Build(ctx context.Context, spec BuildSpec, outputCh cha // Extract artifact from the stopped container (before deferred removal). buildResult := BuildResult{ExitCode: exitCode} - if exitCode == ExpectedExitCode && spec.ArtifactPath != "" { - data, name, extractErr := d.extractArtifact(ctx, containerID, spec.ArtifactPath) - if extractErr != nil { - slog.WarnContext(ctx, "artifact extraction failed", - "task_id", spec.TaskID, "path", spec.ArtifactPath, "error", extractErr) - } else { - buildResult.Artifact = data - buildResult.ArtifactName = name - slog.InfoContext(ctx, "artifact extracted", - "task_id", spec.TaskID, "name", name, "size", len(data)) - } - } if exitCode != ExpectedExitCode { return &buildResult, fmt.Errorf("container exited with status %d", exitCode) } + if spec.ArtifactPath == "" { + return &buildResult, nil + } + + data, name, extractErr := d.extractArtifact(ctx, containerID, spec.ArtifactPath) + if extractErr != nil { + slog.WarnContext(ctx, "artifact extraction failed", + "task_id", spec.TaskID, "path", spec.ArtifactPath, "error", extractErr) + return &buildResult, nil + } + + buildResult.Artifact = data + buildResult.ArtifactName = name + slog.InfoContext(ctx, "artifact extracted", + "task_id", spec.TaskID, "name", name, "size", len(data)) + return &buildResult, nil } @@ -185,13 +189,14 @@ func (d *DockerExecutor) extractArtifact(ctx context.Context, containerID, path if err != nil { return nil, "", fmt.Errorf("reading tar entry: %w", err) } - if hdr.Typeflag == tar.TypeReg { - data, err := io.ReadAll(tr) - if err != nil { - return nil, "", fmt.Errorf("reading artifact data: %w", err) - } - return data, filepath.Base(hdr.Name), nil + if hdr.Typeflag != tar.TypeReg { + continue + } + data, err := io.ReadAll(tr) + if err != nil { + return nil, "", fmt.Errorf("reading artifact data: %w", err) } + return data, filepath.Base(hdr.Name), nil } return nil, "", fmt.Errorf("no regular file found at %q", path) diff --git a/tavern/internal/builder/executor_integration_test.go b/tavern/internal/builder/executor_integration_test.go index f32be5c02..c8a8933e8 100644 --- a/tavern/internal/builder/executor_integration_test.go +++ b/tavern/internal/builder/executor_integration_test.go @@ -74,7 +74,7 @@ func TestExecutorIntegration_ClaimAndExecuteWithMock(t *testing.T) { // Create a build task bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_LINUX). - SetTargetFormat("BIN"). + SetTargetFormat(builderpb.TargetFormat_TARGET_FORMAT_BIN). SetBuildImage("golang:1.21"). SetBuildScript("go build ./..."). SetCallbackURI("https://callback.example.com"). @@ -219,7 +219,7 @@ func TestExecutorIntegration_ClaimAndExecuteWithMockError(t *testing.T) { bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_LINUX). - SetTargetFormat("BIN"). + SetTargetFormat(builderpb.TargetFormat_TARGET_FORMAT_BIN). SetBuildImage("golang:1.21"). SetBuildScript("go build ./..."). SetCallbackURI("https://callback.example.com"). @@ -369,7 +369,7 @@ func TestExecutorIntegration_StreamBuildOutput(t *testing.T) { bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_LINUX). - SetTargetFormat("BIN"). + SetTargetFormat(builderpb.TargetFormat_TARGET_FORMAT_BIN). SetBuildImage("golang:1.21"). SetBuildScript("go build ./..."). SetCallbackURI("https://callback.example.com"). @@ -499,7 +499,7 @@ func TestExecutorIntegration_StreamBuildOutputWithError(t *testing.T) { bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_LINUX). - SetTargetFormat("BIN"). + SetTargetFormat(builderpb.TargetFormat_TARGET_FORMAT_BIN). SetBuildImage("golang:1.21"). SetBuildScript("go build ./..."). SetCallbackURI("https://callback.example.com"). @@ -626,7 +626,7 @@ func TestExecutorIntegration_UploadBuildArtifact(t *testing.T) { graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_LINUX). - SetTargetFormat("BIN"). + SetTargetFormat(builderpb.TargetFormat_TARGET_FORMAT_BIN). SetBuildImage("golang:1.21"). SetBuildScript("go build -o /app/output/binary ./..."). SetCallbackURI("https://callback.example.com"). @@ -717,7 +717,7 @@ func TestExecutorIntegration_UploadBuildArtifact(t *testing.T) { // Verify the asset was created asset, err := graph.Asset.Get(ctx, int(artifactResp.AssetId)) require.NoError(t, err) - assert.Contains(t, asset.Name, "build/linux/BIN/imix-") + assert.Contains(t, asset.Name, "build/linux/bin/imix-") assert.Equal(t, artifactData, asset.Content) assert.Equal(t, len(artifactData), asset.Size) } diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go index 288cbb8fe..9d01e1772 100644 --- a/tavern/internal/builder/integration_test.go +++ b/tavern/internal/builder/integration_test.go @@ -169,7 +169,7 @@ func TestBuilderE2E(t *testing.T) { // Create a build task assigned to this builder bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_LINUX). - SetTargetFormat("BIN"). + SetTargetFormat(builderpb.TargetFormat_TARGET_FORMAT_BIN). SetBuildImage("golang:1.21"). SetBuildScript("echo hello && go build ./..."). SetCallbackURI("https://callback.example.com"). @@ -227,7 +227,7 @@ func TestBuilderE2E(t *testing.T) { // Create and claim a build task bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_MACOS). - SetTargetFormat("BIN"). + SetTargetFormat(builderpb.TargetFormat_TARGET_FORMAT_BIN). SetBuildImage("rust:1.75"). SetBuildScript("cargo build --release"). SetCallbackURI("https://callback.example.com"). @@ -284,7 +284,7 @@ func TestBuilderE2E(t *testing.T) { // Create and claim a build task bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_LINUX). - SetTargetFormat("BIN"). + SetTargetFormat(builderpb.TargetFormat_TARGET_FORMAT_BIN). SetBuildImage("golang:1.21"). SetBuildScript("go build ./..."). SetCallbackURI("https://callback.example.com"). @@ -363,7 +363,7 @@ func TestBuilderE2E(t *testing.T) { // Create a build task assigned to the second builder bt := graph.BuildTask.Create(). SetTargetOs(c2pb.Host_PLATFORM_WINDOWS). - SetTargetFormat("BIN"). + SetTargetFormat(builderpb.TargetFormat_TARGET_FORMAT_BIN). SetBuildImage("mcr.microsoft.com/windows:ltsc2022"). SetBuildScript("msbuild /t:Build"). SetCallbackURI("https://callback.example.com"). diff --git a/tavern/internal/builder/proto/builder.proto b/tavern/internal/builder/proto/builder.proto index 3712265d2..837585cb6 100644 --- a/tavern/internal/builder/proto/builder.proto +++ b/tavern/internal/builder/proto/builder.proto @@ -4,6 +4,13 @@ package builder; option go_package = "realm.pub/tavern/internal/builder/builderpb"; +enum TargetFormat { + TARGET_FORMAT_UNSPECIFIED = 0; + TARGET_FORMAT_BIN = 1; + TARGET_FORMAT_CDYLIB = 2; + TARGET_FORMAT_WINDOWS_SERVICE = 3; +} + message ClaimBuildTasksRequest {} message BuildTaskSpec { diff --git a/tavern/internal/builder/server.go b/tavern/internal/builder/server.go index 565ddd9b5..0c588a57a 100644 --- a/tavern/internal/builder/server.go +++ b/tavern/internal/builder/server.go @@ -310,7 +310,8 @@ func (s *Server) UploadBuildArtifact(stream builderpb.Builder_UploadBuildArtifac randomSuffix := hex.EncodeToString(randomBytes) osName := strings.ToLower(strings.TrimPrefix(bt.TargetOs.String(), "PLATFORM_")) - assetName := fmt.Sprintf("build/%s/%s/imix-%s", osName, bt.TargetFormat, randomSuffix) + formatName := strings.ToLower(strings.TrimPrefix(bt.TargetFormat.String(), "TARGET_FORMAT_")) + assetName := fmt.Sprintf("build/%s/%s/imix-%s", osName, formatName, randomSuffix) asset, err := s.graph.Asset.Create(). SetName(assetName). SetContent(buf.Bytes()). diff --git a/tavern/internal/ent/buildtask/buildtask.go b/tavern/internal/ent/buildtask/buildtask.go index 1d43332c9..143fb205e 100644 --- a/tavern/internal/ent/buildtask/buildtask.go +++ b/tavern/internal/ent/buildtask/buildtask.go @@ -168,8 +168,8 @@ func TargetOsValidator(to c2pb.Host_Platform) error { // TargetFormatValidator is a validator for the "target_format" field enum values. It is called by the builders before save. func TargetFormatValidator(tf builderpb.TargetFormat) error { - switch tf { - case "BIN", "CDYLIB", "WINDOWS_SERVICE": + switch tf.String() { + case "TARGET_FORMAT_BIN", "TARGET_FORMAT_CDYLIB", "TARGET_FORMAT_UNSPECIFIED", "TARGET_FORMAT_WINDOWS_SERVICE": return nil default: return fmt.Errorf("buildtask: invalid enum value for target_format field: %q", tf) diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index aa4757ab2..474e706b5 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -69,7 +69,7 @@ var ( {Name: "created_at", Type: field.TypeTime}, {Name: "last_modified_at", Type: field.TypeTime}, {Name: "target_os", Type: field.TypeEnum, Enums: []string{"PLATFORM_BSD", "PLATFORM_LINUX", "PLATFORM_MACOS", "PLATFORM_UNSPECIFIED", "PLATFORM_WINDOWS"}}, - {Name: "target_format", Type: field.TypeEnum, Enums: []string{"BIN", "CDYLIB", "WINDOWS_SERVICE"}}, + {Name: "target_format", Type: field.TypeEnum, Enums: []string{"TARGET_FORMAT_BIN", "TARGET_FORMAT_CDYLIB", "TARGET_FORMAT_UNSPECIFIED", "TARGET_FORMAT_WINDOWS_SERVICE"}}, {Name: "build_image", Type: field.TypeString}, {Name: "build_script", Type: field.TypeString, Size: 2147483647, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, {Name: "callback_uri", Type: field.TypeString}, diff --git a/tavern/internal/ent/schema/build_task.go b/tavern/internal/ent/schema/build_task.go index 476024e74..3179dd116 100644 --- a/tavern/internal/ent/schema/build_task.go +++ b/tavern/internal/ent/schema/build_task.go @@ -32,7 +32,7 @@ func (BuildTask) Fields() []ent.Field { ). Comment("The target operating system platform for this build."), field.Enum("target_format"). - GoType(builderpb.TargetFormat("")). + GoType(builderpb.TargetFormat(0)). Annotations( entgql.Type("BuildTaskTargetFormat"), ). @@ -53,7 +53,7 @@ func (BuildTask) Fields() []ent.Field { NotEmpty(). Comment("The callback URI for the IMIX agent to connect to."), field.Int("interval"). - Default(builderpb.DefaultInterval). + Default(5). Comment("The callback interval in seconds for the IMIX agent."), field.Enum("transport_type"). GoType(c2pb.Transport_Type(0)). diff --git a/tavern/internal/graphql/build_task_test.go b/tavern/internal/graphql/build_task_test.go index d98d5acce..db101b1e2 100644 --- a/tavern/internal/graphql/build_task_test.go +++ b/tavern/internal/graphql/build_task_test.go @@ -57,10 +57,7 @@ func TestCreateBuildTask(t *testing.T) { } } err := gqlClient.Post(mutIDOnly, &resp, client.Var("input", map[string]any{ - "targetOS": "PLATFORM_LINUX", - "targetFormat": "BIN", - "buildImage": "golang:1.21", - "callbackURI": "https://callback.example.com", + "targetOS": "PLATFORM_LINUX", })) require.Error(t, err) assert.Contains(t, err.Error(), "no builder available") @@ -79,10 +76,7 @@ func TestCreateBuildTask(t *testing.T) { } } err := gqlClient.Post(mutIDOnly, &resp, client.Var("input", map[string]any{ - "targetOS": "PLATFORM_LINUX", - "targetFormat": "BIN", - "buildImage": "golang:1.21", - "callbackURI": "https://callback.example.com", + "targetOS": "PLATFORM_LINUX", })) require.Error(t, err) assert.Contains(t, err.Error(), "no builder available") @@ -115,16 +109,14 @@ func TestCreateBuildTask(t *testing.T) { } } err := gqlClient.Post(mutFull, &resp, client.Var("input", map[string]any{ - "targetOS": "PLATFORM_LINUX", - "targetFormat": "BIN", - "buildImage": "golang:1.21", - "callbackURI": "https://callback.example.com", + "targetOS": "PLATFORM_LINUX", + "callbackURI": "https://callback.example.com", })) require.NoError(t, err) require.NotEmpty(t, resp.CreateBuildTask.ID) assert.Equal(t, "PLATFORM_LINUX", resp.CreateBuildTask.TargetOs) - assert.Equal(t, "BIN", resp.CreateBuildTask.TargetFormat) - assert.Equal(t, "golang:1.21", resp.CreateBuildTask.BuildImage) + assert.Equal(t, "TARGET_FORMAT_BIN", resp.CreateBuildTask.TargetFormat) + assert.Equal(t, "spellshift/devcontainer:main", resp.CreateBuildTask.BuildImage) assert.Contains(t, resp.CreateBuildTask.BuildScript, "cargo build") assert.Equal(t, "https://callback.example.com", resp.CreateBuildTask.CallbackURI) assert.Equal(t, 5, resp.CreateBuildTask.Interval) @@ -173,7 +165,7 @@ func TestCreateBuildTask(t *testing.T) { "targetOS": "PLATFORM_LINUX", })) require.NoError(t, err) - assert.Equal(t, "BIN", resp.CreateBuildTask.TargetFormat) + assert.Equal(t, "TARGET_FORMAT_BIN", resp.CreateBuildTask.TargetFormat) assert.Equal(t, "spellshift/devcontainer:main", resp.CreateBuildTask.BuildImage) assert.Equal(t, "http://127.0.0.1:8000", resp.CreateBuildTask.CallbackURI) assert.Equal(t, 5, resp.CreateBuildTask.Interval) @@ -204,8 +196,6 @@ func TestCreateBuildTask(t *testing.T) { } }`, &resp, client.Var("input", map[string]any{ "targetOS": "PLATFORM_LINUX", - "targetFormat": "BIN", - "buildImage": "golang:1.21", "artifactPath": "/custom/path/to/binary", })) require.NoError(t, err) @@ -236,10 +226,7 @@ func TestCreateBuildTask(t *testing.T) { } } err := gqlClient.Post(mutIDOnly, &resp, client.Var("input", map[string]any{ - "targetOS": "PLATFORM_LINUX", - "targetFormat": "BIN", - "buildImage": "golang:1.21", - "callbackURI": "https://callback.example.com", + "targetOS": "PLATFORM_LINUX", })) require.NoError(t, err) @@ -271,9 +258,7 @@ func TestCreateBuildTask(t *testing.T) { // cdylib is not supported on Linux err := gqlClient.Post(mutIDOnly, &resp, client.Var("input", map[string]any{ "targetOS": "PLATFORM_LINUX", - "targetFormat": "CDYLIB", - "buildImage": "golang:1.21", - "callbackURI": "https://callback.example.com", + "targetFormat": "TARGET_FORMAT_CDYLIB", })) require.Error(t, err) assert.Contains(t, err.Error(), "not supported") @@ -304,12 +289,10 @@ func TestCreateBuildTask(t *testing.T) { } }`, &resp, client.Var("input", map[string]any{ "targetOS": "PLATFORM_WINDOWS", - "targetFormat": "WINDOWS_SERVICE", - "buildImage": "golang:1.21", - "callbackURI": "https://callback.example.com", + "targetFormat": "TARGET_FORMAT_WINDOWS_SERVICE", })) require.NoError(t, err) - assert.Equal(t, "WINDOWS_SERVICE", resp.CreateBuildTask.TargetFormat) + assert.Equal(t, "TARGET_FORMAT_WINDOWS_SERVICE", resp.CreateBuildTask.TargetFormat) assert.Contains(t, resp.CreateBuildTask.BuildScript, "win_service") }) } diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 6c987303c..1d4d6ac2f 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -3924,9 +3924,10 @@ enum BuildTaskOrderField { BuildTaskTargetFormat is enum for the field target_format """ enum BuildTaskTargetFormat @goModel(model: "realm.pub/tavern/internal/builder/builderpb.TargetFormat") { - BIN - CDYLIB - WINDOWS_SERVICE + TARGET_FORMAT_BIN + TARGET_FORMAT_CDYLIB + TARGET_FORMAT_UNSPECIFIED + TARGET_FORMAT_WINDOWS_SERVICE } """ BuildTaskWhereInput is used for filtering BuildTask objects. diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index 7b519a0fb..6ba84c3a1 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -736,9 +736,10 @@ enum BuildTaskOrderField { BuildTaskTargetFormat is enum for the field target_format """ enum BuildTaskTargetFormat @goModel(model: "realm.pub/tavern/internal/builder/builderpb.TargetFormat") { - BIN - CDYLIB - WINDOWS_SERVICE + TARGET_FORMAT_BIN + TARGET_FORMAT_CDYLIB + TARGET_FORMAT_UNSPECIFIED + TARGET_FORMAT_WINDOWS_SERVICE } """ BuildTaskWhereInput is used for filtering BuildTask objects. diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index 459ab0578..eb63f0d73 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -731,9 +731,10 @@ enum BuildTaskOrderField { BuildTaskTargetFormat is enum for the field target_format """ enum BuildTaskTargetFormat @goModel(model: "realm.pub/tavern/internal/builder/builderpb.TargetFormat") { - BIN - CDYLIB - WINDOWS_SERVICE + TARGET_FORMAT_BIN + TARGET_FORMAT_CDYLIB + TARGET_FORMAT_UNSPECIFIED + TARGET_FORMAT_WINDOWS_SERVICE } """ BuildTaskWhereInput is used for filtering BuildTask objects. diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index 7b519a0fb..6ba84c3a1 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -736,9 +736,10 @@ enum BuildTaskOrderField { BuildTaskTargetFormat is enum for the field target_format """ enum BuildTaskTargetFormat @goModel(model: "realm.pub/tavern/internal/builder/builderpb.TargetFormat") { - BIN - CDYLIB - WINDOWS_SERVICE + TARGET_FORMAT_BIN + TARGET_FORMAT_CDYLIB + TARGET_FORMAT_UNSPECIFIED + TARGET_FORMAT_WINDOWS_SERVICE } """ BuildTaskWhereInput is used for filtering BuildTask objects. From 1e4c8e8ade2208209389e64df9974e263f8c441a Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Mon, 16 Feb 2026 00:01:13 +0000 Subject: [PATCH 16/19] merge --- tavern/internal/builder/builderpb/builder.pb.go | 5 ++--- tavern/internal/builder/builderpb/builder_grpc.pb.go | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tavern/internal/builder/builderpb/builder.pb.go b/tavern/internal/builder/builderpb/builder.pb.go index 8b5b50268..9b043509a 100644 --- a/tavern/internal/builder/builderpb/builder.pb.go +++ b/tavern/internal/builder/builderpb/builder.pb.go @@ -7,12 +7,11 @@ package builderpb import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/tavern/internal/builder/builderpb/builder_grpc.pb.go b/tavern/internal/builder/builderpb/builder_grpc.pb.go index 43ae20a50..e1e3e13ca 100644 --- a/tavern/internal/builder/builderpb/builder_grpc.pb.go +++ b/tavern/internal/builder/builderpb/builder_grpc.pb.go @@ -8,7 +8,6 @@ package builderpb import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" From 5d634c849f4129e384abf053d0922b6ee876629a Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Mon, 16 Feb 2026 00:07:55 +0000 Subject: [PATCH 17/19] Fix test --- .../builder/executor_integration_test.go | 10 +++---- tavern/internal/graphql/api_test.go | 2 +- tavern/internal/graphql/build_task_test.go | 2 +- tavern/internal/graphql/quest_test.go | 2 +- tavern/internal/graphql/resolver.go | 29 +++++++++++++------ tavern/internal/graphql/tome_test.go | 2 +- tavern/internal/graphql/user_test.go | 2 +- 7 files changed, 30 insertions(+), 19 deletions(-) diff --git a/tavern/internal/builder/executor_integration_test.go b/tavern/internal/builder/executor_integration_test.go index c8a8933e8..e09fd570d 100644 --- a/tavern/internal/builder/executor_integration_test.go +++ b/tavern/internal/builder/executor_integration_test.go @@ -42,7 +42,7 @@ func TestExecutorIntegration_ClaimAndExecuteWithMock(t *testing.T) { git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, graphql.WithBuilderCA(caCert), graphql.WithBuilderCAKey(caPrivKey))), }, tavernhttp.WithAuthenticationBypass(graph), ) @@ -190,7 +190,7 @@ func TestExecutorIntegration_ClaimAndExecuteWithMockError(t *testing.T) { git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, graphql.WithBuilderCA(caCert), graphql.WithBuilderCAKey(caPrivKey))), }, tavernhttp.WithAuthenticationBypass(graph), ) @@ -340,7 +340,7 @@ func TestExecutorIntegration_StreamBuildOutput(t *testing.T) { git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, graphql.WithBuilderCA(caCert), graphql.WithBuilderCAKey(caPrivKey))), }, tavernhttp.WithAuthenticationBypass(graph), ) @@ -470,7 +470,7 @@ func TestExecutorIntegration_StreamBuildOutputWithError(t *testing.T) { git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, graphql.WithBuilderCA(caCert), graphql.WithBuilderCAKey(caPrivKey))), }, tavernhttp.WithAuthenticationBypass(graph), ) @@ -597,7 +597,7 @@ func TestExecutorIntegration_UploadBuildArtifact(t *testing.T) { git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, graphql.WithBuilderCA(caCert), graphql.WithBuilderCAKey(caPrivKey))), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/api_test.go b/tavern/internal/graphql/api_test.go index b8ad58a76..75046c9e1 100644 --- a/tavern/internal/graphql/api_test.go +++ b/tavern/internal/graphql/api_test.go @@ -94,7 +94,7 @@ func runTestCase(t *testing.T, path string) { // Server srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importerFake{graph}, nil, nil)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importerFake{graph})), }, tavernhttp.WithAuthentication(graph), ) diff --git a/tavern/internal/graphql/build_task_test.go b/tavern/internal/graphql/build_task_test.go index db101b1e2..d90526559 100644 --- a/tavern/internal/graphql/build_task_test.go +++ b/tavern/internal/graphql/build_task_test.go @@ -24,7 +24,7 @@ func TestCreateBuildTask(t *testing.T) { git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/quest_test.go b/tavern/internal/graphql/quest_test.go index 0734bae8d..b02df15b1 100644 --- a/tavern/internal/graphql/quest_test.go +++ b/tavern/internal/graphql/quest_test.go @@ -33,7 +33,7 @@ func TestCreateQuest(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/resolver.go b/tavern/internal/graphql/resolver.go index e1748bc05..010523802 100644 --- a/tavern/internal/graphql/resolver.go +++ b/tavern/internal/graphql/resolver.go @@ -30,21 +30,32 @@ type Resolver struct { builderCAKey ed25519.PrivateKey } +func WithBuilderCAKey(builderCAKey ed25519.PrivateKey) Option { + return Option(func(resolver *Resolver) { + resolver.builderCAKey = builderCAKey + }) +} + +func WithBuilderCA(builderCA *x509.Certificate) Option { + return Option(func(resolver *Resolver) { + resolver.builderCA = builderCA + }) +} + // NewSchema creates a graphql executable schema. -func NewSchema(client *ent.Client, importer RepoImporter, builderCA *x509.Certificate, builderCAKey ed25519.PrivateKey) graphql.ExecutableSchema { - cfg := generated.Config{ - Resolvers: &Resolver{ - client: client, - importer: importer, - builderCA: builderCA, - builderCAKey: builderCAKey, - }, +func NewSchema(client *ent.Client, importer RepoImporter, options ...func(*Resolver)) graphql.ExecutableSchema { + resolver := &Resolver{ + client: client, + importer: importer, } for _, opt := range options { opt(resolver) } cfg := generated.Config{ - Resolvers: resolver, + Resolvers: &Resolver{ + client: client, + importer: importer, + }, } cfg.Directives.RequireRole = func(ctx context.Context, obj interface{}, next graphql.Resolver, requiredRole models.Role) (interface{}, error) { diff --git a/tavern/internal/graphql/tome_test.go b/tavern/internal/graphql/tome_test.go index 1278bea24..2d342b7cf 100644 --- a/tavern/internal/graphql/tome_test.go +++ b/tavern/internal/graphql/tome_test.go @@ -26,7 +26,7 @@ func TestTomeMutations(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/user_test.go b/tavern/internal/graphql/user_test.go index e6cedeb54..d97f9e71d 100644 --- a/tavern/internal/graphql/user_test.go +++ b/tavern/internal/graphql/user_test.go @@ -29,7 +29,7 @@ func TestUserMutations(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), }, tavernhttp.WithAuthenticationBypass(graph), ) From 56e087ef29575f0cadbf902bdb1b07eb4f0b66a3 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Mon, 16 Feb 2026 00:14:43 +0000 Subject: [PATCH 18/19] Fix tests --- tavern/internal/graphql/resolver.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tavern/internal/graphql/resolver.go b/tavern/internal/graphql/resolver.go index 010523802..f54907664 100644 --- a/tavern/internal/graphql/resolver.go +++ b/tavern/internal/graphql/resolver.go @@ -52,10 +52,7 @@ func NewSchema(client *ent.Client, importer RepoImporter, options ...func(*Resol opt(resolver) } cfg := generated.Config{ - Resolvers: &Resolver{ - client: client, - importer: importer, - }, + Resolvers: resolver, } cfg.Directives.RequireRole = func(ctx context.Context, obj interface{}, next graphql.Resolver, requiredRole models.Role) (interface{}, error) { From 72b49678ec8d1c7522912dfe0024513d88215ca8 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Mon, 16 Feb 2026 00:53:10 +0000 Subject: [PATCH 19/19] Feedback --- tavern/internal/builder/build_config.go | 17 +++----------- tavern/internal/builder/client.go | 30 ++++++++++++++----------- tavern/internal/builder/server.go | 9 ++++++-- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/tavern/internal/builder/build_config.go b/tavern/internal/builder/build_config.go index 18adcdf7c..f514f487c 100644 --- a/tavern/internal/builder/build_config.go +++ b/tavern/internal/builder/build_config.go @@ -4,14 +4,13 @@ import ( "fmt" "strings" - yaml "gopkg.in/yaml.v3" "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2/c2pb" ) const ( - // RealmRepoURL is the default git repository URL for building realm agents. - RealmRepoURL = "https://github.com/spellshift/realm.git" + // DefaultRealmRepoURL is the default git repository URL for building realm agents. + DefaultRealmRepoURL = "https://github.com/spellshift/realm.git" // DefaultInterval is the default callback interval in seconds for the IMIX agent. DefaultInterval = 5 @@ -134,16 +133,6 @@ func DeriveArtifactPath(os c2pb.Host_Platform) string { return fmt.Sprintf("/home/vscode/realm/implants/target/%s/release/imix", target) } -// MarshalImixConfig serializes the ImixConfig to a YAML string suitable -// for passing as the IMIX_CONFIG environment variable. -func MarshalImixConfig(cfg ImixConfig) (string, error) { - cfgBytes, err := yaml.Marshal(cfg) - if err != nil { - return "", fmt.Errorf("failed to marshal IMIX config: %w", err) - } - return string(cfgBytes), nil -} - // GenerateBuildScript generates the full build script from the build configuration. // It clones the repository and runs the build command. The IMIX configuration // is passed via the IMIX_CONFIG environment variable rather than being written @@ -156,7 +145,7 @@ func GenerateBuildScript(os c2pb.Host_Platform, format TargetFormat) (string, er script := fmt.Sprintf( `cd /home/vscode && git clone %s realm && cd realm/implants/imix && %s`, - RealmRepoURL, + DefaultRealmRepoURL, buildCmd, ) diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index 3227c57b3..4bc6d99f7 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -7,9 +7,9 @@ import ( "encoding/pem" "fmt" "log/slog" - "sync" "time" + "golang.org/x/sync/semaphore" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" @@ -24,6 +24,9 @@ const ( // maxConcurrentBuilds is the maximum number of builds that can run simultaneously. maxConcurrentBuilds = 4 + + maxOutputChSize = 64 + maxErrorChSize = 64 ) // builderCredentials implements grpc.PerRPCCredentials for mTLS authentication. @@ -129,11 +132,10 @@ func Run(ctx context.Context, cfg *Config, exec executor.Executor) error { client := builderpb.NewBuilderClient(conn) // Semaphore limits concurrent builds. - sem := make(chan struct{}, maxConcurrentBuilds) - var wg sync.WaitGroup + sem := semaphore.NewWeighted(maxConcurrentBuilds) // Check for tasks immediately, then poll on interval - if err := claimAndExecuteTasks(ctx, client, exec, sem, &wg); err != nil { + if err := claimAndExecuteTasks(ctx, client, exec, sem); err != nil { slog.ErrorContext(ctx, "error processing build tasks", "error", err) } @@ -143,17 +145,19 @@ func Run(ctx context.Context, cfg *Config, exec executor.Executor) error { for { select { case <-ctx.Done(): - wg.Wait() + // Wait for all in-flight builds to finish by acquiring all slots. + //nolint:errcheck // context is already cancelled; use background to drain. + sem.Acquire(context.Background(), maxConcurrentBuilds) return ctx.Err() case <-ticker.C: - if err := claimAndExecuteTasks(ctx, client, exec, sem, &wg); err != nil { + if err := claimAndExecuteTasks(ctx, client, exec, sem); err != nil { slog.ErrorContext(ctx, "error processing build tasks", "error", err) } } } } -func claimAndExecuteTasks(ctx context.Context, client builderpb.BuilderClient, exec executor.Executor, sem chan struct{}, wg *sync.WaitGroup) error { +func claimAndExecuteTasks(ctx context.Context, client builderpb.BuilderClient, exec executor.Executor, sem *semaphore.Weighted) error { resp, err := client.ClaimBuildTasks(ctx, &builderpb.ClaimBuildTasksRequest{}) if err != nil { return fmt.Errorf("failed to claim build tasks: %w", err) @@ -167,11 +171,11 @@ func claimAndExecuteTasks(ctx context.Context, client builderpb.BuilderClient, e ) // Acquire semaphore slot (blocks if at max concurrency). - sem <- struct{}{} - wg.Add(1) + if err := sem.Acquire(ctx, 1); err != nil { + return fmt.Errorf("failed to acquire semaphore: %w", err) + } go func(t *builderpb.BuildTaskSpec) { - defer wg.Done() - defer func() { <-sem }() + defer sem.Release(1) executeTask(ctx, client, exec, t) }(task) } @@ -189,8 +193,8 @@ func executeTask(ctx context.Context, client builderpb.BuilderClient, exec execu return } - outputCh := make(chan string, 64) - errorCh := make(chan string, 64) + outputCh := make(chan string, maxOutputChSize) + errorCh := make(chan string, maxErrorChSize) // Stream output and errors to the server in a background goroutine. var sendErr error diff --git a/tavern/internal/builder/server.go b/tavern/internal/builder/server.go index 0c588a57a..865958e95 100644 --- a/tavern/internal/builder/server.go +++ b/tavern/internal/builder/server.go @@ -13,6 +13,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + yaml "gopkg.in/yaml.v3" "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/ent" @@ -118,7 +119,11 @@ func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildT }, }, } - imixCfgYAML, err := MarshalImixConfig(imixCfg) + cfgBytes, err := yaml.Marshal(imixCfg) + if err != nil { + return nil, fmt.Errorf("failed to marshal IMIX config: %w", err) + } + // string(cfgBytes) if err != nil { return nil, status.Errorf(codes.Internal, "failed to marshal IMIX config for task %d: %v", taskID, err) } @@ -129,7 +134,7 @@ func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildT BuildImage: claimedTask.BuildImage, BuildScript: claimedTask.BuildScript, ArtifactPath: claimedTask.ArtifactPath, - Env: []string{fmt.Sprintf("IMIX_CONFIG=%s", imixCfgYAML)}, + Env: []string{fmt.Sprintf("IMIX_CONFIG=%s", string(cfgBytes))}, }) }