From e5dccf023cdd44c31c37bd166a29d78383a054ee Mon Sep 17 00:00:00 2001 From: Alex Rodriguez Fernandez Date: Wed, 18 Dec 2024 12:00:44 +0100 Subject: [PATCH 01/14] feat(api): [KDL6-181] deprecate repository type (#1064) This commit deprecates the repository type and all related logic: - Updated graphql.schema - Regenerated all graphql related files - Deprecated INTERNAL and EXTERNAL repo types - Changed mongodb 'projects' collection attributes ### BREAKING CHANGE Mongodb collection 'projects' has been changed. A migration guide inside docs/upgrade_guide has been provided containing instruction on how to proceed when deploying this commit. --- .github/.golangci.yml | 3 +- app/api/entity/repository.go | 35 +- app/api/go.mod | 3 +- app/api/go.sum | 8 +- .../graph/generated/generated.go | 1365 ++++++----------- .../infrastructure/graph/model/models_gen.go | 30 +- .../infrastructure/graph/schema.resolvers.go | 198 ++- .../k8s/service_account_test.go | 1 - app/api/infrastructure/k8s/user_ssh_test.go | 3 +- app/api/infrastructure/mongodb/mongo_test.go | 18 +- app/api/infrastructure/mongodb/project.go | 13 +- app/api/usecase/project/interactor.go | 48 +- app/api/usecase/project/interactor_test.go | 50 +- app/graphql/schema.graphqls | 209 ++- .../INTERNAL_REPO_DEPRECATION.md | 39 + go.work.sum | 2 + 16 files changed, 765 insertions(+), 1260 deletions(-) create mode 100644 docs/upgrade_guides/INTERNAL_REPO_DEPRECATION.md diff --git a/.github/.golangci.yml b/.github/.golangci.yml index 0d29011e8..606b2a5d3 100644 --- a/.github/.golangci.yml +++ b/.github/.golangci.yml @@ -220,8 +220,9 @@ issues: exclude-rules: - path: _test\.go linters: - - mnd - gochecknoglobals + - gosec + - mnd # https://github.com/go-critic/go-critic/issues/926 - linters: - gocritic diff --git a/app/api/entity/repository.go b/app/api/entity/repository.go index c594ad122..aefbc1e9a 100644 --- a/app/api/entity/repository.go +++ b/app/api/entity/repository.go @@ -1,31 +1,5 @@ package entity -// RepositoryType is an enum for repository types. -type RepositoryType string - -const ( - // RepositoryTypeInternal repository type. - RepositoryTypeInternal RepositoryType = "INTERNAL" - - // RepositoryTypeExternal repository type. - RepositoryTypeExternal RepositoryType = "EXTERNAL" -) - -// IsValid checks if the type is valid. -func (e RepositoryType) IsValid() bool { - switch e { - case RepositoryTypeInternal, RepositoryTypeExternal: - return true - } - - return false -} - -// String implements the fmt.Stringer interface. -func (e RepositoryType) String() string { - return string(e) -} - // RepositoryAuthMethod is an enum for repository authentication method. type RepositoryAuthMethod string @@ -53,9 +27,8 @@ func (e RepositoryAuthMethod) String() string { // Repository entity definition. type Repository struct { - Type RepositoryType - ExternalRepoURL string - RepoName string - Error *string - AuthMethod RepositoryAuthMethod + URL string + RepoName string + Error *string + AuthMethod RepositoryAuthMethod } diff --git a/app/api/go.mod b/app/api/go.mod index a7fba5dd9..2f5bd3c10 100644 --- a/app/api/go.mod +++ b/app/api/go.mod @@ -110,13 +110,14 @@ require ( go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.10.0 // indirect - golang.org/x/net v0.30.0 // indirect + golang.org/x/net v0.32.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/term v0.27.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.28.0 // indirect google.golang.org/protobuf v1.35.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/app/api/go.sum b/app/api/go.sum index a2fa73d5b..a0be354cb 100644 --- a/app/api/go.sum +++ b/app/api/go.sum @@ -290,8 +290,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -338,8 +338,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= -golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= +golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= +golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/app/api/infrastructure/graph/generated/generated.go b/app/api/infrastructure/graph/generated/generated.go index 1ddc1d838..7af664cba 100644 --- a/app/api/infrastructure/graph/generated/generated.go +++ b/app/api/infrastructure/graph/generated/generated.go @@ -43,7 +43,6 @@ type ResolverRoot interface { Mutation() MutationResolver Project() ProjectResolver Query() QueryResolver - Repository() RepositoryResolver SSHKey() SSHKeyResolver User() UserResolver } @@ -121,7 +120,6 @@ type ComplexityRoot struct { Repository struct { Error func(childComplexity int) int - Type func(childComplexity int) int URL func(childComplexity int) int } @@ -149,11 +147,6 @@ type ComplexityRoot struct { VSCode func(childComplexity int) int } - Topic struct { - Name func(childComplexity int) int - Relevance func(childComplexity int) int - } - User struct { APITokens func(childComplexity int) int AccessLevel func(childComplexity int) int @@ -173,18 +166,18 @@ type MemberResolver interface { AddedDate(ctx context.Context, obj *entity.Member) (string, error) } type MutationResolver interface { + RegenerateSSHKey(ctx context.Context) (*entity.User, error) RemoveUsers(ctx context.Context, input model.RemoveUsersInput) ([]entity.User, error) + SetActiveUserTools(ctx context.Context, input model.SetActiveUserToolsInput) (*entity.User, error) UpdateAccessLevel(ctx context.Context, input model.UpdateAccessLevelInput) ([]entity.User, error) - RegenerateSSHKey(ctx context.Context) (*entity.User, error) + AddMembers(ctx context.Context, input model.AddMembersInput) (*entity.Project, error) CreateProject(ctx context.Context, input model.CreateProjectInput) (*entity.Project, error) - UpdateProject(ctx context.Context, input model.UpdateProjectInput) (*entity.Project, error) DeleteProject(ctx context.Context, input model.DeleteProjectInput) (*entity.Project, error) - AddMembers(ctx context.Context, input model.AddMembersInput) (*entity.Project, error) RemoveMembers(ctx context.Context, input model.RemoveMembersInput) (*entity.Project, error) UpdateMembers(ctx context.Context, input model.UpdateMembersInput) (*entity.Project, error) + UpdateProject(ctx context.Context, input model.UpdateProjectInput) (*entity.Project, error) AddAPIToken(ctx context.Context, input *model.APITokenInput) (*entity.APIToken, error) RemoveAPIToken(ctx context.Context, input *model.RemoveAPITokenInput) (*entity.APIToken, error) - SetActiveUserTools(ctx context.Context, input model.SetActiveUserToolsInput) (*entity.User, error) } type ProjectResolver interface { CreationDate(ctx context.Context, obj *entity.Project) (string, error) @@ -193,19 +186,16 @@ type ProjectResolver interface { NeedAccess(ctx context.Context, obj *entity.Project) (bool, error) } type QueryResolver interface { + Capabilities(ctx context.Context) ([]model.Capability, error) + Kubeconfig(ctx context.Context) (string, error) Me(ctx context.Context) (*entity.User, error) - Projects(ctx context.Context) ([]entity.Project, error) Project(ctx context.Context, id string) (*entity.Project, error) - Users(ctx context.Context) ([]entity.User, error) + Projects(ctx context.Context) ([]entity.Project, error) QualityProjectDesc(ctx context.Context, description string) (*model.QualityProjectDesc, error) - Runtimes(ctx context.Context) ([]entity.Runtime, error) - RunningRuntime(ctx context.Context) (*entity.Runtime, error) - Capabilities(ctx context.Context) ([]model.Capability, error) RunningCapability(ctx context.Context) (*model.Capability, error) - Kubeconfig(ctx context.Context) (string, error) -} -type RepositoryResolver interface { - URL(ctx context.Context, obj *entity.Repository) (string, error) + RunningRuntime(ctx context.Context) (*entity.Runtime, error) + Runtimes(ctx context.Context) ([]entity.Runtime, error) + Users(ctx context.Context) ([]entity.User, error) } type SSHKeyResolver interface { CreationDate(ctx context.Context, obj *entity.SSHKey) (string, error) @@ -632,13 +622,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Repository.Error(childComplexity), true - case "Repository.type": - if e.complexity.Repository.Type == nil { - break - } - - return e.complexity.Repository.Type(childComplexity), true - case "Repository.url": if e.complexity.Repository.URL == nil { break @@ -751,20 +734,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ToolUrls.VSCode(childComplexity), true - case "Topic.name": - if e.complexity.Topic.Name == nil { - break - } - - return e.complexity.Topic.Name(childComplexity), true - - case "Topic.relevance": - if e.complexity.Topic.Relevance == nil { - break - } - - return e.complexity.Topic.Relevance(childComplexity), true - case "User.apiTokens": if e.complexity.User.APITokens == nil { break @@ -837,17 +806,14 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec := executionContext{opCtx, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputAddMembersInput, - ec.unmarshalInputAddUserInput, ec.unmarshalInputApiTokenInput, ec.unmarshalInputCreateProjectInput, ec.unmarshalInputDeleteProjectInput, - ec.unmarshalInputExternalRepositoryInput, ec.unmarshalInputRemoveApiTokenInput, ec.unmarshalInputRemoveMembersInput, ec.unmarshalInputRemoveUsersInput, ec.unmarshalInputRepositoryInput, ec.unmarshalInputSetActiveUserToolsInput, - ec.unmarshalInputSetBoolFieldInput, ec.unmarshalInputUpdateAccessLevelInput, ec.unmarshalInputUpdateMembersInput, ec.unmarshalInputUpdateProjectInput, @@ -949,45 +915,33 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er var sources = []*ast.Source{ {Name: "../../../../graphql/schema.graphqls", Input: `type Query { + capabilities: [Capability!]! + kubeconfig: String! me: User! - projects: [Project!]! project(id: ID!): Project! - users: [User!]! + projects: [Project!]! qualityProjectDesc(description: String!): QualityProjectDesc! - runtimes: [Runtime!]! - runningRuntime: Runtime - capabilities: [Capability!]! runningCapability: Capability - kubeconfig: String! + runningRuntime: Runtime + runtimes: [Runtime!]! + users: [User!]! } type Mutation { + regenerateSSHKey: User! removeUsers(input: RemoveUsersInput!): [User!]! + setActiveUserTools(input: SetActiveUserToolsInput!): User! updateAccessLevel(input: UpdateAccessLevelInput!): [User!]! - regenerateSSHKey: User! + + addMembers(input: AddMembersInput!): Project! createProject(input: CreateProjectInput!): Project! - updateProject(input: UpdateProjectInput!): Project! deleteProject(input: DeleteProjectInput!): Project - addMembers(input: AddMembersInput!): Project! removeMembers(input: RemoveMembersInput!): Project! updateMembers(input: UpdateMembersInput!): Project! + updateProject(input: UpdateProjectInput!): Project! + addApiToken(input: ApiTokenInput): ApiToken removeApiToken(input: RemoveApiTokenInput): ApiToken! - setActiveUserTools(input: SetActiveUserToolsInput!): User! -} - -type QualityProjectDesc { - quality: Int! -} - -type Runtime { - id: ID! - name: String! - desc: String! - labels: [String!] - dockerImage: String! - dockerTag: String! - runtimePod: String! } type Capability { @@ -996,18 +950,6 @@ type Capability { default: Boolean! } -type Topic { - name: String! - relevance: Float! -} - -type SSHKey { - public: String! - private: String! - creationDate: String! - lastActivity: String -} - type User { id: ID! username: String! @@ -1020,6 +962,12 @@ type User { sshKey: SSHKey! } +enum AccessLevel { + VIEWER + MANAGER + ADMIN +} + type ApiToken { id: ID! name: String! @@ -1028,6 +976,33 @@ type ApiToken { token: String! } +type SSHKey { + public: String! + private: String! + creationDate: String! + lastActivity: String +} + +type Project { + id: ID! + name: String! + description: String! + favorite: Boolean! + repository: Repository + creationDate: String! + lastActivationDate: String! + error: String + members: [Member!]! + toolUrls: ToolUrls! + needAccess: Boolean! + archived: Boolean! +} + +type Repository { + url: String! + error: String +} + type Member { user: User! accessLevel: AccessLevel! @@ -1041,62 +1016,38 @@ type ToolUrls { mlflow: String! } -enum AccessLevel { - VIEWER - MANAGER - ADMIN -} - -input ApiTokenInput { - userId: ID! - name: String -} - -input UpdateProjectInput { - id: ID! - name: String - description: String - archived: Boolean +type QualityProjectDesc { + quality: Int! } -input DeleteProjectInput { +type Runtime { id: ID! + name: String! + desc: String! + labels: [String!] + dockerImage: String! + dockerTag: String! + runtimePod: String! } -input AddMembersInput { - projectId: ID! - userIds: [ID!]! -} - -input RemoveMembersInput { - projectId: ID! +input RemoveUsersInput { userIds: [ID!]! } -input RemoveApiTokenInput { - apiTokenId: ID! -} - -input UpdateMembersInput { - projectId: ID! - userIds: [ID!]! - accessLevel: AccessLevel! +input SetActiveUserToolsInput { + active: Boolean!, + runtimeId: String, + capabilitiesId: String } -input RemoveUsersInput { +input UpdateAccessLevelInput { userIds: [ID!]! -} - -input AddUserInput { - email: String! - username: String! - password: String! accessLevel: AccessLevel! } -input UpdateAccessLevelInput { +input AddMembersInput { + projectId: ID! userIds: [ID!]! - accessLevel: AccessLevel! } input CreateProjectInput { @@ -1106,58 +1057,47 @@ input CreateProjectInput { repository: RepositoryInput! } -input SetBoolFieldInput { - id: ID! - value: Boolean! +input RepositoryInput { + url: String! + username: String! + credential: String! + authMethod: RepositoryAuthMethod! } -input SetActiveUserToolsInput { - active: Boolean!, - runtimeId: String, - capabilitiesId: String +enum RepositoryAuthMethod { + PASSWORD + TOKEN } -type Project { +input DeleteProjectInput { id: ID! - name: String! - description: String! - favorite: Boolean! - repository: Repository - creationDate: String! - lastActivationDate: String! - error: String - members: [Member!]! - toolUrls: ToolUrls! - needAccess: Boolean! - archived: Boolean! } -input RepositoryInput { - type: RepositoryType! - external: ExternalRepositoryInput +input RemoveMembersInput { + projectId: ID! + userIds: [ID!]! } -input ExternalRepositoryInput { - url: String! - username: String! - credential: String! - authMethod: RepositoryAuthMethod! +input UpdateMembersInput { + projectId: ID! + userIds: [ID!]! + accessLevel: AccessLevel! } -type Repository { - type: RepositoryType! - url: String! - error: String +input UpdateProjectInput { + id: ID! + name: String + description: String + archived: Boolean } -enum RepositoryAuthMethod { - PASSWORD - TOKEN +input ApiTokenInput { + userId: ID! + name: String } -enum RepositoryType { - INTERNAL - EXTERNAL +input RemoveApiTokenInput { + apiTokenId: ID! } `, BuiltIn: false}, } @@ -2191,8 +2131,8 @@ func (ec *executionContext) fieldContext_Member_addedDate(_ context.Context, fie return fc, nil } -func (ec *executionContext) _Mutation_removeUsers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_removeUsers(ctx, field) +func (ec *executionContext) _Mutation_regenerateSSHKey(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_regenerateSSHKey(ctx, field) if err != nil { return graphql.Null } @@ -2205,7 +2145,7 @@ func (ec *executionContext) _Mutation_removeUsers(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RemoveUsers(rctx, fc.Args["input"].(model.RemoveUsersInput)) + return ec.resolvers.Mutation().RegenerateSSHKey(rctx) }) if err != nil { ec.Error(ctx, err) @@ -2217,12 +2157,12 @@ func (ec *executionContext) _Mutation_removeUsers(ctx context.Context, field gra } return graphql.Null } - res := resTmp.([]entity.User) + res := resTmp.(*entity.User) fc.Result = res - return ec.marshalNUser2ᚕgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐUserᚄ(ctx, field.Selections, res) + return ec.marshalNUser2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_removeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_regenerateSSHKey(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -2252,22 +2192,11 @@ func (ec *executionContext) fieldContext_Mutation_removeUsers(ctx context.Contex 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_Mutation_removeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateAccessLevel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateAccessLevel(ctx, field) +func (ec *executionContext) _Mutation_removeUsers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_removeUsers(ctx, field) if err != nil { return graphql.Null } @@ -2280,7 +2209,7 @@ func (ec *executionContext) _Mutation_updateAccessLevel(ctx context.Context, fie }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateAccessLevel(rctx, fc.Args["input"].(model.UpdateAccessLevelInput)) + return ec.resolvers.Mutation().RemoveUsers(rctx, fc.Args["input"].(model.RemoveUsersInput)) }) if err != nil { ec.Error(ctx, err) @@ -2297,7 +2226,7 @@ func (ec *executionContext) _Mutation_updateAccessLevel(ctx context.Context, fie return ec.marshalNUser2ᚕgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐUserᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateAccessLevel(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_removeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -2334,15 +2263,15 @@ func (ec *executionContext) fieldContext_Mutation_updateAccessLevel(ctx context. } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateAccessLevel_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_removeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_regenerateSSHKey(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_regenerateSSHKey(ctx, field) +func (ec *executionContext) _Mutation_setActiveUserTools(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_setActiveUserTools(ctx, field) if err != nil { return graphql.Null } @@ -2355,7 +2284,7 @@ func (ec *executionContext) _Mutation_regenerateSSHKey(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RegenerateSSHKey(rctx) + return ec.resolvers.Mutation().SetActiveUserTools(rctx, fc.Args["input"].(model.SetActiveUserToolsInput)) }) if err != nil { ec.Error(ctx, err) @@ -2372,7 +2301,7 @@ func (ec *executionContext) _Mutation_regenerateSSHKey(ctx context.Context, fiel return ec.marshalNUser2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_regenerateSSHKey(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_setActiveUserTools(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -2402,11 +2331,22 @@ func (ec *executionContext) fieldContext_Mutation_regenerateSSHKey(_ context.Con 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_Mutation_setActiveUserTools_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Mutation_createProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createProject(ctx, field) +func (ec *executionContext) _Mutation_updateAccessLevel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateAccessLevel(ctx, field) if err != nil { return graphql.Null } @@ -2419,7 +2359,7 @@ func (ec *executionContext) _Mutation_createProject(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateProject(rctx, fc.Args["input"].(model.CreateProjectInput)) + return ec.resolvers.Mutation().UpdateAccessLevel(rctx, fc.Args["input"].(model.UpdateAccessLevelInput)) }) if err != nil { ec.Error(ctx, err) @@ -2431,12 +2371,12 @@ func (ec *executionContext) _Mutation_createProject(ctx context.Context, field g } return graphql.Null } - res := resTmp.(*entity.Project) + res := resTmp.([]entity.User) fc.Result = res - return ec.marshalNProject2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐProject(ctx, field.Selections, res) + return ec.marshalNUser2ᚕgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐUserᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createProject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateAccessLevel(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -2445,31 +2385,25 @@ func (ec *executionContext) fieldContext_Mutation_createProject(ctx context.Cont Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Project_id(ctx, field) - case "name": - return ec.fieldContext_Project_name(ctx, field) - case "description": - return ec.fieldContext_Project_description(ctx, field) - case "favorite": - return ec.fieldContext_Project_favorite(ctx, field) - case "repository": - return ec.fieldContext_Project_repository(ctx, field) + return ec.fieldContext_User_id(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) case "creationDate": - return ec.fieldContext_Project_creationDate(ctx, field) - case "lastActivationDate": - return ec.fieldContext_Project_lastActivationDate(ctx, field) - case "error": - return ec.fieldContext_Project_error(ctx, field) - case "members": - return ec.fieldContext_Project_members(ctx, field) - case "toolUrls": - return ec.fieldContext_Project_toolUrls(ctx, field) - case "needAccess": - return ec.fieldContext_Project_needAccess(ctx, field) - case "archived": - return ec.fieldContext_Project_archived(ctx, field) + return ec.fieldContext_User_creationDate(ctx, field) + case "accessLevel": + return ec.fieldContext_User_accessLevel(ctx, field) + case "lastActivity": + return ec.fieldContext_User_lastActivity(ctx, field) + case "apiTokens": + return ec.fieldContext_User_apiTokens(ctx, field) + case "isKubeconfigEnabled": + return ec.fieldContext_User_isKubeconfigEnabled(ctx, field) + case "sshKey": + return ec.fieldContext_User_sshKey(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Project", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { @@ -2479,15 +2413,15 @@ func (ec *executionContext) fieldContext_Mutation_createProject(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createProject_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateAccessLevel_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateProject(ctx, field) +func (ec *executionContext) _Mutation_addMembers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_addMembers(ctx, field) if err != nil { return graphql.Null } @@ -2500,7 +2434,7 @@ func (ec *executionContext) _Mutation_updateProject(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateProject(rctx, fc.Args["input"].(model.UpdateProjectInput)) + return ec.resolvers.Mutation().AddMembers(rctx, fc.Args["input"].(model.AddMembersInput)) }) if err != nil { ec.Error(ctx, err) @@ -2517,7 +2451,7 @@ func (ec *executionContext) _Mutation_updateProject(ctx context.Context, field g return ec.marshalNProject2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐProject(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateProject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_addMembers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -2560,15 +2494,15 @@ func (ec *executionContext) fieldContext_Mutation_updateProject(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateProject_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_addMembers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_deleteProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteProject(ctx, field) +func (ec *executionContext) _Mutation_createProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createProject(ctx, field) if err != nil { return graphql.Null } @@ -2581,21 +2515,24 @@ func (ec *executionContext) _Mutation_deleteProject(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteProject(rctx, fc.Args["input"].(model.DeleteProjectInput)) + return ec.resolvers.Mutation().CreateProject(rctx, fc.Args["input"].(model.CreateProjectInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*entity.Project) fc.Result = res - return ec.marshalOProject2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐProject(ctx, field.Selections, res) + return ec.marshalNProject2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐProject(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteProject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createProject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -2638,15 +2575,15 @@ func (ec *executionContext) fieldContext_Mutation_deleteProject(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteProject_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createProject_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_addMembers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_addMembers(ctx, field) +func (ec *executionContext) _Mutation_deleteProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteProject(ctx, field) if err != nil { return graphql.Null } @@ -2659,24 +2596,21 @@ func (ec *executionContext) _Mutation_addMembers(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().AddMembers(rctx, fc.Args["input"].(model.AddMembersInput)) + return ec.resolvers.Mutation().DeleteProject(rctx, fc.Args["input"].(model.DeleteProjectInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(*entity.Project) fc.Result = res - return ec.marshalNProject2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐProject(ctx, field.Selections, res) + return ec.marshalOProject2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐProject(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_addMembers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteProject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -2719,7 +2653,7 @@ func (ec *executionContext) fieldContext_Mutation_addMembers(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_addMembers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_deleteProject_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -2888,8 +2822,8 @@ func (ec *executionContext) fieldContext_Mutation_updateMembers(ctx context.Cont return fc, nil } -func (ec *executionContext) _Mutation_addApiToken(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_addApiToken(ctx, field) +func (ec *executionContext) _Mutation_updateProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateProject(ctx, field) if err != nil { return graphql.Null } @@ -2902,21 +2836,24 @@ func (ec *executionContext) _Mutation_addApiToken(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().AddAPIToken(rctx, fc.Args["input"].(*model.APITokenInput)) + return ec.resolvers.Mutation().UpdateProject(rctx, fc.Args["input"].(model.UpdateProjectInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*entity.APIToken) + res := resTmp.(*entity.Project) fc.Result = res - return ec.marshalOApiToken2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐAPIToken(ctx, field.Selections, res) + return ec.marshalNProject2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐProject(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_addApiToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateProject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -2925,17 +2862,31 @@ func (ec *executionContext) fieldContext_Mutation_addApiToken(ctx context.Contex Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_ApiToken_id(ctx, field) + return ec.fieldContext_Project_id(ctx, field) case "name": - return ec.fieldContext_ApiToken_name(ctx, field) + return ec.fieldContext_Project_name(ctx, field) + case "description": + return ec.fieldContext_Project_description(ctx, field) + case "favorite": + return ec.fieldContext_Project_favorite(ctx, field) + case "repository": + return ec.fieldContext_Project_repository(ctx, field) case "creationDate": - return ec.fieldContext_ApiToken_creationDate(ctx, field) - case "lastUsedDate": - return ec.fieldContext_ApiToken_lastUsedDate(ctx, field) - case "token": - return ec.fieldContext_ApiToken_token(ctx, field) + return ec.fieldContext_Project_creationDate(ctx, field) + case "lastActivationDate": + return ec.fieldContext_Project_lastActivationDate(ctx, field) + case "error": + return ec.fieldContext_Project_error(ctx, field) + case "members": + return ec.fieldContext_Project_members(ctx, field) + case "toolUrls": + return ec.fieldContext_Project_toolUrls(ctx, field) + case "needAccess": + return ec.fieldContext_Project_needAccess(ctx, field) + case "archived": + return ec.fieldContext_Project_archived(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type ApiToken", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Project", field.Name) }, } defer func() { @@ -2945,15 +2896,15 @@ func (ec *executionContext) fieldContext_Mutation_addApiToken(ctx context.Contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_addApiToken_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateProject_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_removeApiToken(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_removeApiToken(ctx, field) +func (ec *executionContext) _Mutation_addApiToken(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_addApiToken(ctx, field) if err != nil { return graphql.Null } @@ -2966,24 +2917,21 @@ func (ec *executionContext) _Mutation_removeApiToken(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RemoveAPIToken(rctx, fc.Args["input"].(*model.RemoveAPITokenInput)) + return ec.resolvers.Mutation().AddAPIToken(rctx, fc.Args["input"].(*model.APITokenInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(*entity.APIToken) fc.Result = res - return ec.marshalNApiToken2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐAPIToken(ctx, field.Selections, res) + return ec.marshalOApiToken2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐAPIToken(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_removeApiToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_addApiToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -3012,15 +2960,15 @@ func (ec *executionContext) fieldContext_Mutation_removeApiToken(ctx context.Con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_removeApiToken_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_addApiToken_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_setActiveUserTools(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_setActiveUserTools(ctx, field) +func (ec *executionContext) _Mutation_removeApiToken(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_removeApiToken(ctx, field) if err != nil { return graphql.Null } @@ -3033,7 +2981,7 @@ func (ec *executionContext) _Mutation_setActiveUserTools(ctx context.Context, fi }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().SetActiveUserTools(rctx, fc.Args["input"].(model.SetActiveUserToolsInput)) + return ec.resolvers.Mutation().RemoveAPIToken(rctx, fc.Args["input"].(*model.RemoveAPITokenInput)) }) if err != nil { ec.Error(ctx, err) @@ -3045,12 +2993,12 @@ func (ec *executionContext) _Mutation_setActiveUserTools(ctx context.Context, fi } return graphql.Null } - res := resTmp.(*entity.User) + res := resTmp.(*entity.APIToken) fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐUser(ctx, field.Selections, res) + return ec.marshalNApiToken2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐAPIToken(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_setActiveUserTools(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_removeApiToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -3059,25 +3007,17 @@ func (ec *executionContext) fieldContext_Mutation_setActiveUserTools(ctx context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_User_id(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) + return ec.fieldContext_ApiToken_id(ctx, field) + case "name": + return ec.fieldContext_ApiToken_name(ctx, field) case "creationDate": - return ec.fieldContext_User_creationDate(ctx, field) - case "accessLevel": - return ec.fieldContext_User_accessLevel(ctx, field) - case "lastActivity": - return ec.fieldContext_User_lastActivity(ctx, field) - case "apiTokens": - return ec.fieldContext_User_apiTokens(ctx, field) - case "isKubeconfigEnabled": - return ec.fieldContext_User_isKubeconfigEnabled(ctx, field) - case "sshKey": - return ec.fieldContext_User_sshKey(ctx, field) + return ec.fieldContext_ApiToken_creationDate(ctx, field) + case "lastUsedDate": + return ec.fieldContext_ApiToken_lastUsedDate(ctx, field) + case "token": + return ec.fieldContext_ApiToken_token(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 ApiToken", field.Name) }, } defer func() { @@ -3087,7 +3027,7 @@ func (ec *executionContext) fieldContext_Mutation_setActiveUserTools(ctx context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_setActiveUserTools_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_removeApiToken_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -3306,8 +3246,6 @@ func (ec *executionContext) fieldContext_Project_repository(_ context.Context, f IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "type": - return ec.fieldContext_Repository_type(ctx, field) case "url": return ec.fieldContext_Repository_url(ctx, field) case "error": @@ -3686,8 +3624,8 @@ func (ec *executionContext) fieldContext_QualityProjectDesc_quality(_ context.Co return fc, nil } -func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_me(ctx, field) +func (ec *executionContext) _Query_capabilities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_capabilities(ctx, field) if err != nil { return graphql.Null } @@ -3700,7 +3638,7 @@ func (ec *executionContext) _Query_me(ctx context.Context, field graphql.Collect }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Me(rctx) + return ec.resolvers.Query().Capabilities(rctx) }) if err != nil { ec.Error(ctx, err) @@ -3712,12 +3650,12 @@ func (ec *executionContext) _Query_me(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(*entity.User) + res := resTmp.([]model.Capability) fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐUser(ctx, field.Selections, res) + return ec.marshalNCapability2ᚕgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋinfrastructureᚋgraphᚋmodelᚐCapabilityᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_capabilities(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -3726,32 +3664,20 @@ func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graph Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_User_id(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "creationDate": - return ec.fieldContext_User_creationDate(ctx, field) - case "accessLevel": - return ec.fieldContext_User_accessLevel(ctx, field) - case "lastActivity": - return ec.fieldContext_User_lastActivity(ctx, field) - case "apiTokens": - return ec.fieldContext_User_apiTokens(ctx, field) - case "isKubeconfigEnabled": - return ec.fieldContext_User_isKubeconfigEnabled(ctx, field) - case "sshKey": - return ec.fieldContext_User_sshKey(ctx, field) + return ec.fieldContext_Capability_id(ctx, field) + case "name": + return ec.fieldContext_Capability_name(ctx, field) + case "default": + return ec.fieldContext_Capability_default(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 Capability", field.Name) }, } return fc, nil } -func (ec *executionContext) _Query_projects(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_projects(ctx, field) +func (ec *executionContext) _Query_kubeconfig(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_kubeconfig(ctx, field) if err != nil { return graphql.Null } @@ -3764,7 +3690,7 @@ func (ec *executionContext) _Query_projects(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Projects(rctx) + return ec.resolvers.Query().Kubeconfig(rctx) }) if err != nil { ec.Error(ctx, err) @@ -3776,12 +3702,56 @@ func (ec *executionContext) _Query_projects(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]entity.Project) + res := resTmp.(string) fc.Result = res - return ec.marshalNProject2ᚕgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐProjectᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_projects(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_kubeconfig(_ 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) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_me(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Me(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*entity.User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -3790,31 +3760,25 @@ func (ec *executionContext) fieldContext_Query_projects(_ context.Context, field Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Project_id(ctx, field) - case "name": - return ec.fieldContext_Project_name(ctx, field) - case "description": - return ec.fieldContext_Project_description(ctx, field) - case "favorite": - return ec.fieldContext_Project_favorite(ctx, field) - case "repository": - return ec.fieldContext_Project_repository(ctx, field) + return ec.fieldContext_User_id(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) case "creationDate": - return ec.fieldContext_Project_creationDate(ctx, field) - case "lastActivationDate": - return ec.fieldContext_Project_lastActivationDate(ctx, field) - case "error": - return ec.fieldContext_Project_error(ctx, field) - case "members": - return ec.fieldContext_Project_members(ctx, field) - case "toolUrls": - return ec.fieldContext_Project_toolUrls(ctx, field) - case "needAccess": - return ec.fieldContext_Project_needAccess(ctx, field) - case "archived": - return ec.fieldContext_Project_archived(ctx, field) + return ec.fieldContext_User_creationDate(ctx, field) + case "accessLevel": + return ec.fieldContext_User_accessLevel(ctx, field) + case "lastActivity": + return ec.fieldContext_User_lastActivity(ctx, field) + case "apiTokens": + return ec.fieldContext_User_apiTokens(ctx, field) + case "isKubeconfigEnabled": + return ec.fieldContext_User_isKubeconfigEnabled(ctx, field) + case "sshKey": + return ec.fieldContext_User_sshKey(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Project", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil @@ -3901,8 +3865,8 @@ func (ec *executionContext) fieldContext_Query_project(ctx context.Context, fiel return fc, nil } -func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_users(ctx, field) +func (ec *executionContext) _Query_projects(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_projects(ctx, field) if err != nil { return graphql.Null } @@ -3915,7 +3879,7 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Users(rctx) + return ec.resolvers.Query().Projects(rctx) }) if err != nil { ec.Error(ctx, err) @@ -3927,12 +3891,12 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.([]entity.User) + res := resTmp.([]entity.Project) fc.Result = res - return ec.marshalNUser2ᚕgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐUserᚄ(ctx, field.Selections, res) + return ec.marshalNProject2ᚕgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐProjectᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_users(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_projects(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -3941,25 +3905,31 @@ func (ec *executionContext) fieldContext_Query_users(_ context.Context, field gr Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_User_id(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) + return ec.fieldContext_Project_id(ctx, field) + case "name": + return ec.fieldContext_Project_name(ctx, field) + case "description": + return ec.fieldContext_Project_description(ctx, field) + case "favorite": + return ec.fieldContext_Project_favorite(ctx, field) + case "repository": + return ec.fieldContext_Project_repository(ctx, field) case "creationDate": - return ec.fieldContext_User_creationDate(ctx, field) - case "accessLevel": - return ec.fieldContext_User_accessLevel(ctx, field) - case "lastActivity": - return ec.fieldContext_User_lastActivity(ctx, field) - case "apiTokens": - return ec.fieldContext_User_apiTokens(ctx, field) - case "isKubeconfigEnabled": - return ec.fieldContext_User_isKubeconfigEnabled(ctx, field) - case "sshKey": - return ec.fieldContext_User_sshKey(ctx, field) + return ec.fieldContext_Project_creationDate(ctx, field) + case "lastActivationDate": + return ec.fieldContext_Project_lastActivationDate(ctx, field) + case "error": + return ec.fieldContext_Project_error(ctx, field) + case "members": + return ec.fieldContext_Project_members(ctx, field) + case "toolUrls": + return ec.fieldContext_Project_toolUrls(ctx, field) + case "needAccess": + return ec.fieldContext_Project_needAccess(ctx, field) + case "archived": + return ec.fieldContext_Project_archived(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 Project", field.Name) }, } return fc, nil @@ -4024,8 +3994,8 @@ func (ec *executionContext) fieldContext_Query_qualityProjectDesc(ctx context.Co return fc, nil } -func (ec *executionContext) _Query_runtimes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_runtimes(ctx, field) +func (ec *executionContext) _Query_runningCapability(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_runningCapability(ctx, field) if err != nil { return graphql.Null } @@ -4038,24 +4008,21 @@ func (ec *executionContext) _Query_runtimes(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Runtimes(rctx) + return ec.resolvers.Query().RunningCapability(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]entity.Runtime) + res := resTmp.(*model.Capability) fc.Result = res - return ec.marshalNRuntime2ᚕgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRuntimeᚄ(ctx, field.Selections, res) + return ec.marshalOCapability2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋinfrastructureᚋgraphᚋmodelᚐCapability(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_runtimes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_runningCapability(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -4064,21 +4031,13 @@ func (ec *executionContext) fieldContext_Query_runtimes(_ context.Context, field Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Runtime_id(ctx, field) + return ec.fieldContext_Capability_id(ctx, field) case "name": - return ec.fieldContext_Runtime_name(ctx, field) - case "desc": - return ec.fieldContext_Runtime_desc(ctx, field) - case "labels": - return ec.fieldContext_Runtime_labels(ctx, field) - case "dockerImage": - return ec.fieldContext_Runtime_dockerImage(ctx, field) - case "dockerTag": - return ec.fieldContext_Runtime_dockerTag(ctx, field) - case "runtimePod": - return ec.fieldContext_Runtime_runtimePod(ctx, field) + return ec.fieldContext_Capability_name(ctx, field) + case "default": + return ec.fieldContext_Capability_default(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Runtime", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Capability", field.Name) }, } return fc, nil @@ -4141,8 +4100,8 @@ func (ec *executionContext) fieldContext_Query_runningRuntime(_ context.Context, return fc, nil } -func (ec *executionContext) _Query_capabilities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_capabilities(ctx, field) +func (ec *executionContext) _Query_runtimes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_runtimes(ctx, field) if err != nil { return graphql.Null } @@ -4155,7 +4114,7 @@ func (ec *executionContext) _Query_capabilities(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Capabilities(rctx) + return ec.resolvers.Query().Runtimes(rctx) }) if err != nil { ec.Error(ctx, err) @@ -4167,61 +4126,12 @@ func (ec *executionContext) _Query_capabilities(ctx context.Context, field graph } return graphql.Null } - res := resTmp.([]model.Capability) - fc.Result = res - return ec.marshalNCapability2ᚕgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋinfrastructureᚋgraphᚋmodelᚐCapabilityᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_capabilities(_ 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_Capability_id(ctx, field) - case "name": - return ec.fieldContext_Capability_name(ctx, field) - case "default": - return ec.fieldContext_Capability_default(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Capability", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_runningCapability(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_runningCapability(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().RunningCapability(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*model.Capability) + res := resTmp.([]entity.Runtime) fc.Result = res - return ec.marshalOCapability2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋinfrastructureᚋgraphᚋmodelᚐCapability(ctx, field.Selections, res) + return ec.marshalNRuntime2ᚕgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRuntimeᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_runningCapability(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_runtimes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -4230,20 +4140,28 @@ func (ec *executionContext) fieldContext_Query_runningCapability(_ context.Conte Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Capability_id(ctx, field) + return ec.fieldContext_Runtime_id(ctx, field) case "name": - return ec.fieldContext_Capability_name(ctx, field) - case "default": - return ec.fieldContext_Capability_default(ctx, field) + return ec.fieldContext_Runtime_name(ctx, field) + case "desc": + return ec.fieldContext_Runtime_desc(ctx, field) + case "labels": + return ec.fieldContext_Runtime_labels(ctx, field) + case "dockerImage": + return ec.fieldContext_Runtime_dockerImage(ctx, field) + case "dockerTag": + return ec.fieldContext_Runtime_dockerTag(ctx, field) + case "runtimePod": + return ec.fieldContext_Runtime_runtimePod(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Capability", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Runtime", field.Name) }, } return fc, nil } -func (ec *executionContext) _Query_kubeconfig(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_kubeconfig(ctx, field) +func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_users(ctx, field) if err != nil { return graphql.Null } @@ -4256,7 +4174,7 @@ func (ec *executionContext) _Query_kubeconfig(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Kubeconfig(rctx) + return ec.resolvers.Query().Users(rctx) }) if err != nil { ec.Error(ctx, err) @@ -4268,19 +4186,39 @@ func (ec *executionContext) _Query_kubeconfig(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]entity.User) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNUser2ᚕgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐUserᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_kubeconfig(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_users(_ 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) { - 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 "username": + return ec.fieldContext_User_username(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "creationDate": + return ec.fieldContext_User_creationDate(ctx, field) + case "accessLevel": + return ec.fieldContext_User_accessLevel(ctx, field) + case "lastActivity": + return ec.fieldContext_User_lastActivity(ctx, field) + case "apiTokens": + return ec.fieldContext_User_apiTokens(ctx, field) + case "isKubeconfigEnabled": + return ec.fieldContext_User_isKubeconfigEnabled(ctx, field) + case "sshKey": + return ec.fieldContext_User_sshKey(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil @@ -4415,50 +4353,6 @@ func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field return fc, nil } -func (ec *executionContext) _Repository_type(ctx context.Context, field graphql.CollectedField, obj *entity.Repository) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Repository_type(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entity.RepositoryType) - fc.Result = res - return ec.marshalNRepositoryType2githubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRepositoryType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Repository_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - 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 RepositoryType does not have child fields") - }, - } - return fc, nil -} - func (ec *executionContext) _Repository_url(ctx context.Context, field graphql.CollectedField, obj *entity.Repository) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Repository_url(ctx, field) if err != nil { @@ -4473,7 +4367,7 @@ func (ec *executionContext) _Repository_url(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Repository().URL(rctx, obj) + return obj.URL, nil }) if err != nil { ec.Error(ctx, err) @@ -4494,8 +4388,8 @@ func (ec *executionContext) fieldContext_Repository_url(_ context.Context, field fc = &graphql.FieldContext{ Object: "Repository", 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("field of type String does not have child fields") }, @@ -5198,94 +5092,6 @@ func (ec *executionContext) fieldContext_ToolUrls_mlflow(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _Topic_name(ctx context.Context, field graphql.CollectedField, obj *model.Topic) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Topic_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Topic_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Topic", - 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) _Topic_relevance(ctx context.Context, field graphql.CollectedField, obj *model.Topic) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Topic_relevance(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Relevance, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(float64) - fc.Result = res - return ec.marshalNFloat2float64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Topic_relevance(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Topic", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Float does not have child fields") - }, - } - return fc, nil -} - func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *entity.User) (ret graphql.Marshaler) { fc, err := ec.fieldContext_User_id(ctx, field) if err != nil { @@ -7508,54 +7314,6 @@ func (ec *executionContext) unmarshalInputAddMembersInput(ctx context.Context, o return it, nil } -func (ec *executionContext) unmarshalInputAddUserInput(ctx context.Context, obj interface{}) (model.AddUserInput, error) { - var it model.AddUserInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"email", "username", "password", "accessLevel"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "email": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Email = data - case "username": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Username = data - case "password": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Password = data - case "accessLevel": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accessLevel")) - data, err := ec.unmarshalNAccessLevel2githubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐAccessLevel(ctx, v) - if err != nil { - return it, err - } - it.AccessLevel = data - } - } - - return it, nil -} - func (ec *executionContext) unmarshalInputApiTokenInput(ctx context.Context, obj interface{}) (model.APITokenInput, error) { var it model.APITokenInput asMap := map[string]interface{}{} @@ -7650,63 +7408,15 @@ func (ec *executionContext) unmarshalInputDeleteProjectInput(ctx context.Context v, ok := asMap[k] if !ok { continue - } - switch k { - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalNID2string(ctx, v) - if err != nil { - return it, err - } - it.ID = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputExternalRepositoryInput(ctx context.Context, obj interface{}) (model.ExternalRepositoryInput, error) { - var it model.ExternalRepositoryInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"url", "username", "credential", "authMethod"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "url": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.URL = data - case "username": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Username = data - case "credential": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("credential")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Credential = data - case "authMethod": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("authMethod")) - data, err := ec.unmarshalNRepositoryAuthMethod2githubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRepositoryAuthMethod(ctx, v) + } + switch k { + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalNID2string(ctx, v) if err != nil { return it, err } - it.AuthMethod = data + it.ID = data } } @@ -7808,27 +7518,41 @@ func (ec *executionContext) unmarshalInputRepositoryInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"type", "external"} + fieldsInOrder := [...]string{"url", "username", "credential", "authMethod"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "type": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type")) - data, err := ec.unmarshalNRepositoryType2githubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRepositoryType(ctx, v) + case "url": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.URL = data + case "username": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Username = data + case "credential": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("credential")) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - it.Type = data - case "external": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("external")) - data, err := ec.unmarshalOExternalRepositoryInput2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋinfrastructureᚋgraphᚋmodelᚐExternalRepositoryInput(ctx, v) + it.Credential = data + case "authMethod": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("authMethod")) + data, err := ec.unmarshalNRepositoryAuthMethod2githubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRepositoryAuthMethod(ctx, v) if err != nil { return it, err } - it.External = data + it.AuthMethod = data } } @@ -7876,40 +7600,6 @@ func (ec *executionContext) unmarshalInputSetActiveUserToolsInput(ctx context.Co return it, nil } -func (ec *executionContext) unmarshalInputSetBoolFieldInput(ctx context.Context, obj interface{}) (model.SetBoolFieldInput, error) { - var it model.SetBoolFieldInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"id", "value"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalNID2string(ctx, v) - if err != nil { - return it, err - } - it.ID = data - case "value": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) - data, err := ec.unmarshalNBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.Value = data - } - } - - return it, nil -} - func (ec *executionContext) unmarshalInputUpdateAccessLevelInput(ctx context.Context, obj interface{}) (model.UpdateAccessLevelInput, error) { var it model.UpdateAccessLevelInput asMap := map[string]interface{}{} @@ -8279,6 +7969,13 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") + case "regenerateSSHKey": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_regenerateSSHKey(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "removeUsers": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_removeUsers(ctx, field) @@ -8286,30 +7983,30 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateAccessLevel": + case "setActiveUserTools": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateAccessLevel(ctx, field) + return ec._Mutation_setActiveUserTools(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "regenerateSSHKey": + case "updateAccessLevel": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_regenerateSSHKey(ctx, field) + return ec._Mutation_updateAccessLevel(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "createProject": + case "addMembers": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_createProject(ctx, field) + return ec._Mutation_addMembers(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateProject": + case "createProject": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateProject(ctx, field) + return ec._Mutation_createProject(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ @@ -8318,23 +8015,23 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_deleteProject(ctx, field) }) - case "addMembers": + case "removeMembers": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_addMembers(ctx, field) + return ec._Mutation_removeMembers(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "removeMembers": + case "updateMembers": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_removeMembers(ctx, field) + return ec._Mutation_updateMembers(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateMembers": + case "updateProject": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateMembers(ctx, field) + return ec._Mutation_updateProject(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ @@ -8350,13 +8047,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } - case "setActiveUserTools": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_setActiveUserTools(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -8619,7 +8309,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") - case "me": + case "capabilities": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -8628,7 +8318,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_me(ctx, field) + res = ec._Query_capabilities(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -8641,7 +8331,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "projects": + case "kubeconfig": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -8650,7 +8340,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_projects(ctx, field) + res = ec._Query_kubeconfig(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -8663,7 +8353,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "project": + case "me": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -8672,7 +8362,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_project(ctx, field) + res = ec._Query_me(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -8685,7 +8375,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "users": + case "project": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -8694,7 +8384,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_users(ctx, field) + res = ec._Query_project(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -8707,7 +8397,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "qualityProjectDesc": + case "projects": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -8716,7 +8406,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_qualityProjectDesc(ctx, field) + res = ec._Query_projects(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -8729,7 +8419,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "runtimes": + case "qualityProjectDesc": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -8738,7 +8428,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_runtimes(ctx, field) + res = ec._Query_qualityProjectDesc(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -8751,7 +8441,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "runningRuntime": + case "runningCapability": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { @@ -8760,7 +8450,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_runningRuntime(ctx, field) + res = ec._Query_runningCapability(ctx, field) return res } @@ -8770,19 +8460,16 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "capabilities": + case "runningRuntime": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + 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._Query_capabilities(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_runningRuntime(ctx, field) return res } @@ -8792,16 +8479,19 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "runningCapability": + case "runtimes": field := field - innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + 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_runningCapability(ctx, field) + res = ec._Query_runtimes(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } return res } @@ -8811,7 +8501,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "kubeconfig": + case "users": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -8820,7 +8510,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_kubeconfig(ctx, field) + res = ec._Query_users(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -8875,47 +8565,11 @@ func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSe switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Repository") - case "type": - out.Values[i] = ec._Repository_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } case "url": - 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._Repository_url(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.Values[i] = ec._Repository_url(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "error": out.Values[i] = ec._Repository_error(ctx, field, obj) default: @@ -9174,50 +8828,6 @@ func (ec *executionContext) _ToolUrls(ctx context.Context, sel ast.SelectionSet, return out } -var topicImplementors = []string{"Topic"} - -func (ec *executionContext) _Topic(ctx context.Context, sel ast.SelectionSet, obj *model.Topic) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, topicImplementors) - - 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("Topic") - case "name": - out.Values[i] = ec._Topic_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "relevance": - out.Values[i] = ec._Topic_relevance(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 userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *entity.User) graphql.Marshaler { @@ -9865,21 +9475,6 @@ func (ec *executionContext) unmarshalNDeleteProjectInput2githubᚗcomᚋkonstell return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v interface{}) (float64, error) { - res, err := graphql.UnmarshalFloatContext(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - res := graphql.MarshalFloatContext(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return graphql.WrapContextMarshaler(ctx, res) -} - func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalID(v) return res, graphql.ErrorOnPath(ctx, err) @@ -10093,22 +9688,6 @@ func (ec *executionContext) unmarshalNRepositoryInput2ᚖgithubᚗcomᚋkonstell return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalNRepositoryType2githubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRepositoryType(ctx context.Context, v interface{}) (entity.RepositoryType, error) { - tmp, err := graphql.UnmarshalString(v) - res := entity.RepositoryType(tmp) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNRepositoryType2githubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRepositoryType(ctx context.Context, sel ast.SelectionSet, v entity.RepositoryType) graphql.Marshaler { - res := graphql.MarshalString(string(v)) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - func (ec *executionContext) marshalNRuntime2githubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRuntime(ctx context.Context, sel ast.SelectionSet, v entity.Runtime) graphql.Marshaler { return ec._Runtime(ctx, sel, &v) } @@ -10569,14 +10148,6 @@ func (ec *executionContext) marshalOCapability2ᚖgithubᚗcomᚋkonstellation return ec._Capability(ctx, sel, v) } -func (ec *executionContext) unmarshalOExternalRepositoryInput2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋinfrastructureᚋgraphᚋmodelᚐExternalRepositoryInput(ctx context.Context, v interface{}) (*model.ExternalRepositoryInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputExternalRepositoryInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) marshalOProject2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐProject(ctx context.Context, sel ast.SelectionSet, v *entity.Project) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/app/api/infrastructure/graph/model/models_gen.go b/app/api/infrastructure/graph/model/models_gen.go index e732de791..0f8d7c7de 100644 --- a/app/api/infrastructure/graph/model/models_gen.go +++ b/app/api/infrastructure/graph/model/models_gen.go @@ -11,13 +11,6 @@ type AddMembersInput struct { UserIds []string `json:"userIds"` } -type AddUserInput struct { - Email string `json:"email"` - Username string `json:"username"` - Password string `json:"password"` - AccessLevel entity.AccessLevel `json:"accessLevel"` -} - type APITokenInput struct { UserID string `json:"userId"` Name *string `json:"name,omitempty"` @@ -40,13 +33,6 @@ type DeleteProjectInput struct { ID string `json:"id"` } -type ExternalRepositoryInput struct { - URL string `json:"url"` - Username string `json:"username"` - Credential string `json:"credential"` - AuthMethod entity.RepositoryAuthMethod `json:"authMethod"` -} - type Mutation struct { } @@ -71,8 +57,10 @@ type RemoveUsersInput struct { } type RepositoryInput struct { - Type entity.RepositoryType `json:"type"` - External *ExternalRepositoryInput `json:"external,omitempty"` + URL string `json:"url"` + Username string `json:"username"` + Credential string `json:"credential"` + AuthMethod entity.RepositoryAuthMethod `json:"authMethod"` } type SetActiveUserToolsInput struct { @@ -81,16 +69,6 @@ type SetActiveUserToolsInput struct { CapabilitiesID *string `json:"capabilitiesId,omitempty"` } -type SetBoolFieldInput struct { - ID string `json:"id"` - Value bool `json:"value"` -} - -type Topic struct { - Name string `json:"name"` - Relevance float64 `json:"relevance"` -} - type UpdateAccessLevelInput struct { UserIds []string `json:"userIds"` AccessLevel entity.AccessLevel `json:"accessLevel"` diff --git a/app/api/infrastructure/graph/schema.resolvers.go b/app/api/infrastructure/graph/schema.resolvers.go index 2c61b94fe..c2912bce6 100644 --- a/app/api/infrastructure/graph/schema.resolvers.go +++ b/app/api/infrastructure/graph/schema.resolvers.go @@ -29,29 +29,64 @@ func (r *memberResolver) AddedDate(ctx context.Context, obj *entity.Member) (str return obj.AddedDate.Format(time.RFC3339), nil } +// RegenerateSSHKey is the resolver for the regenerateSSHKey field. +func (r *mutationResolver) RegenerateSSHKey(ctx context.Context) (*entity.User, error) { + loggedUser, err := r.getLoggedUser(ctx) + if err != nil { + return nil, err + } + + loggedUser, err = r.users.RegenerateSSHKeys(ctx, loggedUser) + if err != nil { + return nil, err + } + + return &loggedUser, nil +} + // RemoveUsers is the resolver for the removeUsers field. func (r *mutationResolver) RemoveUsers(ctx context.Context, input model.RemoveUsersInput) ([]entity.User, error) { return nil, entity.ErrNotImplemented } +// SetActiveUserTools is the resolver for the setActiveUserTools field. +func (r *mutationResolver) SetActiveUserTools(ctx context.Context, input model.SetActiveUserToolsInput) (*entity.User, error) { + email := ctx.Value(middleware.LoggedUserEmailKey).(string) + + if input.Active { + u, err := r.users.StartTools(ctx, email, input.RuntimeID, input.CapabilitiesID) + return &u, err + } + + u, err := r.users.StopTools(ctx, email) + + return &u, err +} + // UpdateAccessLevel is the resolver for the updateAccessLevel field. func (r *mutationResolver) UpdateAccessLevel(ctx context.Context, input model.UpdateAccessLevelInput) ([]entity.User, error) { return r.users.UpdateAccessLevel(ctx, input.UserIds, input.AccessLevel) } -// RegenerateSSHKey is the resolver for the regenerateSSHKey field. -func (r *mutationResolver) RegenerateSSHKey(ctx context.Context) (*entity.User, error) { +// AddMembers is the resolver for the addMembers field. +func (r *mutationResolver) AddMembers(ctx context.Context, input model.AddMembersInput) (*entity.Project, error) { loggedUser, err := r.getLoggedUser(ctx) if err != nil { return nil, err } - loggedUser, err = r.users.RegenerateSSHKeys(ctx, loggedUser) + users, err := r.users.FindByIDs(ctx, input.UserIds) if err != nil { return nil, err } - return &loggedUser, nil + p, err := r.projects.AddMembers(ctx, project.AddMembersOption{ + ProjectID: input.ProjectID, + Users: users, + LoggedUser: loggedUser, + }) + + return &p, err } // CreateProject is the resolver for the createProject field. @@ -65,17 +100,13 @@ func (r *mutationResolver) CreateProject(ctx context.Context, input model.Create ProjectID: input.ID, Name: input.Name, Description: input.Description, - RepoType: input.Repository.Type, + URL: &input.Repository.URL, + Username: &input.Repository.Username, + Credential: input.Repository.Credential, + AuthMethod: input.Repository.AuthMethod, Owner: loggedUser, } - if input.Repository.External != nil { - opts.ExternalRepoURL = &input.Repository.External.URL - opts.ExternalRepoUsername = &input.Repository.External.Username - opts.ExternalRepoCredential = input.Repository.External.Credential - opts.ExternalRepoAuthMethod = input.Repository.External.AuthMethod - } - createdProject, err := r.projects.Create(ctx, opts) if err != nil { r.logger.Error(err, "Error creating project") @@ -84,18 +115,6 @@ func (r *mutationResolver) CreateProject(ctx context.Context, input model.Create return &createdProject, err } -// UpdateProject is the resolver for the updateProject field. -func (r *mutationResolver) UpdateProject(ctx context.Context, input model.UpdateProjectInput) (*entity.Project, error) { - p, err := r.projects.Update(ctx, project.UpdateProjectOption{ - ProjectID: input.ID, - Name: input.Name, - Description: input.Description, - Archived: input.Archived, - }) - - return &p, err -} - // DeleteProject is the resolver for the deleteProject field. func (r *mutationResolver) DeleteProject(ctx context.Context, input model.DeleteProjectInput) (*entity.Project, error) { loggedUser, err := r.getLoggedUser(ctx) @@ -111,27 +130,6 @@ func (r *mutationResolver) DeleteProject(ctx context.Context, input model.Delete return p, err } -// AddMembers is the resolver for the addMembers field. -func (r *mutationResolver) AddMembers(ctx context.Context, input model.AddMembersInput) (*entity.Project, error) { - loggedUser, err := r.getLoggedUser(ctx) - if err != nil { - return nil, err - } - - users, err := r.users.FindByIDs(ctx, input.UserIds) - if err != nil { - return nil, err - } - - p, err := r.projects.AddMembers(ctx, project.AddMembersOption{ - ProjectID: input.ProjectID, - Users: users, - LoggedUser: loggedUser, - }) - - return &p, err -} - // RemoveMembers is the resolver for the removeMembers field. func (r *mutationResolver) RemoveMembers(ctx context.Context, input model.RemoveMembersInput) (*entity.Project, error) { loggedUser, err := r.getLoggedUser(ctx) @@ -175,6 +173,18 @@ func (r *mutationResolver) UpdateMembers(ctx context.Context, input model.Update return &p, err } +// UpdateProject is the resolver for the updateProject field. +func (r *mutationResolver) UpdateProject(ctx context.Context, input model.UpdateProjectInput) (*entity.Project, error) { + p, err := r.projects.Update(ctx, project.UpdateProjectOption{ + ProjectID: input.ID, + Name: input.Name, + Description: input.Description, + Archived: input.Archived, + }) + + return &p, err +} + // AddAPIToken is the resolver for the addApiToken field. func (r *mutationResolver) AddAPIToken(ctx context.Context, input *model.APITokenInput) (*entity.APIToken, error) { return nil, entity.ErrNotImplemented @@ -185,20 +195,6 @@ func (r *mutationResolver) RemoveAPIToken(ctx context.Context, input *model.Remo return nil, entity.ErrNotImplemented } -// SetActiveUserTools is the resolver for the setActiveUserTools field. -func (r *mutationResolver) SetActiveUserTools(ctx context.Context, input model.SetActiveUserToolsInput) (*entity.User, error) { - email := ctx.Value(middleware.LoggedUserEmailKey).(string) - - if input.Active { - u, err := r.users.StartTools(ctx, email, input.RuntimeID, input.CapabilitiesID) - return &u, err - } - - u, err := r.users.StopTools(ctx, email) - - return &u, err -} - // CreationDate is the resolver for the creationDate field. func (r *projectResolver) CreationDate(ctx context.Context, obj *entity.Project) (string, error) { return obj.CreationDate.Format(time.RFC3339), nil @@ -251,6 +247,25 @@ func (r *projectResolver) NeedAccess(ctx context.Context, obj *entity.Project) ( return true, nil } +// Capabilities is the resolver for the capabilities field. +func (r *queryResolver) Capabilities(ctx context.Context) ([]model.Capability, error) { + return r.capabilities.GetCapabilities(ctx) +} + +// Kubeconfig is the resolver for the kubeconfig field. +func (r *queryResolver) Kubeconfig(ctx context.Context) (string, error) { + email := ctx.Value(middleware.LoggedUserEmailKey).(string) + + user, err := r.users.GetByEmail(ctx, email) + if err != nil { + return "", err + } + + k, err := r.users.GetKubeconfig(ctx, user.Username) + + return k, err +} + // Me is the resolver for the me field. func (r *queryResolver) Me(ctx context.Context) (*entity.User, error) { loggedUser, err := r.getLoggedUser(ctx) @@ -261,11 +276,6 @@ func (r *queryResolver) Me(ctx context.Context) (*entity.User, error) { return &loggedUser, nil } -// Projects is the resolver for the projects field. -func (r *queryResolver) Projects(ctx context.Context) ([]entity.Project, error) { - return r.projects.FindAll(ctx) -} - // Project is the resolver for the project field. func (r *queryResolver) Project(ctx context.Context, id string) (*entity.Project, error) { p, err := r.projects.GetByID(ctx, id) @@ -276,9 +286,9 @@ func (r *queryResolver) Project(ctx context.Context, id string) (*entity.Project return &p, nil } -// Users is the resolver for the users field. -func (r *queryResolver) Users(ctx context.Context) ([]entity.User, error) { - return r.users.FindAll(ctx) +// Projects is the resolver for the projects field. +func (r *queryResolver) Projects(ctx context.Context) ([]entity.Project, error) { + return r.projects.FindAll(ctx) } // QualityProjectDesc is the resolver for the qualityProjectDesc field. @@ -286,15 +296,17 @@ func (r *queryResolver) QualityProjectDesc(ctx context.Context, description stri panic(entity.ErrNotImplemented) // implemented in knowledge galaxy server } -// Runtimes is the resolver for the runtimes field. -func (r *queryResolver) Runtimes(ctx context.Context) ([]entity.Runtime, error) { +// RunningCapability is the resolver for the runningCapability field. +func (r *queryResolver) RunningCapability(ctx context.Context) (*model.Capability, error) { email := ctx.Value(middleware.LoggedUserEmailKey).(string) user, err := r.users.GetByEmail(ctx, email) if err != nil { - return nil, err + return &model.Capability{}, err } - return r.runtimes.GetRuntimes(ctx, user.Username) + + capabilities, err := r.capabilities.GetRunningCapability(ctx, user.Username) + return capabilities, err } // RunningRuntime is the resolver for the runningRuntime field. @@ -309,46 +321,20 @@ func (r *queryResolver) RunningRuntime(ctx context.Context) (*entity.Runtime, er return runtime, err } -// Capabilities is the resolver for the capabilities field. -func (r *queryResolver) Capabilities(ctx context.Context) ([]model.Capability, error) { - return r.capabilities.GetCapabilities(ctx) -} - -// RunningCapability is the resolver for the runningCapability field. -func (r *queryResolver) RunningCapability(ctx context.Context) (*model.Capability, error) { - email := ctx.Value(middleware.LoggedUserEmailKey).(string) - - user, err := r.users.GetByEmail(ctx, email) - if err != nil { - return &model.Capability{}, err - } - - capabilities, err := r.capabilities.GetRunningCapability(ctx, user.Username) - return capabilities, err -} - -// Kubeconfig is the resolver for the kubeconfig field. -func (r *queryResolver) Kubeconfig(ctx context.Context) (string, error) { +// Runtimes is the resolver for the runtimes field. +func (r *queryResolver) Runtimes(ctx context.Context) ([]entity.Runtime, error) { email := ctx.Value(middleware.LoggedUserEmailKey).(string) user, err := r.users.GetByEmail(ctx, email) if err != nil { - return "", err + return nil, err } - - k, err := r.users.GetKubeconfig(ctx, user.Username) - - return k, err + return r.runtimes.GetRuntimes(ctx, user.Username) } -// URL is the resolver for the url field. -func (r *repositoryResolver) URL(ctx context.Context, obj *entity.Repository) (string, error) { - switch obj.Type { - case entity.RepositoryTypeExternal: - return obj.ExternalRepoURL, nil - } - - return "", nil +// Users is the resolver for the users field. +func (r *queryResolver) Users(ctx context.Context) ([]entity.User, error) { + return r.users.FindAll(ctx) } // CreationDate is the resolver for the creationDate field. @@ -400,9 +386,6 @@ func (r *Resolver) Project() generated.ProjectResolver { return &projectResolver // Query returns generated.QueryResolver implementation. func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } -// Repository returns generated.RepositoryResolver implementation. -func (r *Resolver) Repository() generated.RepositoryResolver { return &repositoryResolver{r} } - // SSHKey returns generated.SSHKeyResolver implementation. func (r *Resolver) SSHKey() generated.SSHKeyResolver { return &sSHKeyResolver{r} } @@ -413,6 +396,5 @@ type memberResolver struct{ *Resolver } type mutationResolver struct{ *Resolver } type projectResolver struct{ *Resolver } type queryResolver struct{ *Resolver } -type repositoryResolver struct{ *Resolver } type sSHKeyResolver struct{ *Resolver } type userResolver struct{ *Resolver } diff --git a/app/api/infrastructure/k8s/service_account_test.go b/app/api/infrastructure/k8s/service_account_test.go index c0fb661b6..ea8ee9e70 100644 --- a/app/api/infrastructure/k8s/service_account_test.go +++ b/app/api/infrastructure/k8s/service_account_test.go @@ -12,7 +12,6 @@ import ( const ( saSimpleName = "sa" saName = "sa-service-account" - //nolint:gosec //this is a test saSecretName = "sa-service-account-secret" ) diff --git a/app/api/infrastructure/k8s/user_ssh_test.go b/app/api/infrastructure/k8s/user_ssh_test.go index 37696cd2b..d47ba9683 100644 --- a/app/api/infrastructure/k8s/user_ssh_test.go +++ b/app/api/infrastructure/k8s/user_ssh_test.go @@ -10,8 +10,7 @@ import ( ) const ( - userSSHName = "user" - //nolint:gosec //this is a test + userSSHName = "user" secretSSHName = "user-ssh-keys" ) diff --git a/app/api/infrastructure/mongodb/mongo_test.go b/app/api/infrastructure/mongodb/mongo_test.go index b8fc79942..124b0014f 100644 --- a/app/api/infrastructure/mongodb/mongo_test.go +++ b/app/api/infrastructure/mongodb/mongo_test.go @@ -67,11 +67,10 @@ var projectExamples = map[string]entity.Project{ Archived: false, Error: nil, Repository: entity.Repository{ - Type: entity.RepositoryTypeExternal, - ExternalRepoURL: "http://repo1", - RepoName: "repo1", - Error: nil, - AuthMethod: entity.RepositoryAuthToken, + URL: "http://repo1", + RepoName: "repo1", + Error: nil, + AuthMethod: entity.RepositoryAuthToken, }, Members: []entity.Member{ { @@ -91,11 +90,10 @@ var projectExamples = map[string]entity.Project{ Archived: false, Error: nil, Repository: entity.Repository{ - Type: entity.RepositoryTypeExternal, - ExternalRepoURL: "http://repo2", - RepoName: "repo2", - Error: nil, - AuthMethod: entity.RepositoryAuthToken, + URL: "http://repo2", + RepoName: "repo2", + Error: nil, + AuthMethod: entity.RepositoryAuthToken, }, Members: []entity.Member{ { diff --git a/app/api/infrastructure/mongodb/project.go b/app/api/infrastructure/mongodb/project.go index 1fb563d1a..43a4b4f7e 100644 --- a/app/api/infrastructure/mongodb/project.go +++ b/app/api/infrastructure/mongodb/project.go @@ -31,10 +31,9 @@ type projectDTO struct { Description string `bson:"description"` CreationDate time.Time `bson:"creation_date"` LastActivationDate string `bson:"last_activation_date"` - RepositoryType entity.RepositoryType `bson:"repo_type"` RepoName string `bson:"repo_name"` AuthMethod entity.RepositoryAuthMethod `bson:"auth_method"` - ExternalRepoURL string `bson:"external_repo_url"` + URL string `bson:"url"` Members []memberDTO `bson:"members"` } @@ -244,10 +243,9 @@ func (m *ProjectRepo) entityToDTO(p entity.Project) (projectDTO, error) { Description: p.Description, CreationDate: p.CreationDate, LastActivationDate: p.LastActivationDate, - RepositoryType: p.Repository.Type, RepoName: p.Repository.RepoName, AuthMethod: p.Repository.AuthMethod, - ExternalRepoURL: p.Repository.ExternalRepoURL, + URL: p.Repository.URL, Archived: p.Archived, } @@ -288,10 +286,9 @@ func (m *ProjectRepo) dtoToEntity(dto projectDTO) entity.Project { CreationDate: dto.CreationDate, LastActivationDate: dto.LastActivationDate, Repository: entity.Repository{ - AuthMethod: dto.AuthMethod, - Type: dto.RepositoryType, - ExternalRepoURL: dto.ExternalRepoURL, - RepoName: dto.RepoName, + AuthMethod: dto.AuthMethod, + URL: dto.URL, + RepoName: dto.RepoName, }, Archived: dto.Archived, } diff --git a/app/api/usecase/project/interactor.go b/app/api/usecase/project/interactor.go index a5b6cca14..a1ad5893d 100644 --- a/app/api/usecase/project/interactor.go +++ b/app/api/usecase/project/interactor.go @@ -25,15 +25,14 @@ var ( // CreateProjectOption options when creating project. type CreateProjectOption struct { - ProjectID string - Name string - Description string - RepoType entity.RepositoryType - ExternalRepoURL *string - ExternalRepoUsername *string - ExternalRepoCredential string - ExternalRepoAuthMethod entity.RepositoryAuthMethod - Owner entity.User + ProjectID string + Name string + Description string + URL *string + Username *string + Credential string + AuthMethod entity.RepositoryAuthMethod + Owner entity.User } // DeleteProjectOption options when deleting a project. @@ -76,26 +75,20 @@ func (c CreateProjectOption) Validate() error { return fmt.Errorf("%w: project description cannot be null", ErrCreateProjectValidation) } - if !c.RepoType.IsValid() { - return fmt.Errorf("%w: invalid repository type", ErrCreateProjectValidation) + if kdlutil.IsNilOrEmpty(c.URL) { + return fmt.Errorf("%w: repository URL cannot be null", ErrCreateProjectValidation) } - if c.RepoType == entity.RepositoryTypeExternal { - if kdlutil.IsNilOrEmpty(c.ExternalRepoURL) { - return fmt.Errorf("%w: external repository URL cannot be null", ErrCreateProjectValidation) - } - - if kdlutil.IsNilOrEmpty(c.ExternalRepoUsername) { - return fmt.Errorf("%w: external repository username cannot be null", ErrCreateProjectValidation) - } + if kdlutil.IsNilOrEmpty(c.Username) { + return fmt.Errorf("%w: repository username cannot be null", ErrCreateProjectValidation) + } - if !c.ExternalRepoAuthMethod.IsValid() { - return fmt.Errorf("%w: invalid repository authentication method", ErrCreateProjectValidation) - } + if !c.AuthMethod.IsValid() { + return fmt.Errorf("%w: invalid repository authentication method", ErrCreateProjectValidation) + } - if c.ExternalRepoCredential == "" { - return fmt.Errorf("%w: external repository token cannot be null", ErrCreateProjectValidation) - } + if c.Credential == "" { + return fmt.Errorf("%w: repository token cannot be null", ErrCreateProjectValidation) } return nil @@ -162,9 +155,8 @@ func (i *interactor) Create(ctx context.Context, opt CreateProjectOption) (entit // Set project repository project.Repository = entity.Repository{ - Type: entity.RepositoryTypeExternal, - ExternalRepoURL: *opt.ExternalRepoURL, - RepoName: opt.ProjectID, + URL: *opt.URL, + RepoName: opt.ProjectID, } // Create a k8s KDLProject containing a MLFLow instance diff --git a/app/api/usecase/project/interactor_test.go b/app/api/usecase/project/interactor_test.go index e141f4463..bb186e738 100644 --- a/app/api/usecase/project/interactor_test.go +++ b/app/api/usecase/project/interactor_test.go @@ -76,7 +76,7 @@ func newProjectSuite(t *testing.T) *projectSuite { } } -func TestInteractor_CreateExternal(t *testing.T) { +func TestInteractor_Create(t *testing.T) { s := newProjectSuite(t) defer s.ctrl.Finish() @@ -87,10 +87,10 @@ func TestInteractor_CreateExternal(t *testing.T) { ownerUsername = "john" ) - externalRepoURL := "https://github.com/org/repo.git" - externalRepoUsername := "username" - externalRepoToken := "token" - externalAuthMethod := entity.RepositoryAuthToken + url := "https://github.com/org/repo.git" + username := "username" + token := "token" + authMethod := entity.RepositoryAuthToken ctx := context.Background() now := time.Now().UTC() @@ -105,9 +105,8 @@ func TestInteractor_CreateExternal(t *testing.T) { }, } createProject.Repository = entity.Repository{ - Type: entity.RepositoryTypeExternal, - ExternalRepoURL: externalRepoURL, - RepoName: testProjectID, + URL: url, + RepoName: testProjectID, } expectedProject := entity.Project{ @@ -116,9 +115,8 @@ func TestInteractor_CreateExternal(t *testing.T) { Description: projectDesc, CreationDate: now, Repository: entity.Repository{ - Type: entity.RepositoryTypeExternal, - ExternalRepoURL: externalRepoURL, - RepoName: testProjectID, + URL: url, + RepoName: testProjectID, }, } @@ -130,15 +128,14 @@ func TestInteractor_CreateExternal(t *testing.T) { s.mocks.repo.EXPECT().Get(ctx, testProjectID).Return(expectedProject, nil) createdProject, err := s.interactor.Create(ctx, project.CreateProjectOption{ - ProjectID: testProjectID, - Name: projectName, - Description: projectDesc, - RepoType: entity.RepositoryTypeExternal, - ExternalRepoURL: &externalRepoURL, - ExternalRepoUsername: &externalRepoUsername, - ExternalRepoCredential: externalRepoToken, - ExternalRepoAuthMethod: externalAuthMethod, - Owner: entity.User{ID: ownerUserID, Username: ownerUsername}, + ProjectID: testProjectID, + Name: projectName, + Description: projectDesc, + URL: &url, + Username: &username, + Credential: token, + AuthMethod: authMethod, + Owner: entity.User{ID: ownerUserID, Username: ownerUsername}, }) require.NoError(t, err) @@ -197,7 +194,6 @@ func TestInteractor_AddMembers(t *testing.T) { p.ID = testProjectID p.Members = []entity.Member{adminMember} p.Repository = entity.Repository{ - Type: entity.RepositoryTypeInternal, RepoName: "repo-A", } @@ -258,7 +254,6 @@ func TestInteractor_RemoveMembers(t *testing.T) { {UserID: usersToRemove[1].ID}, } p.Repository = entity.Repository{ - Type: entity.RepositoryTypeInternal, RepoName: "projectRepo-A", } @@ -342,7 +337,6 @@ func TestInteractor_UpdateMembers(t *testing.T) { {UserID: usersToUpd[1].ID}, } p.Repository = entity.Repository{ - Type: entity.RepositoryTypeInternal, RepoName: "projectRepo-A", } @@ -452,9 +446,8 @@ func TestInteractor_Delete(t *testing.T) { Description: "The Project Y Description", CreationDate: now, Repository: entity.Repository{ - Type: entity.RepositoryTypeExternal, - ExternalRepoURL: "https://github.com/org/repo.git", - RepoName: testProjectID, + URL: "https://github.com/org/repo.git", + RepoName: testProjectID, }, Members: []entity.Member{ { @@ -515,9 +508,8 @@ func TestInteractor_Delete_NotAdminUser(t *testing.T) { Description: "The Project Y Description", CreationDate: now, Repository: entity.Repository{ - Type: entity.RepositoryTypeExternal, - ExternalRepoURL: "https://github.com/org/repo.git", - RepoName: testProjectID, + URL: "https://github.com/org/repo.git", + RepoName: testProjectID, }, } diff --git a/app/graphql/schema.graphqls b/app/graphql/schema.graphqls index 72cfbf41a..35bc6deb8 100644 --- a/app/graphql/schema.graphqls +++ b/app/graphql/schema.graphqls @@ -1,43 +1,38 @@ +# This schema.graphqls file uses the following sorting criteria: +# 1. Queries (alphabetical order) +# 2. Mutations (grouped by returned type, then alphabetical order) +# 3. Types and Enums (apparicion order in schema.graphqls) +# 3.1 Types that are contained within other types are to be under the parent type + + type Query { + capabilities: [Capability!]! + kubeconfig: String! me: User! - projects: [Project!]! project(id: ID!): Project! - users: [User!]! + projects: [Project!]! qualityProjectDesc(description: String!): QualityProjectDesc! - runtimes: [Runtime!]! - runningRuntime: Runtime - capabilities: [Capability!]! runningCapability: Capability - kubeconfig: String! + runningRuntime: Runtime + runtimes: [Runtime!]! + users: [User!]! } type Mutation { + regenerateSSHKey: User! removeUsers(input: RemoveUsersInput!): [User!]! + setActiveUserTools(input: SetActiveUserToolsInput!): User! updateAccessLevel(input: UpdateAccessLevelInput!): [User!]! - regenerateSSHKey: User! + + addMembers(input: AddMembersInput!): Project! createProject(input: CreateProjectInput!): Project! - updateProject(input: UpdateProjectInput!): Project! deleteProject(input: DeleteProjectInput!): Project - addMembers(input: AddMembersInput!): Project! removeMembers(input: RemoveMembersInput!): Project! updateMembers(input: UpdateMembersInput!): Project! + updateProject(input: UpdateProjectInput!): Project! + addApiToken(input: ApiTokenInput): ApiToken removeApiToken(input: RemoveApiTokenInput): ApiToken! - setActiveUserTools(input: SetActiveUserToolsInput!): User! -} - -type QualityProjectDesc { - quality: Int! -} - -type Runtime { - id: ID! - name: String! - desc: String! - labels: [String!] - dockerImage: String! - dockerTag: String! - runtimePod: String! } type Capability { @@ -46,18 +41,6 @@ type Capability { default: Boolean! } -type Topic { - name: String! - relevance: Float! -} - -type SSHKey { - public: String! - private: String! - creationDate: String! - lastActivity: String -} - type User { id: ID! username: String! @@ -70,6 +53,12 @@ type User { sshKey: SSHKey! } +enum AccessLevel { + VIEWER + MANAGER + ADMIN +} + type ApiToken { id: ID! name: String! @@ -78,6 +67,33 @@ type ApiToken { token: String! } +type SSHKey { + public: String! + private: String! + creationDate: String! + lastActivity: String +} + +type Project { + id: ID! + name: String! + description: String! + favorite: Boolean! + repository: Repository + creationDate: String! + lastActivationDate: String! + error: String + members: [Member!]! + toolUrls: ToolUrls! + needAccess: Boolean! + archived: Boolean! +} + +type Repository { + url: String! + error: String +} + type Member { user: User! accessLevel: AccessLevel! @@ -91,62 +107,38 @@ type ToolUrls { mlflow: String! } -enum AccessLevel { - VIEWER - MANAGER - ADMIN -} - -input ApiTokenInput { - userId: ID! - name: String -} - -input UpdateProjectInput { - id: ID! - name: String - description: String - archived: Boolean +type QualityProjectDesc { + quality: Int! } -input DeleteProjectInput { +type Runtime { id: ID! + name: String! + desc: String! + labels: [String!] + dockerImage: String! + dockerTag: String! + runtimePod: String! } -input AddMembersInput { - projectId: ID! - userIds: [ID!]! -} - -input RemoveMembersInput { - projectId: ID! +input RemoveUsersInput { userIds: [ID!]! } -input RemoveApiTokenInput { - apiTokenId: ID! -} - -input UpdateMembersInput { - projectId: ID! - userIds: [ID!]! - accessLevel: AccessLevel! +input SetActiveUserToolsInput { + active: Boolean!, + runtimeId: String, + capabilitiesId: String } -input RemoveUsersInput { +input UpdateAccessLevelInput { userIds: [ID!]! -} - -input AddUserInput { - email: String! - username: String! - password: String! accessLevel: AccessLevel! } -input UpdateAccessLevelInput { +input AddMembersInput { + projectId: ID! userIds: [ID!]! - accessLevel: AccessLevel! } input CreateProjectInput { @@ -156,56 +148,45 @@ input CreateProjectInput { repository: RepositoryInput! } -input SetBoolFieldInput { - id: ID! - value: Boolean! +input RepositoryInput { + url: String! + username: String! + credential: String! + authMethod: RepositoryAuthMethod! } -input SetActiveUserToolsInput { - active: Boolean!, - runtimeId: String, - capabilitiesId: String +enum RepositoryAuthMethod { + PASSWORD + TOKEN } -type Project { +input DeleteProjectInput { id: ID! - name: String! - description: String! - favorite: Boolean! - repository: Repository - creationDate: String! - lastActivationDate: String! - error: String - members: [Member!]! - toolUrls: ToolUrls! - needAccess: Boolean! - archived: Boolean! } -input RepositoryInput { - type: RepositoryType! - external: ExternalRepositoryInput +input RemoveMembersInput { + projectId: ID! + userIds: [ID!]! } -input ExternalRepositoryInput { - url: String! - username: String! - credential: String! - authMethod: RepositoryAuthMethod! +input UpdateMembersInput { + projectId: ID! + userIds: [ID!]! + accessLevel: AccessLevel! } -type Repository { - type: RepositoryType! - url: String! - error: String +input UpdateProjectInput { + id: ID! + name: String + description: String + archived: Boolean } -enum RepositoryAuthMethod { - PASSWORD - TOKEN +input ApiTokenInput { + userId: ID! + name: String } -enum RepositoryType { - INTERNAL - EXTERNAL +input RemoveApiTokenInput { + apiTokenId: ID! } diff --git a/docs/upgrade_guides/INTERNAL_REPO_DEPRECATION.md b/docs/upgrade_guides/INTERNAL_REPO_DEPRECATION.md new file mode 100644 index 000000000..80f90429d --- /dev/null +++ b/docs/upgrade_guides/INTERNAL_REPO_DEPRECATION.md @@ -0,0 +1,39 @@ +# DESCRIPTION + +When a new KDL version containing this commit (you can tell so if this upgrade guide still exists) was to be deployed, you will need to take into account some changes and execute the mongodb migration query: + +- There is a breaking change in the Mongo - for the collection "project", a couple of its row have changed: external_repo_url -> url y repo_type -> (deprecated) + +- These are the structures in the graphql.schema that have been deprecated: + type Topic + type SetBoolFieldInput + type AddUserInput + enum RepositoryType + +- These are the structures in the graphql.schema that have been changed: + input RepositoryInput + type Repository + input ExternalRepositoryInput -> RepositoryInput + +## MONGODB MIGRATION GUIDE + +The MongoDB needs to be aligned with the new data structure for the collection `projects`. For that, you will need to execute the following script: + +```mongo +db.projects.updateMany( + {}, + [ + { + $set: { + url: "$external_repo_url" + } + }, + { + $unset: "external_repo_url" + }, + { + $unset: "repo_type" + } + ] +); +``` diff --git a/go.work.sum b/go.work.sum index 7f833ad4d..43a577f99 100644 --- a/go.work.sum +++ b/go.work.sum @@ -101,6 +101,8 @@ golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= From 5cdc44d94a73cc0fc49a4ce56ffe8a1ff651378a Mon Sep 17 00:00:00 2001 From: Alex Rodriguez Fernandez Date: Thu, 19 Dec 2024 10:15:06 +0100 Subject: [PATCH 02/14] feat(api): [KDL6-234] deprecate authMethod and credentials (#1089) Deprecate two unused attributes: authMethod and credentials. These were used during gitea internal repo creation. --- app/api/entity/repository.go | 32 ++----------- .../graph/generated/generated.go | 48 ++++--------------- .../infrastructure/graph/model/models_gen.go | 6 +-- .../infrastructure/graph/schema.resolvers.go | 2 - app/api/infrastructure/mongodb/mongo_test.go | 14 +++--- app/api/infrastructure/mongodb/project.go | 25 +++++----- app/api/usecase/project/interactor.go | 10 ---- app/api/usecase/project/interactor_test.go | 4 -- app/graphql/schema.graphqls | 7 --- .../INTERNAL_REPO_DEPRECATION.md | 7 +++ 10 files changed, 38 insertions(+), 117 deletions(-) diff --git a/app/api/entity/repository.go b/app/api/entity/repository.go index aefbc1e9a..8c68eff9b 100644 --- a/app/api/entity/repository.go +++ b/app/api/entity/repository.go @@ -1,34 +1,8 @@ package entity -// RepositoryAuthMethod is an enum for repository authentication method. -type RepositoryAuthMethod string - -const ( - // RepositoryAuthPassword authentication method. - RepositoryAuthPassword RepositoryAuthMethod = "PASSWORD" - - // RepositoryAuthToken authentication method. - RepositoryAuthToken RepositoryAuthMethod = "TOKEN" -) - -// IsValid checks if the auth method is valid. -func (e RepositoryAuthMethod) IsValid() bool { - if e == RepositoryAuthPassword || e == RepositoryAuthToken { - return true - } - - return false -} - -// String implements the fmt.Stringer interface. -func (e RepositoryAuthMethod) String() string { - return string(e) -} - // Repository entity definition. type Repository struct { - URL string - RepoName string - Error *string - AuthMethod RepositoryAuthMethod + URL string + RepoName string + Error *string } diff --git a/app/api/infrastructure/graph/generated/generated.go b/app/api/infrastructure/graph/generated/generated.go index 7af664cba..a84994a65 100644 --- a/app/api/infrastructure/graph/generated/generated.go +++ b/app/api/infrastructure/graph/generated/generated.go @@ -914,7 +914,14 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var sources = []*ast.Source{ - {Name: "../../../../graphql/schema.graphqls", Input: `type Query { + {Name: "../../../../graphql/schema.graphqls", Input: `# This schema.graphqls file uses the following sorting criteria: +# 1. Queries (alphabetical order) +# 2. Mutations (grouped by returned type, then alphabetical order) +# 3. Types and Enums (apparicion order in schema.graphqls) +# 3.1 Types that are contained within other types are to be under the parent type + + +type Query { capabilities: [Capability!]! kubeconfig: String! me: User! @@ -1060,13 +1067,6 @@ input CreateProjectInput { input RepositoryInput { url: String! username: String! - credential: String! - authMethod: RepositoryAuthMethod! -} - -enum RepositoryAuthMethod { - PASSWORD - TOKEN } input DeleteProjectInput { @@ -7518,7 +7518,7 @@ func (ec *executionContext) unmarshalInputRepositoryInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"url", "username", "credential", "authMethod"} + fieldsInOrder := [...]string{"url", "username"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -7539,20 +7539,6 @@ func (ec *executionContext) unmarshalInputRepositoryInput(ctx context.Context, o return it, err } it.Username = data - case "credential": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("credential")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Credential = data - case "authMethod": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("authMethod")) - data, err := ec.unmarshalNRepositoryAuthMethod2githubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRepositoryAuthMethod(ctx, v) - if err != nil { - return it, err - } - it.AuthMethod = data } } @@ -9667,22 +9653,6 @@ func (ec *executionContext) unmarshalNRemoveUsersInput2githubᚗcomᚋkonstellat return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalNRepositoryAuthMethod2githubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRepositoryAuthMethod(ctx context.Context, v interface{}) (entity.RepositoryAuthMethod, error) { - tmp, err := graphql.UnmarshalString(v) - res := entity.RepositoryAuthMethod(tmp) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNRepositoryAuthMethod2githubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋentityᚐRepositoryAuthMethod(ctx context.Context, sel ast.SelectionSet, v entity.RepositoryAuthMethod) graphql.Marshaler { - res := graphql.MarshalString(string(v)) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - func (ec *executionContext) unmarshalNRepositoryInput2ᚖgithubᚗcomᚋkonstellationᚑioᚋkdlᚑserverᚋappᚋapiᚋinfrastructureᚋgraphᚋmodelᚐRepositoryInput(ctx context.Context, v interface{}) (*model.RepositoryInput, error) { res, err := ec.unmarshalInputRepositoryInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) diff --git a/app/api/infrastructure/graph/model/models_gen.go b/app/api/infrastructure/graph/model/models_gen.go index 0f8d7c7de..84d19bbf6 100644 --- a/app/api/infrastructure/graph/model/models_gen.go +++ b/app/api/infrastructure/graph/model/models_gen.go @@ -57,10 +57,8 @@ type RemoveUsersInput struct { } type RepositoryInput struct { - URL string `json:"url"` - Username string `json:"username"` - Credential string `json:"credential"` - AuthMethod entity.RepositoryAuthMethod `json:"authMethod"` + URL string `json:"url"` + Username string `json:"username"` } type SetActiveUserToolsInput struct { diff --git a/app/api/infrastructure/graph/schema.resolvers.go b/app/api/infrastructure/graph/schema.resolvers.go index c2912bce6..9dacd0fc4 100644 --- a/app/api/infrastructure/graph/schema.resolvers.go +++ b/app/api/infrastructure/graph/schema.resolvers.go @@ -102,8 +102,6 @@ func (r *mutationResolver) CreateProject(ctx context.Context, input model.Create Description: input.Description, URL: &input.Repository.URL, Username: &input.Repository.Username, - Credential: input.Repository.Credential, - AuthMethod: input.Repository.AuthMethod, Owner: loggedUser, } diff --git a/app/api/infrastructure/mongodb/mongo_test.go b/app/api/infrastructure/mongodb/mongo_test.go index 124b0014f..3efa2d719 100644 --- a/app/api/infrastructure/mongodb/mongo_test.go +++ b/app/api/infrastructure/mongodb/mongo_test.go @@ -67,10 +67,9 @@ var projectExamples = map[string]entity.Project{ Archived: false, Error: nil, Repository: entity.Repository{ - URL: "http://repo1", - RepoName: "repo1", - Error: nil, - AuthMethod: entity.RepositoryAuthToken, + URL: "http://repo1", + RepoName: "repo1", + Error: nil, }, Members: []entity.Member{ { @@ -90,10 +89,9 @@ var projectExamples = map[string]entity.Project{ Archived: false, Error: nil, Repository: entity.Repository{ - URL: "http://repo2", - RepoName: "repo2", - Error: nil, - AuthMethod: entity.RepositoryAuthToken, + URL: "http://repo2", + RepoName: "repo2", + Error: nil, }, Members: []entity.Member{ { diff --git a/app/api/infrastructure/mongodb/project.go b/app/api/infrastructure/mongodb/project.go index 43a4b4f7e..ed9797d4b 100644 --- a/app/api/infrastructure/mongodb/project.go +++ b/app/api/infrastructure/mongodb/project.go @@ -25,16 +25,15 @@ type memberDTO struct { } type projectDTO struct { - ID string `bson:"_id"` - Archived bool `bson:"archived"` - Name string `bson:"name"` - Description string `bson:"description"` - CreationDate time.Time `bson:"creation_date"` - LastActivationDate string `bson:"last_activation_date"` - RepoName string `bson:"repo_name"` - AuthMethod entity.RepositoryAuthMethod `bson:"auth_method"` - URL string `bson:"url"` - Members []memberDTO `bson:"members"` + ID string `bson:"_id"` + Archived bool `bson:"archived"` + Name string `bson:"name"` + Description string `bson:"description"` + CreationDate time.Time `bson:"creation_date"` + LastActivationDate string `bson:"last_activation_date"` + RepoName string `bson:"repo_name"` + URL string `bson:"url"` + Members []memberDTO `bson:"members"` } type ProjectRepo struct { @@ -244,7 +243,6 @@ func (m *ProjectRepo) entityToDTO(p entity.Project) (projectDTO, error) { CreationDate: p.CreationDate, LastActivationDate: p.LastActivationDate, RepoName: p.Repository.RepoName, - AuthMethod: p.Repository.AuthMethod, URL: p.Repository.URL, Archived: p.Archived, } @@ -286,9 +284,8 @@ func (m *ProjectRepo) dtoToEntity(dto projectDTO) entity.Project { CreationDate: dto.CreationDate, LastActivationDate: dto.LastActivationDate, Repository: entity.Repository{ - AuthMethod: dto.AuthMethod, - URL: dto.URL, - RepoName: dto.RepoName, + URL: dto.URL, + RepoName: dto.RepoName, }, Archived: dto.Archived, } diff --git a/app/api/usecase/project/interactor.go b/app/api/usecase/project/interactor.go index a1ad5893d..c584498ce 100644 --- a/app/api/usecase/project/interactor.go +++ b/app/api/usecase/project/interactor.go @@ -30,8 +30,6 @@ type CreateProjectOption struct { Description string URL *string Username *string - Credential string - AuthMethod entity.RepositoryAuthMethod Owner entity.User } @@ -83,14 +81,6 @@ func (c CreateProjectOption) Validate() error { return fmt.Errorf("%w: repository username cannot be null", ErrCreateProjectValidation) } - if !c.AuthMethod.IsValid() { - return fmt.Errorf("%w: invalid repository authentication method", ErrCreateProjectValidation) - } - - if c.Credential == "" { - return fmt.Errorf("%w: repository token cannot be null", ErrCreateProjectValidation) - } - return nil } diff --git a/app/api/usecase/project/interactor_test.go b/app/api/usecase/project/interactor_test.go index bb186e738..d9b1cc633 100644 --- a/app/api/usecase/project/interactor_test.go +++ b/app/api/usecase/project/interactor_test.go @@ -89,8 +89,6 @@ func TestInteractor_Create(t *testing.T) { url := "https://github.com/org/repo.git" username := "username" - token := "token" - authMethod := entity.RepositoryAuthToken ctx := context.Background() now := time.Now().UTC() @@ -133,8 +131,6 @@ func TestInteractor_Create(t *testing.T) { Description: projectDesc, URL: &url, Username: &username, - Credential: token, - AuthMethod: authMethod, Owner: entity.User{ID: ownerUserID, Username: ownerUsername}, }) diff --git a/app/graphql/schema.graphqls b/app/graphql/schema.graphqls index 35bc6deb8..f89cb984e 100644 --- a/app/graphql/schema.graphqls +++ b/app/graphql/schema.graphqls @@ -151,13 +151,6 @@ input CreateProjectInput { input RepositoryInput { url: String! username: String! - credential: String! - authMethod: RepositoryAuthMethod! -} - -enum RepositoryAuthMethod { - PASSWORD - TOKEN } input DeleteProjectInput { diff --git a/docs/upgrade_guides/INTERNAL_REPO_DEPRECATION.md b/docs/upgrade_guides/INTERNAL_REPO_DEPRECATION.md index 80f90429d..d2480844f 100644 --- a/docs/upgrade_guides/INTERNAL_REPO_DEPRECATION.md +++ b/docs/upgrade_guides/INTERNAL_REPO_DEPRECATION.md @@ -9,6 +9,10 @@ When a new KDL version containing this commit (you can tell so if this upgrade g type SetBoolFieldInput type AddUserInput enum RepositoryType + enum RepositoryAuthMethod + + RepositoryInput.credential + RepositoryInput.authMethod - These are the structures in the graphql.schema that have been changed: input RepositoryInput @@ -33,6 +37,9 @@ db.projects.updateMany( }, { $unset: "repo_type" + }, + { + $unset: "auth_method" } ] ); From d60289ee719a194daf310441228033fbdd955f16 Mon Sep 17 00:00:00 2001 From: Joan Carballo Cabanes <45364181+joancarballo@users.noreply.github.com> Date: Thu, 19 Dec 2024 12:13:49 +0100 Subject: [PATCH 03/14] feat(ui): [KDL6-130] remove repository type (#1088) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: bump hack kdl-server upgrade (#1030) * chore: bump release * chore: configure Keycloak integration with new values * chore: kdl-server set configuration * chore: [KDL6-107] use keycloak login print --------- Co-authored-by: Igor Prochazka Co-authored-by: Javier Gil * feat(api): [KDL6-5] Create users (#1016) * feat(api): [KDL6-5] Create users As new users are logged in KDL, they need to be created as new users. Meaning, creating new user in database and corresponding k8s resources. Place to insert new user is auth middleware. Add auth middleware tests. Replace usage of user usecase GetByUsername by GetByEmail * feat(api): [KDL6-13] remove gitea from create project (#1034) * chore: bump hack kdl-server upgrade (#1030) * chore: bump release * chore: configure Keycloak integration with new values * chore: kdl-server set configuration * chore: [KDL6-107] use keycloak login print --------- Co-authored-by: Igor Prochazka Co-authored-by: Javier Gil * feat(api): [KDL6-5] Create users (#1016) * feat(api): [KDL6-5] Create users As new users are logged in KDL, they need to be created as new users. Meaning, creating new user in database and corresponding k8s resources. Place to insert new user is auth middleware. Add auth middleware tests. Replace usage of user usecase GetByUsername by GetByEmail * feat(api): [KDL6-13] remove gitea integration when creating a new project --------- Co-authored-by: Iván Alejandro Marugán Co-authored-by: Igor Prochazka * feat(api): [KDL6-143] remove gitea oauth2 setup (#1033) * feat(api): [KDL6-143] remove gitea oauth2 setup * feat(api): [KDL6-143] update rc value * chore: clean values * chore: parametrize template (#1035) * chore: parametrize template * fix: update rc --------- Co-authored-by: Javier Gil * chore: [KDL6-3] eliminate duplicate mount of configjson (#1039) chore: eliminate duplicate config.json mount * feat: [KDL6-3] default oauth2 credentials (#1037) feat: default oauth2 credentials * Fix/disabled usertools vscode (#1040) * fix: parametrize disabled usertools vscode --------- Co-authored-by: ialejandro * ci(github): remove arm64 build * feat(int): add new initial data * fix: latest fixes on values to work in local * fix: update go dependencies * fix: rollback lint issue * feat: remove gitea from api (#1045) * feat: remove gitea from app/api * feat: remove gitea and templates * feat: remove gitea from hack and helm (#1044) feat: remove gitea from hack and helm * fix(hack): improve selfsigned with CA * feat: minio rollback (#1062) * feat(hack): minio rollback version --------- Co-authored-by: ialejandro Co-authored-by: Iván Alejandro Marugán * feat: remove gitea from repo cloner (#1046) * feat: remove gitea from repo-cloner Co-authored-by: Alex Rodriguez Fernandez Signed-off-by: Javier Gil --------- Signed-off-by: Javier Gil Co-authored-by: Alex Rodriguez Fernandez * feat(hackl): remove gitea values (#1063) * feat: release without gitea * ci(github): fix kdl-app ref * feat: remove UserTools secrets not used. Execute cmd go generate * feat(api): [KDL6-181] deprecate repository type * more merging * fix: Added exclude to TSConfig for linting * Deleted external referencies. WIP TS Types problems * Deleted all external references * update graphql types * WIP mock server * fix typo * Deleted commented code * Updated test snaps * fix mocks user * fix schema resolvers * fix generated * Deleted commented code * Updated Readme with graphql/schema and mock-server relation * Updated Tests * Updated Tests * Updated Tests --------- Signed-off-by: Javier Gil Co-authored-by: Iván Alejandro Marugán Co-authored-by: Igor Prochazka Co-authored-by: Javier Gil Co-authored-by: Iván Alejandro Marugán Co-authored-by: Igor Prochazka <160044658+igzor@users.noreply.github.com> Co-authored-by: Alex Rodriguez Fernandez --- app/ui/README.md | 3 +- app/ui/cypress/tsconfig.json | 16 +- app/ui/mock-server/src/mock.js | 15 +- app/ui/mock-server/src/mocks/projectMock.js | 4 +- .../mock-server/src/mocks/repositoryMock.js | 12 +- app/ui/src/Graphql/client/cache.tsx | 24 +- .../src/Graphql/client/hooks/useNewProject.ts | 22 +- .../src/Graphql/client/models/NewProject.ts | 35 +-- app/ui/src/Graphql/mutations/createProject.ts | 1 - .../Graphql/mutations/types/CreateProject.ts | 3 +- .../Graphql/mutations/types/UpdateProject.ts | 3 +- app/ui/src/Graphql/mutations/updateProject.ts | 1 - app/ui/src/Graphql/queries/getProjects.ts | 1 - .../src/Graphql/queries/types/GetProjects.ts | 3 +- app/ui/src/Graphql/types/globalTypes.ts | 18 +- app/ui/src/Mocks/entities/project.ts | 2 - app/ui/src/Pages/NewProject/NewProject.tsx | 21 +- .../pages/Repository/Repository.tsx | 7 +- .../RepositoryDetails/RepositoryDetails.tsx | 4 +- .../ExternalRepository/ExternalRepository.tsx | 10 +- .../NewProject/pages/Summary/Summary.tsx | 6 +- .../Pages/Project/pages/Overview/Overview.tsx | 8 +- .../components/TabGit/TabGit.tsx | 14 +- .../Pages/ProjectCreation/ProjectCreation.tsx | 16 +- .../__snapshots__/Projects.test.tsx.snap | 14 +- .../Projects/components/Project/Project.tsx | 7 +- .../__snapshots__/Project.test.tsx.snap | 7 +- app/ui/test-report.xml | 220 ++++++++++++++++++ 28 files changed, 311 insertions(+), 186 deletions(-) create mode 100644 app/ui/test-report.xml diff --git a/app/ui/README.md b/app/ui/README.md index b2a4994ad..0b080d3c6 100644 --- a/app/ui/README.md +++ b/app/ui/README.md @@ -7,6 +7,7 @@ You can access contributing documentation [here](./docs/contributing.md). To initialize the development environment: 1. Run the mock-server +- The mock-server uses the same graphql schema as the real server, but it returns mock data. To update the schema check "Other scripts" section. ```bash # Go to kdl-server/app/ui/mock-server cd mock-server @@ -90,7 +91,7 @@ yarn audit:fix ## Available Scripts -* Regenerate all `interfaces`, `types` and `enums` for the graphql queries and schema used. +* Regenerate all `interfaces`, `types` and `enums` for the graphql queries and schema used. This schema is used to generate types for the frontend and is used by the real backend and mock-server (without doing anything in the mock-server code). ```bash yarn gen:types ``` diff --git a/app/ui/cypress/tsconfig.json b/app/ui/cypress/tsconfig.json index d3e3e2f7e..e4052ca74 100644 --- a/app/ui/cypress/tsconfig.json +++ b/app/ui/cypress/tsconfig.json @@ -4,15 +4,25 @@ "*/*.ts" ], "exclude": [ - "node_modules/*/*.*", "**/*.spec.js", "**/*.spec.ts", "**/*.spec.tsx", "**/*.d.ts", "cypress/*" + "node_modules/*/*.*", + "**/*.spec.js", + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.d.ts", + "cypress/*" + ], + "types": [ + "node" ], - "types":["node"], "jsx": "react-jsx", "moduleResolution": "node", "compilerOptions": { "noEmit": false, "isolatedModules": false, - "types": ["cypress", "node"], + "types": [ + "cypress", + "node" + ], "paths": { "@/*": [ "./src/*" diff --git a/app/ui/mock-server/src/mock.js b/app/ui/mock-server/src/mock.js index c2736deee..ced44da1a 100644 --- a/app/ui/mock-server/src/mock.js +++ b/app/ui/mock-server/src/mock.js @@ -42,9 +42,7 @@ module.exports = { }, removeMembers: (_, { input: { projectId, userIds } }) => { const project = projects.find(({ id }) => id === projectId); - project.members = project.members.filter( - ({ user }) => !userIds.includes(user.id) - ); + project.members = project.members.filter(({ user }) => !userIds.includes(user.id)); return project; }, @@ -58,9 +56,9 @@ module.exports = { return project; }, - deleteProject:(_, { input: { id }}) => { + deleteProject: (_, { input: { id } }) => { const project = projects.find((p) => p.id === id); - projects = projects.filter(p => p.id !== id) + projects = projects.filter((p) => p.id !== id); return project; }, removeApiToken: (_, { input: { apiTokenId } }) => ({ @@ -91,11 +89,8 @@ module.exports = { ...casualProject, ...input, repository: { - type: input.repository.type, - url: - input.repository.type === 'INTERNAL' - ? `${casual.url}${input.id}` - : input.repository.external.url, + url: input.repository.url, + username: input.repository.username, error: false, }, members: [meAsMember], diff --git a/app/ui/mock-server/src/mocks/projectMock.js b/app/ui/mock-server/src/mocks/projectMock.js index f67b816a1..8f6478b73 100644 --- a/app/ui/mock-server/src/mocks/projectMock.js +++ b/app/ui/mock-server/src/mocks/projectMock.js @@ -16,12 +16,12 @@ function buildProject(_, index) { needAccess: index < activeProjectsCount ? false : casual.boolean, members: buildRandomMembers(casual.integer(1, 5)), archived: index < activeProjectsCount ? false : casual.boolean, - toolUrls: () => ({ + toolUrls: { knowledgeGalaxy: 'https://filebrowser.org/', filebrowser: 'https://filebrowser.org/', vscode: 'https://code.visualstudio.com/', mlflow: 'https://mlflow.org/', - }), + }, }; } diff --git a/app/ui/mock-server/src/mocks/repositoryMock.js b/app/ui/mock-server/src/mocks/repositoryMock.js index 59791495f..f1028d0d3 100644 --- a/app/ui/mock-server/src/mocks/repositoryMock.js +++ b/app/ui/mock-server/src/mocks/repositoryMock.js @@ -1,18 +1,10 @@ const casual = require('casual'); function buildRepository() { - const type = casual.random_element(['INTERNAL', 'EXTERNAL']); - let url = casual.url; - if (type === 'INTERNAL') - url = `${casual.url}${casual.array_of_words(3).join('-')}`; - return { - type, - url, + url: casual.url, error: casual.boolean, - external: { - username: casual.username, - }, + username: casual.username, }; } diff --git a/app/ui/src/Graphql/client/cache.tsx b/app/ui/src/Graphql/client/cache.tsx index 02d8e6a4d..25776aa07 100644 --- a/app/ui/src/Graphql/client/cache.tsx +++ b/app/ui/src/Graphql/client/cache.tsx @@ -31,12 +31,6 @@ export const initialNewProject: NewProject = { }, }, repository: { - values: { - type: null, - }, - errors: { type: 'Please choose a repo type' }, - }, - externalRepository: { values: { url: '', username: '', @@ -47,9 +41,25 @@ export const initialNewProject: NewProject = { url: 'This field is mandatory', credential: 'This field is mandatory', username: 'This field is mandatory', - authMethod: 'This field is mandatory', + authMethod: RepositoryAuthMethod.TOKEN, + type: 'Repo type is wrong', }, + // errors: { type: 'Please choose a repo type' }, }, + // externalRepository: { + // values: { + // url: '', + // username: '', + // credential: '', + // authMethod: RepositoryAuthMethod.TOKEN, + // }, + // errors: { + // url: 'This field is mandatory', + // credential: 'This field is mandatory', + // username: 'This field is mandatory', + // authMethod: 'This field is mandatory', + // }, + // }, }; const initialStateUserSettings: UserSettings = { diff --git a/app/ui/src/Graphql/client/hooks/useNewProject.ts b/app/ui/src/Graphql/client/hooks/useNewProject.ts index c9f2215c0..a79057744 100644 --- a/app/ui/src/Graphql/client/hooks/useNewProject.ts +++ b/app/ui/src/Graphql/client/hooks/useNewProject.ts @@ -1,8 +1,4 @@ import { - ExternalRepositoryValues, - ExternalRepositoryErrors, - InternalRepositoryValues, - InternalRepositoryErrors, InformationErrors, InformationValues, NewProject, @@ -14,14 +10,7 @@ import { initialNewProject, newProject } from '../cache'; import { cloneDeep } from 'lodash'; function useNewProject(section: keyof NewProject) { - function updateValue( - key: - | keyof InformationValues - | keyof RepositoryValues - | keyof ExternalRepositoryValues - | keyof InternalRepositoryValues, - value: string | boolean, - ) { + function updateValue(key: keyof InformationValues | keyof RepositoryValues, value: string | boolean) { const newState = cloneDeep(newProject()); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore @@ -30,14 +19,7 @@ function useNewProject(section: keyof NewProject) { newProject(newState); } - function updateError( - key: - | keyof InformationErrors - | keyof RepositoryErrors - | keyof ExternalRepositoryErrors - | keyof InternalRepositoryErrors, - value: string, - ) { + function updateError(key: keyof InformationErrors | keyof RepositoryErrors, value: string) { const newState = cloneDeep(newProject()); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore diff --git a/app/ui/src/Graphql/client/models/NewProject.ts b/app/ui/src/Graphql/client/models/NewProject.ts index bdd8ee12c..c51360f93 100644 --- a/app/ui/src/Graphql/client/models/NewProject.ts +++ b/app/ui/src/Graphql/client/models/NewProject.ts @@ -1,4 +1,4 @@ -import { RepositoryAuthMethod, RepositoryType } from 'Graphql/types/globalTypes'; +import { RepositoryAuthMethod } from 'Graphql/types/globalTypes'; export interface InformationValues { id: string; @@ -13,43 +13,23 @@ export interface InformationErrors { } export interface RepositoryValues { - type: RepositoryType | null; -} - -export interface RepositoryErrors { - type: string; -} - -export interface ExternalRepositoryValues { url: string; username: string; credential: string; authMethod: RepositoryAuthMethod; } -export interface ExternalRepositoryErrors { +export interface RepositoryErrors { + type: string; url: string; username: string; credential: string; - authMethod: string; -} - -export interface InternalRepositoryValues { - slug: string; -} - -export interface InternalRepositoryErrors { - slug: string; -} - -export interface NewProject_ExternalRepository { - values: ExternalRepositoryValues; - errors: ExternalRepositoryErrors; + authMethod: RepositoryAuthMethod; } -export interface NewProject_InternalRepository { - values: InternalRepositoryValues; - errors: InternalRepositoryErrors; +export interface NewProject_Repository { + values: RepositoryValues; + errors: RepositoryErrors; } export interface NewProject_Information { @@ -65,5 +45,4 @@ export interface NewProject_Repository { export interface NewProject { information: NewProject_Information; repository: NewProject_Repository; - externalRepository: NewProject_ExternalRepository; } diff --git a/app/ui/src/Graphql/mutations/createProject.ts b/app/ui/src/Graphql/mutations/createProject.ts index cb140bbc2..7bf541ca8 100644 --- a/app/ui/src/Graphql/mutations/createProject.ts +++ b/app/ui/src/Graphql/mutations/createProject.ts @@ -10,7 +10,6 @@ export default gql` creationDate lastActivationDate repository { - type url error } diff --git a/app/ui/src/Graphql/mutations/types/CreateProject.ts b/app/ui/src/Graphql/mutations/types/CreateProject.ts index dd06124af..7656d25c5 100644 --- a/app/ui/src/Graphql/mutations/types/CreateProject.ts +++ b/app/ui/src/Graphql/mutations/types/CreateProject.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { CreateProjectInput, RepositoryType } from "./../../types/globalTypes"; +import { CreateProjectInput } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: CreateProject @@ -11,7 +11,6 @@ import { CreateProjectInput, RepositoryType } from "./../../types/globalTypes"; export interface CreateProject_createProject_repository { __typename: "Repository"; - type: RepositoryType; url: string; error: string | null; } diff --git a/app/ui/src/Graphql/mutations/types/UpdateProject.ts b/app/ui/src/Graphql/mutations/types/UpdateProject.ts index fc6df53fa..b54da3dba 100644 --- a/app/ui/src/Graphql/mutations/types/UpdateProject.ts +++ b/app/ui/src/Graphql/mutations/types/UpdateProject.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { UpdateProjectInput, RepositoryType } from "./../../types/globalTypes"; +import { UpdateProjectInput } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UpdateProject @@ -12,7 +12,6 @@ import { UpdateProjectInput, RepositoryType } from "./../../types/globalTypes"; export interface UpdateProject_updateProject_repository { __typename: "Repository"; error: string | null; - type: RepositoryType; url: string; } diff --git a/app/ui/src/Graphql/mutations/updateProject.ts b/app/ui/src/Graphql/mutations/updateProject.ts index 4fe7e49c7..6c80bf94d 100644 --- a/app/ui/src/Graphql/mutations/updateProject.ts +++ b/app/ui/src/Graphql/mutations/updateProject.ts @@ -8,7 +8,6 @@ export default gql` description repository { error - type url } archived diff --git a/app/ui/src/Graphql/queries/getProjects.ts b/app/ui/src/Graphql/queries/getProjects.ts index 7b9004267..99c6e01bc 100644 --- a/app/ui/src/Graphql/queries/getProjects.ts +++ b/app/ui/src/Graphql/queries/getProjects.ts @@ -12,7 +12,6 @@ export default gql` creationDate lastActivationDate repository { - type url error } diff --git a/app/ui/src/Graphql/queries/types/GetProjects.ts b/app/ui/src/Graphql/queries/types/GetProjects.ts index 50d5cbe65..34ddf4bce 100644 --- a/app/ui/src/Graphql/queries/types/GetProjects.ts +++ b/app/ui/src/Graphql/queries/types/GetProjects.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { RepositoryType, AccessLevel } from "./../../types/globalTypes"; +import { AccessLevel } from "./../../types/globalTypes"; // ==================================================== // GraphQL query operation: GetProjects @@ -11,7 +11,6 @@ import { RepositoryType, AccessLevel } from "./../../types/globalTypes"; export interface GetProjects_projects_repository { __typename: "Repository"; - type: RepositoryType; url: string; error: string | null; } diff --git a/app/ui/src/Graphql/types/globalTypes.ts b/app/ui/src/Graphql/types/globalTypes.ts index 2454e65d2..c4a1177da 100644 --- a/app/ui/src/Graphql/types/globalTypes.ts +++ b/app/ui/src/Graphql/types/globalTypes.ts @@ -18,11 +18,6 @@ export enum RepositoryAuthMethod { TOKEN = "TOKEN", } -export enum RepositoryType { - EXTERNAL = "EXTERNAL", - INTERNAL = "INTERNAL", -} - export interface AddMembersInput { projectId: string; userIds: string[]; @@ -44,13 +39,6 @@ export interface DeleteProjectInput { id: string; } -export interface ExternalRepositoryInput { - url: string; - username: string; - credential: string; - authMethod: RepositoryAuthMethod; -} - export interface RemoveApiTokenInput { apiTokenId: string; } @@ -61,8 +49,10 @@ export interface RemoveMembersInput { } export interface RepositoryInput { - type: RepositoryType; - external?: ExternalRepositoryInput | null; + url: string; + username: string; + credential: string; + authMethod: RepositoryAuthMethod; } export interface SetActiveUserToolsInput { diff --git a/app/ui/src/Mocks/entities/project.ts b/app/ui/src/Mocks/entities/project.ts index cf137400c..de1d01fbd 100644 --- a/app/ui/src/Mocks/entities/project.ts +++ b/app/ui/src/Mocks/entities/project.ts @@ -1,5 +1,4 @@ import { memberMe, member1, member2 } from './member'; -import { RepositoryType } from '../../Graphql/types/globalTypes'; const toolUrls = { knowledgeGalaxy: 'https://knowledgeGalaxy', @@ -16,7 +15,6 @@ export const project1 = { creationDate: '2020-02-02', lastActivationDate: '2020-02-02', repository: { - type: RepositoryType.EXTERNAL, url: 'https://my-super-url.com', error: false, }, diff --git a/app/ui/src/Pages/NewProject/NewProject.tsx b/app/ui/src/Pages/NewProject/NewProject.tsx index 3365b5210..1a40943e0 100644 --- a/app/ui/src/Pages/NewProject/NewProject.tsx +++ b/app/ui/src/Pages/NewProject/NewProject.tsx @@ -6,7 +6,6 @@ import DefaultPage from 'Components/Layout/Page/DefaultPage/DefaultPage'; import Information from './pages/Information/Information'; import ROUTE from 'Constants/routes'; import RepositoryDetails from './pages/RepositoryDetails/RepositoryDetails'; -import { RepositoryType } from 'Graphql/types/globalTypes'; import Stepper from 'Components/Stepper/Stepper'; import Summary from './pages/Summary/Summary'; import cx from 'classnames'; @@ -31,8 +30,6 @@ enum StepNames { INFORMATION = 'information', REPOSITORY = 'repository', DETAILS = 'repository details', - EXTERNAL = 'externalRepository', - INTERNAL = 'internalRepository', SUMMARY = 'summary', } @@ -51,12 +48,6 @@ const stepperSteps = [ }, ]; -export const repoTypeToStepName: { - [k: string]: StepNames.EXTERNAL; -} = { - [RepositoryType.EXTERNAL]: StepNames.EXTERNAL, -}; - function NewProject() { const history = useHistory(); const { clearAll } = useNewProject('information'); @@ -65,13 +56,11 @@ function NewProject() { const [isPromptEnabled, setIsPromptEnabled] = useState(false); const { enableUnloadPrompt, disableUnloadPrompt } = useUnloadPrompt(); - const data = useReactiveVar(newProject); - - const type = data.repository.values.type; + const data: { [key in StepNames.INFORMATION | StepNames.DETAILS]?: any } = useReactiveVar(newProject); - const stepsWithData: (StepNames.INFORMATION | StepNames.EXTERNAL)[] = useMemo(() => { - return [StepNames.INFORMATION, repoTypeToStepName[type || '']]; - }, [type]); + const stepsWithData: (StepNames.INFORMATION | StepNames.DETAILS)[] = useMemo(() => { + return [StepNames.INFORMATION]; + }, []); // We want to execute this on on component mount and unmount // eslint-disable-next-line react-hooks/exhaustive-deps @@ -165,7 +154,7 @@ function NewProject() { switch (step) { case StepNames.INFORMATION: return ; - case StepNames.EXTERNAL: + case StepNames.DETAILS: return ; default: return <>; diff --git a/app/ui/src/Pages/NewProject/pages/Repository/Repository.tsx b/app/ui/src/Pages/NewProject/pages/Repository/Repository.tsx index 387945eca..4e50604ea 100644 --- a/app/ui/src/Pages/NewProject/pages/Repository/Repository.tsx +++ b/app/ui/src/Pages/NewProject/pages/Repository/Repository.tsx @@ -1,7 +1,6 @@ import RepositoryTypeComponent, { LOCATION } from './components/RepositoryTypeComponent/RepositoryTypeComponent'; import * as React from 'react'; import RepositoryOption from './components/RepositoryOption/RepositoryOption'; -import { RepositoryType } from 'Graphql/types/globalTypes'; import cx from 'classnames'; import styles from './Repository.module.scss'; import useNewProject from 'Graphql/client/hooks/useNewProject'; @@ -19,18 +18,16 @@ function Repository(params: { showErrors: boolean }) {
{ clearError('type'); - updateValue('type', RepositoryType.EXTERNAL); }} Repository={} /> diff --git a/app/ui/src/Pages/NewProject/pages/RepositoryDetails/RepositoryDetails.tsx b/app/ui/src/Pages/NewProject/pages/RepositoryDetails/RepositoryDetails.tsx index 24466ac37..779a1aefc 100644 --- a/app/ui/src/Pages/NewProject/pages/RepositoryDetails/RepositoryDetails.tsx +++ b/app/ui/src/Pages/NewProject/pages/RepositoryDetails/RepositoryDetails.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import ExternalRepository from './components/ExternalRepository/ExternalRepository'; +import Repository from './components/ExternalRepository/ExternalRepository'; type Props = { showErrors: boolean; @@ -8,7 +8,7 @@ type Props = { function RepositoryDetails({ showErrors }: Props) { return (
- +
); } diff --git a/app/ui/src/Pages/NewProject/pages/RepositoryDetails/components/ExternalRepository/ExternalRepository.tsx b/app/ui/src/Pages/NewProject/pages/RepositoryDetails/components/ExternalRepository/ExternalRepository.tsx index 80a92af58..fc84ceab2 100644 --- a/app/ui/src/Pages/NewProject/pages/RepositoryDetails/components/ExternalRepository/ExternalRepository.tsx +++ b/app/ui/src/Pages/NewProject/pages/RepositoryDetails/components/ExternalRepository/ExternalRepository.tsx @@ -15,20 +15,20 @@ type Props = { const authMethods = [RepositoryAuthMethod.PASSWORD, RepositoryAuthMethod.TOKEN]; -function ExternalRepository({ showErrors }: Props) { +function Repository({ showErrors }: Props) { const project = useReactiveVar(newProject); - const { updateValue, updateError, clearError } = useNewProject('externalRepository'); + const { updateValue, updateError, clearError } = useNewProject('repository'); if (!project) return ; const { values: { url, credential, username, authMethod }, errors: { url: urlError, credential: credentialError, username: usernameError, authMethod: authMethodError }, - } = project.externalRepository; + } = project.repository; return (
-

Your external repository

+

Your repository

= ({ title, children }) => ( ); function Summary() { - const { information, externalRepository } = useReactiveVar(newProject); + const { information, repository } = useReactiveVar(newProject); const { name, description, id } = information.values; return ( @@ -46,8 +46,8 @@ function Summary() {
-

{externalRepository.values.url}

- {externalRepository.values.url} +

{repository.values.url}

+ {repository.values.url}
diff --git a/app/ui/src/Pages/Project/pages/Overview/Overview.tsx b/app/ui/src/Pages/Project/pages/Overview/Overview.tsx index ba0f72df5..6b0ea83b2 100644 --- a/app/ui/src/Pages/Project/pages/Overview/Overview.tsx +++ b/app/ui/src/Pages/Project/pages/Overview/Overview.tsx @@ -7,7 +7,6 @@ import RepositoryTypeComponent, { import DescriptionScore from 'Components/DescriptionScore/DescriptionScore'; import { GetProjects_projects } from 'Graphql/queries/types/GetProjects'; import * as React from 'react'; -import { RepositoryType } from 'Graphql/types/globalTypes'; import styles from './Overview.module.scss'; import useQualityDescription from 'Hooks/useQualityDescription/useQualityDescription'; import useSettingTabs from 'Graphql/client/hooks/useSettingTabs'; @@ -70,12 +69,7 @@ function Overview({ openedProject }: Props) {
- -

{`${openedProject.repository?.type} REPOSITORY`}

+
; if (!repository || error) return ; - const isExternal = repository.type === RepositoryType.EXTERNAL; - return (
- -

{`${repository.type} REPOSITORY`}

+

{repository.url}

diff --git a/app/ui/src/Pages/ProjectCreation/ProjectCreation.tsx b/app/ui/src/Pages/ProjectCreation/ProjectCreation.tsx index c819c1787..d69d731bd 100644 --- a/app/ui/src/Pages/ProjectCreation/ProjectCreation.tsx +++ b/app/ui/src/Pages/ProjectCreation/ProjectCreation.tsx @@ -1,7 +1,6 @@ import { Button } from 'kwc'; import ROUTE, { buildRoute } from 'Constants/routes'; import React, { useEffect, useState } from 'react'; -import { RepositoryInput, RepositoryType } from 'Graphql/types/globalTypes'; import StatusCircle, { States } from 'Components/LottieShapes/StatusCircle/StatusCircle'; import styles from './ProjectCreation.module.scss'; @@ -22,7 +21,7 @@ function ProjectCreation() { create: { data: createData, error: createError }, } = useProject(); - const { repository, information, externalRepository } = useReactiveVar(newProject); + const { repository, information } = useReactiveVar(newProject); const error = animationFinished && !!createError; const success = animationFinished && !!createData; @@ -37,24 +36,15 @@ function ProjectCreation() { }, []); useEffect(() => { - // If the user reload the page he/she will be redirected to the home + // If the user reloads the page, they will be redirected to the home screen if (!information.values.id) { history.push(ROUTE.HOME); return; } - const type = repository.values.type || RepositoryType.EXTERNAL; - - const inputRepository: RepositoryInput = { - type, - }; - - if (type === RepositoryType.EXTERNAL) { - inputRepository.external = externalRepository.values; - } addNewProject({ ...information.values, - repository: inputRepository, + repository: repository.values, }); // We want to execute this on on component mount // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/app/ui/src/Pages/Projects/__snapshots__/Projects.test.tsx.snap b/app/ui/src/Pages/Projects/__snapshots__/Projects.test.tsx.snap index 8e2808d75..3a98b90f2 100644 --- a/app/ui/src/Pages/Projects/__snapshots__/Projects.test.tsx.snap +++ b/app/ui/src/Pages/Projects/__snapshots__/Projects.test.tsx.snap @@ -16,7 +16,7 @@ exports[`When data is ready should render without crashing 1`] = `
- +
@@ -50,7 +50,7 @@ exports[`When data is ready should render without crashing 1`] = `
- +
@@ -172,11 +172,6 @@ exports[`When data is ready should render without crashing 1`] = `
-
- External -
@@ -274,9 +269,6 @@ exports[`When data is ready should render without crashing 1`] = `
-
@@ -288,7 +280,7 @@ exports[`When data is ready should render without crashing 1`] = ` class="repoType" >
= ({ project }) => ( const Band: FC = ({ project }) => (
-
{capitalize(project.repository?.type)}
+ {/*
{capitalize(project.repository?.type)}
*/}
{project.archived && (
@@ -109,7 +109,8 @@ const Square: FC = ({ project }) => (
diff --git a/app/ui/src/Pages/Projects/components/Project/__snapshots__/Project.test.tsx.snap b/app/ui/src/Pages/Projects/components/Project/__snapshots__/Project.test.tsx.snap index 8161baa0e..55a481fbc 100644 --- a/app/ui/src/Pages/Projects/components/Project/__snapshots__/Project.test.tsx.snap +++ b/app/ui/src/Pages/Projects/components/Project/__snapshots__/Project.test.tsx.snap @@ -305,9 +305,6 @@ exports[`Project component Component match snapshot 1`] = `
-
@@ -379,10 +376,10 @@ exports[`Project component Component match snapshot 1`] = `
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4d29eca678197be46cf20e6fbe1b557dcdc745a8 Mon Sep 17 00:00:00 2001 From: Alex Rodriguez Fernandez Date: Fri, 20 Dec 2024 12:24:44 +0100 Subject: [PATCH 04/14] feat(ui): followup, delete authmethod and credentials (#1090) Delete authmethod and credentials buttons, update graphql types --- app/ui/src/Graphql/client/cache.tsx | 21 ---------- .../src/Graphql/client/models/NewProject.ts | 7 ---- app/ui/src/Graphql/types/globalTypes.ts | 7 ---- .../ExternalRepository/ExternalRepository.tsx | 39 +------------------ .../__snapshots__/Projects.test.tsx.snap | 4 +- .../Projects/components/Project/Project.tsx | 2 - 6 files changed, 4 insertions(+), 76 deletions(-) diff --git a/app/ui/src/Graphql/client/cache.tsx b/app/ui/src/Graphql/client/cache.tsx index 25776aa07..11346fe2e 100644 --- a/app/ui/src/Graphql/client/cache.tsx +++ b/app/ui/src/Graphql/client/cache.tsx @@ -10,7 +10,6 @@ import { PanelInfo } from './models/Panel'; import { SettingsTab } from './models/SettingsTab'; import { GetRuntimes_runtimes } from '../queries/types/GetRuntimes'; import { GetCapabilities_capabilities } from '../queries/types/GetCapabilities'; -import { RepositoryAuthMethod } from '../types/globalTypes'; type ToolName = keyof GetUserTools_project_toolUrls; @@ -34,32 +33,12 @@ export const initialNewProject: NewProject = { values: { url: '', username: '', - credential: '', - authMethod: RepositoryAuthMethod.TOKEN, }, errors: { url: 'This field is mandatory', - credential: 'This field is mandatory', username: 'This field is mandatory', - authMethod: RepositoryAuthMethod.TOKEN, - type: 'Repo type is wrong', }, - // errors: { type: 'Please choose a repo type' }, }, - // externalRepository: { - // values: { - // url: '', - // username: '', - // credential: '', - // authMethod: RepositoryAuthMethod.TOKEN, - // }, - // errors: { - // url: 'This field is mandatory', - // credential: 'This field is mandatory', - // username: 'This field is mandatory', - // authMethod: 'This field is mandatory', - // }, - // }, }; const initialStateUserSettings: UserSettings = { diff --git a/app/ui/src/Graphql/client/models/NewProject.ts b/app/ui/src/Graphql/client/models/NewProject.ts index c51360f93..62e715825 100644 --- a/app/ui/src/Graphql/client/models/NewProject.ts +++ b/app/ui/src/Graphql/client/models/NewProject.ts @@ -1,5 +1,3 @@ -import { RepositoryAuthMethod } from 'Graphql/types/globalTypes'; - export interface InformationValues { id: string; name: string; @@ -15,16 +13,11 @@ export interface InformationErrors { export interface RepositoryValues { url: string; username: string; - credential: string; - authMethod: RepositoryAuthMethod; } export interface RepositoryErrors { - type: string; url: string; username: string; - credential: string; - authMethod: RepositoryAuthMethod; } export interface NewProject_Repository { diff --git a/app/ui/src/Graphql/types/globalTypes.ts b/app/ui/src/Graphql/types/globalTypes.ts index c4a1177da..505c64409 100644 --- a/app/ui/src/Graphql/types/globalTypes.ts +++ b/app/ui/src/Graphql/types/globalTypes.ts @@ -13,11 +13,6 @@ export enum AccessLevel { VIEWER = "VIEWER", } -export enum RepositoryAuthMethod { - PASSWORD = "PASSWORD", - TOKEN = "TOKEN", -} - export interface AddMembersInput { projectId: string; userIds: string[]; @@ -51,8 +46,6 @@ export interface RemoveMembersInput { export interface RepositoryInput { url: string; username: string; - credential: string; - authMethod: RepositoryAuthMethod; } export interface SetActiveUserToolsInput { diff --git a/app/ui/src/Pages/NewProject/pages/RepositoryDetails/components/ExternalRepository/ExternalRepository.tsx b/app/ui/src/Pages/NewProject/pages/RepositoryDetails/components/ExternalRepository/ExternalRepository.tsx index fc84ceab2..6c4cbb772 100644 --- a/app/ui/src/Pages/NewProject/pages/RepositoryDetails/components/ExternalRepository/ExternalRepository.tsx +++ b/app/ui/src/Pages/NewProject/pages/RepositoryDetails/components/ExternalRepository/ExternalRepository.tsx @@ -7,13 +7,11 @@ import { useReactiveVar } from '@apollo/client'; import { newProject } from 'Graphql/client/cache'; import { validateMandatoryField, validateUrl } from './ExternalRepositoryUtils'; import { getErrorMsg } from 'Utils/string'; -import { RepositoryAuthMethod } from 'Graphql/types/globalTypes'; type Props = { showErrors: boolean; }; -const authMethods = [RepositoryAuthMethod.PASSWORD, RepositoryAuthMethod.TOKEN]; function Repository({ showErrors }: Props) { const project = useReactiveVar(newProject); @@ -22,8 +20,8 @@ function Repository({ showErrors }: Props) { if (!project) return ; const { - values: { url, credential, username, authMethod }, - errors: { url: urlError, credential: credentialError, username: usernameError, authMethod: authMethodError }, + values: { url, username }, + errors: { url: urlError, username: usernameError }, } = project.repository; return ( @@ -62,39 +60,6 @@ function Repository({ showErrors }: Props) { formValue={username} showClearButton /> -