diff --git a/.tools/__http__/ci.http.yml b/.tools/__http__/ci.http.yml deleted file mode 100644 index 93857e911..000000000 --- a/.tools/__http__/ci.http.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -global: - sample: true ---- -label: Search Harbor Images -query: | - query Ci_harborSearch($accountId: ID!, $q: String!, $pagination: PaginationIn) { - ci_harborSearch(accountId: $accountId, q: $q, pagination: $pagination) { - imageName - createdAt - updatedAt - # tags { - # name - # } - } - } -variables: - accountId: acc-xnnbf-kd254lyrcnu2jqvnoksvk - q: mon - pagination: - page: 1 - perPage: 100 - ---- - -label: List Image Tags -query: | - query Query($imageName: String!, $pagination: PaginationIn) { - ci_harborImageTags(imageName: $imageName, pagination: $pagination) { - name - } - } -variables: - imageName: "kloudlite/production/kloudlite-operator" - pagination: - page: 1 - perPage: 100 - diff --git a/.tools/__http__/console.graphql.yml b/.tools/__http__/console.graphql.yml deleted file mode 100644 index 734c07db4..000000000 --- a/.tools/__http__/console.graphql.yml +++ /dev/null @@ -1,109 +0,0 @@ ---- -global: - accountId: acc-k-hw-z1woxao88zzw8wjwl5mu2bih - projectId: proj-hhaqjt-f-hwjisccuugzkru25ami ---- -label: List Projects -query: | - query Core_projects($accountId: ID) { - core_projects(accountId: $accountId) { - id - name - region { - id - name - } - } - } -variables: - accountId: "{{.accountId}}" - ---- - -label: Create Project -query: | - mutation Core_createProject($accountId: ID!, $name: String!, $displayName: String!, $description: String, $regionId: ID) { - core_createProject(accountId: $accountId, name: $name, displayName: $displayName, description: $description, regionId: $regionId) { - id - name - } - } -variables: - accountId: "{{.accountId}}" - name: "anotherone-t" - displayName: "sample x" - regionId: "reg-vmtjj-k9w-v8i-c7jtkzp5rmlubz" - description: "this is just a dummy, project and will be deleted soon" - ---- -# clus-t2a-sfpxmcmw9qfydq0kzqswfhvb -label: Add New Cluster -query: | - mutation Core_addNewCluster($cluster: ClusterIn!) { - core_addNewCluster(cluster: $cluster) { - id - name - subDomain - } - } -variables: - cluster: - name: dev-01 - subDomain: dev-01.clusters.dev.kloudlite.io - kubeConfig: |+ - apiVersion: v1 - clusters: - - cluster: - certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJkekNDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdGMyVnkKZG1WeUxXTmhRREUyTnpBME9UazNOak13SGhjTk1qSXhNakE0TVRFME1qUXpXaGNOTXpJeE1qQTFNVEUwTWpRegpXakFqTVNFd0h3WURWUVFEREJock0zTXRjMlZ5ZG1WeUxXTmhRREUyTnpBME9UazNOak13V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFTQlZSV0dpbXRjRWxpUnVEQ1lFeDhXRlVBdHowQzU1TEg3R1ZVdEhienAKaSs4TXZ5MWY4bmJqQ2Ezb1VxWUx5NHA0NjZmbUNTLzBXTVFIOEdvenJiK0ZvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVUpkdmhtZDgwbjV2QnJaZTlsdm1ECkJuRGpRSEl3Q2dZSUtvWkl6ajBFQXdJRFNBQXdSUUlnRnRrdFdPelVWR096c0Z5SitwOEV4TEZYZm9aeEZUOWIKa3BIWUZnZ0x0Q0lDSVFEWFpCQUY1bzd0Kzg0ZlhHSzlnZzJKdVlBODNvSXhhZHpDcndYRGZLSWttUT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K - server: ***REMOVED*** - name: dev-azure - contexts: - - context: - cluster: dev-azure - user: dev-azure - name: dev-azure - current-context: dev-azure - kind: Config - preferences: {} - users: - - name: dev-azure - user: - client-certificate-data: ***REMOVED***= - client-key-data: ***REMOVED***= - ---- -label: Create App -query: |+ - mutation Core_createApp($projectId: ID!, $app: AppInput!) { - core_createApp(projectId: $projectId, app: $app) { - id - name - namespace - project { - id - name - } - } - } -variables: - projectId: "{{.projectId}}" - app: - isLambda: false - name: sample - projectId: "{{.projectId}}" - readableId: "sample-app-2312" - services: - - exposed: 80 - target: 80 - type: tcp - containers: - - computePlan: basic - quantity: 1 - name: sample-app - attachedResources: [] - envVars: - - key: NAME - value: - type: literal - value: "sample-app" ---- diff --git a/.tools/__http__/console.v2.graphql.yml b/.tools/__http__/console.v2.graphql.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.tools/__http__/consolev2/apps.graphql.yml b/.tools/__http__/consolev2/apps.graphql.yml deleted file mode 100644 index 837b05218..000000000 --- a/.tools/__http__/consolev2/apps.graphql.yml +++ /dev/null @@ -1,100 +0,0 @@ ---- -global: - # accountId: acc-k-9egfp-0nvz1wmpc6ylj9pxibqzt - accountId: acc-k-hw-z1woxao88zzw8wjwl5mu2bih - ---- - -label: Create App -query: |+ - mutation Core_createApp($app: App!) { - core_createApp(app: $app) - } - -variables: - app: - apiVersion: crds.kloudlite.io/v1 - kind: App - metadata: - name: sample-app - namespace: sample - spec: - region: master - containers: - - name: main - image: nginx - ---- - -label: Update App -query: |+ - mutation Core_updateApp($app: App!) { - core_updateApp(app: $app) - } - -variables: - app: - apiVersion: crds.kloudlite.io/v1 - kind: App - metadata: - name: sample-app - namespace: sample - spec: - region: master - containers: - - name: main - image: kong/httpbin - ---- - -label: Updating App running in an environment -query: |+ - mutation Core_updateApp($app: App!) { - core_updateApp(app: $app) - } - -variables: - app: - apiVersion: crds.kloudlite.io/v1 - kind: App - metadata: - name: sample-app - namespace: sample-default - spec: - region: master - containers: - - name: main - image: kong/httpbin - ---- - -label: Delete App -query: |+ - mutation Core_deleteApp($namespace: String!, $name: String!) { - core_deleteApp(namespace: $namespace, name: $name) - } -variables: - namespace: sample - name: sample-app - ---- - -label: Get Apps -query: |+ - query Core_Apps($namespace: String!) { - core_apps(namespace: $namespace) - } -variables: - namespace: sample - ---- - -label: Get App -query: |+ - query Core_App($namespace: String!, $name: String!) { - core_app(namespace: $namespace, name: $name) - } -variables: - namespace: sample - name: sample-app ---- diff --git a/.tools/__http__/consolev2/configs.graphql.yml b/.tools/__http__/consolev2/configs.graphql.yml deleted file mode 100644 index 8b33257a4..000000000 --- a/.tools/__http__/consolev2/configs.graphql.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -global: - # accountId: acc-k-9egfp-0nvz1wmpc6ylj9pxibqzt - accountId: acc-k-hw-z1woxao88zzw8wjwl5mu2bih - namespace: sample ---- - -label: Create Config -query: |+ - mutation Core_createConfig($config: Config!) { - core_createConfig(config: $config) - } -variables: - config: - apiVersion: crds.kloudlite.io/v1 - kind: Config - metadata: - name: sample-app - namespace: sample - data: - k1: v1 ---- diff --git a/.tools/__http__/consolev2/projects.graphql.yml b/.tools/__http__/consolev2/projects.graphql.yml deleted file mode 100644 index b0db158da..000000000 --- a/.tools/__http__/consolev2/projects.graphql.yml +++ /dev/null @@ -1,75 +0,0 @@ ---- -global: - # accountId: acc-k-9egfp-0nvz1wmpc6ylj9pxibqzt - accountId: acc-k-hw-z1woxao88zzw8wjwl5mu2bih - ---- - -label: List Projects -query: | - query Core_projects($accountId: ID!) { - core_projects(accountId: $accountId) - } -variables: - accountId: "{{.accountId}}" - ---- -label: Get Project -query: | - query Core_project($name: String!) { - core_project(name: $name) - } -variables: - name: "sample" - ---- - -label: Create Project -query: | - mutation Core_createProject($project: Project!) { - core_createProject(project: $project) - } -variables: - # accountId: "{{accountId}}" - # name: "sample" - # displayName: "sample" - # regionId: "centralindia" - # description: "this is just a dev only project" - project: - apiVersion: crds.kloudlite.io/v1 - kind: Project - metadata: - name: sample - spec: - accountId: "{{.accountId}}" - displayName: "Sample Project" ---- - -label: Delete Project -query: | - mutation Core_deleteProject($name: String!) { - core_deleteProject(name: $name) - } -variables: - name: "sample" - ---- - -### Environments -label: Get Environments -query: | - query Core_getEnvironments($projectName: String!) { - core_getEnvironments(projectName: $projectName) - } -variables: - projectName: sample ---- - -label: Get Environment -query: | - query Core_getEnvironment($namespace: String!) { - core_getEnvironment(namespace: $namespace) - } -variables: - namespace: sample ---- diff --git a/.tools/__http__/consolev2/routers.graphql.yml b/.tools/__http__/consolev2/routers.graphql.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.tools/__http__/consolev2/secrets.graphql.yml b/.tools/__http__/consolev2/secrets.graphql.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.tools/__http__/container-registry/container-registry.graphql.yml b/.tools/__http__/container-registry/container-registry.graphql.yml deleted file mode 100644 index e221bc5db..000000000 --- a/.tools/__http__/container-registry/container-registry.graphql.yml +++ /dev/null @@ -1,95 +0,0 @@ ---- -label: 'List Repos' -query: | - query Cr_listRepos { - cr_listRepos { - artifactCount - name - id - pullCount - } - } - ---- - -label: Listing Artifacts -query: |+ - query Cr_listArtifacts($repoName: String!) { - cr_listArtifacts(repoName: $repoName) { - size - tags { - name - signed - immutable - pushedAt - } - } - } -variables: - repoName: kloudlite-dev/development/webhooks-api - ---- - -label: List Robots -query: |+ - query Cr_listRobots { - cr_listRobots { - apiVersion - kind - spec { - enabled - harborProjectName - permissions - targetSecret - } - metadata { - name - } - status { - isReady - displayVars - checks - } - syncStatus { - action - generation - lastSyncedAt - state - syncScheduledAt - } - } - } - ---- - -label: Create Robot User -query: |+ - mutation Cr_createRobot($robotUser: HarborRobotUserIn!) { - cr_createRobot(robotUser: $robotUser) { - kind - metadata { - name - namespace - generation - annotations - creationTimestamp - } - syncStatus { - state - action - generation - lastSyncedAt - syncScheduledAt - } - } - } -variables: - robotUser: - metadata: - name: s1 - spec: - harborProjectName: kloudlite-dev - permissions: - - push-repository - - pull-repository ---- diff --git a/.tools/__http__/github.ci.http.yml b/.tools/__http__/github.ci.http.yml deleted file mode 100644 index 78db39c58..000000000 --- a/.tools/__http__/github.ci.http.yml +++ /dev/null @@ -1,171 +0,0 @@ -global: - accountId: acc-5mr4frb21ssmhh2rriuxluzveodv - projectId: "proj-bopxvo-qpfpodbz9lciwu45s5uqd" - projectName: "sample" - -# accountId: acc-4xrbue-eevzhin57x8maf2ddq9md -# projectId: "proj-wnmjf1c5ndqzevswbeuej5dyiknp" -# projectName: "sample-14847" ---- -label: github installations -query: | - query Query($pagination: PaginationIn) { - ci_githubInstallations(pagination: $pagination) - } -variables: - pagination: - page: 1 - perPage: 20 - ---- - -label: Github -query: | - query Query($org: String!, $search: String) { - ci_searchGithubRepos(org: $org, search: $search) - } -variables: - search: "demo" - org: KloudLite ---- - -label: Github Repos -query: | - query Query($installationId: Int!, $pagination: PaginationIn) { - ci_githubRepos(installationId: $installationId, pagination: $pagination) - } -variables: - # installationId: 22717460 - installationId: 22487879 - pagination: - page: 1 - perPage: 2 - ---- - -label: Github Repo Branches -query: | - query Query($repoUrl: String!) { - ci_githubRepoBranches(repoUrl: $repoUrl) - } -variables: - # repoUrl: https://github.com/kloudlite/demo-env - repoUrl: https://github.com/ScaleGroup/crewscale.git ---- - -label: Github Installation Token by installation id -query: | - query Query($instId: Int) { - ci_githubInstallationToken(instId: $instId) - } -variables: - instId: 22636591 - ---- - -label: Searching github -query: | - query SearchQuery($search: String!, $org: String!) { - ci_searchGithubRepos(search: $search, org: $org) - } -variables: - search: we - org: kloudlite - # pagination: - # page: 1 - # perPage: 5 ---- - -label: Get Installation Token By RepoUrl -query: | - query Query($repoUrl: String!) { - ci_githubInstallationToken(repoUrl: $repoUrl) - } -variables: - repoUrl: https://github.com/kloudlite/demo-env - ---- - -label: Create Github Pipeline with Docker -query: | - mutation Ci_createDockerPipeline($in: GitDockerPipelineIn!) { - ci_createDockerPipeline(in: $in) - } -variables: - in: - name: sample-example-github-asdfdasfas - # accountId: "{{accountId}}" - accountId: "acc-p3as823bdcuymhtz3upzzxh2wobw" - projectId: "{{projectId}}" - appId: "not-app-id-github-2" - # projectName: "{{projectName}}" - projectName: "testproj-22875" - containerName: "main" - gitProvider: github - repoName: "website" - gitRepoUrl: "https://github.com/nxtcoder17/sample" - gitBranch: master - dockerFile: ./Dockerfile - contextDir: ./ - buildArgs: "" - artifactRef: - # dockerImageName: "{{accountId}}/website2" - dockerImageName: "website2" - dockerImageTag: "latest" - ---- - -label: Create Github Pipeline with Docker -query: | - mutation Ci_createDockerPipeline($in: GitDockerPipelineIn!) { - ci_createDockerPipeline(in: $in) - } -variables: - in: - name: sample-example-github-asdfdasfas - # accountId: "{{accountId}}" - accountId: "acc-xnnbf-kd254lyrcnu2jqvnoksvk" - projectId: "proj-xv9pfmcwaov1yxuftpcwkq1n0sxi" - appId: "app-mnkuxqyzjrsf0e1kb9i43wrkxpho" - # projectName: "{{projectName}}" - projectName: "devenv-14473" - containerName: "main" - gitProvider: github - repoName: "website" - gitRepoUrl: "https://github.com/ScaleGroup/crewscale.git" - gitBranch: feature/cs-01_demo_branch - dockerFile: ./Dockerfile - contextDir: ./ - buildArgs: "" - artifactRef: - # dockerImageName: "{{accountId}}/website2" - dockerImageName: "c97-4c06-ae29-d1757c984c25" - dockerImageTag: "latest" - ---- - -label: List Pipelines -query: | - query Ci_getPipelines($projectId: ID!) { - ci_getPipelines(projectId: $projectId) { - id - name - dockerBuild { - dockerFile - } - build { - cmd - } - } - } -variables: - projectId: "{{projectId}}" ---- -label: Pipeline -query: | - query Query($pipelineId: ID!) { - ci_triggerPipeline(pipelineId: $pipelineId) - } - -variables: - pipelineId: pip-3pdwimijh1rnsrub72x05wmt4vcv diff --git a/.tools/__http__/gitlab.ci.http.yml b/.tools/__http__/gitlab.ci.http.yml deleted file mode 100644 index 45eeb4561..000000000 --- a/.tools/__http__/gitlab.ci.http.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -global: - accountId: acc-5mr4frb21ssmhh2rriuxluzveodv - projectId: "proj-bopxvo-qpfpodbz9lciwu45s5uqd" - projectName: "sample" ---- -label: Gitlab Groups -query: | - query Query($query: String) { - ci_gitlabGroups(query: $query) - } -variables: - query: "" - ---- - -label: Gitlab Repos with Search -query: | - query Query($groupId: String!, $search: String) { - ci_gitlabRepos(groupId: $groupId, search: $search) - } - -variables: - # groupId: "8508925" - groupId: "1459765" - search: "sample" - ---- - -label: Gitlab Repo Branches -query: | - query Query($repoId: String!) { - ci_gitlabRepoBranches(repoId: $repoId) - } -variables: - repoId: "26232015" - ---- - -label: Create Gitlab Pipeline with Docker -query: | - mutation Ci_createDockerPipeline($in: GitDockerPipelineIn!) { - ci_createDockerPipeline(in: $in) - } -variables: - in: - name: sample-example-2 - accountId: "{{accountId}}" - projectId: "{{projectId}}" - appId: "not-app-id-gitlab" - projectName: "{{projectName}}" - containerName: "main" - gitProvider: gitlab - repoName: "website" - gitRepoUrl: "https://gitlab.com/madhouselabs/sample" - gitBranch: master - dockerFile: ./Dockerfile - contextDir: ./ - buildArgs: "" - artifactRef: - dockerImageName: "harbor.dev.madhouselabs.io/{{accountId}}/website" - dockerImageTag: "latest" - ---- - -label: List Pipelines -query: | - query Ci_getPipelines($projectId: ID!) { - ci_getPipelines(projectId: $projectId) { - id - name - dockerBuild { - dockerFile - } - build { - cmd - } - } - } -variables: - projectId: "{{projectId}}" diff --git a/.tools/__http__/pipeline.gql.yml b/.tools/__http__/pipeline.gql.yml deleted file mode 100644 index 84b511d7e..000000000 --- a/.tools/__http__/pipeline.gql.yml +++ /dev/null @@ -1,17 +0,0 @@ -label: get pipeline runs -query: | - query Ci_getPipelineRuns($pipelineId: ID!) { - ci_getPipelineRuns(pipelineId: $pipelineId) { - id - pipelineId - startTime - endTime - success - message - state - } - } -variables: - pipelineId: 'pip-dxgx9zuzyj-skjv4nxxarjah2lf6' - ---- diff --git a/.tools/__http__/pipeline.http.yml b/.tools/__http__/pipeline.http.yml deleted file mode 100644 index e906aef69..000000000 --- a/.tools/__http__/pipeline.http.yml +++ /dev/null @@ -1,170 +0,0 @@ ---- -global: - accountId: "acc-imgtxz4logeg-isxm4uqlpzzwctr" - projectId: "proj-ci1xmobjyia7cc00optpbeavpnmn" - projectName: "example-plaxonic" ---- -label: create github pipeline -query: | - mutation Ci_createPipeline($in: GitPipelineIn!) { - ci_createPipeline(in: $in) - } -variables: - in: - name: sample-pipeline - accountId: acc-wo4rgoszo9dmsa1na-yhbsvh75gj - projectId: proj-s1ok37ubokp62aszwu0jdoq4uorr - appId: app-pg5r5t4bqez31rvwyjgys8z0k55y - gitProvider: github - gitRepoUrl: https://github.com/nxtcoder17/sample - repoName: sample - gitBranch: master - build: - baseImage: docker - cmd: |+ - docker build -t ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} . - run: - baseImage: docker - cmd: "" - artifactRef: - dockerImageName: sample - dockerImageTag: latest - ---- -label: Create Gitlab Pipeline -query: | - mutation Ci_createPipeline($in: GitPipelineIn!) { - ci_createPipeline(in: $in) - } -variables: - in: - name: sample-pipeline2 - projectName: "{{projectName}}" - accountId: "{{accountId}}" - projectId: "{{projectName}}" - # appId: app-pg5r5t4bqez31rvwyjgys8z0k55y - appId: "sample" - gitProvider: gitlab - gitRepoUrl: https://gitlab.com/madhouselabs/sample - repoName: sample - gitBranch: latest - dockerFile: ./Dockerfile - dockerContextDir: ./ - # build: - # baseImage: docker - # cmd: |+ - # docker build -t ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} . - # run: - # baseImage: docker - # cmd: "" - artifactRef: - dockerImageName: harbor.dev.madhouselabs.io/kloudlite/sample - dockerImageTag: latest ---- -label: Create Gitlab Pipeline with buildCmd -query: | - mutation Ci_createPipeline($in: GitPipelineIn!) { - ci_createPipeline(in: $in) - } -variables: - in: - name: sample-pipeliney - projectName: sample-x - containerName: main - accountId: acc-wo4rgoszo9dmsa1na-yhbsvh75gj - projectId: proj-ll5s-miviimb0icwvznki9jqzkyi - appId: app-pg5r5t4bqez31rvwyjgys8z0k55y - gitProvider: gitlab - gitRepoUrl: https://gitlab.com/nxtcoder17/sample - repoName: sample - gitBranch: master - build: - baseImage: node:alpine - cmd: npm i - outputDir: app,package.json - run: - baseImage: node:alpine - cmd: npm start - artifactRef: - dockerImageName: sample - dockerImageTag: latest ---- -label: Create Gitlab Pipeline with buildCmd (error) -query: | - mutation Ci_createDockerPipeLine($in: GitDockerPipelineIn!) { - ci_createDockerPipeLine(in: $in) - } -variables: - in: - repoName: backend_np-cart - projectId: proj-0f1hjg-c0q0ndi9-damtr5f78vrq - accountId: acc-gqjm9v7geosp9mnkdt-kdiewwjc4 - projectName: sample-proje-24785 - containerName: main - gitBranch: main - name: pipeline_sample-app-27390-main - gitRepoUrl: https://github.com/abdheshnayak/backend_np-cart.git - gitProvider: github - artifactRef: - dockerImageName: 9fb-4d0b-bb67-e9dc16834193 - dockerImageTag: latest - appId: sample-app-27390 - dockerFile: Dockerfile - contextDir: ./ - buildArgs: '' ---- -label: list pipelines -query: | - query Ci_getPipelines($projectId: ID!) { - ci_getPipelines(projectId: $projectId) { - id - name - gitProvider - gitRepoUrl - gitBranch - build { - baseImage - cmd - } - run { - baseImage - cmd - } - metadata - } - } -variables: - projectId: proj-ll5s-miviimb0icwvznki9jqzkyi ---- - -label: get pipeline -query: | - query Ci_getPipelines($pipelineId: ID!) { - ci_getPipeline(pipelineId: $pipelineId) { - id - repoName - name - gitProvider - gitRepoUrl - build { - baseImage - cmd - } - gitBranch - run { - baseImage - cmd - } - metadata - } - } -variables: - pipelineId: pip-xlf2psoeq4ft215kuyhija7vlezj ---- -label: Delete pipeline -query: | - mutation Ci_deletePipeline($pipelineId: ID!) { - ci_deletePipeline(pipelineId: $pipelineId) - } -variables: - pipelineId: pip-sdmpguqbhbcdsbbsbzklc9ogfsff diff --git a/.tools/__http__/sample.yml b/.tools/__http__/sample.yml deleted file mode 100644 index faca27f4e..000000000 --- a/.tools/__http__/sample.yml +++ /dev/null @@ -1,115 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: wireguard - labels: - name: wireguard - ---- - -# apiVersion: v1 -# kind: PersistentVolumeClaim -# metadata: -# name: pv-claim-wireguard -# namespace: wireguard -# spec: -# storageClassName: do-block-storage -# accessModes: -# - ReadWriteOnce -# resources: -# requests: -# storage: 1Gi - ---- - -apiVersion: v1 -kind: ConfigMap -metadata: - name: wireguard-configmap - namespace: wireguard -data: - PUID: "1000" - PGID: "1000" - TZ: "Asia/kolkata" - SERVERPORT: "31820" - PEERS: "0" - ---- - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: wireguard-deployment - namespace: wireguard -spec: - replicas: 1 - strategy: - type: Recreate - selector: - matchLabels: - app: wireguard - template: - metadata: - labels: - app: wireguard - spec: - containers: - - name: wireguard - image: ghcr.io/linuxserver/wireguard - # command: - # - bash - # - -c - # - tail -f /dev/null - envFrom: - - configMapRef: - name: wireguard-configmap - securityContext: - capabilities: - add: - - NET_ADMIN - - SYS_MODULE - privileged: true - volumeMounts: - - name: wg-config - mountPath: /config - - name: host-volumes - mountPath: /lib/modules - ports: - - containerPort: 51820 - protocol: UDP - resources: - requests: - memory: "64Mi" - cpu: "100m" - limits: - memory: "128Mi" - cpu: "200m" - volumes: - - name: wg-config - hostPath: - path: /tmp - type: Directory - - name: host-volumes - hostPath: - path: /lib/modules - type: Directory - ---- - -kind: Service -apiVersion: v1 -metadata: - labels: - k8s-app: wireguard - name: wireguard-service - namespace: wireguard -spec: - type: NodePort - ports: - - port: 51820 - nodePort: 31820 - protocol: UDP - targetPort: 51820 - selector: - app: wireguard - diff --git a/.tools/__http__/test-redis.yml b/.tools/__http__/test-redis.yml deleted file mode 100644 index 5a9fce0ce..000000000 --- a/.tools/__http__/test-redis.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -query: | - query Test { - sample - } diff --git a/.tools/__http__/wireguard-cluster.graphql.yml b/.tools/__http__/wireguard-cluster.graphql.yml deleted file mode 100644 index ec3046574..000000000 --- a/.tools/__http__/wireguard-cluster.graphql.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -label: List Clusters -query: | - query ListClusters { - listClusters { - id - name - } - } - ---- -label: Create Cluster -query: | - mutation CreateCluster($name: String!, $provider: String!, $region: String!) { - createCluster(name: $name, provider: $provider, region: $region) { - id - name - provider - endpoint - region - } - } - -variables: - name: "clusterfather" - provider: do - region: blr1 ---- diff --git a/.tools/dev/ci-external-name.yml b/.tools/dev/ci-external-name.yml deleted file mode 100644 index fbf4557f9..000000000 --- a/.tools/dev/ci-external-name.yml +++ /dev/null @@ -1,8 +0,0 @@ -kind: Service -apiVersion: v1 -metadata: - name: ci-api-local - namespace: hotspot -spec: - type: ExternalName - externalName: tunneling.hotspot.svc.cluster.local diff --git a/.tools/dev/ci-local-ingress.yml b/.tools/dev/ci-local-ingress.yml deleted file mode 100644 index 8c3ed03fa..000000000 --- a/.tools/dev/ci-local-ingress.yml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: ci-api.hotspot.local - namespace: hotspot - annotations: - # cert-manager.io/cluster-issuer: kl-cert-issuer - kubernetes.io/ingress.class: nginx - nginx.ingress.kubernetes.io/ssl-redirect: "false" - nginx.ingress.kubernetes.io/upstream-vhost: ci-api.hotspot.local -spec: - rules: - - host: ci-api.hotspot.local - http: - paths: - - pathType: Prefix - path: / - backend: - service: - name: tunneling - port: - number: 80 diff --git a/.tools/hotspot.yml b/.tools/hotspot.yml deleted file mode 100644 index ee9589c76..000000000 --- a/.tools/hotspot.yml +++ /dev/null @@ -1,47 +0,0 @@ -namespace: hotspot - -tunnels: - - nxt-gateway:80 -> app:4000 - - tekton-interceptor:80 -> app:5001 - - message-consumer:80 -> app:5001 - -local: - services: - - name: app - image: nxtcoder17/home - environment: - ABC: 'hello' - # command: - # - pnpm all - working_dir: /home/node/app - volumes: - - .:/home/node/app - - - name: mongo - image: mongo:latest - command: mongod --port 27018 - - - name: messenger - image: nxtcoder17/home - working_dir: /home/node/app - volumes: - - ../api-go:/home/node/app - - ~/.kube/configs/dev-hotspot-01.yml:/tmp/kconfig - environment: - KUBECONFIG: /tmp/kconfig - # command: - # - pnpm all - - mounts: - dir: /var/mounts - configs: - - gateway-supergraph - secrets: - - auth-api-secret - - auth-api-github-app-pk - - mongo-creds-mongodb - - redis-creds-redis-db - - comms-sendgrid-api - - finance-api-secret - -kubeConfig: ~/.kube/configs/dev-hotspot-01.yml diff --git a/.tools/pipeline/test.json b/.tools/pipeline/test.json deleted file mode 100644 index b2249a113..000000000 --- a/.tools/pipeline/test.json +++ /dev/null @@ -1,150 +0,0 @@ -{ - "zen": "Favor focus over features.", - "hook_id": 368082572, - "hook": { - "type": "Repository", - "id": 368082572, - "name": "web", - "active": true, - "events": [ - "push" - ], - "config": { - "content_type": "json", - "url": "https://tk.webhooks.dev.kloudlite.io/github?pipelineId=pip-9cnxjhxkqat9abb0wc2enxyf6bzj", - "insecure_ssl": "0" - }, - "updated_at": "2022-07-11T16:40:28Z", - "created_at": "2022-07-11T16:40:28Z", - "url": "https://api.github.com/repos/nxtcoder17/sample/hooks/368082572", - "test_url": "https://api.github.com/repos/nxtcoder17/sample/hooks/368082572/test", - "ping_url": "https://api.github.com/repos/nxtcoder17/sample/hooks/368082572/pings", - "deliveries_url": "https://api.github.com/repos/nxtcoder17/sample/hooks/368082572/deliveries", - "last_response": { - "code": null, - "status": "unused", - "message": null - } - }, - "repository": { - "id": 426581953, - "node_id": "R_kgDOGW0fwQ", - "name": "sample", - "full_name": "nxtcoder17/sample", - "private": false, - "owner": { - "login": "nxtcoder17", - "id": 22402557, - "node_id": "MDQ6VXNlcjIyNDAyNTU3", - "avatar_url": "https://avatars.githubusercontent.com/u/22402557?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/nxtcoder17", - "html_url": "https://github.com/nxtcoder17", - "followers_url": "https://api.github.com/users/nxtcoder17/followers", - "following_url": "https://api.github.com/users/nxtcoder17/following{/other_user}", - "gists_url": "https://api.github.com/users/nxtcoder17/gists{/gist_id}", - "starred_url": "https://api.github.com/users/nxtcoder17/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/nxtcoder17/subscriptions", - "organizations_url": "https://api.github.com/users/nxtcoder17/orgs", - "repos_url": "https://api.github.com/users/nxtcoder17/repos", - "events_url": "https://api.github.com/users/nxtcoder17/events{/privacy}", - "received_events_url": "https://api.github.com/users/nxtcoder17/received_events", - "type": "User", - "site_admin": false - }, - "html_url": "https://github.com/nxtcoder17/sample", - "description": null, - "fork": false, - "url": "https://api.github.com/repos/nxtcoder17/sample", - "forks_url": "https://api.github.com/repos/nxtcoder17/sample/forks", - "keys_url": "https://api.github.com/repos/nxtcoder17/sample/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/nxtcoder17/sample/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/nxtcoder17/sample/teams", - "hooks_url": "https://api.github.com/repos/nxtcoder17/sample/hooks", - "issue_events_url": "https://api.github.com/repos/nxtcoder17/sample/issues/events{/number}", - "events_url": "https://api.github.com/repos/nxtcoder17/sample/events", - "assignees_url": "https://api.github.com/repos/nxtcoder17/sample/assignees{/user}", - "branches_url": "https://api.github.com/repos/nxtcoder17/sample/branches{/branch}", - "tags_url": "https://api.github.com/repos/nxtcoder17/sample/tags", - "blobs_url": "https://api.github.com/repos/nxtcoder17/sample/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/nxtcoder17/sample/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/nxtcoder17/sample/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/nxtcoder17/sample/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/nxtcoder17/sample/statuses/{sha}", - "languages_url": "https://api.github.com/repos/nxtcoder17/sample/languages", - "stargazers_url": "https://api.github.com/repos/nxtcoder17/sample/stargazers", - "contributors_url": "https://api.github.com/repos/nxtcoder17/sample/contributors", - "subscribers_url": "https://api.github.com/repos/nxtcoder17/sample/subscribers", - "subscription_url": "https://api.github.com/repos/nxtcoder17/sample/subscription", - "commits_url": "https://api.github.com/repos/nxtcoder17/sample/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/nxtcoder17/sample/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/nxtcoder17/sample/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/nxtcoder17/sample/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/nxtcoder17/sample/contents/{+path}", - "compare_url": "https://api.github.com/repos/nxtcoder17/sample/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/nxtcoder17/sample/merges", - "archive_url": "https://api.github.com/repos/nxtcoder17/sample/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/nxtcoder17/sample/downloads", - "issues_url": "https://api.github.com/repos/nxtcoder17/sample/issues{/number}", - "pulls_url": "https://api.github.com/repos/nxtcoder17/sample/pulls{/number}", - "milestones_url": "https://api.github.com/repos/nxtcoder17/sample/milestones{/number}", - "notifications_url": "https://api.github.com/repos/nxtcoder17/sample/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/nxtcoder17/sample/labels{/name}", - "releases_url": "https://api.github.com/repos/nxtcoder17/sample/releases{/id}", - "deployments_url": "https://api.github.com/repos/nxtcoder17/sample/deployments", - "created_at": "2021-11-10T10:39:50Z", - "updated_at": "2022-07-04T08:37:56Z", - "pushed_at": "2022-04-26T07:30:43Z", - "git_url": "git://github.com/nxtcoder17/sample.git", - "ssh_url": "git@github.com:nxtcoder17/sample.git", - "clone_url": "https://github.com/nxtcoder17/sample.git", - "svn_url": "https://github.com/nxtcoder17/sample", - "homepage": "sample3-seven.vercel.app", - "size": 10, - "stargazers_count": 0, - "watchers_count": 0, - "language": "JavaScript", - "has_issues": true, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": false, - "forks_count": 1, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 0, - "license": null, - "allow_forking": true, - "is_template": false, - "web_commit_signoff_required": false, - "topics": [ - - ], - "visibility": "public", - "forks": 1, - "open_issues": 0, - "watchers": 0, - "default_branch": "master" - }, - "sender": { - "login": "nxtcoder17", - "id": 22402557, - "node_id": "MDQ6VXNlcjIyNDAyNTU3", - "avatar_url": "https://avatars.githubusercontent.com/u/22402557?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/nxtcoder17", - "html_url": "https://github.com/nxtcoder17", - "followers_url": "https://api.github.com/users/nxtcoder17/followers", - "following_url": "https://api.github.com/users/nxtcoder17/following{/other_user}", - "gists_url": "https://api.github.com/users/nxtcoder17/gists{/gist_id}", - "starred_url": "https://api.github.com/users/nxtcoder17/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/nxtcoder17/subscriptions", - "organizations_url": "https://api.github.com/users/nxtcoder17/orgs", - "repos_url": "https://api.github.com/users/nxtcoder17/repos", - "events_url": "https://api.github.com/users/nxtcoder17/events{/privacy}", - "received_events_url": "https://api.github.com/users/nxtcoder17/received_events", - "type": "User", - "site_admin": false - } -} diff --git a/.tools/pipeline/test.sh b/.tools/pipeline/test.sh deleted file mode 100644 index c21f617a9..000000000 --- a/.tools/pipeline/test.sh +++ /dev/null @@ -1,2 +0,0 @@ -# curl -H 'Content-Type: application/json' -XPOST 'https://tk.webhooks.dev.kloudlite.io/github?pipelineId=pip-9cnxjhxkqat9abb0wc2enxyf6bzj' --data @test.json -curl -H 'Content-Type: application/json' -XPOST 'https://ci-17.app.khost.dev/github?pipelineId=pip-9cnxjhxkqat9abb0wc2enxyf6bzj' --data @test.json diff --git a/.tools/scripts/runner.sh b/.tools/scripts/runner.sh deleted file mode 100644 index b6d782632..000000000 --- a/.tools/scripts/runner.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /usr/bin/env bash - -APP=$1 - -if [ -d $APP ]; then - echo "app does not exist ..." -fi diff --git a/.tools/test.sh b/.tools/test.sh deleted file mode 100644 index 03b657fdd..000000000 --- a/.tools/test.sh +++ /dev/null @@ -1 +0,0 @@ -#! /usr/bin/bash diff --git a/apps/ad-webhook/Dockerfile b/apps/ad-webhook/Dockerfile deleted file mode 100644 index 6937e2ece..000000000 --- a/apps/ad-webhook/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM golang:1.18.3-alpine3.16 AS base -USER 1001 -ENV GOPATH=/tmp/go -ENV GOCACHE=/tmp/go-cache -WORKDIR /tmp/app -COPY . . -RUN go mod download -x -ARG APP -RUN mkdir -p ./apps/$APP -WORKDIR /tmp/app/apps/$APP -COPY --chown=1001 ./ ./ -RUN CGO_ENABLED=0 go build -tags musl -o /tmp/bin/$APP ./main.go -RUN chmod +x /tmp/bin/$APP - -#FROM gcr.io/distroless/static-debian11 -FROM alpine -ARG APP -RUN adduser -D -h /home/nonroot nonroot -USER nonroot -WORKDIR /tmp/app -COPY --chown=nonroot --from=base /tmp/bin/$APP ./$APP -CMD ["./admission-webhook"] diff --git a/apps/ad-webhook/Taskfile.yml b/apps/ad-webhook/Taskfile.yml deleted file mode 100644 index 23d82310e..000000000 --- a/apps/ad-webhook/Taskfile.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: '3' - -dotenv: [] - -tasks: - run: - cmds: - - nodemon -e go --signal SIGKILL --exec 'go run -tags dynamic main.go --dev || exit 1' - - docker-build: - vars: -# IMAGE: registry.kloudlite.io/kloudlite/admission-webhook:v2 - APP: admission-webhook - IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}:{{.Tag}} - preconditions: - - sh: '[[ -n "{{.Tag}}" ]]' - msg: 'var Tag must have a value' - - - sh: '[[ "{{.EnvName}}" == "development" ]] || [[ "{{.EnvName}}" == "staging" ]] || [[ "{{.EnvName}}" == "production" ]]' - msg: 'var EnvName must have one of [development, staging, production] as its value' - cmds: - - docker buildx build -f ./Dockerfile -t {{.IMAGE}} . --build-arg APP={{.APP}} --platform linux/amd64 --build-context project-root=../.. - - docker push {{.IMAGE}} diff --git a/apps/ad-webhook/cr/admission-webhook.yml b/apps/ad-webhook/cr/admission-webhook.yml deleted file mode 100644 index 75715b1d0..000000000 --- a/apps/ad-webhook/cr/admission-webhook.yml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: admissionregistration.k8s.io/v1beta1 -kind: MutatingWebhookConfiguration -metadata: - name: add-node-selector -webhooks: -- name: add-node-selector.kl - rules: - - apiGroups: [""] - apiVersions: ["v1"] - resources: ["pods"] - operations: ["CREATE"] - failurePolicy: Fail - clientConfig: - service: - name: add-node-selector - namespace: kube-system - path: "/add-node-selector" - # caBundle: diff --git a/apps/ad-webhook/cr/deploy.yml b/apps/ad-webhook/cr/deploy.yml deleted file mode 100644 index 9d66e124d..000000000 --- a/apps/ad-webhook/cr/deploy.yml +++ /dev/null @@ -1,26 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: admission-webhook - namespace: kube-system -spec: - selector: - matchLabels: - app: add-node-selector - template: - metadata: - creationTimestamp: null - labels: - app: add-node-selector - spec: - containers: - - image: registry.kloudlite.io/kloudlite/development/admission-webhook:v1.0.5 - imagePullPolicy: Always - name: main - resources: - limits: - cpu: 50m - memory: 50Mi - requests: - cpu: 10m - memory: 10Mi diff --git a/apps/ad-webhook/cr/service.yml b/apps/ad-webhook/cr/service.yml deleted file mode 100644 index 40cf7490c..000000000 --- a/apps/ad-webhook/cr/service.yml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: add-node-selector - namespace: kube-system -spec: - selector: - app: add-node-selector - ports: - - name: webhook - port: 443 - targetPort: 8443 diff --git a/apps/ad-webhook/go.mod b/apps/ad-webhook/go.mod deleted file mode 100644 index af3ce20f8..000000000 --- a/apps/ad-webhook/go.mod +++ /dev/null @@ -1,27 +0,0 @@ -module github.com/kloudlite/admission-webhook - -go 1.20 - -require ( - k8s.io/api v0.26.1 - k8s.io/apimachinery v0.26.1 - k8s.io/klog v1.0.0 -) - -require ( - github.com/go-logr/logr v1.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/google/gofuzz v1.1.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/text v0.13.0 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - k8s.io/klog/v2 v2.80.1 // indirect - k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect - sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect -) diff --git a/apps/ad-webhook/go.sum b/apps/ad-webhook/go.sum deleted file mode 100644 index ef1c5e438..000000000 --- a/apps/ad-webhook/go.sum +++ /dev/null @@ -1,85 +0,0 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -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= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -k8s.io/api v0.26.1 h1:f+SWYiPd/GsiWwVRz+NbFyCgvv75Pk9NK6dlkZgpCRQ= -k8s.io/api v0.26.1/go.mod h1:xd/GBNgR0f707+ATNyPmQ1oyKSgndzXij81FzWGsejg= -k8s.io/apimachinery v0.26.1 h1:8EZ/eGJL+hY/MYCNwhmDzVqq2lPl3N3Bo8rvweJwXUQ= -k8s.io/apimachinery v0.26.1/go.mod h1:tnPmbONNJ7ByJNz9+n9kMjNP8ON+1qoAIIC70lztu74= -k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= -k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= -k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4= -k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/utils v0.0.0-20221107191617-1a15be271d1d h1:0Smp/HP1OH4Rvhe+4B8nWGERtlqAGSftbSbbmm45oFs= -k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= -sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/apps/ad-webhook/main.go b/apps/ad-webhook/main.go deleted file mode 100644 index 367aa6d8f..000000000 --- a/apps/ad-webhook/main.go +++ /dev/null @@ -1,115 +0,0 @@ -package main - -import ( - "encoding/json" - "net/http" - "strings" - - admissionv1 "k8s.io/api/admission/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/klog" -) - -var ( - scheme = runtime.NewScheme() - codecs = serializer.NewCodecFactory(scheme) -) - -func init() { - _ = corev1.AddToScheme(scheme) - _ = admissionv1.AddToScheme(scheme) -} - -func main() { - http.HandleFunc("/add-node-selector", func(w http.ResponseWriter, r *http.Request) { - contentType := r.Header.Get("Content-Type") - if !strings.Contains(contentType, "application/json") { - klog.Errorf("unexpected content type: %s", contentType) - http.Error(w, "unexpected content type", http.StatusBadRequest) - return - } - - req := admissionv1.AdmissionReview{} - if err := json.NewDecoder(r.Body).Decode(&req); err != nil { - klog.Errorf("failed to decode request body: %v", err) - http.Error(w, "failed to decode request body", http.StatusBadRequest) - return - } - - resp := admit(&req) - if resp != nil { - klog.Infof("sending response: %s", resp) - if err := json.NewEncoder(w).Encode(resp); err != nil { - klog.Errorf("failed to encode response: %v", err) - http.Error(w, "failed to encode response", http.StatusInternalServerError) - } - return - } - - http.Error(w, "no response", http.StatusNotFound) - }) - - server := &http.Server{ - Addr: ":8443", - } - - klog.Infof("listening on %s", server.Addr) - - if err := server.ListenAndServe(); err != nil { - klog.Fatalf("failed to serve: %v", err) - } -} - -func admit(req *admissionv1.AdmissionReview) *admissionv1.AdmissionResponse { - pod := &corev1.Pod{} - if err := json.Unmarshal(req.Request.Object.Raw, pod); err != nil { - klog.Errorf("failed to unmarshal Pod: %v", err) - return toAdmissionResponse(err) - } - - pvcFound := false - for _, volume := range pod.Spec.Volumes { - if volume.VolumeSource.PersistentVolumeClaim != nil { - pvcFound = true - break - } - } - - if !pvcFound { - return nil - } - - if pod.Spec.NodeSelector == nil { - pod.Spec.NodeSelector = map[string]string{} - } - - pod.Spec.NodeSelector["kloudlite.io/stateful"] = "true" - pod.Spec.PriorityClassName = "stateful" - - marshaledPod, err := json.Marshal(pod) - if err != nil { - klog.Errorf("failed to marshal Pod: %v", err) - return toAdmissionResponse(err) - } - - return &admissionv1.AdmissionResponse{ - UID: req.Request.UID, - Allowed: true, - Patch: marshaledPod, - PatchType: func() *admissionv1.PatchType { - pt := admissionv1.PatchTypeJSONPatch - return &pt - }(), - } -} - -func toAdmissionResponse(err error) *admissionv1.AdmissionResponse { - return &admissionv1.AdmissionResponse{ - Result: &metav1.Status{ - Message: err.Error(), - }, - } -} diff --git a/apps/auth/Taskfile.yml b/apps/auth/Taskfile.yml index 416a1aabf..126790235 100644 --- a/apps/auth/Taskfile.yml +++ b/apps/auth/Taskfile.yml @@ -21,6 +21,8 @@ tasks: build: env: CGO_ENABLED: 0 + GOOS: linux + GOARCH: amd64 vars: BuiltAt: sh: date | sed 's/\s/_/g' diff --git a/apps/build-agent/Taskfile.yml b/apps/build-agent/Taskfile.yml index 46ccd73f6..34224ba87 100644 --- a/apps/build-agent/Taskfile.yml +++ b/apps/build-agent/Taskfile.yml @@ -16,6 +16,8 @@ tasks: build: env: CGO_ENABLED: 0 + GOOS: linux + GOARCH: amd64 preconditions: - sh: '[ -n "{{.Out}}" ]' msg: var Out must have a value diff --git a/apps/build-agent/internal/app/build-consumer.go b/apps/build-agent/internal/app/build-consumer.go index b56d94d06..00e91b3b8 100644 --- a/apps/build-agent/internal/app/build-consumer.go +++ b/apps/build-agent/internal/app/build-consumer.go @@ -26,7 +26,6 @@ type Obj struct { func fxInvokeProcessBuilds() fx.Option { return fx.Options( - fx.Invoke( func(consumer redpanda.Consumer, logr logging.Logger, yamlClient kubectl.YAMLClient) { consumer.StartConsuming( diff --git a/apps/build-agent/main.go b/apps/build-agent/main.go index 6f299ca10..912bad9e7 100644 --- a/apps/build-agent/main.go +++ b/apps/build-agent/main.go @@ -6,7 +6,6 @@ import ( "fmt" "runtime/trace" - "github.com/kloudlite/operator/pkg/kubectl" "go.uber.org/fx" "k8s.io/client-go/rest" "kloudlite.io/apps/build-agent/internal/env" @@ -38,14 +37,6 @@ func main() { return k8s.RestInclusterConfig() }), - fx.Provide(func(restCfg *rest.Config) (kubectl.YAMLClient, error) { - return kubectl.NewYAMLClient(restCfg) - }), - - fx.Provide(func(restCfg *rest.Config) (k8s.ExtendedK8sClient, error) { - return k8s.NewExtendedK8sClient(restCfg) - }), - fn.FxErrorHandler(), framework.Module, ) diff --git a/apps/comms/Taskfile.yml b/apps/comms/Taskfile.yml index 551797553..9cf127727 100644 --- a/apps/comms/Taskfile.yml +++ b/apps/comms/Taskfile.yml @@ -17,8 +17,8 @@ tasks: build: env: CGO_ENABLED: 0 - # GOOS: linux - # GOARCH: amd64 + GOOS: linux + GOARCH: amd64 preconditions: - sh: '[ -n "{{.Out}}" ]' msg: var Out must have a value diff --git a/apps/container-registry/Taskfile.yml b/apps/container-registry/Taskfile.yml index 5b759f3f5..253d21862 100644 --- a/apps/container-registry/Taskfile.yml +++ b/apps/container-registry/Taskfile.yml @@ -16,6 +16,8 @@ tasks: build: env: CGO_ENABLED: 0 + GOOS: linux + GOARCH: amd64 vars: BuiltAt: sh: date | sed 's/\s/_/g' diff --git a/apps/container-registry/main.go b/apps/container-registry/main.go index 9ac098058..f432f509b 100644 --- a/apps/container-registry/main.go +++ b/apps/container-registry/main.go @@ -5,14 +5,11 @@ import ( "flag" "runtime/trace" - "github.com/kloudlite/operator/pkg/kubectl" "go.uber.org/fx" - "k8s.io/client-go/rest" "kloudlite.io/apps/container-registry/internal/env" "kloudlite.io/apps/container-registry/internal/framework" "kloudlite.io/common" fn "kloudlite.io/pkg/functions" - "kloudlite.io/pkg/k8s" "kloudlite.io/pkg/logging" ) @@ -29,29 +26,11 @@ func main() { return logging.New(&logging.Options{Name: "container-registry", Dev: isDev}) }, ), - fx.Provide(func() (*rest.Config, error) { - if isDev { - return &rest.Config{ - Host: "localhost:8080", - }, nil - } - return k8s.RestInclusterConfig() - }), - - fx.Provide(func(restCfg *rest.Config) (kubectl.YAMLClient, error) { - return kubectl.NewYAMLClient(restCfg) - }), - - fx.Provide(func(restCfg *rest.Config) (k8s.ExtendedK8sClient, error) { - return k8s.NewExtendedK8sClient(restCfg) - }), fn.FxErrorHandler(), framework.Module, ) - // ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - // defer cancel() if err := app.Start(context.TODO()); err != nil { trace.Log(context.TODO(), "app.Start", err.Error()) panic(err) diff --git a/apps/dns/Dockerfile b/apps/dns/Dockerfile deleted file mode 100644 index b241ab8eb..000000000 --- a/apps/dns/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -# syntax=docker/dockerfile:1.4 -FROM golang:1.18.3-alpine3.16 AS base -USER 1001 -ENV GOPATH=/tmp/go -ENV GOCACHE=/tmp/go-cache -WORKDIR /tmp/app -COPY --chown=1001 --from=project-root ./go.mod ./go.sum ./tools.go ./ -RUN go mod download -x -COPY --chown=1001 --from=project-root common ./common -COPY --chown=1001 --from=project-root grpc-interfaces ./grpc-interfaces -COPY --chown=1001 --from=project-root pkg ./pkg -ARG APP -RUN mkdir -p ./apps/$APP -WORKDIR /tmp/app/apps/$APP -COPY --chown=1001 ./ ./ -RUN CGO_ENABLED=0 go build -tags musl -o /tmp/bin/$APP ./main.go -RUN chmod +x /tmp/bin/$APP - -#FROM gcr.io/distroless/static-debian11 -FROM alpine -USER 1001 -WORKDIR /tmp/app -COPY --from=base --chown=1001 /tmp/bin/dns ./dns -CMD ["./dns"] diff --git a/apps/dns/Taskfile.yml b/apps/dns/Taskfile.yml deleted file mode 100644 index bc6ff504b..000000000 --- a/apps/dns/Taskfile.yml +++ /dev/null @@ -1,69 +0,0 @@ -version: "3" - -dotenv: [".secrets/.env"] - -tasks: - gql: - dir: ./internal/app - cmds: - - go run -tags dynamic github.com/99designs/gqlgen generate - run: - sources: - - ./internal/**/*.go - - ./main.go - cmds: - - go version - - nodemon -e go --signal SIGKILL --exec 'go run -tags dynamic main.go --dev || exit 1' - # - go run -tags dynamic main.go --dev - - - docker-build: - vars: - APP: dns - IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}-api:{{.Tag}} - preconditions: - - sh: '[[ -n "{{.Tag}}" ]]' - msg: 'var Tag must have a value' - - - sh: '[[ "{{.EnvName}}" == "development" ]] || [[ "{{.EnvName}}" == "staging" ]] || [[ "{{.EnvName}}" == "production" ]]' - msg: 'var EnvName must have one of [development, staging, production] as its value' - cmds: - - docker buildx build -f ./Dockerfile -t {{.IMAGE}} . --build-arg APP={{.APP}} --platform linux/amd64 --build-context project-root=../.. - - docker push {{.IMAGE}} - - local-build: - vars: - APP: dns - IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}-api:{{.Tag}} - preconditions: - - sh: '[[ -n "{{.Tag}}" ]]' - msg: 'var Tag must have a value' - - - sh: '[[ "{{.EnvName}}" == "development" ]] || [[ "{{.EnvName}}" == "staging" ]] || [[ "{{.EnvName}}" == "production" ]]' - msg: 'var EnvName must have one of [development, staging, production] as its value' - env: - CGO_ENABLED: 0 - GOOS: linux - GOARCH: amd64 - silent: true - cmds: - - |+ - lineNumbers=$(cat Dockerfile | grep -i '^FROM' -n | tail +2 | awk -F: '{print $1}') - - startLineNo=$(echo "$lineNumbers" | head -n+1) - finalLineNo=$(echo "$lineNumbers" | tail -1) - - tDir=$(mktemp -d) - - nDockerfile=$(cat Dockerfile | tail --lines=+$startLineNo | grep -i --invert-match 'from=base') - echo "$nDockerfile" | sed "1 i # syntax=docker/dockerfile:1.4" > $tDir/Dockerfile.base - - #lineNo=$(cat Dockerfile | grep -i '^FROM' -n | tail -1 | awk -F: '{print $1}') - CGO_ENABLED=0 go build -o $tDir/{{.APP}} . - - cat $tDir/Dockerfile.base | sed "5 i COPY --from=local-builder ./{{.APP}} ./{{.APP}}" > $tDir/Dockerfile - cat $tDir/Dockerfile - - docker buildx build -f $tDir/Dockerfile -t {{.IMAGE}} . --build-context local-builder=${tDir} - docker push {{.IMAGE}} - rm -rf $tDir diff --git a/apps/dns/internal/app/gqlgen.yml b/apps/dns/internal/app/gqlgen.yml deleted file mode 100644 index 37d61dff5..000000000 --- a/apps/dns/internal/app/gqlgen.yml +++ /dev/null @@ -1,71 +0,0 @@ -# Where are all the schema files located? globs are supported eg src/**/*.graphqls -schema: - - graph/*.graphqls - -# Where should the generated server code go? -exec: - filename: graph/generated/generated.go - package: generated - -# Uncomment to enable federation -federation: - filename: graph/generated/federation.go - package: generated - -# Where should any generated models go? -model: - filename: graph/model/models_gen.go - package: model - -# Where should the resolver implementations go? -resolver: - layout: follow-schema - dir: graph - package: graph - -# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models -# struct_tag: json - -# Optional: turn on to use []Thing instead of []*Thing -# omit_slice_element_pointers: false - -# Optional: set to speed up generation time by not performing a final validation pass. -# skip_validation: true - -# gqlgen will search for any type names in the schema in these go packages -# if they match it will use them, otherwise it will generate them. -autobind: - - "kloudlite.io/pkg/errors" - # - "kloudlite.io/apps/wireguard/internal/domain/entities" - -# This section declares type mapping between the GraphQL and go type systems -# -# The first line in each type will be used as defaults for resolver arguments and -# modelgen, the others will be allowed when binding to fields. Configure them to -# your liking -skip_validation: true -models: - Account: - fields: - edgeCname: - resolver: true - sites: - resolver: true - Site: - fields: - records: - resolver: true - ID: - model: - - kloudlite.io/pkg/repos.ID - Int: - model: - - github.com/99designs/gqlgen/graphql.Int - - github.com/99designs/gqlgen/graphql.Int64 - - github.com/99designs/gqlgen/graphql.Int32 - PaginationIn: - model: - - kloudlite.io/pkg/types.Pagination - Json: - model: - - github.com/99designs/gqlgen/graphql.Map diff --git a/apps/dns/internal/app/graph/entity.resolvers.go b/apps/dns/internal/app/graph/entity.resolvers.go deleted file mode 100644 index 35d5832e0..000000000 --- a/apps/dns/internal/app/graph/entity.resolvers.go +++ /dev/null @@ -1,35 +0,0 @@ -package graph - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. - -import ( - "context" - - "kloudlite.io/apps/dns/internal/app/graph/generated" - "kloudlite.io/apps/dns/internal/app/graph/model" - "kloudlite.io/pkg/repos" -) - -func (r *entityResolver) FindAccountByID(ctx context.Context, id repos.ID) (*model.Account, error) { - return &model.Account{ - ID: id, - }, nil -} - -func (r *entityResolver) FindSiteByID(ctx context.Context, id repos.ID) (*model.Site, error) { - site, err := r.d.GetSite(ctx, string(id)) - if err != nil { - return nil, err - } - return &model.Site{ - ID: id, - AccountID: site.AccountId, - Domain: site.Domain, - }, nil -} - -// Entity returns generated.EntityResolver implementation. -func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} } - -type entityResolver struct{ *Resolver } diff --git a/apps/dns/internal/app/graph/generated/federation.go b/apps/dns/internal/app/graph/generated/federation.go deleted file mode 100644 index f8a10c758..000000000 --- a/apps/dns/internal/app/graph/generated/federation.go +++ /dev/null @@ -1,224 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "context" - "errors" - "fmt" - "strings" - "sync" - - "github.com/99designs/gqlgen/plugin/federation/fedruntime" -) - -var ( - ErrUnknownType = errors.New("unknown type") - ErrTypeNotFound = errors.New("type not found") -) - -func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { - if ec.DisableIntrospection { - return fedruntime.Service{}, errors.New("federated introspection disabled") - } - - var sdl []string - - for _, src := range sources { - if src.BuiltIn { - continue - } - sdl = append(sdl, src.Input) - } - - return fedruntime.Service{ - SDL: strings.Join(sdl, "\n"), - }, nil -} - -func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity { - list := make([]fedruntime.Entity, len(representations)) - - repsMap := map[string]struct { - i []int - r []map[string]interface{} - }{} - - // We group entities by typename so that we can parallelize their resolution. - // This is particularly helpful when there are entity groups in multi mode. - buildRepresentationGroups := func(reps []map[string]interface{}) { - for i, rep := range reps { - typeName, ok := rep["__typename"].(string) - if !ok { - // If there is no __typename, we just skip the representation; - // we just won't be resolving these unknown types. - ec.Error(ctx, errors.New("__typename must be an existing string")) - continue - } - - _r := repsMap[typeName] - _r.i = append(_r.i, i) - _r.r = append(_r.r, rep) - repsMap[typeName] = _r - } - } - - isMulti := func(typeName string) bool { - switch typeName { - default: - return false - } - } - - resolveEntity := func(ctx context.Context, typeName string, rep map[string]interface{}, idx []int, i int) (err error) { - // we need to do our own panic handling, because we may be called in a - // goroutine, where the usual panic handling can't catch us - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - } - }() - - switch typeName { - case "Account": - resolverName, err := entityResolverNameForAccount(ctx, rep) - if err != nil { - return fmt.Errorf(`finding resolver for Entity "Account": %w`, err) - } - switch resolverName { - - case "findAccountByID": - id0, err := ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, rep["id"]) - if err != nil { - return fmt.Errorf(`unmarshalling param 0 for findAccountByID(): %w`, err) - } - entity, err := ec.resolvers.Entity().FindAccountByID(ctx, id0) - if err != nil { - return fmt.Errorf(`resolving Entity "Account": %w`, err) - } - - list[idx[i]] = entity - return nil - } - case "Site": - resolverName, err := entityResolverNameForSite(ctx, rep) - if err != nil { - return fmt.Errorf(`finding resolver for Entity "Site": %w`, err) - } - switch resolverName { - - case "findSiteByID": - id0, err := ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, rep["id"]) - if err != nil { - return fmt.Errorf(`unmarshalling param 0 for findSiteByID(): %w`, err) - } - entity, err := ec.resolvers.Entity().FindSiteByID(ctx, id0) - if err != nil { - return fmt.Errorf(`resolving Entity "Site": %w`, err) - } - - list[idx[i]] = entity - return nil - } - - } - return fmt.Errorf("%w: %s", ErrUnknownType, typeName) - } - - resolveManyEntities := func(ctx context.Context, typeName string, reps []map[string]interface{}, idx []int) (err error) { - // we need to do our own panic handling, because we may be called in a - // goroutine, where the usual panic handling can't catch us - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - } - }() - - switch typeName { - - default: - return errors.New("unknown type: " + typeName) - } - } - - resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) { - if isMulti(typeName) { - err := resolveManyEntities(ctx, typeName, reps, idx) - if err != nil { - ec.Error(ctx, err) - } - } else { - // if there are multiple entities to resolve, parallelize (similar to - // graphql.FieldSet.Dispatch) - var e sync.WaitGroup - e.Add(len(reps)) - for i, rep := range reps { - i, rep := i, rep - go func(i int, rep map[string]interface{}) { - err := resolveEntity(ctx, typeName, rep, idx, i) - if err != nil { - ec.Error(ctx, err) - } - e.Done() - }(i, rep) - } - e.Wait() - } - } - buildRepresentationGroups(representations) - - switch len(repsMap) { - case 0: - return list - case 1: - for typeName, reps := range repsMap { - resolveEntityGroup(typeName, reps.r, reps.i) - } - return list - default: - var g sync.WaitGroup - g.Add(len(repsMap)) - for typeName, reps := range repsMap { - go func(typeName string, reps []map[string]interface{}, idx []int) { - resolveEntityGroup(typeName, reps, idx) - g.Done() - }(typeName, reps.r, reps.i) - } - g.Wait() - return list - } -} - -func entityResolverNameForAccount(ctx context.Context, rep map[string]interface{}) (string, error) { - for { - var ( - m map[string]interface{} - val interface{} - ok bool - ) - _ = val - m = rep - if _, ok = m["id"]; !ok { - break - } - return "findAccountByID", nil - } - return "", fmt.Errorf("%w for Account", ErrTypeNotFound) -} - -func entityResolverNameForSite(ctx context.Context, rep map[string]interface{}) (string, error) { - for { - var ( - m map[string]interface{} - val interface{} - ok bool - ) - _ = val - m = rep - if _, ok = m["id"]; !ok { - break - } - return "findSiteByID", nil - } - return "", fmt.Errorf("%w for Site", ErrTypeNotFound) -} diff --git a/apps/dns/internal/app/graph/generated/generated.go b/apps/dns/internal/app/graph/generated/generated.go deleted file mode 100644 index 511e4ff4b..000000000 --- a/apps/dns/internal/app/graph/generated/generated.go +++ /dev/null @@ -1,4135 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "bytes" - "context" - "errors" - "fmt" - "strconv" - "sync" - "sync/atomic" - - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" - "github.com/99designs/gqlgen/plugin/federation/fedruntime" - gqlparser "github.com/vektah/gqlparser/v2" - "github.com/vektah/gqlparser/v2/ast" - "kloudlite.io/apps/dns/internal/app/graph/model" - "kloudlite.io/pkg/repos" -) - -// region ************************** generated!.gotpl ************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Account() AccountResolver - Entity() EntityResolver - Mutation() MutationResolver - Query() QueryResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - Account struct { - ID func(childComplexity int) int - Sites func(childComplexity int) int - } - - Entity struct { - FindAccountByID func(childComplexity int, id repos.ID) int - FindSiteByID func(childComplexity int, id repos.ID) int - } - - Mutation struct { - DNSCreateSite func(childComplexity int, domain string, accountID repos.ID, regionID repos.ID) int - DNSDeleteSite func(childComplexity int, siteID repos.ID) int - DNSVerifySite func(childComplexity int, siteID repos.ID) int - } - - Query struct { - DNSGetSite func(childComplexity int, siteID repos.ID) int - __resolve__service func(childComplexity int) int - __resolve_entities func(childComplexity int, representations []map[string]interface{}) int - } - - Site struct { - AccountID func(childComplexity int) int - CreationDate func(childComplexity int) int - Domain func(childComplexity int) int - EdgeCname func(childComplexity int) int - ID func(childComplexity int) int - IsVerified func(childComplexity int) int - RegionID func(childComplexity int) int - } - - _Service struct { - SDL func(childComplexity int) int - } -} - -type AccountResolver interface { - Sites(ctx context.Context, obj *model.Account) ([]*model.Site, error) -} -type EntityResolver interface { - FindAccountByID(ctx context.Context, id repos.ID) (*model.Account, error) - FindSiteByID(ctx context.Context, id repos.ID) (*model.Site, error) -} -type MutationResolver interface { - DNSCreateSite(ctx context.Context, domain string, accountID repos.ID, regionID repos.ID) (bool, error) - DNSDeleteSite(ctx context.Context, siteID repos.ID) (bool, error) - DNSVerifySite(ctx context.Context, siteID repos.ID) (bool, error) -} -type QueryResolver interface { - DNSGetSite(ctx context.Context, siteID repos.ID) (*model.Site, error) -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - ec := executionContext{nil, e} - _ = ec - switch typeName + "." + field { - - case "Account.id": - if e.complexity.Account.ID == nil { - break - } - - return e.complexity.Account.ID(childComplexity), true - - case "Account.sites": - if e.complexity.Account.Sites == nil { - break - } - - return e.complexity.Account.Sites(childComplexity), true - - case "Entity.findAccountByID": - if e.complexity.Entity.FindAccountByID == nil { - break - } - - args, err := ec.field_Entity_findAccountByID_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Entity.FindAccountByID(childComplexity, args["id"].(repos.ID)), true - - case "Entity.findSiteByID": - if e.complexity.Entity.FindSiteByID == nil { - break - } - - args, err := ec.field_Entity_findSiteByID_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Entity.FindSiteByID(childComplexity, args["id"].(repos.ID)), true - - case "Mutation.dns_createSite": - if e.complexity.Mutation.DNSCreateSite == nil { - break - } - - args, err := ec.field_Mutation_dns_createSite_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.DNSCreateSite(childComplexity, args["domain"].(string), args["accountId"].(repos.ID), args["regionId"].(repos.ID)), true - - case "Mutation.dns_deleteSite": - if e.complexity.Mutation.DNSDeleteSite == nil { - break - } - - args, err := ec.field_Mutation_dns_deleteSite_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.DNSDeleteSite(childComplexity, args["siteId"].(repos.ID)), true - - case "Mutation.dns_VerifySite": - if e.complexity.Mutation.DNSVerifySite == nil { - break - } - - args, err := ec.field_Mutation_dns_VerifySite_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.DNSVerifySite(childComplexity, args["siteId"].(repos.ID)), true - - case "Query.dns_getSite": - if e.complexity.Query.DNSGetSite == nil { - break - } - - args, err := ec.field_Query_dns_getSite_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.DNSGetSite(childComplexity, args["siteId"].(repos.ID)), true - - case "Query._service": - if e.complexity.Query.__resolve__service == nil { - break - } - - return e.complexity.Query.__resolve__service(childComplexity), true - - case "Query._entities": - if e.complexity.Query.__resolve_entities == nil { - break - } - - args, err := ec.field_Query__entities_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]interface{})), true - - case "Site.accountId": - if e.complexity.Site.AccountID == nil { - break - } - - return e.complexity.Site.AccountID(childComplexity), true - - case "Site.creationDate": - if e.complexity.Site.CreationDate == nil { - break - } - - return e.complexity.Site.CreationDate(childComplexity), true - - case "Site.domain": - if e.complexity.Site.Domain == nil { - break - } - - return e.complexity.Site.Domain(childComplexity), true - - case "Site.edgeCname": - if e.complexity.Site.EdgeCname == nil { - break - } - - return e.complexity.Site.EdgeCname(childComplexity), true - - case "Site.id": - if e.complexity.Site.ID == nil { - break - } - - return e.complexity.Site.ID(childComplexity), true - - case "Site.isVerified": - if e.complexity.Site.IsVerified == nil { - break - } - - return e.complexity.Site.IsVerified(childComplexity), true - - case "Site.regionId": - if e.complexity.Site.RegionID == nil { - break - } - - return e.complexity.Site.RegionID(childComplexity), true - - case "_Service.sdl": - if e.complexity._Service.SDL == nil { - break - } - - return e.complexity._Service.SDL(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { - rc := graphql.GetOperationContext(ctx) - ec := executionContext{rc, e} - first := true - - switch rc.Operation.Operation { - case ast.Query: - return func(ctx context.Context) *graphql.Response { - if !first { - return nil - } - first = false - data := ec._Query(ctx, rc.Operation.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), - } - } - case ast.Mutation: - return func(ctx context.Context) *graphql.Response { - if !first { - return nil - } - first = false - data := ec._Mutation(ctx, rc.Operation.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), - } - } - - default: - return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) - } -} - -type executionContext struct { - *graphql.OperationContext - *executableSchema -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapSchema(parsedSchema), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} - -var sources = []*ast.Source{ - {Name: "graph/schema.graphqls", Input: `scalar Json -scalar Any - -type Query { - dns_getSite(siteId:ID!): Site! # account-owner-access, account-admin-access -} - -extend type Account @key(fields: "id") { - id: ID! @external - sites:[Site]! # account-owner-access, account-admin-access, project-admin-access, project-developer-access, account-developer-access -} - -type Site @key(fields: "id"){ - id : ID! - regionId: ID! - accountId: ID! - isVerified: Boolean! - domain: String! - creationDate: String! - edgeCname: String! -} - - -type Mutation { - dns_createSite(domain:String!, accountId:ID!, regionId:ID!) :Boolean! # account-owner-access, account-admin-access - dns_deleteSite(siteId:ID!) :Boolean! # account-owner-access, account-admin-access - dns_VerifySite(siteId:ID!) :Boolean! # account-owner-access, account-admin-access -} -`, BuiltIn: false}, - {Name: "federation/directives.graphql", Input: ` -scalar _Any -scalar _FieldSet - -directive @external on FIELD_DEFINITION -directive @requires(fields: _FieldSet!) on FIELD_DEFINITION -directive @provides(fields: _FieldSet!) on FIELD_DEFINITION -directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE -directive @extends on OBJECT | INTERFACE -`, BuiltIn: true}, - {Name: "federation/entity.graphql", Input: ` -# a union of all types that use the @key directive -union _Entity = Account | Site - -# fake type to build resolver interfaces for users to implement -type Entity { - findAccountByID(id: ID!,): Account! - findSiteByID(id: ID!,): Site! - -} - -type _Service { - sdl: String -} - -extend type Query { - _entities(representations: [_Any!]!): [_Entity]! - _service: _Service! -} -`, BuiltIn: true}, -} -var parsedSchema = gqlparser.MustLoadSchema(sources...) - -// endregion ************************** generated!.gotpl ************************** - -// region ***************************** args.gotpl ***************************** - -func (ec *executionContext) field_Entity_findAccountByID_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 repos.ID - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Entity_findSiteByID_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 repos.ID - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_dns_VerifySite_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 repos.ID - if tmp, ok := rawArgs["siteId"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("siteId")) - arg0, err = ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["siteId"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_dns_createSite_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["domain"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("domain")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["domain"] = arg0 - var arg1 repos.ID - if tmp, ok := rawArgs["accountId"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountId")) - arg1, err = ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountId"] = arg1 - var arg2 repos.ID - if tmp, ok := rawArgs["regionId"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("regionId")) - arg2, err = ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["regionId"] = arg2 - return args, nil -} - -func (ec *executionContext) field_Mutation_dns_deleteSite_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 repos.ID - if tmp, ok := rawArgs["siteId"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("siteId")) - arg0, err = ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["siteId"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query__entities_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 []map[string]interface{} - if tmp, ok := rawArgs["representations"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("representations")) - arg0, err = ec.unmarshalN_Any2ᚕmapᚄ(ctx, tmp) - if err != nil { - return nil, err - } - } - args["representations"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_dns_getSite_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 repos.ID - if tmp, ok := rawArgs["siteId"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("siteId")) - arg0, err = ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["siteId"] = arg0 - return args, nil -} - -func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -// endregion ***************************** args.gotpl ***************************** - -// region ************************** directives.gotpl ************************** - -// endregion ************************** directives.gotpl ************************** - -// region **************************** field.gotpl ***************************** - -func (ec *executionContext) _Account_id(ctx context.Context, field graphql.CollectedField, obj *model.Account) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Account", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, 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.(repos.ID) - fc.Result = res - return ec.marshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, field.Selections, res) -} - -func (ec *executionContext) _Account_sites(ctx context.Context, field graphql.CollectedField, obj *model.Account) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Account", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Account().Sites(rctx, obj) - }) - 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.([]*model.Site) - fc.Result = res - return ec.marshalNSite2ᚕᚖkloudliteᚗioᚋappsᚋdnsᚋinternalᚋappᚋgraphᚋmodelᚐSite(ctx, field.Selections, res) -} - -func (ec *executionContext) _Entity_findAccountByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Entity", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Entity_findAccountByID_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindAccountByID(rctx, args["id"].(repos.ID)) - }) - 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.(*model.Account) - fc.Result = res - return ec.marshalNAccount2ᚖkloudliteᚗioᚋappsᚋdnsᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx, field.Selections, res) -} - -func (ec *executionContext) _Entity_findSiteByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Entity", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Entity_findSiteByID_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindSiteByID(rctx, args["id"].(repos.ID)) - }) - 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.(*model.Site) - fc.Result = res - return ec.marshalNSite2ᚖkloudliteᚗioᚋappsᚋdnsᚋinternalᚋappᚋgraphᚋmodelᚐSite(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_dns_createSite(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_dns_createSite_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DNSCreateSite(rctx, args["domain"].(string), args["accountId"].(repos.ID), args["regionId"].(repos.ID)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_dns_deleteSite(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_dns_deleteSite_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DNSDeleteSite(rctx, args["siteId"].(repos.ID)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_dns_VerifySite(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_dns_VerifySite_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DNSVerifySite(rctx, args["siteId"].(repos.ID)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_dns_getSite(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_dns_getSite_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DNSGetSite(rctx, args["siteId"].(repos.ID)) - }) - 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.(*model.Site) - fc.Result = res - return ec.marshalNSite2ᚖkloudliteᚗioᚋappsᚋdnsᚋinternalᚋappᚋgraphᚋmodelᚐSite(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query__entities_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.__resolve_entities(ctx, args["representations"].([]map[string]interface{})), 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.([]fedruntime.Entity) - fc.Result = res - return ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.__resolve__service(ctx) - }) - 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.(fedruntime.Service) - fc.Result = res - return ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) -} - -func (ec *executionContext) _Site_id(ctx context.Context, field graphql.CollectedField, obj *model.Site) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Site", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, 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.(repos.ID) - fc.Result = res - return ec.marshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, field.Selections, res) -} - -func (ec *executionContext) _Site_regionId(ctx context.Context, field graphql.CollectedField, obj *model.Site) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Site", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.RegionID, 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.(repos.ID) - fc.Result = res - return ec.marshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, field.Selections, res) -} - -func (ec *executionContext) _Site_accountId(ctx context.Context, field graphql.CollectedField, obj *model.Site) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Site", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.AccountID, 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.(repos.ID) - fc.Result = res - return ec.marshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, field.Selections, res) -} - -func (ec *executionContext) _Site_isVerified(ctx context.Context, field graphql.CollectedField, obj *model.Site) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Site", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsVerified, 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Site_domain(ctx context.Context, field graphql.CollectedField, obj *model.Site) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Site", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Domain, 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) _Site_creationDate(ctx context.Context, field graphql.CollectedField, obj *model.Site) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Site", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.CreationDate, 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) _Site_edgeCname(ctx context.Context, field graphql.CollectedField, obj *model.Site) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Site", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EdgeCname, 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) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "_Service", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SDL, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - 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) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, 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.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsRepeatable, 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - 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) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - 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) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, 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.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - 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.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - 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) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - 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.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), 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.([]introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.QueryType(), 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.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Directives(), 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.([]introspection.Directive) - fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - 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 { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.EnumValue) - fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SpecifiedByURL(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** - -func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler { - switch obj := (obj).(type) { - case nil: - return graphql.Null - case model.Account: - return ec._Account(ctx, sel, &obj) - case *model.Account: - if obj == nil { - return graphql.Null - } - return ec._Account(ctx, sel, obj) - case model.Site: - return ec._Site(ctx, sel, &obj) - case *model.Site: - if obj == nil { - return graphql.Null - } - return ec._Site(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } -} - -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - -var accountImplementors = []string{"Account", "_Entity"} - -func (ec *executionContext) _Account(ctx context.Context, sel ast.SelectionSet, obj *model.Account) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, accountImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Account") - case "id": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Account_id(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "sites": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Account_sites(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) - - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var entityImplementors = []string{"Entity"} - -func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Entity", - }) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Entity") - case "findAccountByID": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Entity_findAccountByID(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "findSiteByID": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Entity_findSiteByID(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var mutationImplementors = []string{"Mutation"} - -func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Mutation", - }) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Mutation") - case "dns_createSite": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_dns_createSite(ctx, field) - } - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "dns_deleteSite": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_dns_deleteSite(ctx, field) - } - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "dns_VerifySite": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_dns_VerifySite(ctx, field) - } - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var queryImplementors = []string{"Query"} - -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "dns_getSite": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_dns_getSite(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "_entities": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query__entities(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "_service": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query__service(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "__type": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___type(ctx, field) - } - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) - - case "__schema": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___schema(ctx, field) - } - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var siteImplementors = []string{"Site", "_Entity"} - -func (ec *executionContext) _Site(ctx context.Context, sel ast.SelectionSet, obj *model.Site) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, siteImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Site") - case "id": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Site_id(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "regionId": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Site_regionId(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "accountId": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Site_accountId(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "isVerified": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Site_isVerified(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "domain": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Site_domain(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "creationDate": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Site_creationDate(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "edgeCname": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec._Site_edgeCname(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var _ServiceImplementors = []string{"_Service"} - -func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, obj *fedruntime.Service) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, _ServiceImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("_Service") - case "sdl": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.__Service_sdl(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __DirectiveImplementors = []string{"__Directive"} - -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Directive_name(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Directive_description(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "locations": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Directive_locations(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "args": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Directive_args(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "isRepeatable": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Directive_isRepeatable(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __EnumValueImplementors = []string{"__EnumValue"} - -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___EnumValue_name(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___EnumValue_description(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "isDeprecated": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___EnumValue_isDeprecated(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "deprecationReason": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___EnumValue_deprecationReason(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __FieldImplementors = []string{"__Field"} - -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_name(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_description(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "args": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_args(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "type": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_type(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "isDeprecated": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_isDeprecated(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "deprecationReason": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Field_deprecationReason(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __InputValueImplementors = []string{"__InputValue"} - -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___InputValue_name(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___InputValue_description(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "type": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___InputValue_type(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "defaultValue": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___InputValue_defaultValue(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __SchemaImplementors = []string{"__Schema"} - -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_description(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "types": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_types(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "queryType": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_queryType(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "mutationType": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_mutationType(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "subscriptionType": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_subscriptionType(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "directives": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Schema_directives(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __TypeImplementors = []string{"__Type"} - -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_kind(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "name": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_name(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "description": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_description(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "fields": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_fields(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "interfaces": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_interfaces(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "possibleTypes": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_possibleTypes(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "enumValues": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_enumValues(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "inputFields": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_inputFields(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "ofType": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_ofType(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - case "specifiedByURL": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - return ec.___Type_specifiedByURL(ctx, field, obj) - } - - out.Values[i] = innerFunc(ctx) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -// endregion **************************** object.gotpl **************************** - -// region ***************************** type.gotpl ***************************** - -func (ec *executionContext) marshalNAccount2kloudliteᚗioᚋappsᚋdnsᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx context.Context, sel ast.SelectionSet, v model.Account) graphql.Marshaler { - return ec._Account(ctx, sel, &v) -} - -func (ec *executionContext) marshalNAccount2ᚖkloudliteᚗioᚋappsᚋdnsᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx context.Context, sel ast.SelectionSet, v *model.Account) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._Account(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx context.Context, v interface{}) (repos.ID, error) { - tmp, err := graphql.UnmarshalString(v) - res := repos.ID(tmp) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx context.Context, sel ast.SelectionSet, v repos.ID) graphql.Marshaler { - res := graphql.MarshalString(string(v)) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) marshalNSite2kloudliteᚗioᚋappsᚋdnsᚋinternalᚋappᚋgraphᚋmodelᚐSite(ctx context.Context, sel ast.SelectionSet, v model.Site) graphql.Marshaler { - return ec._Site(ctx, sel, &v) -} - -func (ec *executionContext) marshalNSite2ᚕᚖkloudliteᚗioᚋappsᚋdnsᚋinternalᚋappᚋgraphᚋmodelᚐSite(ctx context.Context, sel ast.SelectionSet, v []*model.Site) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOSite2ᚖkloudliteᚗioᚋappsᚋdnsᚋinternalᚋappᚋgraphᚋmodelᚐSite(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalNSite2ᚖkloudliteᚗioᚋappsᚋdnsᚋinternalᚋappᚋgraphᚋmodelᚐSite(ctx context.Context, sel ast.SelectionSet, v *model.Site) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._Site(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { - res, err := graphql.UnmarshalMap(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := graphql.MarshalMap(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]map[string]interface{}, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalN_Any2map(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.SelectionSet, v []map[string]interface{}) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalN_Any2map(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { - return ec.__Service(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) - return res -} - -func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalBoolean(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalBoolean(*v) - return res -} - -func (ec *executionContext) marshalOSite2ᚖkloudliteᚗioᚋappsᚋdnsᚋinternalᚋappᚋgraphᚋmodelᚐSite(ctx context.Context, sel ast.SelectionSet, v *model.Site) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Site(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - return res -} - -func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalString(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalString(*v) - return res -} - -func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.__Entity(ctx, sel, v) -} - -func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) -} - -func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -// endregion ***************************** type.gotpl ***************************** diff --git a/apps/dns/internal/app/graph/model/models_gen.go b/apps/dns/internal/app/graph/model/models_gen.go deleted file mode 100644 index ba1448b52..000000000 --- a/apps/dns/internal/app/graph/model/models_gen.go +++ /dev/null @@ -1,26 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package model - -import ( - "kloudlite.io/pkg/repos" -) - -type Account struct { - ID repos.ID `json:"id"` - Sites []*Site `json:"sites"` -} - -func (Account) IsEntity() {} - -type Site struct { - ID repos.ID `json:"id"` - RegionID repos.ID `json:"regionId"` - AccountID repos.ID `json:"accountId"` - IsVerified bool `json:"isVerified"` - Domain string `json:"domain"` - CreationDate string `json:"creationDate"` - EdgeCname string `json:"edgeCname"` -} - -func (Site) IsEntity() {} diff --git a/apps/dns/internal/app/graph/resolver.go b/apps/dns/internal/app/graph/resolver.go deleted file mode 100644 index 5959dda75..000000000 --- a/apps/dns/internal/app/graph/resolver.go +++ /dev/null @@ -1,19 +0,0 @@ -package graph - -import ( - "kloudlite.io/apps/dns/internal/domain" -) - -// This file will not be regenerated automatically. -// -// It serves as dependency injection for your app, add any dependencies you require here. - -type Resolver struct { - d domain.Domain -} - -func NewResolver(domain domain.Domain) *Resolver { - return &Resolver{ - domain, - } -} diff --git a/apps/dns/internal/app/graph/schema.graphqls b/apps/dns/internal/app/graph/schema.graphqls deleted file mode 100644 index 3c56a1785..000000000 --- a/apps/dns/internal/app/graph/schema.graphqls +++ /dev/null @@ -1,28 +0,0 @@ -scalar Json -scalar Any - -type Query { - dns_getSite(siteId:ID!): Site! # account-owner-access, account-admin-access -} - -extend type Account @key(fields: "name") { - name: String! @external - sites:[Site]! # account-owner-access, account-admin-access, project-admin-access, project-developer-access, account-developer-access -} - -type Site @key(fields: "id"){ - id : ID! - regionId: ID! - accountId: ID! - isVerified: Boolean! - domain: String! - creationDate: String! - edgeCname: String! -} - - -type Mutation { - dns_createSite(domain:String!, accountId:ID!, regionId:ID!) :Boolean! # account-owner-access, account-admin-access - dns_deleteSite(siteId:ID!) :Boolean! # account-owner-access, account-admin-access - dns_VerifySite(siteId:ID!) :Boolean! # account-owner-access, account-admin-access -} diff --git a/apps/dns/internal/app/graph/schema.resolvers.go b/apps/dns/internal/app/graph/schema.resolvers.go deleted file mode 100644 index d6e2e8a5f..000000000 --- a/apps/dns/internal/app/graph/schema.resolvers.go +++ /dev/null @@ -1,89 +0,0 @@ -package graph - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. - -import ( - "context" - - "kloudlite.io/apps/dns/internal/app/graph/generated" - "kloudlite.io/apps/dns/internal/app/graph/model" - "kloudlite.io/pkg/repos" -) - -func (r *accountResolver) Sites(ctx context.Context, obj *model.Account) ([]*model.Site, error) { - sitesEntities, err := r.d.GetSites(ctx, string(obj.ID)) - if err != nil { - return nil, err - } - sites := make([]*model.Site, 0) - for _, e := range sitesEntities { - edgeCname, err := r.d.GetAccountEdgeCName(ctx, string(e.AccountId), e.RegionId) - if err != nil { - edgeCname = "" - } - sites = append(sites, &model.Site{ - ID: e.Id, - RegionID: e.RegionId, - AccountID: e.AccountId, - IsVerified: e.Verified, - Domain: e.Domain, - EdgeCname: edgeCname, - }) - } - return sites, nil -} - -func (r *mutationResolver) DNSCreateSite(ctx context.Context, domain string, accountID repos.ID, regionID repos.ID) (bool, error) { - err := r.d.CreateSite(ctx, domain, accountID, regionID) - if err != nil { - return false, err - } - return true, nil -} - -func (r *mutationResolver) DNSDeleteSite(ctx context.Context, siteID repos.ID) (bool, error) { - err := r.d.DeleteSite(ctx, siteID) - if err != nil { - return false, err - } - return true, nil -} - -func (r *mutationResolver) DNSVerifySite(ctx context.Context, siteID repos.ID) (bool, error) { - err := r.d.VerifySite(ctx, siteID) - return err == nil, err -} - -func (r *queryResolver) DNSGetSite(ctx context.Context, siteID repos.ID) (*model.Site, error) { - site, err := r.d.GetSite(ctx, string(siteID)) - if err != nil { - return nil, err - } - edgeCname, err := r.d.GetAccountEdgeCName(ctx, string(site.AccountId), site.RegionId) - if err != nil { - return nil, err - } - - return &model.Site{ - ID: site.Id, - RegionID: site.RegionId, - AccountID: site.AccountId, - IsVerified: site.Verified, - Domain: site.Domain, - EdgeCname: edgeCname, - }, nil -} - -// Account returns generated.AccountResolver implementation. -func (r *Resolver) Account() generated.AccountResolver { return &accountResolver{r} } - -// Mutation returns generated.MutationResolver implementation. -func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } - -// Query returns generated.QueryResolver implementation. -func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } - -type accountResolver struct{ *Resolver } -type mutationResolver struct{ *Resolver } -type queryResolver struct{ *Resolver } diff --git a/apps/dns/internal/app/grpc-server.go b/apps/dns/internal/app/grpc-server.go deleted file mode 100644 index 4b8f7db25..000000000 --- a/apps/dns/internal/app/grpc-server.go +++ /dev/null @@ -1,34 +0,0 @@ -package app - -import ( - "context" - "kloudlite.io/apps/dns/internal/domain" - kldns "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/dns" -) - -type dnsServerI struct { - kldns.UnimplementedDNSServer - d domain.Domain -} - -func (d *dnsServerI) GetAccountDomains(ctx context.Context, in *kldns.GetAccountDomainsIn) (*kldns.GetAccountDomainsOut, error) { - _sites, err := d.d.GetSites(ctx, in.AccountId) - if err != nil { - return nil, err - } - return &kldns.GetAccountDomainsOut{ - Domains: func() []string { - sites := make([]string, 0) - for _, site := range _sites { - sites = append(sites, site.Domain) - } - return sites - }(), - }, nil -} - -func fxDNSGrpcServer(d domain.Domain) kldns.DNSServer { - return &dnsServerI{ - d: d, - } -} diff --git a/apps/dns/internal/app/main.go b/apps/dns/internal/app/main.go deleted file mode 100644 index 39f9e4671..000000000 --- a/apps/dns/internal/app/main.go +++ /dev/null @@ -1,286 +0,0 @@ -package app - -import ( - "context" - "encoding/json" - "fmt" - "github.com/codingconcepts/env" - "github.com/gofiber/fiber/v2" - "google.golang.org/grpc" - "kloudlite.io/constants" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/console" - kldns "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/dns" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/finance" - "math/rand" - "net" - "strings" - - "github.com/miekg/dns" - "go.uber.org/fx" - "kloudlite.io/apps/dns/internal/app/graph" - "kloudlite.io/apps/dns/internal/app/graph/generated" - "kloudlite.io/apps/dns/internal/domain" - "kloudlite.io/common" - "kloudlite.io/pkg/cache" - "kloudlite.io/pkg/config" - httpServer "kloudlite.io/pkg/http-server" - "kloudlite.io/pkg/repos" -) - -type Env struct { - CookieDomain string `env:"COOKIE_DOMAIN"` - EdgeCnameBaseDomain string `env:"EDGE_CNAME_BASE_DOMAIN" required:"true"` - DNSDomainNames string `env:"DNS_DOMAIN_NAMES" required:"true"` -} - -type DNSHandler struct { - domain domain.Domain - EdgeCnameBaseDomain string - dnsDomainNames []string -} - -func (h *DNSHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) { - var e Env - if err := env.Set(&e); err == nil { - h.EdgeCnameBaseDomain = e.EdgeCnameBaseDomain - } - msg := dns.Msg{} - msg.SetReply(r) - msg.Answer = []dns.RR{} - for _, q := range r.Question { - switch q.Qtype { - case dns.TypeNS: - for _, name := range h.dnsDomainNames { - rr := &dns.NS{ - Hdr: dns.RR_Header{ - Name: q.Name, - Rrtype: dns.TypeNS, - Class: q.Qclass, - Ttl: 60, - }, - Ns: fmt.Sprintf("%s.", name), - } - msg.Answer = append(msg.Answer, rr) - } - case dns.TypeA: - msg.Authoritative = true - d := q.Name - todo := context.TODO() - host := strings.ToLower(d[:len(d)-1]) - - if strings.HasSuffix(host, h.EdgeCnameBaseDomain) { - splits := strings.Split(host, h.EdgeCnameBaseDomain) - queryPart := splits[0] - querySplits := strings.Split(queryPart, ".") - var ips []string - var err error - if len(querySplits) == 4 { - regionPart := querySplits[0] - accountPart := querySplits[1] - clusterPart := querySplits[2] - ips, err = h.domain.GetNodeIps(todo, ®ionPart, &accountPart, clusterPart) - if err != nil { - fmt.Println(err) - continue - } - } else if len(querySplits) == 3 { - accountPart := querySplits[0] - clusterPart := querySplits[1] - ips, err = h.domain.GetNodeIps(todo, nil, &accountPart, clusterPart) - if err != nil { - fmt.Println(err) - continue - } - } else { - clusterPart := querySplits[0] - ips, err = h.domain.GetNodeIps(todo, nil, nil, clusterPart) - if err != nil { - fmt.Println(err) - continue - } - } - - //ips, err := h.domain.GetNodeIps(todo, nil) - if len(ips) == 0 { - msg.Answer = append(msg.Answer, &dns.A{ - Hdr: dns.RR_Header{Name: d, Rrtype: dns.TypeA, Class: dns.ClassINET}, - }) - } - for _, ip := range ips { - msg.Answer = append(msg.Answer, &dns.A{ - Hdr: dns.RR_Header{Name: d, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 300}, - A: net.ParseIP(ip), - }, - ) - } - } else { - record, err := h.domain.GetRecord(todo, host) - if err != nil || record == nil { - msg.Answer = append(msg.Answer, &dns.A{ - Hdr: dns.RR_Header{Name: d, Rrtype: dns.TypeA, Class: dns.ClassINET}, - }) - } else { - rand.Shuffle(len(record.Answers), func(i, j int) { - record.Answers[i], record.Answers[j] = record.Answers[j], record.Answers[i] - }) - - for _, a := range record.Answers { - msg.Answer = append(msg.Answer, &dns.A{ - Hdr: dns.RR_Header{Name: d, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: uint32(30)}, - A: net.ParseIP(a), - }, - ) - } - } - } - } - } - - err := w.WriteMsg(&msg) - if err != nil { - fmt.Println(err) - } - fmt.Println("HERE3", msg.Answer) -} - -type ConsoleClientConnection *grpc.ClientConn -type FinanceClientConnection *grpc.ClientConn - -var Module = fx.Module( - "app", - config.EnvFx[Env](), - repos.NewFxMongoRepo[*domain.Record]("records", "rec", domain.RecordIndexes), - repos.NewFxMongoRepo[*domain.Site]("sites", "site", domain.SiteIndexes), - repos.NewFxMongoRepo[*domain.AccountCName]("account_cnames", "dns", domain.AccountCNameIndexes), - repos.NewFxMongoRepo[*domain.RegionCName]("region_cnames", "dns", domain.RegionCNameIndexes), - repos.NewFxMongoRepo[*domain.NodeIps]("node_ips", "nips", domain.NodeIpIndexes), - cache.NewFxRepo[[]*domain.Record](), - domain.Module, - - fx.Provide(func(conn ConsoleClientConnection) console.ConsoleClient { - return console.NewConsoleClient((*grpc.ClientConn)(conn)) - }), - - fx.Provide(func(conn FinanceClientConnection) finance.FinanceClient { - return finance.NewFinanceClient((*grpc.ClientConn)(conn)) - }), - - fx.Invoke(func(lifecycle fx.Lifecycle, s *dns.Server, d domain.Domain, recCache cache.Repo[[]*domain.Record], env *Env) { - lifecycle.Append(fx.Hook{ - OnStart: func(ctx context.Context) error { - s.Handler = &DNSHandler{ - domain: d, - dnsDomainNames: strings.Split(env.DNSDomainNames, ","), - } - return nil - }, - }) - }), - fx.Provide(fxDNSGrpcServer), - fx.Invoke(func(server *grpc.Server, dnsServer kldns.DNSServer) { - kldns.RegisterDNSServer(server, dnsServer) - }), - fx.Invoke(func( - server *fiber.App, - d domain.Domain, - env *Env, - cacheClient cache.Client, - ) { - schema := generated.NewExecutableSchema( - generated.Config{Resolvers: graph.NewResolver(d)}, - ) - - server.Post("/upsert-domain", func(c *fiber.Ctx) error { - var data struct { - Domain string - ARecords []string - } - err := json.Unmarshal(c.Body(), &data) - if err != nil { - return err - } - err = d.UpsertARecords(c.Context(), data.Domain, data.ARecords) - if err != nil { - return err - } - c.Send([]byte("done")) - return nil - - }) - - server.Post("/upsert-node-ips", func(c *fiber.Ctx) error { - var regionIps struct { - RegionId string `json:"region"` - Cluster string `json:"cluster"` - AccountId string `json:"account"` - Ips []string `json:"ips"` - } - - err := json.Unmarshal(c.Body(), ®ionIps) - if err != nil { - return err - } - done := d.UpdateNodeIPs( - c.Context(), - regionIps.RegionId, - regionIps.AccountId, - regionIps.Cluster, - regionIps.Ips, - ) - if !done { - return fmt.Errorf("failed to update node ips") - } - c.Send([]byte("done")) - return nil - }) - - server.Get("/get-records/:domain_name", func(c *fiber.Ctx) error { - domainName := c.Params("domain_name") - record, err := d.GetRecord(c.Context(), domainName) - if err != nil { - return err - } - r, err := json.Marshal(record) - if err != nil { - return err - } - c.Send(r) - return nil - }) - - server.Get("/get-region-domain/:accountId/:regionId", func(c *fiber.Ctx) error { - accountId := c.Params("accountId") - regionId := c.Params("regionId") - s, err := d.GetAccountEdgeCName(c.Context(), accountId, repos.ID(regionId)) - if err != nil { - return err - } - c.Send([]byte(s)) - return nil - }) - - server.Delete("/delete-domain/:domain_name", func(c *fiber.Ctx) error { - domainName := c.Params("domain_name") - - err := d.DeleteRecords(c.Context(), domainName) - - if err != nil { - return err - } - - c.Send([]byte("done")) - return nil - }) - - httpServer.SetupGQLServer( - server, - schema, - httpServer.NewSessionMiddleware[*common.AuthSession]( - cacheClient, - constants.CookieName, - env.CookieDomain, - constants.CacheSessionPrefix, - ), - ) - }), -) diff --git a/apps/dns/internal/domain/data.go b/apps/dns/internal/domain/data.go deleted file mode 100644 index f6ba9461e..000000000 --- a/apps/dns/internal/domain/data.go +++ /dev/null @@ -1,2879 +0,0 @@ -package domain - -var ADJECTIVES = []string{ - "abandoned", - "able", - "absolute", - "adorable", - "adventurous", - "academic", - "acceptable", - "acclaimed", - "accomplished", - "accurate", - "aching", - "acidic", - "acrobatic", - "active", - "actual", - "adept", - "admirable", - "admired", - "adolescent", - "adorable", - "adored", - "advanced", - "afraid", - "affectionate", - "aged", - "aggravating", - "aggressive", - "agile", - "agitated", - "agonizing", - "agreeable", - "ajar", - "alarmed", - "alarming", - "alert", - "alienated", - "alive", - "all", - "altruistic", - "amazing", - "ambitious", - "ample", - "amused", - "amusing", - "anchored", - "ancient", - "angelic", - "angry", - "anguished", - "animated", - "annual", - "another", - "antique", - "anxious", - "any", - "apprehensive", - "appropriate", - "apt", - "arctic", - "arid", - "aromatic", - "artistic", - "ashamed", - "assured", - "astonishing", - "athletic", - "attached", - "attentive", - "attractive", - "austere", - "authentic", - "authorized", - "automatic", - "avaricious", - "average", - "aware", - "awesome", - "awful", - "awkward", - "babyish", - "bad", - "back", - "baggy", - "bare", - "barren", - "basic", - "beautiful", - "belated", - "beloved", - "beneficial", - "better", - "best", - "bewitched", - "big", - "big-hearted", - "biodegradable", - "bite-sized", - "bitter", - "black", - "black-and-white", - "bland", - "blank", - "blaring", - "bleak", - "blind", - "blissful", - "blond", - "blue", - "blushing", - "bogus", - "boiling", - "bold", - "bony", - "boring", - "bossy", - "both", - "bouncy", - "bountiful", - "bowed", - "brave", - "breakable", - "brief", - "bright", - "brilliant", - "brisk", - "broken", - "bronze", - "brown", - "bruised", - "bubbly", - "bulky", - "bumpy", - "buoyant", - "burdensome", - "burly", - "bustling", - "busy", - "buttery", - "buzzing", - "calculating", - "calm", - "candid", - "canine", - "capital", - "carefree", - "careful", - "careless", - "caring", - "cautious", - "cavernous", - "celebrated", - "charming", - "cheap", - "cheerful", - "cheery", - "chief", - "chilly", - "chubby", - "circular", - "classic", - "clean", - "clear", - "clear-cut", - "clever", - "close", - "closed", - "cloudy", - "clueless", - "clumsy", - "cluttered", - "coarse", - "cold", - "colorful", - "colorless", - "colossal", - "comfortable", - "common", - "compassionate", - "competent", - "complete", - "complex", - "complicated", - "composed", - "concerned", - "concrete", - "confused", - "conscious", - "considerate", - "constant", - "content", - "conventional", - "cooked", - "cool", - "cooperative", - "coordinated", - "corny", - "corrupt", - "costly", - "courageous", - "courteous", - "crafty", - "crazy", - "creamy", - "creative", - "creepy", - "criminal", - "crisp", - "critical", - "crooked", - "crowded", - "cruel", - "crushing", - "cuddly", - "cultivated", - "cultured", - "cumbersome", - "curly", - "curvy", - "cute", - "cylindrical", - "damaged", - "damp", - "dangerous", - "dapper", - "daring", - "darling", - "dark", - "dazzling", - "dead", - "deadly", - "deafening", - "dear", - "dearest", - "decent", - "decimal", - "decisive", - "deep", - "defenseless", - "defensive", - "defiant", - "deficient", - "definite", - "definitive", - "delayed", - "delectable", - "delicious", - "delightful", - "delirious", - "demanding", - "dense", - "dental", - "dependable", - "dependent", - "descriptive", - "deserted", - "detailed", - "determined", - "devoted", - "different", - "difficult", - "digital", - "diligent", - "dim", - "dimpled", - "dimwitted", - "direct", - "disastrous", - "discrete", - "disfigured", - "disgusting", - "disloyal", - "dismal", - "distant", - "downright", - "dreary", - "dirty", - "disguised", - "dishonest", - "dismal", - "distant", - "distinct", - "distorted", - "dizzy", - "dopey", - "doting", - "double", - "downright", - "drab", - "drafty", - "dramatic", - "dreary", - "droopy", - "dry", - "dual", - "dull", - "dutiful", - "each", - "eager", - "earnest", - "early", - "easy", - "easy-going", - "ecstatic", - "edible", - "educated", - "elaborate", - "elastic", - "elated", - "elderly", - "electric", - "elegant", - "elementary", - "elliptical", - "embarrassed", - "embellished", - "eminent", - "emotional", - "empty", - "enchanted", - "enchanting", - "energetic", - "enlightened", - "enormous", - "enraged", - "entire", - "envious", - "equal", - "equatorial", - "essential", - "esteemed", - "ethical", - "euphoric", - "even", - "evergreen", - "everlasting", - "every", - "evil", - "exalted", - "excellent", - "exemplary", - "exhausted", - "excitable", - "excited", - "exciting", - "exotic", - "expensive", - "experienced", - "expert", - "extraneous", - "extroverted", - "extra-large", - "extra-small", - "fabulous", - "failing", - "faint", - "fair", - "faithful", - "fake", - "false", - "familiar", - "famous", - "fancy", - "fantastic", - "far", - "faraway", - "far-flung", - "far-off", - "fast", - "fat", - "fatal", - "fatherly", - "favorable", - "favorite", - "fearful", - "fearless", - "feisty", - "feline", - "female", - "feminine", - "few", - "fickle", - "filthy", - "fine", - "finished", - "firm", - "first", - "firsthand", - "fitting", - "fixed", - "flaky", - "flamboyant", - "flashy", - "flat", - "flawed", - "flawless", - "flickering", - "flimsy", - "flippant", - "flowery", - "fluffy", - "fluid", - "flustered", - "focused", - "fond", - "foolhardy", - "foolish", - "forceful", - "forked", - "formal", - "forsaken", - "forthright", - "fortunate", - "fragrant", - "frail", - "frank", - "frayed", - "free", - "French", - "fresh", - "frequent", - "friendly", - "frightened", - "frightening", - "frigid", - "frilly", - "frizzy", - "frivolous", - "front", - "frosty", - "frozen", - "frugal", - "fruitful", - "full", - "fumbling", - "functional", - "funny", - "fussy", - "fuzzy", - "gargantuan", - "gaseous", - "general", - "generous", - "gentle", - "genuine", - "giant", - "giddy", - "gigantic", - "gifted", - "giving", - "glamorous", - "glaring", - "glass", - "gleaming", - "gleeful", - "glistening", - "glittering", - "gloomy", - "glorious", - "glossy", - "glum", - "golden", - "good", - "good-natured", - "gorgeous", - "graceful", - "gracious", - "grand", - "grandiose", - "granular", - "grateful", - "grave", - "gray", - "great", - "greedy", - "green", - "gregarious", - "grim", - "grimy", - "gripping", - "grizzled", - "gross", - "grotesque", - "grouchy", - "grounded", - "growing", - "growling", - "grown", - "grubby", - "gruesome", - "grumpy", - "guilty", - "gullible", - "gummy", - "hairy", - "half", - "handmade", - "handsome", - "handy", - "happy", - "happy-go-lucky", - "hard", - "hard-to-find", - "harmful", - "harmless", - "harmonious", - "harsh", - "hasty", - "hateful", - "haunting", - "healthy", - "heartfelt", - "hearty", - "heavenly", - "heavy", - "hefty", - "helpful", - "helpless", - "hidden", - "hideous", - "high", - "high-level", - "hilarious", - "hoarse", - "hollow", - "homely", - "honest", - "honorable", - "honored", - "hopeful", - "horrible", - "hospitable", - "hot", - "huge", - "humble", - "humiliating", - "humming", - "humongous", - "hungry", - "hurtful", - "husky", - "icky", - "icy", - "ideal", - "idealistic", - "identical", - "idle", - "idiotic", - "idolized", - "ignorant", - "ill", - "illegal", - "ill-fated", - "ill-informed", - "illiterate", - "illustrious", - "imaginary", - "imaginative", - "immaculate", - "immaterial", - "immediate", - "immense", - "impassioned", - "impeccable", - "impartial", - "imperfect", - "imperturbable", - "impish", - "impolite", - "important", - "impossible", - "impractical", - "impressionable", - "impressive", - "improbable", - "impure", - "inborn", - "incomparable", - "incompatible", - "incomplete", - "inconsequential", - "incredible", - "indelible", - "inexperienced", - "indolent", - "infamous", - "infantile", - "infatuated", - "inferior", - "infinite", - "informal", - "innocent", - "insecure", - "insidious", - "insignificant", - "insistent", - "instructive", - "insubstantial", - "intelligent", - "intent", - "intentional", - "interesting", - "internal", - "international", - "intrepid", - "ironclad", - "irresponsible", - "irritating", - "itchy", - "jaded", - "jagged", - "jam-packed", - "jaunty", - "jealous", - "jittery", - "joint", - "jolly", - "jovial", - "joyful", - "joyous", - "jubilant", - "judicious", - "juicy", - "jumbo", - "junior", - "jumpy", - "juvenile", - "kaleidoscopic", - "keen", - "key", - "kind", - "kindhearted", - "kindly", - "klutzy", - "knobby", - "knotty", - "knowledgeable", - "knowing", - "known", - "kooky", - "kosher", - "lame", - "lanky", - "large", - "last", - "lasting", - "late", - "lavish", - "lawful", - "lazy", - "leading", - "lean", - "leafy", - "left", - "legal", - "legitimate", - "light", - "lighthearted", - "likable", - "likely", - "limited", - "limp", - "limping", - "linear", - "lined", - "liquid", - "little", - "live", - "lively", - "livid", - "loathsome", - "lone", - "lonely", - "long", - "long-term", - "loose", - "lopsided", - "lost", - "loud", - "lovable", - "lovely", - "loving", - "low", - "loyal", - "lucky", - "lumbering", - "luminous", - "lumpy", - "lustrous", - "luxurious", - "mad", - "made-up", - "magnificent", - "majestic", - "major", - "male", - "mammoth", - "married", - "marvelous", - "masculine", - "massive", - "mature", - "meager", - "mealy", - "mean", - "measly", - "meaty", - "medical", - "mediocre", - "medium", - "meek", - "mellow", - "melodic", - "memorable", - "menacing", - "merry", - "messy", - "metallic", - "mild", - "milky", - "mindless", - "miniature", - "minor", - "minty", - "miserable", - "miserly", - "misguided", - "misty", - "mixed", - "modern", - "modest", - "moist", - "monstrous", - "monthly", - "monumental", - "moral", - "mortified", - "motherly", - "motionless", - "mountainous", - "muddy", - "muffled", - "multicolored", - "mundane", - "murky", - "mushy", - "musty", - "muted", - "mysterious", - "naive", - "narrow", - "nasty", - "natural", - "naughty", - "nautical", - "near", - "neat", - "necessary", - "needy", - "negative", - "neglected", - "negligible", - "neighboring", - "nervous", - "new", - "next", - "nice", - "nifty", - "nimble", - "nippy", - "nocturnal", - "noisy", - "nonstop", - "normal", - "notable", - "noted", - "noteworthy", - "novel", - "noxious", - "numb", - "nutritious", - "nutty", - "obedient", - "obese", - "oblong", - "oily", - "oblong", - "obvious", - "occasional", - "odd", - "oddball", - "offbeat", - "offensive", - "official", - "old", - "old-fashioned", - "only", - "open", - "optimal", - "optimistic", - "opulent", - "orange", - "orderly", - "organic", - "ornate", - "ornery", - "ordinary", - "original", - "other", - "our", - "outlying", - "outgoing", - "outlandish", - "outrageous", - "outstanding", - "oval", - "overcooked", - "overdue", - "overjoyed", - "overlooked", - "palatable", - "pale", - "paltry", - "parallel", - "parched", - "partial", - "passionate", - "past", - "pastel", - "peaceful", - "peppery", - "perfect", - "perfumed", - "periodic", - "perky", - "personal", - "pertinent", - "pesky", - "pessimistic", - "petty", - "phony", - "physical", - "piercing", - "pink", - "pitiful", - "plain", - "plaintive", - "plastic", - "playful", - "pleasant", - "pleased", - "pleasing", - "plump", - "plush", - "polished", - "polite", - "political", - "pointed", - "pointless", - "poised", - "poor", - "popular", - "portly", - "posh", - "positive", - "possible", - "potable", - "powerful", - "powerless", - "practical", - "precious", - "present", - "prestigious", - "pretty", - "precious", - "previous", - "pricey", - "prickly", - "primary", - "prime", - "pristine", - "private", - "prize", - "probable", - "productive", - "profitable", - "profuse", - "proper", - "proud", - "prudent", - "punctual", - "pungent", - "puny", - "pure", - "purple", - "pushy", - "putrid", - "puzzled", - "puzzling", - "quaint", - "qualified", - "quarrelsome", - "quarterly", - "queasy", - "querulous", - "questionable", - "quick", - "quick-witted", - "quiet", - "quintessential", - "quirky", - "quixotic", - "quizzical", - "radiant", - "ragged", - "rapid", - "rare", - "rash", - "raw", - "recent", - "reckless", - "rectangular", - "ready", - "real", - "realistic", - "reasonable", - "red", - "reflecting", - "regal", - "regular", - "reliable", - "relieved", - "remarkable", - "remorseful", - "remote", - "repentant", - "required", - "respectful", - "responsible", - "repulsive", - "revolving", - "rewarding", - "rich", - "rigid", - "right", - "ringed", - "ripe", - "roasted", - "robust", - "rosy", - "rotating", - "rotten", - "rough", - "round", - "rowdy", - "royal", - "rubbery", - "rundown", - "ruddy", - "rude", - "runny", - "rural", - "rusty", - "sad", - "safe", - "salty", - "same", - "sandy", - "sane", - "sarcastic", - "sardonic", - "satisfied", - "scaly", - "scarce", - "scared", - "scary", - "scented", - "scholarly", - "scientific", - "scornful", - "scratchy", - "scrawny", - "second", - "secondary", - "second-hand", - "secret", - "self-assured", - "self-reliant", - "selfish", - "sentimental", - "separate", - "serene", - "serious", - "serpentine", - "several", - "severe", - "shabby", - "shadowy", - "shady", - "shallow", - "shameful", - "shameless", - "sharp", - "shimmering", - "shiny", - "shocked", - "shocking", - "shoddy", - "short", - "short-term", - "showy", - "shrill", - "shy", - "sick", - "silent", - "silky", - "silly", - "silver", - "similar", - "simple", - "simplistic", - "sinful", - "single", - "sizzling", - "skeletal", - "skinny", - "sleepy", - "slight", - "slim", - "slimy", - "slippery", - "slow", - "slushy", - "small", - "smart", - "smoggy", - "smooth", - "smug", - "snappy", - "snarling", - "sneaky", - "sniveling", - "snoopy", - "sociable", - "soft", - "soggy", - "solid", - "somber", - "some", - "spherical", - "sophisticated", - "sore", - "sorrowful", - "soulful", - "soupy", - "sour", - "Spanish", - "sparkling", - "sparse", - "specific", - "spectacular", - "speedy", - "spicy", - "spiffy", - "spirited", - "spiteful", - "splendid", - "spotless", - "spotted", - "spry", - "square", - "squeaky", - "squiggly", - "stable", - "staid", - "stained", - "stale", - "standard", - "starchy", - "stark", - "starry", - "steep", - "sticky", - "stiff", - "stimulating", - "stingy", - "stormy", - "straight", - "strange", - "steel", - "strict", - "strident", - "striking", - "striped", - "strong", - "studious", - "stunning", - "stupendous", - "stupid", - "sturdy", - "stylish", - "subdued", - "submissive", - "substantial", - "subtle", - "suburban", - "sudden", - "sugary", - "sunny", - "super", - "superb", - "superficial", - "superior", - "supportive", - "sure-footed", - "surprised", - "suspicious", - "svelte", - "sweaty", - "sweet", - "sweltering", - "swift", - "sympathetic", - "tall", - "talkative", - "tame", - "tan", - "tangible", - "tart", - "tasty", - "tattered", - "taut", - "tedious", - "teeming", - "tempting", - "tender", - "tense", - "tepid", - "terrible", - "terrific", - "testy", - "thankful", - "that", - "these", - "thick", - "thin", - "third", - "thirsty", - "this", - "thorough", - "thorny", - "those", - "thoughtful", - "threadbare", - "thrifty", - "thunderous", - "tidy", - "tight", - "timely", - "tinted", - "tiny", - "tired", - "torn", - "total", - "tough", - "traumatic", - "treasured", - "tremendous", - "tragic", - "trained", - "tremendous", - "triangular", - "tricky", - "trifling", - "trim", - "trivial", - "troubled", - "true", - "trusting", - "trustworthy", - "trusty", - "truthful", - "tubby", - "turbulent", - "twin", - "ugly", - "ultimate", - "unacceptable", - "unaware", - "uncomfortable", - "uncommon", - "unconscious", - "understated", - "unequaled", - "uneven", - "unfinished", - "unfit", - "unfolded", - "unfortunate", - "unhappy", - "unhealthy", - "uniform", - "unimportant", - "unique", - "united", - "unkempt", - "unknown", - "unlawful", - "unlined", - "unlucky", - "unnatural", - "unpleasant", - "unrealistic", - "unripe", - "unruly", - "unselfish", - "unsightly", - "unsteady", - "unsung", - "untidy", - "untimely", - "untried", - "untrue", - "unused", - "unusual", - "unwelcome", - "unwieldy", - "unwilling", - "unwitting", - "unwritten", - "upbeat", - "upright", - "upset", - "urban", - "usable", - "used", - "useful", - "useless", - "utilized", - "utter", - "vacant", - "vague", - "vain", - "valid", - "valuable", - "vapid", - "variable", - "vast", - "velvety", - "venerated", - "vengeful", - "verifiable", - "vibrant", - "vicious", - "victorious", - "vigilant", - "vigorous", - "villainous", - "violet", - "violent", - "virtual", - "virtuous", - "visible", - "vital", - "vivacious", - "vivid", - "voluminous", - "wan", - "warlike", - "warm", - "warmhearted", - "warped", - "wary", - "wasteful", - "watchful", - "waterlogged", - "watery", - "wavy", - "wealthy", - "weak", - "weary", - "webbed", - "wee", - "weekly", - "weepy", - "weighty", - "weird", - "welcome", - "well-documented", - "well-groomed", - "well-informed", - "well-lit", - "well-made", - "well-off", - "well-to-do", - "well-worn", - "wet", - "which", - "whimsical", - "whirlwind", - "whispered", - "white", - "whole", - "whopping", - "wicked", - "wide", - "wide-eyed", - "wiggly", - "wild", - "willing", - "wilted", - "winding", - "windy", - "winged", - "wiry", - "wise", - "witty", - "wobbly", - "woeful", - "wonderful", - "wooden", - "woozy", - "wordy", - "worldly", - "worn", - "worried", - "worrisome", - "worse", - "worst", - "worthless", - "worthwhile", - "worthy", - "wrathful", - "wretched", - "writhing", - "wrong", - "wry", - "yawning", - "yearly", - "yellow", - "yellowish", - "young", - "youthful", - "yummy", - "zany", - "zealous", - "zesty", - "zigzag", -} - -var NOUNS = []string{ - "people", - "history", - "way", - "art", - "world", - "information", - "map", - "two", - "family", - "government", - "health", - "system", - "computer", - "meat", - "year", - "thanks", - "music", - "person", - "reading", - "method", - "data", - "food", - "understanding", - "theory", - "law", - "bird", - "literature", - "problem", - "software", - "control", - "knowledge", - "power", - "ability", - "economics", - "love", - "internet", - "television", - "science", - "library", - "nature", - "fact", - "product", - "idea", - "temperature", - "investment", - "area", - "society", - "activity", - "story", - "industry", - "media", - "thing", - "oven", - "community", - "definition", - "safety", - "quality", - "development", - "language", - "management", - "player", - "variety", - "video", - "week", - "security", - "country", - "exam", - "movie", - "organization", - "equipment", - "physics", - "analysis", - "policy", - "series", - "thought", - "basis", - "boyfriend", - "direction", - "strategy", - "technology", - "army", - "camera", - "freedom", - "paper", - "environment", - "child", - "instance", - "month", - "truth", - "marketing", - "university", - "writing", - "article", - "department", - "difference", - "goal", - "news", - "audience", - "fishing", - "growth", - "income", - "marriage", - "user", - "combination", - "failure", - "meaning", - "medicine", - "philosophy", - "teacher", - "communication", - "night", - "chemistry", - "disease", - "disk", - "energy", - "nation", - "road", - "role", - "soup", - "advertising", - "location", - "success", - "addition", - "apartment", - "education", - "math", - "moment", - "painting", - "politics", - "attention", - "decision", - "event", - "property", - "shopping", - "student", - "wood", - "competition", - "distribution", - "entertainment", - "office", - "population", - "president", - "unit", - "category", - "cigarette", - "context", - "introduction", - "opportunity", - "performance", - "driver", - "flight", - "length", - "magazine", - "newspaper", - "relationship", - "teaching", - "cell", - "dealer", - "finding", - "lake", - "member", - "message", - "phone", - "scene", - "appearance", - "association", - "concept", - "customer", - "death", - "discussion", - "housing", - "inflation", - "insurance", - "mood", - "woman", - "advice", - "blood", - "effort", - "expression", - "importance", - "opinion", - "payment", - "reality", - "responsibility", - "situation", - "skill", - "statement", - "wealth", - "application", - "city", - "county", - "depth", - "estate", - "foundation", - "grandmother", - "heart", - "perspective", - "photo", - "recipe", - "studio", - "topic", - "collection", - "depression", - "imagination", - "passion", - "percentage", - "resource", - "setting", - "ad", - "agency", - "college", - "connection", - "criticism", - "debt", - "description", - "memory", - "patience", - "secretary", - "solution", - "administration", - "aspect", - "attitude", - "director", - "personality", - "psychology", - "recommendation", - "response", - "selection", - "storage", - "version", - "alcohol", - "argument", - "complaint", - "contract", - "emphasis", - "highway", - "loss", - "membership", - "possession", - "preparation", - "steak", - "union", - "agreement", - "cancer", - "currency", - "employment", - "engineering", - "entry", - "interaction", - "mixture", - "preference", - "region", - "republic", - "tradition", - "virus", - "actor", - "classroom", - "delivery", - "device", - "difficulty", - "drama", - "election", - "engine", - "football", - "guidance", - "hotel", - "owner", - "priority", - "protection", - "suggestion", - "tension", - "variation", - "anxiety", - "atmosphere", - "awareness", - "bath", - "bread", - "candidate", - "climate", - "comparison", - "confusion", - "construction", - "elevator", - "emotion", - "employee", - "employer", - "guest", - "height", - "leadership", - "mall", - "manager", - "operation", - "recording", - "sample", - "transportation", - "charity", - "cousin", - "disaster", - "editor", - "efficiency", - "excitement", - "extent", - "feedback", - "guitar", - "homework", - "leader", - "mom", - "outcome", - "permission", - "presentation", - "promotion", - "reflection", - "refrigerator", - "resolution", - "revenue", - "session", - "singer", - "tennis", - "basket", - "bonus", - "cabinet", - "childhood", - "church", - "clothes", - "coffee", - "dinner", - "drawing", - "hair", - "hearing", - "initiative", - "judgment", - "lab", - "measurement", - "mode", - "mud", - "orange", - "poetry", - "police", - "possibility", - "procedure", - "queen", - "ratio", - "relation", - "restaurant", - "satisfaction", - "sector", - "signature", - "significance", - "song", - "tooth", - "town", - "vehicle", - "volume", - "wife", - "accident", - "airport", - "appointment", - "arrival", - "assumption", - "baseball", - "chapter", - "committee", - "conversation", - "database", - "enthusiasm", - "error", - "explanation", - "farmer", - "gate", - "girl", - "hall", - "historian", - "hospital", - "injury", - "instruction", - "maintenance", - "manufacturer", - "meal", - "perception", - "pie", - "poem", - "presence", - "proposal", - "reception", - "replacement", - "revolution", - "river", - "son", - "speech", - "tea", - "village", - "warning", - "winner", - "worker", - "writer", - "assistance", - "breath", - "buyer", - "chest", - "chocolate", - "conclusion", - "contribution", - "cookie", - "courage", - "dad", - "desk", - "drawer", - "establishment", - "examination", - "garbage", - "grocery", - "honey", - "impression", - "improvement", - "independence", - "insect", - "inspection", - "inspector", - "king", - "ladder", - "menu", - "penalty", - "piano", - "potato", - "profession", - "professor", - "quantity", - "reaction", - "requirement", - "salad", - "sister", - "supermarket", - "tongue", - "weakness", - "wedding", - "affair", - "ambition", - "analyst", - "apple", - "assignment", - "assistant", - "bathroom", - "bedroom", - "beer", - "birthday", - "celebration", - "championship", - "cheek", - "client", - "consequence", - "departure", - "diamond", - "dirt", - "ear", - "fortune", - "friendship", - "funeral", - "gene", - "girlfriend", - "hat", - "indication", - "intention", - "lady", - "midnight", - "negotiation", - "obligation", - "passenger", - "pizza", - "platform", - "poet", - "pollution", - "recognition", - "reputation", - "shirt", - "sir", - "speaker", - "stranger", - "surgery", - "sympathy", - "tale", - "throat", - "trainer", - "uncle", - "youth", - "time", - "work", - "film", - "water", - "money", - "example", - "while", - "business", - "study", - "game", - "life", - "form", - "air", - "day", - "place", - "number", - "part", - "field", - "fish", - "back", - "process", - "heat", - "hand", - "experience", - "job", - "book", - "end", - "point", - "type", - "home", - "economy", - "value", - "body", - "market", - "guide", - "interest", - "state", - "radio", - "course", - "company", - "price", - "size", - "card", - "list", - "mind", - "trade", - "line", - "care", - "group", - "risk", - "word", - "fat", - "force", - "key", - "light", - "training", - "name", - "school", - "top", - "amount", - "level", - "order", - "practice", - "research", - "sense", - "service", - "piece", - "web", - "boss", - "sport", - "fun", - "house", - "page", - "term", - "test", - "answer", - "sound", - "focus", - "matter", - "kind", - "soil", - "board", - "oil", - "picture", - "access", - "garden", - "range", - "rate", - "reason", - "future", - "site", - "demand", - "exercise", - "image", - "case", - "cause", - "coast", - "action", - "age", - "bad", - "boat", - "record", - "result", - "section", - "building", - "mouse", - "cash", - "class", - "nothing", - "period", - "plan", - "store", - "tax", - "side", - "subject", - "space", - "rule", - "stock", - "weather", - "chance", - "figure", - "man", - "model", - "source", - "beginning", - "earth", - "program", - "chicken", - "design", - "feature", - "head", - "material", - "purpose", - "question", - "rock", - "salt", - "act", - "birth", - "car", - "dog", - "object", - "scale", - "sun", - "note", - "profit", - "rent", - "speed", - "style", - "war", - "bank", - "craft", - "half", - "inside", - "outside", - "standard", - "bus", - "exchange", - "eye", - "fire", - "position", - "pressure", - "stress", - "advantage", - "benefit", - "box", - "frame", - "issue", - "step", - "cycle", - "face", - "item", - "metal", - "paint", - "review", - "room", - "screen", - "structure", - "view", - "account", - "ball", - "discipline", - "medium", - "share", - "balance", - "bit", - "black", - "bottom", - "choice", - "gift", - "impact", - "machine", - "shape", - "tool", - "wind", - "address", - "average", - "career", - "culture", - "morning", - "pot", - "sign", - "table", - "task", - "condition", - "contact", - "credit", - "egg", - "hope", - "ice", - "network", - "north", - "square", - "attempt", - "date", - "effect", - "link", - "post", - "star", - "voice", - "capital", - "challenge", - "friend", - "self", - "shot", - "brush", - "couple", - "debate", - "exit", - "front", - "function", - "lack", - "living", - "plant", - "plastic", - "spot", - "summer", - "taste", - "theme", - "track", - "wing", - "brain", - "button", - "click", - "desire", - "foot", - "gas", - "influence", - "notice", - "rain", - "wall", - "base", - "damage", - "distance", - "feeling", - "pair", - "savings", - "staff", - "sugar", - "target", - "text", - "animal", - "author", - "budget", - "discount", - "file", - "ground", - "lesson", - "minute", - "officer", - "phase", - "reference", - "register", - "sky", - "stage", - "stick", - "title", - "trouble", - "bowl", - "bridge", - "campaign", - "character", - "club", - "edge", - "evidence", - "fan", - "letter", - "lock", - "maximum", - "novel", - "option", - "pack", - "park", - "plenty", - "quarter", - "skin", - "sort", - "weight", - "baby", - "background", - "carry", - "dish", - "factor", - "fruit", - "glass", - "joint", - "master", - "muscle", - "red", - "strength", - "traffic", - "trip", - "vegetable", - "appeal", - "chart", - "gear", - "ideal", - "kitchen", - "land", - "log", - "mother", - "net", - "party", - "principle", - "relative", - "sale", - "season", - "signal", - "spirit", - "street", - "tree", - "wave", - "belt", - "bench", - "commission", - "copy", - "drop", - "minimum", - "path", - "progress", - "project", - "sea", - "south", - "status", - "stuff", - "ticket", - "tour", - "angle", - "blue", - "breakfast", - "confidence", - "daughter", - "degree", - "doctor", - "dot", - "dream", - "duty", - "essay", - "father", - "fee", - "finance", - "hour", - "juice", - "limit", - "luck", - "milk", - "mouth", - "peace", - "pipe", - "seat", - "stable", - "storm", - "substance", - "team", - "trick", - "afternoon", - "bat", - "beach", - "blank", - "catch", - "chain", - "consideration", - "cream", - "crew", - "detail", - "gold", - "interview", - "kid", - "mark", - "match", - "mission", - "pain", - "pleasure", - "score", - "screw", - "sex", - "shop", - "shower", - "suit", - "tone", - "window", - "agent", - "band", - "block", - "bone", - "calendar", - "cap", - "coat", - "contest", - "corner", - "court", - "cup", - "district", - "door", - "east", - "finger", - "garage", - "guarantee", - "hole", - "hook", - "implement", - "layer", - "lecture", - "lie", - "manner", - "meeting", - "nose", - "parking", - "partner", - "profile", - "respect", - "rice", - "routine", - "schedule", - "swimming", - "telephone", - "tip", - "winter", - "airline", - "bag", - "battle", - "bed", - "bill", - "bother", - "cake", - "code", - "curve", - "designer", - "dimension", - "dress", - "ease", - "emergency", - "evening", - "extension", - "farm", - "fight", - "gap", - "grade", - "holiday", - "horror", - "horse", - "host", - "husband", - "loan", - "mistake", - "mountain", - "nail", - "noise", - "occasion", - "package", - "patient", - "pause", - "phrase", - "proof", - "race", - "relief", - "sand", - "sentence", - "shoulder", - "smoke", - "stomach", - "string", - "tourist", - "towel", - "vacation", - "west", - "wheel", - "wine", - "arm", - "aside", - "associate", - "bet", - "blow", - "border", - "branch", - "breast", - "brother", - "buddy", - "bunch", - "chip", - "coach", - "cross", - "document", - "draft", - "dust", - "expert", - "floor", - "god", - "golf", - "habit", - "iron", - "judge", - "knife", - "landscape", - "league", - "mail", - "mess", - "native", - "opening", - "parent", - "pattern", - "pin", - "pool", - "pound", - "request", - "salary", - "shame", - "shelter", - "shoe", - "silver", - "tackle", - "tank", - "trust", - "assist", - "bake", - "bar", - "bell", - "bike", - "blame", - "boy", - "brick", - "chair", - "closet", - "clue", - "collar", - "comment", - "conference", - "devil", - "diet", - "fear", - "fuel", - "glove", - "jacket", - "lunch", - "monitor", - "mortgage", - "nurse", - "pace", - "panic", - "peak", - "plane", - "reward", - "row", - "sandwich", - "shock", - "spite", - "spray", - "surprise", - "till", - "transition", - "weekend", - "welcome", - "yard", - "alarm", - "bend", - "bicycle", - "bite", - "blind", - "bottle", - "cable", - "candle", - "clerk", - "cloud", - "concert", - "counter", - "flower", - "grandfather", - "harm", - "knee", - "lawyer", - "leather", - "load", - "mirror", - "neck", - "pension", - "plate", - "purple", - "ruin", - "ship", - "skirt", - "slice", - "snow", - "specialist", - "stroke", - "switch", - "trash", - "tune", - "zone", - "anger", - "award", - "bid", - "bitter", - "boot", - "bug", - "camp", - "candy", - "carpet", - "cat", - "champion", - "channel", - "clock", - "comfort", - "cow", - "crack", - "engineer", - "entrance", - "fault", - "grass", - "guy", - "hell", - "highlight", - "incident", - "island", - "joke", - "jury", - "leg", - "lip", - "mate", - "motor", - "nerve", - "passage", - "pen", - "pride", - "priest", - "prize", - "promise", - "resident", - "resort", - "ring", - "roof", - "rope", - "sail", - "scheme", - "script", - "sock", - "station", - "toe", - "tower", - "truck", - "witness", - "a", - "you", - "it", - "can", - "will", - "if", - "one", - "many", - "most", - "other", - "use", - "make", - "good", - "look", - "help", - "go", - "great", - "being", - "few", - "might", - "still", - "public", - "read", - "keep", - "start", - "give", - "human", - "local", - "general", - "she", - "specific", - "long", - "play", - "feel", - "high", - "tonight", - "put", - "common", - "set", - "change", - "simple", - "past", - "big", - "possible", - "particular", - "today", - "major", - "personal", - "current", - "national", - "cut", - "natural", - "physical", - "show", - "try", - "check", - "second", - "call", - "move", - "pay", - "let", - "increase", - "single", - "individual", - "turn", - "ask", - "buy", - "guard", - "hold", - "main", - "offer", - "potential", - "professional", - "international", - "travel", - "cook", - "alternative", - "following", - "special", - "working", - "whole", - "dance", - "excuse", - "cold", - "commercial", - "low", - "purchase", - "deal", - "primary", - "worth", - "fall", - "necessary", - "positive", - "produce", - "search", - "present", - "spend", - "talk", - "creative", - "tell", - "cost", - "drive", - "green", - "support", - "glad", - "remove", - "return", - "run", - "complex", - "due", - "effective", - "middle", - "regular", - "reserve", - "independent", - "leave", - "original", - "reach", - "rest", - "serve", - "watch", - "beautiful", - "charge", - "active", - "break", - "negative", - "safe", - "stay", - "visit", - "visual", - "affect", - "cover", - "report", - "rise", - "walk", - "white", - "beyond", - "junior", - "pick", - "unique", - "anything", - "classic", - "final", - "lift", - "mix", - "private", - "stop", - "teach", - "western", - "concern", - "familiar", - "fly", - "official", - "broad", - "comfortable", - "gain", - "maybe", - "rich", - "save", - "stand", - "young", - "fail", - "heavy", - "hello", - "lead", - "listen", - "valuable", - "worry", - "handle", - "leading", - "meet", - "release", - "sell", - "finish", - "normal", - "press", - "ride", - "secret", - "spread", - "spring", - "tough", - "wait", - "brown", - "deep", - "display", - "flow", - "hit", - "objective", - "shoot", - "touch", - "cancel", - "chemical", - "cry", - "dump", - "extreme", - "push", - "conflict", - "eat", - "fill", - "formal", - "jump", - "kick", - "opposite", - "pass", - "pitch", - "remote", - "total", - "treat", - "vast", - "abuse", - "beat", - "burn", - "deposit", - "print", - "raise", - "sleep", - "somewhere", - "advance", - "anywhere", - "consist", - "dark", - "double", - "draw", - "equal", - "fix", - "hire", - "internal", - "join", - "kill", - "sensitive", - "tap", - "win", - "attack", - "claim", - "constant", - "drag", - "drink", - "guess", - "minor", - "pull", - "raw", - "soft", - "solid", - "wear", - "weird", - "wonder", - "annual", - "count", - "dead", - "doubt", - "feed", - "forever", - "impress", - "nobody", - "repeat", - "round", - "sing", - "slide", - "strip", - "whereas", - "wish", - "combine", - "command", - "dig", - "divide", - "equivalent", - "hang", - "hunt", - "initial", - "march", - "mention", - "smell", - "spiritual", - "survey", - "tie", - "adult", - "brief", - "crazy", - "escape", - "gather", - "hate", - "prior", - "repair", - "rough", - "sad", - "scratch", - "sick", - "strike", - "employ", - "external", - "hurt", - "illegal", - "laugh", - "lay", - "mobile", - "nasty", - "ordinary", - "respond", - "royal", - "senior", - "split", - "strain", - "struggle", - "swim", - "train", - "upper", - "wash", - "yellow", - "convert", - "crash", - "dependent", - "fold", - "funny", - "grab", - "hide", - "miss", - "permit", - "quote", - "recover", - "resolve", - "roll", - "sink", - "slip", - "spare", - "suspect", - "sweet", - "swing", - "twist", - "upstairs", - "usual", - "abroad", - "brave", - "calm", - "concentrate", - "estimate", - "grand", - "male", - "mine", - "prompt", - "quiet", - "refuse", - "regret", - "reveal", - "rush", - "shake", - "shift", - "shine", - "steal", - "suck", - "surround", - "anybody", - "bear", - "brilliant", - "dare", - "dear", - "delay", - "drunk", - "female", - "hurry", - "inevitable", - "invite", - "kiss", - "neat", - "pop", - "punch", - "quit", - "reply", - "representative", - "resist", - "rip", - "rub", - "silly", - "smile", - "spell", - "stretch", - "stupid", - "tear", - "temporary", - "tomorrow", - "wake", - "wrap", - "yesterday", -} diff --git a/apps/dns/internal/domain/entity.go b/apps/dns/internal/domain/entity.go deleted file mode 100644 index 4b611398c..000000000 --- a/apps/dns/internal/domain/entity.go +++ /dev/null @@ -1,118 +0,0 @@ -package domain - -import "kloudlite.io/pkg/repos" - -type AccountCName struct { - repos.BaseEntity `bson:",inline"` - AccountId repos.ID `bson:"accountId" json:"accountId"` - CName string `bson:"cName" json:"cName"` -} - -type RegionCName struct { - repos.BaseEntity `bson:",inline"` - RegionId repos.ID `bson:"regionId" json:"regionId"` - CName string `bson:"cName" json:"cName"` - IsShared bool `bson:"isShared" json:"isShared"` -} - -type NodeIps struct { - repos.BaseEntity `bson:",inline"` - RegionPart string `bson:"regionPart" json:"regionPart"` - ClusterPart string `bson:"clusterPart" json:"clusterPart"` - AccountPart string `bson:"accountPart" json:"accountPart"` - Ips []string `bson:"ips"` -} - -type Site struct { - repos.BaseEntity `bson:",inline"` - AccountId repos.ID `bson:"accountId,omitempty" json:"accountId,omitempty"` - RegionId repos.ID `bson:"regionId,omitempty" json:"regionId,omitempty"` - Domain string `bson:"host,omitempty" json:"host,omitempty"` - Verified bool `bson:"verified,omitempty" json:"verified,omitempty"` -} - -type Record struct { - repos.BaseEntity `bson:",inline"` - Host string `bson:"host,omitempty" json:"host,omitempty"` - Answers []string `bson:"answers,omitempty" json:"answers,omitempty"` -} - -var RecordIndexes = []repos.IndexField{ - { - Field: []repos.IndexKey{ - {Key: "id", Value: repos.IndexAsc}, - }, - Unique: true, - }, - { - Field: []repos.IndexKey{ - {Key: "host", Value: repos.IndexAsc}, - {Key: "type", Value: repos.IndexAsc}, - {Key: "answer", Value: repos.IndexAsc}, - }, - Unique: true, - }, -} -var SiteIndexes = []repos.IndexField{ - { - Field: []repos.IndexKey{ - {Key: "id", Value: repos.IndexAsc}, - }, - Unique: true, - }, - { - Field: []repos.IndexKey{ - {Key: "domain", Value: repos.IndexAsc}, - }, - }, -} -var NodeIpIndexes = []repos.IndexField{ - { - Field: []repos.IndexKey{ - {Key: "id", Value: repos.IndexAsc}, - }, - Unique: true, - }, -} - -var RegionCNameIndexes = []repos.IndexField{ - { - Field: []repos.IndexKey{ - {Key: "id", Value: repos.IndexAsc}, - }, - Unique: true, - }, - { - Field: []repos.IndexKey{ - {Key: "regionId", Value: repos.IndexAsc}, - }, - Unique: true, - }, - { - Field: []repos.IndexKey{ - {Key: "cName", Value: repos.IndexAsc}, - }, - Unique: true, - }, -} - -var AccountCNameIndexes = []repos.IndexField{ - { - Field: []repos.IndexKey{ - {Key: "id", Value: repos.IndexAsc}, - }, - Unique: true, - }, - { - Field: []repos.IndexKey{ - {Key: "accountId", Value: repos.IndexAsc}, - }, - Unique: true, - }, - { - Field: []repos.IndexKey{ - {Key: "cName", Value: repos.IndexAsc}, - }, - Unique: true, - }, -} diff --git a/apps/dns/internal/domain/main.go b/apps/dns/internal/domain/main.go deleted file mode 100644 index e2819368c..000000000 --- a/apps/dns/internal/domain/main.go +++ /dev/null @@ -1,441 +0,0 @@ -package domain - -import ( - "context" - "fmt" - "go.uber.org/fx" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/console" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/finance" - "kloudlite.io/pkg/cache" - "kloudlite.io/pkg/config" - "kloudlite.io/pkg/errors" - "kloudlite.io/pkg/repos" - "math/rand" - "net" -) - -type domainI struct { - recordsRepo repos.DbRepo[*Record] - sitesRepo repos.DbRepo[*Site] - recordsCache cache.Repo[[]*Record] - accountCNamesRepo repos.DbRepo[*AccountCName] - regionCNamesRepo repos.DbRepo[*RegionCName] - nodeIpsRepo repos.DbRepo[*NodeIps] - env *Env - consoleClient console.ConsoleClient - financeClient finance.FinanceClient -} - -func (d *domainI) UpsertARecords(ctx context.Context, host string, records []string) error { - err := d.deleteRecords(ctx, host) - if err != nil { - return err - } - return d.addARecords(ctx, host, records) -} - -func (d *domainI) UpdateNodeIPs(ctx context.Context, regionId string, accountId string, clusterPart string, ips []string) bool { - accountCname, err := d.getAccountCName(ctx, accountId) - if err != nil { - return false - } - regionCname, err := d.getRegionCName(ctx, regionId) - if err != nil { - return false - } - one, err := d.nodeIpsRepo.FindOne(ctx, repos.Filter{ - "regionPart": regionCname, - "accountPart": accountCname, - "clusterPart": clusterPart, - }) - if err != nil { - return false - } - if one == nil { - _, err = d.nodeIpsRepo.Create(ctx, &NodeIps{ - RegionPart: regionCname, - AccountPart: accountCname, - ClusterPart: clusterPart, - Ips: ips, - }) - if err != nil { - return false - } - } else { - one.Ips = ips - _, err = d.nodeIpsRepo.UpdateById(ctx, one.Id, one) - if err != nil { - return false - } - } - return true -} - -func (d *domainI) GetNodeIps(ctx context.Context, - regionPart *string, accountPart *string, clusterPart string, -) ([]string, error) { - filter := repos.Filter{ - "clusterPart": clusterPart, - } - if regionPart != nil { - filter["regionPart"] = *regionPart - } - if accountPart != nil { - filter["accountPart"] = *accountPart - } - all, err := d.nodeIpsRepo.Find(ctx, repos.Query{ - Filter: filter, - }) - out := make([]string, 0) - for _, nodeIps := range all { - out = append(out, nodeIps.Ips...) - } - if len(out) == 0 && regionPart != nil { - result, e := d.regionCNamesRepo.FindOne(ctx, repos.Filter{ - "cName": regionPart, - }) - if e == nil && result != nil && result.IsShared { - filter := repos.Filter{ - "regionPart": regionPart, - } - all, e2 := d.nodeIpsRepo.Find(ctx, repos.Query{ - Filter: filter, - }) - if e2 == nil { - for _, nodeIps := range all { - out = append(out, nodeIps.Ips...) - } - } - } - } - return out, err -} - -func (d *domainI) DeleteSite(ctx context.Context, siteId repos.ID) error { - site, err := d.sitesRepo.FindById(ctx, siteId) - if err != nil { - return err - } - err = d.sitesRepo.DeleteById(ctx, siteId) - if err != nil { - return err - } - _, err = d.consoleClient.SetupAccount(ctx, &console.AccountSetupIn{ - AccountId: string(site.AccountId), - }) - if err != nil { - return err - } - return err -} - -func (d *domainI) GetSiteFromDomain(ctx context.Context, domain string) (*Site, error) { - one, err := d.sitesRepo.FindOne(ctx, repos.Filter{ - "host": domain, - }) - if err != nil { - return nil, err - } - if one == nil { - return nil, errors.New("site not found") - } - return one, nil -} - -func (d *domainI) GetSites(ctx context.Context, accountId string) ([]*Site, error) { - return d.sitesRepo.Find(ctx, repos.Query{ - Filter: repos.Filter{ - "accountId": accountId, - }, - }) -} - -func (d *domainI) GetVerifiedSites(ctx context.Context, accountId string) ([]*Site, error) { - return d.sitesRepo.Find(ctx, repos.Query{ - Filter: repos.Filter{ - "accountId": accountId, - "verified": true, - }, - }) -} - -func (d *domainI) CreateSite(ctx context.Context, domain string, accountId, regionId repos.ID) error { - one, err := d.sitesRepo.FindOne(ctx, repos.Filter{ - "host": domain, - "accountId": accountId, - }) - if err != nil { - return err - } - if one != nil { - return errors.New("site already exists") - } - if one == nil { - _, err = d.sitesRepo.Create(ctx, &Site{ - Domain: domain, - AccountId: accountId, - RegionId: regionId, - Verified: false, - }) - if err != nil { - return err - } - } - if err != nil { - return err - } - return nil -} - -func (d *domainI) VerifySite(ctx context.Context, siteId repos.ID) error { - site, err := d.sitesRepo.FindById(ctx, siteId) - if err != nil { - return err - } - if site == nil { - return errors.New("site not found") - } - if site.Verified { - return errors.New("site already verified") - } - - cname, err := net.LookupCNAME(site.Domain) - if err != nil { - return errors.New("Unable to verify CName. Please wait for a while and try again.") - } - - fmt.Println(site.Domain, cname) - accountCnameIdentity, err := d.getAccountCName(ctx, string(site.AccountId)) - if err != nil { - return err - } - - regionCnameIdentity, err := d.getRegionCName(ctx, string(site.RegionId)) - if err != nil { - return err - } - - accountId := string(site.AccountId) - - clusterId, err := d.getClusterFromAccount(ctx, err, accountId) - if err != nil { - return err - } - - if cname != fmt.Sprintf("%s.%s.%s.%s.", regionCnameIdentity, accountCnameIdentity, clusterId, d.env.EdgeCnameBaseDomain) { - return errors.New("cname does not match") - } - err = d.sitesRepo.UpdateMany(ctx, repos.Filter{ - "host": site.Domain, - }, map[string]any{ - "verified": false, - }) - if err != nil { - return err - } - site.Verified = true - _, err = d.sitesRepo.UpdateById(ctx, site.Id, site) - if err != nil { - return err - } - _, err = d.consoleClient.SetupAccount(ctx, &console.AccountSetupIn{ - AccountId: string(site.AccountId), - }) - if err != nil { - return err - } - return err -} - -func (d *domainI) getClusterFromAccount(ctx context.Context, err error, accountId string) (string, error) { - cluster, err := d.financeClient.GetAttachedCluster(ctx, &finance.GetAttachedClusterIn{ - AccountId: accountId, - }) - if err != nil { - return "", err - } - return cluster.ClusterId, nil -} - -func (d *domainI) GetSite(ctx context.Context, siteId string) (*Site, error) { - return d.sitesRepo.FindById(ctx, repos.ID(siteId)) -} - -func (d *domainI) GetAccountEdgeCName(ctx context.Context, accountId string, regionId repos.ID) (string, error) { - name, err := d.getAccountCName(ctx, accountId) - if err != nil { - return "", err - } - - regionCnameIdentity, err := d.getRegionCName(ctx, string(regionId)) - if err != nil { - return "", err - } - - cluster, err := d.getClusterFromAccount(ctx, err, accountId) - if err != nil { - return fmt.Sprintf("%s.%s.%s", regionCnameIdentity, name, d.env.EdgeCnameBaseDomain), nil - } - - return fmt.Sprintf("%s.%s.%s.%s", regionCnameIdentity, name, cluster, d.env.EdgeCnameBaseDomain), nil -} - -func generateName() string { - randomAdjective := ADJECTIVES[rand.Intn(len(ADJECTIVES))] - randomNoun := NOUNS[rand.Intn(len(NOUNS))] - return fmt.Sprintf("%v-%v", randomAdjective, randomNoun) -} - -func (d *domainI) getRegionCName(ctx context.Context, regionId string) (string, error) { - regionDNS, err := d.regionCNamesRepo.FindOne(ctx, repos.Filter{ - "regionId": regionId, - }) - if err != nil { - return "", err - } - if regionDNS != nil { - return regionDNS.CName, nil - } - var genUniqueName func() (string, error) - genUniqueName = func() (string, error) { - name := generateName() - regionDNS, err = d.regionCNamesRepo.FindOne(ctx, repos.Filter{ - "cName": name, - }) - if err != nil { - return "", err - } - if regionDNS != nil { - return genUniqueName() - } - return name, nil - } - - generatedName, err := genUniqueName() - if err != nil { - return "", err - } - if regionDNS == nil { - create, err := d.regionCNamesRepo.Create(ctx, &RegionCName{ - RegionId: repos.ID(regionId), - CName: generatedName, - }) - if err != nil { - return "", err - } - return create.CName, nil - } - return regionDNS.CName, nil -} - -func (d *domainI) getAccountCName(ctx context.Context, accountId string) (string, error) { - accountDNS, err := d.accountCNamesRepo.FindOne(ctx, repos.Filter{ - "accountId": accountId, - }) - if err != nil { - return "", err - } - if err == nil && accountDNS != nil { - return accountDNS.CName, nil - } - var genUniqueName func() (string, error) - genUniqueName = func() (string, error) { - name := generateName() - accountDNS, err = d.accountCNamesRepo.FindOne(ctx, repos.Filter{ - "cName": name, - }) - if err != nil { - return "", err - } - if accountDNS != nil { - return genUniqueName() - } - return name, nil - } - - generatedName, err := genUniqueName() - if err != nil { - return "", err - } - if accountDNS == nil { - create, err := d.accountCNamesRepo.Create(ctx, &AccountCName{ - AccountId: repos.ID(accountId), - CName: generatedName, - }) - if err != nil { - return "", err - } - return create.CName, nil - } - return accountDNS.CName, nil -} - -func (d *domainI) GetRecord(ctx context.Context, host string) (*Record, error) { - one, err := d.recordsRepo.FindOne(ctx, repos.Filter{ - "host": host, - }) - if err != nil { - return nil, err - } - return one, nil -} - -func (d *domainI) deleteRecords(ctx context.Context, host string) error { - d.recordsCache.Drop(ctx, host) - return d.recordsRepo.DeleteMany(ctx, repos.Filter{ - "host": host, - }) -} - -func (d *domainI) DeleteRecords(ctx context.Context, host string) error { - return d.deleteRecords(ctx, host) -} - -func (d *domainI) addARecords(ctx context.Context, host string, aRecords []string) error { - var err error - d.recordsCache.Drop(ctx, host) - _, err = d.recordsRepo.Create(ctx, &Record{ - Host: host, - Answers: aRecords, - }) - return err -} - -func (d *domainI) AddARecords(ctx context.Context, host string, aRecords []string) error { - return d.addARecords(ctx, host, aRecords) -} - -func fxDomain( - recordsRepo repos.DbRepo[*Record], - sitesRepo repos.DbRepo[*Site], - nodeIpsRepo repos.DbRepo[*NodeIps], - accountDNSRepo repos.DbRepo[*AccountCName], - regionDNSRepo repos.DbRepo[*RegionCName], - recordsCache cache.Repo[[]*Record], - consoleclient console.ConsoleClient, - financeClient finance.FinanceClient, - env *Env, -) Domain { - return &domainI{ - recordsRepo, - sitesRepo, - recordsCache, - accountDNSRepo, - regionDNSRepo, - nodeIpsRepo, - env, - consoleclient, - financeClient, - } -} - -type Env struct { - EdgeCnameBaseDomain string `env:"EDGE_CNAME_BASE_DOMAIN" required:"true"` - MongoUri string `env:"MONGO_URI" required:"true"` -} - -var Module = fx.Module( - "domain", - config.EnvFx[Env](), - fx.Provide(fxDomain), -) diff --git a/apps/dns/internal/domain/port.go b/apps/dns/internal/domain/port.go deleted file mode 100644 index 1873cb81a..000000000 --- a/apps/dns/internal/domain/port.go +++ /dev/null @@ -1,31 +0,0 @@ -package domain - -import ( - "context" - "kloudlite.io/pkg/repos" -) - -type Domain interface { - GetNodeIps(ctx context.Context, regionPart *string, accountPart *string, clusterPart string) ([]string, error) - GetRecord(ctx context.Context, host string) (*Record, error) - DeleteRecords(ctx context.Context, host string) error - AddARecords(ctx context.Context, host string, aRecords []string) error - - UpsertARecords(ctx context.Context, host string, records []string) error - VerifySite(ctx context.Context, claimId repos.ID) error - GetSites(ctx context.Context, accountId string) ([]*Site, error) - GetVerifiedSites(ctx context.Context, accountId string) ([]*Site, error) - GetSite(ctx context.Context, siteId string) (*Site, error) - GetSiteFromDomain(ctx context.Context, domain string) (*Site, error) - GetAccountEdgeCName(ctx context.Context, accountId string, regionId repos.ID) (string, error) - - CreateSite(ctx context.Context, domain string, accountId, regionId repos.ID) error - DeleteSite(ctx context.Context, siteId repos.ID) error - UpdateNodeIPs( - ctx context.Context, - regionId string, - accountId string, - clusterPart string, - ips []string, - ) bool -} diff --git a/apps/dns/internal/framework/main.go b/apps/dns/internal/framework/main.go deleted file mode 100644 index 7bc1e44af..000000000 --- a/apps/dns/internal/framework/main.go +++ /dev/null @@ -1,83 +0,0 @@ -package framework - -import ( - "go.uber.org/fx" - "kloudlite.io/apps/dns/internal/app" - rpc "kloudlite.io/pkg/grpc" - - // "kloudlite.io/pkg/cache" - "kloudlite.io/pkg/cache" - "kloudlite.io/pkg/config" - "kloudlite.io/pkg/dns" - httpServer "kloudlite.io/pkg/http-server" - "kloudlite.io/pkg/repos" -) - -type GrpcConsoleConfig struct { - ConsoleService string `env:"CONSOLE_SERVICE" required:"true"` -} - -func (e *GrpcConsoleConfig) GetGRPCServerURL() string { - return e.ConsoleService -} - -type GrpcFinanceConfig struct { - FinanceService string `env:"FINANCE_SERVICE" required:"true"` -} - -func (e *GrpcFinanceConfig) GetGRPCServerURL() string { - return e.FinanceService -} - -type Env struct { - DNSPort uint16 `env:"DNS_PORT" required:"true"` - MongoUri string `env:"MONGO_URI" required:"true"` - RedisHosts string `env:"REDIS_HOSTS" required:"true"` - RedisUserName string `env:"REDIS_USERNAME"` - RedisPassword string `env:"REDIS_PASSWORD"` - RedisPrefix string `env:"REDIS_PREFIX"` - MongoDbName string `env:"MONGO_DB_NAME" required:"true"` - Port uint16 `env:"PORT" required:"true"` - IsDev bool `env:"DEV" default:"false" required:"true"` - CorsOrigins string `env:"ORIGINS"` - GrpcPort uint16 `env:"GRPC_PORT" required:"true"` -} - -func (e *Env) GetDNSPort() uint16 { - return e.DNSPort -} - -func (e *Env) GetMongoConfig() (url string, dbName string) { - return e.MongoUri, e.MongoDbName -} - -func (e *Env) RedisOptions() (hosts, username, password, prefix string) { - return e.RedisHosts, e.RedisUserName, e.RedisPassword, e.RedisPrefix -} - -func (e *Env) GetHttpPort() uint16 { - return e.Port -} - -func (e *Env) GetHttpCors() string { - return e.CorsOrigins -} - -func (e *Env) GetGRPCPort() uint16 { - return e.GrpcPort -} - -var Module = fx.Module( - "framework", - config.EnvFx[Env](), - config.EnvFx[GrpcConsoleConfig](), - config.EnvFx[GrpcFinanceConfig](), - rpc.NewGrpcServerFx[*Env](), - repos.NewMongoClientFx[*Env](), - cache.NewRedisFx[*Env](), - httpServer.NewHttpServerFx[*Env](), - rpc.NewGrpcClientFx[*GrpcConsoleConfig, app.ConsoleClientConnection](), - rpc.NewGrpcClientFx[*GrpcFinanceConfig, app.FinanceClientConnection](), - dns.Fx[*Env](), - app.Module, -) diff --git a/apps/dns/main.go b/apps/dns/main.go deleted file mode 100644 index 943434c32..000000000 --- a/apps/dns/main.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - "flag" - - "go.uber.org/fx" - "kloudlite.io/apps/dns/internal/framework" - "kloudlite.io/pkg/logging" -) - -func main() { - var isDev bool - flag.BoolVar(&isDev, "dev", false, "--dev") - flag.Parse() - fx.New( - framework.Module, - fx.Provide( - func() (logging.Logger, error) { - return logging.New(&logging.Options{Name: "auth", Dev: isDev}) - }, - ), - ).Run() -} diff --git a/apps/finance_deprecated/.dockerignore b/apps/finance_deprecated/.dockerignore deleted file mode 100644 index b30fec26f..000000000 --- a/apps/finance_deprecated/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -** -!main.go -!internal diff --git a/apps/finance_deprecated/Dockerfile b/apps/finance_deprecated/Dockerfile deleted file mode 100644 index c85dfa2ef..000000000 --- a/apps/finance_deprecated/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -# syntax=docker/dockerfile:1.4 -FROM golang:1.18.3-alpine3.16 AS base -USER 1001 -ENV GOPATH=/tmp/go -ENV GOCACHE=/tmp/go-cache -WORKDIR /tmp/app -COPY --chown=1001 --from=project-root ./go.mod ./go.sum ./tools.go ./ -RUN go mod download -x -COPY --chown=1001 --from=project-root common ./common -COPY --chown=1001 --from=project-root grpc-interfaces ./grpc-interfaces -COPY --chown=1001 --from=project-root pkg ./pkg -ARG APP -RUN mkdir -p ./apps/$APP -WORKDIR /tmp/app/apps/$APP -COPY --chown=1001 ./ ./ -RUN CGO_ENABLED=0 go build -tags musl -o /tmp/bin/$APP ./main.go -RUN chmod +x /tmp/bin/$APP - -FROM gcr.io/distroless/static-debian11 -USER 1001 -WORKDIR /tmp/app -COPY --from=base --chown=1001 /tmp/bin/finance ./finance -CMD ["./finance"] diff --git a/apps/finance_deprecated/Taskfile.yml b/apps/finance_deprecated/Taskfile.yml deleted file mode 100644 index 02487e0a2..000000000 --- a/apps/finance_deprecated/Taskfile.yml +++ /dev/null @@ -1,79 +0,0 @@ -version: "3" - -dotenv: - - .secrets/env - -vars: - ImagePrefix: "ghcr.io/kloudlite/platform/apis" - -tasks: - gql: - dir: ./internal/app - cmds: - - go run github.com/99designs/gqlgen generate - - build: - env: - CGO_ENABLED: 0 - GOOS: linux - GOARCH: amd64 - preconditions: - - sh: '[ -n "{{.Out}}" ]' - msg: var Out must have a value - cmds: - - go build -ldflags="-s -w" -o {{.Out}} - - upx {{.Out}} - - run: - dotenv: - - .secrets/env - cmds: - - go run main.go --dev - - docker-build: - vars: - APP: finance - IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}-api:{{.Tag}} - preconditions: - - sh: '[[ -n "{{.Tag}}" ]]' - msg: 'var Tag must have a value' - - - sh: '[[ "{{.EnvName}}" == "development" ]] || [[ "{{.EnvName}}" == "staging" ]] || [[ "{{.EnvName}}" == "production" ]]' - msg: 'var EnvName must have one of [development, staging, production] as its value' - cmds: - - docker buildx build -f ./Dockerfile -t {{.IMAGE}} . --build-arg APP={{.APP}} --platform linux/amd64 --build-context project-root=../.. - - docker push {{.IMAGE}} - - local-build: - preconditions: - - sh: '[ -n "{{.Tag}}" ]' - msg: 'var Tag must have a value' - vars: - APP: finance - IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}" - silent: true - cmds: - - |+ - lineNumbers=$(cat Dockerfile | grep -i '^FROM' -n | tail +2 | awk -F: '{print $1}') - - startLineNo=$(echo "$lineNumbers" | head -n+1) - finalLineNo=$(echo "$lineNumbers" | tail -1) - - tDir=$(mktemp -d) - - nDockerfile=$(cat Dockerfile | tail --lines=+$startLineNo | grep -i --invert-match 'from=base') - echo "$nDockerfile" | sed "1 i # syntax=docker/dockerfile:1.4" > $tDir/Dockerfile.base - - #lineNo=$(cat Dockerfile | grep -i '^FROM' -n | tail -1 | awk -F: '{print $1}') - - cat $tDir/Dockerfile.base | sed "5 i COPY --from=local-builder ./{{.APP}} ./finance" > $tDir/Dockerfile - cat $tDir/Dockerfile - - task build Out="$tDir/{{.APP}}" - - docker buildx build -f $tDir/Dockerfile -t {{.IMAGE}} . --build-context local-builder=${tDir} - docker push {{.IMAGE}} - rm -rf $tDir - - - diff --git a/apps/finance_deprecated/cron/main.go b/apps/finance_deprecated/cron/main.go deleted file mode 100644 index 412122938..000000000 --- a/apps/finance_deprecated/cron/main.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "context" - "flag" - - "go.uber.org/fx" - "kloudlite.io/apps/finance_deprecated/internal/domain" - "kloudlite.io/apps/finance_deprecated/internal/framework" - "kloudlite.io/pkg/logging" - "kloudlite.io/pkg/repos" -) - -func main() { - accountId := flag.String("dev", "", "--accountId") - flag.Parse() - if accountId == nil { - panic("accountId is required") - } - fx.New( - fx.Provide( - func() (logging.Logger, error) { - return logging.New(&logging.Options{Name: "console", Dev: false}) - }, - ), - framework.Module, - fx.Invoke( - func(d domain.Domain) { - d.GenerateBillingInvoice(context.Background(), repos.ID(*accountId)) - }, - ), - ).Start(context.TODO()) -} diff --git a/apps/finance_deprecated/internal/app/gqlgen.yml b/apps/finance_deprecated/internal/app/gqlgen.yml deleted file mode 100644 index a4090361c..000000000 --- a/apps/finance_deprecated/internal/app/gqlgen.yml +++ /dev/null @@ -1,80 +0,0 @@ -# Where are all the schema files located? globs are supported eg src/**/*.graphqls -schema: - - crd-to-gql/*.graphqls - - graph/*.graphqls - -# Where should the generated server code go? -exec: - filename: graph/generated/generated.go - package: generated - -# Uncomment to enable federation -federation: - filename: graph/generated/federation.go - package: generated - version: 2 - -# Where should any generated models go? -model: - filename: graph/model/models_gen.go - package: model - -# Where should the resolver implementations go? -resolver: - layout: follow-schema - dir: graph - package: graph - -# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models -# struct_tag: json - -# Optional: turn on to use []Thing instead of []*Thing -# omit_slice_element_pointers: false - -# Optional: set to speed up generation time by not performing a final validation pass. -# skip_validation: true - -# gqlgen will search for any type names in the schema in these go packages -# if they match it will use them, otherwise it will generate them. -autobind: - - "kloudlite.io/pkg/errors" - # - "kloudlite.io/apps/wireguard/internal/domain/entities" - -# This section declares type mapping between the GraphQL and go type systems -# -# The first line in each type will be used as defaults for resolver arguments and -# modelgen, the others will be allowed when binding to fields. Configure them to -# your liking - -models: - Json: - model: - - github.com/99designs/gqlgen/graphql.Map - User: - fields: - accountMembership: - resolver: true - accountMemberships: - resolver: true - Account: - # model: kloudlite.io/apps/finance_deprecated/internal/domain.Account - fields: - # accountMemberships: - memberships: - resolver: true - # outstandingAmount: - # resolver: true - AccountMembership: - fields: - user: - resolver: true - account: - resolver: true - ID: - model: - - kloudlite.io/pkg/repos.ID - Int: - model: - - github.com/99designs/gqlgen/graphql.Int - - github.com/99designs/gqlgen/graphql.Int64 - - github.com/99designs/gqlgen/graphql.Int32 diff --git a/apps/finance_deprecated/internal/app/graph/entity.resolvers.go b/apps/finance_deprecated/internal/app/graph/entity.resolvers.go deleted file mode 100644 index 5c198b0da..000000000 --- a/apps/finance_deprecated/internal/app/graph/entity.resolvers.go +++ /dev/null @@ -1,43 +0,0 @@ -package graph - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.28 - -import ( - "context" - "time" - - "kloudlite.io/apps/finance_deprecated/internal/app/graph/generated" - "kloudlite.io/apps/finance_deprecated/internal/app/graph/model" - fn "kloudlite.io/pkg/functions" - "kloudlite.io/pkg/repos" -) - -// FindAccountByName is the resolver for the findAccountByName field. -func (r *entityResolver) FindAccountByName(ctx context.Context, name string) (*model.Account, error) { - cc := toFinanceContext(ctx) - acc, err := r.domain.GetAccount(cc, name) - if err != nil { - return nil, err - } - return &model.Account{ - // ID: acc.Id, - Name: acc.Name, - Billing: nil, - IsActive: fn.DefaultIfNil(acc.IsActive, false), - ContactEmail: acc.ContactEmail, - ReadableID: acc.ReadableId, - Created: acc.CreatedAt.Format(time.RFC3339), - }, nil -} - -// FindUserByID is the resolver for the findUserByID field. -func (r *entityResolver) FindUserByID(ctx context.Context, id repos.ID) (*model.User, error) { - return &model.User{ID: id}, nil -} - -// Entity returns generated.EntityResolver implementation. -func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} } - -type entityResolver struct{ *Resolver } diff --git a/apps/finance_deprecated/internal/app/graph/generated/federation.go b/apps/finance_deprecated/internal/app/graph/generated/federation.go deleted file mode 100644 index 40a14d07a..000000000 --- a/apps/finance_deprecated/internal/app/graph/generated/federation.go +++ /dev/null @@ -1,224 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "context" - "errors" - "fmt" - "strings" - "sync" - - "github.com/99designs/gqlgen/plugin/federation/fedruntime" -) - -var ( - ErrUnknownType = errors.New("unknown type") - ErrTypeNotFound = errors.New("type not found") -) - -func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { - if ec.DisableIntrospection { - return fedruntime.Service{}, errors.New("federated introspection disabled") - } - - var sdl []string - - for _, src := range sources { - if src.BuiltIn { - continue - } - sdl = append(sdl, src.Input) - } - - return fedruntime.Service{ - SDL: strings.Join(sdl, "\n"), - }, nil -} - -func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity { - list := make([]fedruntime.Entity, len(representations)) - - repsMap := map[string]struct { - i []int - r []map[string]interface{} - }{} - - // We group entities by typename so that we can parallelize their resolution. - // This is particularly helpful when there are entity groups in multi mode. - buildRepresentationGroups := func(reps []map[string]interface{}) { - for i, rep := range reps { - typeName, ok := rep["__typename"].(string) - if !ok { - // If there is no __typename, we just skip the representation; - // we just won't be resolving these unknown types. - ec.Error(ctx, errors.New("__typename must be an existing string")) - continue - } - - _r := repsMap[typeName] - _r.i = append(_r.i, i) - _r.r = append(_r.r, rep) - repsMap[typeName] = _r - } - } - - isMulti := func(typeName string) bool { - switch typeName { - default: - return false - } - } - - resolveEntity := func(ctx context.Context, typeName string, rep map[string]interface{}, idx []int, i int) (err error) { - // we need to do our own panic handling, because we may be called in a - // goroutine, where the usual panic handling can't catch us - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - } - }() - - switch typeName { - case "Account": - resolverName, err := entityResolverNameForAccount(ctx, rep) - if err != nil { - return fmt.Errorf(`finding resolver for Entity "Account": %w`, err) - } - switch resolverName { - - case "findAccountByName": - id0, err := ec.unmarshalNString2string(ctx, rep["name"]) - if err != nil { - return fmt.Errorf(`unmarshalling param 0 for findAccountByName(): %w`, err) - } - entity, err := ec.resolvers.Entity().FindAccountByName(ctx, id0) - if err != nil { - return fmt.Errorf(`resolving Entity "Account": %w`, err) - } - - list[idx[i]] = entity - return nil - } - case "User": - resolverName, err := entityResolverNameForUser(ctx, rep) - if err != nil { - return fmt.Errorf(`finding resolver for Entity "User": %w`, err) - } - switch resolverName { - - case "findUserByID": - id0, err := ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, rep["id"]) - if err != nil { - return fmt.Errorf(`unmarshalling param 0 for findUserByID(): %w`, err) - } - entity, err := ec.resolvers.Entity().FindUserByID(ctx, id0) - if err != nil { - return fmt.Errorf(`resolving Entity "User": %w`, err) - } - - list[idx[i]] = entity - return nil - } - - } - return fmt.Errorf("%w: %s", ErrUnknownType, typeName) - } - - resolveManyEntities := func(ctx context.Context, typeName string, reps []map[string]interface{}, idx []int) (err error) { - // we need to do our own panic handling, because we may be called in a - // goroutine, where the usual panic handling can't catch us - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - } - }() - - switch typeName { - - default: - return errors.New("unknown type: " + typeName) - } - } - - resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) { - if isMulti(typeName) { - err := resolveManyEntities(ctx, typeName, reps, idx) - if err != nil { - ec.Error(ctx, err) - } - } else { - // if there are multiple entities to resolve, parallelize (similar to - // graphql.FieldSet.Dispatch) - var e sync.WaitGroup - e.Add(len(reps)) - for i, rep := range reps { - i, rep := i, rep - go func(i int, rep map[string]interface{}) { - err := resolveEntity(ctx, typeName, rep, idx, i) - if err != nil { - ec.Error(ctx, err) - } - e.Done() - }(i, rep) - } - e.Wait() - } - } - buildRepresentationGroups(representations) - - switch len(repsMap) { - case 0: - return list - case 1: - for typeName, reps := range repsMap { - resolveEntityGroup(typeName, reps.r, reps.i) - } - return list - default: - var g sync.WaitGroup - g.Add(len(repsMap)) - for typeName, reps := range repsMap { - go func(typeName string, reps []map[string]interface{}, idx []int) { - resolveEntityGroup(typeName, reps, idx) - g.Done() - }(typeName, reps.r, reps.i) - } - g.Wait() - return list - } -} - -func entityResolverNameForAccount(ctx context.Context, rep map[string]interface{}) (string, error) { - for { - var ( - m map[string]interface{} - val interface{} - ok bool - ) - _ = val - m = rep - if _, ok = m["name"]; !ok { - break - } - return "findAccountByName", nil - } - return "", fmt.Errorf("%w for Account", ErrTypeNotFound) -} - -func entityResolverNameForUser(ctx context.Context, rep map[string]interface{}) (string, error) { - for { - var ( - m map[string]interface{} - val interface{} - ok bool - ) - _ = val - m = rep - if _, ok = m["id"]; !ok { - break - } - return "findUserByID", nil - } - return "", fmt.Errorf("%w for User", ErrTypeNotFound) -} diff --git a/apps/finance_deprecated/internal/app/graph/generated/generated.go b/apps/finance_deprecated/internal/app/graph/generated/generated.go deleted file mode 100644 index 01fe384f1..000000000 --- a/apps/finance_deprecated/internal/app/graph/generated/generated.go +++ /dev/null @@ -1,7216 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "bytes" - "context" - "errors" - "fmt" - "strconv" - "sync" - "sync/atomic" - - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" - "github.com/99designs/gqlgen/plugin/federation/fedruntime" - gqlparser "github.com/vektah/gqlparser/v2" - "github.com/vektah/gqlparser/v2/ast" - "kloudlite.io/apps/finance_deprecated/internal/app/graph/model" - "kloudlite.io/pkg/repos" -) - -// region ************************** generated!.gotpl ************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Account() AccountResolver - AccountMembership() AccountMembershipResolver - Entity() EntityResolver - Mutation() MutationResolver - Query() QueryResolver - User() UserResolver -} - -type DirectiveRoot struct { - IsLoggedIn func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) -} - -type ComplexityRoot struct { - Account struct { - Billing func(childComplexity int) int - ContactEmail func(childComplexity int) int - Created func(childComplexity int) int - DisplayName func(childComplexity int) int - IsActive func(childComplexity int) int - Memberships func(childComplexity int) int - Name func(childComplexity int) int - OutstandingAmount func(childComplexity int) int - ReadableID func(childComplexity int) int - } - - AccountMembership struct { - Accepted func(childComplexity int) int - Account func(childComplexity int) int - Role func(childComplexity int) int - User func(childComplexity int) int - } - - Billing struct { - Address func(childComplexity int) int - CardholderName func(childComplexity int) int - } - - Entity struct { - FindAccountByName func(childComplexity int, name string) int - FindUserByID func(childComplexity int, id repos.ID) int - } - - Mutation struct { - FinanceActivateAccount func(childComplexity int, accountName string) int - FinanceCreateAccount func(childComplexity int, name string, displayName string) int - FinanceDeactivateAccount func(childComplexity int, accountName string) int - FinanceDeleteAccount func(childComplexity int, accountName string) int - FinanceDeleteInvitation func(childComplexity int, accountName string, email string) int - FinanceInviteUser func(childComplexity int, accountName string, name *string, email string, role string) int - FinanceRemoveAccountMember func(childComplexity int, accountName string, userID repos.ID) int - FinanceUpdateAccount func(childComplexity int, accountName string, name *string, contactEmail *string) int - FinanceUpdateAccountMember func(childComplexity int, accountName string, userID repos.ID, role string) int - } - - Query struct { - FinanceAccount func(childComplexity int, accountName string) int - FinanceListAccounts func(childComplexity int) int - FinanceListInvitations func(childComplexity int, accountName string) int - FinanceReSyncAccount func(childComplexity int, accountName string) int - __resolve__service func(childComplexity int) int - __resolve_entities func(childComplexity int, representations []map[string]interface{}) int - } - - User struct { - AccountMembership func(childComplexity int, accountName string) int - AccountMemberships func(childComplexity int) int - ID func(childComplexity int) int - } - - _Service struct { - SDL func(childComplexity int) int - } -} - -type AccountResolver interface { - Memberships(ctx context.Context, obj *model.Account) ([]*model.AccountMembership, error) -} -type AccountMembershipResolver interface { - User(ctx context.Context, obj *model.AccountMembership) (*model.User, error) - - Account(ctx context.Context, obj *model.AccountMembership) (*model.Account, error) -} -type EntityResolver interface { - FindAccountByName(ctx context.Context, name string) (*model.Account, error) - FindUserByID(ctx context.Context, id repos.ID) (*model.User, error) -} -type MutationResolver interface { - FinanceCreateAccount(ctx context.Context, name string, displayName string) (*model.Account, error) - FinanceUpdateAccount(ctx context.Context, accountName string, name *string, contactEmail *string) (*model.Account, error) - FinanceRemoveAccountMember(ctx context.Context, accountName string, userID repos.ID) (bool, error) - FinanceUpdateAccountMember(ctx context.Context, accountName string, userID repos.ID, role string) (bool, error) - FinanceDeactivateAccount(ctx context.Context, accountName string) (bool, error) - FinanceActivateAccount(ctx context.Context, accountName string) (bool, error) - FinanceDeleteAccount(ctx context.Context, accountName string) (bool, error) - FinanceInviteUser(ctx context.Context, accountName string, name *string, email string, role string) (bool, error) - FinanceDeleteInvitation(ctx context.Context, accountName string, email string) (bool, error) -} -type QueryResolver interface { - FinanceListAccounts(ctx context.Context) ([]*model.Account, error) - FinanceAccount(ctx context.Context, accountName string) (*model.Account, error) - FinanceListInvitations(ctx context.Context, accountName string) ([]*model.AccountMembership, error) - FinanceReSyncAccount(ctx context.Context, accountName string) (bool, error) -} -type UserResolver interface { - AccountMemberships(ctx context.Context, obj *model.User) ([]*model.AccountMembership, error) - AccountMembership(ctx context.Context, obj *model.User, accountName string) (*model.AccountMembership, error) -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - ec := executionContext{nil, e} - _ = ec - switch typeName + "." + field { - - case "Account.billing": - if e.complexity.Account.Billing == nil { - break - } - - return e.complexity.Account.Billing(childComplexity), true - - case "Account.contactEmail": - if e.complexity.Account.ContactEmail == nil { - break - } - - return e.complexity.Account.ContactEmail(childComplexity), true - - case "Account.created": - if e.complexity.Account.Created == nil { - break - } - - return e.complexity.Account.Created(childComplexity), true - - case "Account.displayName": - if e.complexity.Account.DisplayName == nil { - break - } - - return e.complexity.Account.DisplayName(childComplexity), true - - case "Account.isActive": - if e.complexity.Account.IsActive == nil { - break - } - - return e.complexity.Account.IsActive(childComplexity), true - - case "Account.memberships": - if e.complexity.Account.Memberships == nil { - break - } - - return e.complexity.Account.Memberships(childComplexity), true - - case "Account.name": - if e.complexity.Account.Name == nil { - break - } - - return e.complexity.Account.Name(childComplexity), true - - case "Account.outstandingAmount": - if e.complexity.Account.OutstandingAmount == nil { - break - } - - return e.complexity.Account.OutstandingAmount(childComplexity), true - - case "Account.readableId": - if e.complexity.Account.ReadableID == nil { - break - } - - return e.complexity.Account.ReadableID(childComplexity), true - - case "AccountMembership.accepted": - if e.complexity.AccountMembership.Accepted == nil { - break - } - - return e.complexity.AccountMembership.Accepted(childComplexity), true - - case "AccountMembership.account": - if e.complexity.AccountMembership.Account == nil { - break - } - - return e.complexity.AccountMembership.Account(childComplexity), true - - case "AccountMembership.role": - if e.complexity.AccountMembership.Role == nil { - break - } - - return e.complexity.AccountMembership.Role(childComplexity), true - - case "AccountMembership.user": - if e.complexity.AccountMembership.User == nil { - break - } - - return e.complexity.AccountMembership.User(childComplexity), true - - case "Billing.address": - if e.complexity.Billing.Address == nil { - break - } - - return e.complexity.Billing.Address(childComplexity), true - - case "Billing.cardholderName": - if e.complexity.Billing.CardholderName == nil { - break - } - - return e.complexity.Billing.CardholderName(childComplexity), true - - case "Entity.findAccountByName": - if e.complexity.Entity.FindAccountByName == nil { - break - } - - args, err := ec.field_Entity_findAccountByName_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Entity.FindAccountByName(childComplexity, args["name"].(string)), true - - case "Entity.findUserByID": - if e.complexity.Entity.FindUserByID == nil { - break - } - - args, err := ec.field_Entity_findUserByID_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Entity.FindUserByID(childComplexity, args["id"].(repos.ID)), true - - case "Mutation.finance_activateAccount": - if e.complexity.Mutation.FinanceActivateAccount == nil { - break - } - - args, err := ec.field_Mutation_finance_activateAccount_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.FinanceActivateAccount(childComplexity, args["accountName"].(string)), true - - case "Mutation.finance_createAccount": - if e.complexity.Mutation.FinanceCreateAccount == nil { - break - } - - args, err := ec.field_Mutation_finance_createAccount_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.FinanceCreateAccount(childComplexity, args["name"].(string), args["displayName"].(string)), true - - case "Mutation.finance_deactivateAccount": - if e.complexity.Mutation.FinanceDeactivateAccount == nil { - break - } - - args, err := ec.field_Mutation_finance_deactivateAccount_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.FinanceDeactivateAccount(childComplexity, args["accountName"].(string)), true - - case "Mutation.finance_deleteAccount": - if e.complexity.Mutation.FinanceDeleteAccount == nil { - break - } - - args, err := ec.field_Mutation_finance_deleteAccount_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.FinanceDeleteAccount(childComplexity, args["accountName"].(string)), true - - case "Mutation.finance_deleteInvitation": - if e.complexity.Mutation.FinanceDeleteInvitation == nil { - break - } - - args, err := ec.field_Mutation_finance_deleteInvitation_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.FinanceDeleteInvitation(childComplexity, args["accountName"].(string), args["email"].(string)), true - - case "Mutation.finance_inviteUser": - if e.complexity.Mutation.FinanceInviteUser == nil { - break - } - - args, err := ec.field_Mutation_finance_inviteUser_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.FinanceInviteUser(childComplexity, args["accountName"].(string), args["name"].(*string), args["email"].(string), args["role"].(string)), true - - case "Mutation.finance_removeAccountMember": - if e.complexity.Mutation.FinanceRemoveAccountMember == nil { - break - } - - args, err := ec.field_Mutation_finance_removeAccountMember_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.FinanceRemoveAccountMember(childComplexity, args["accountName"].(string), args["userId"].(repos.ID)), true - - case "Mutation.finance_updateAccount": - if e.complexity.Mutation.FinanceUpdateAccount == nil { - break - } - - args, err := ec.field_Mutation_finance_updateAccount_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.FinanceUpdateAccount(childComplexity, args["accountName"].(string), args["name"].(*string), args["contactEmail"].(*string)), true - - case "Mutation.finance_updateAccountMember": - if e.complexity.Mutation.FinanceUpdateAccountMember == nil { - break - } - - args, err := ec.field_Mutation_finance_updateAccountMember_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.FinanceUpdateAccountMember(childComplexity, args["accountName"].(string), args["userId"].(repos.ID), args["role"].(string)), true - - case "Query.finance_account": - if e.complexity.Query.FinanceAccount == nil { - break - } - - args, err := ec.field_Query_finance_account_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.FinanceAccount(childComplexity, args["accountName"].(string)), true - - case "Query.finance_listAccounts": - if e.complexity.Query.FinanceListAccounts == nil { - break - } - - return e.complexity.Query.FinanceListAccounts(childComplexity), true - - case "Query.finance_listInvitations": - if e.complexity.Query.FinanceListInvitations == nil { - break - } - - args, err := ec.field_Query_finance_listInvitations_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.FinanceListInvitations(childComplexity, args["accountName"].(string)), true - - case "Query.finance_reSyncAccount": - if e.complexity.Query.FinanceReSyncAccount == nil { - break - } - - args, err := ec.field_Query_finance_reSyncAccount_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.FinanceReSyncAccount(childComplexity, args["accountName"].(string)), true - - case "Query._service": - if e.complexity.Query.__resolve__service == nil { - break - } - - return e.complexity.Query.__resolve__service(childComplexity), true - - case "Query._entities": - if e.complexity.Query.__resolve_entities == nil { - break - } - - args, err := ec.field_Query__entities_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]interface{})), true - - case "User.accountMembership": - if e.complexity.User.AccountMembership == nil { - break - } - - args, err := ec.field_User_accountMembership_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.User.AccountMembership(childComplexity, args["accountName"].(string)), true - - case "User.accountMemberships": - if e.complexity.User.AccountMemberships == nil { - break - } - - return e.complexity.User.AccountMemberships(childComplexity), true - - case "User.id": - if e.complexity.User.ID == nil { - break - } - - return e.complexity.User.ID(childComplexity), true - - case "_Service.sdl": - if e.complexity._Service.SDL == nil { - break - } - - return e.complexity._Service.SDL(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { - rc := graphql.GetOperationContext(ctx) - ec := executionContext{rc, e} - inputUnmarshalMap := graphql.BuildUnmarshalerMap( - ec.unmarshalInputBillingInput, - ) - first := true - - switch rc.Operation.Operation { - case ast.Query: - return func(ctx context.Context) *graphql.Response { - if !first { - return nil - } - first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._Query(ctx, rc.Operation.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), - } - } - case ast.Mutation: - return func(ctx context.Context) *graphql.Response { - if !first { - return nil - } - first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._Mutation(ctx, rc.Operation.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), - } - } - - default: - return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) - } -} - -type executionContext struct { - *graphql.OperationContext - *executableSchema -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapSchema(parsedSchema), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} - -var sources = []*ast.Source{ - {Name: "../schema.graphqls", Input: `directive @isLoggedIn on FIELD_DEFINITION - -type Query { - finance_listAccounts: [Account] @isLoggedIn - finance_account(accountName: String!): Account @isLoggedIn - finance_listInvitations(accountName: String!): [AccountMembership] @isLoggedIn - # finance_stripeSetupIntent: String # user-access - # finance_testStripe(accountId: ID!): Boolean! #private - - finance_reSyncAccount(accountName: String!): Boolean! @isLoggedIn -} - -type Mutation { - finance_createAccount(name: String!, displayName: String!): Account! @isLoggedIn - finance_updateAccount(accountName: String!, name: String, contactEmail: String): Account! @isLoggedIn - # finance_updateAccountBilling(accountId: ID!, billing: BillingInput!): Account! # account-admin-access, account-owner-access - finance_removeAccountMember(accountName: String!, userId: ID!): Boolean! @isLoggedIn - finance_updateAccountMember(accountName: String!, userId: ID!, role: String!): Boolean! @isLoggedIn - finance_deactivateAccount(accountName: String!): Boolean! @isLoggedIn - finance_activateAccount(accountName: String!): Boolean! @isLoggedIn - finance_deleteAccount(accountName: String!): Boolean! @isLoggedIn - # finance_attachToCluster(accountId: ID!, clusterId: ID!): Boolean! - - finance_inviteUser(accountName: String!, name: String, email: String!, role: String!): Boolean! @isLoggedIn - finance_deleteInvitation(accountName: String!, email: String!): Boolean! @isLoggedIn -} - -scalar Json -scalar Date - -type Account @key(fields: "name") { - name: String! - displayName: String! - billing: Billing! - isActive: Boolean! - contactEmail: String! - readableId: ID! - memberships: [AccountMembership!]! # account-admin-access, account-owner-access - created: Date! - outstandingAmount: Float! -} - -# extend type Account @key(fields: "name") { -# name: String! -# memberships: [AccountMembership!]! # account-admin-access, account-owner-access -# } - -# extend type StoragePlan @key(fields: "name"){ -# name: String! @external -# pricePerGB: Float! -# } -# -# extend type ComputePlan @key(fields: "name"){ -# name: String! @external -# sharedPrice: Float! -# dedicatedPrice: Float! -# } -# -# extend type LambdaPlan @key(fields: "name"){ -# name: String! @external -# freeTier: Int! -# pricePerGBHr: Float! -# } - -extend type User @key(fields: "id") { - id: ID! @external - accountMemberships:[AccountMembership!]! @isLoggedIn # user-access - accountMembership(accountName: String!):AccountMembership! @isLoggedIn # user-access -} - -type AccountMembership { - user: User! - role: String! - account: Account! - accepted: Boolean! -} - -type Billing { - cardholderName: String! - address: Json! -} - -input BillingInput { - stripePaymentMethodId: String! - cardholderName: String! - address: Json! -} -`, BuiltIn: false}, - {Name: "../../federation/directives.graphql", Input: ` - scalar _Any - scalar _FieldSet - directive @requires(fields: _FieldSet!) on FIELD_DEFINITION - directive @provides(fields: _FieldSet!) on FIELD_DEFINITION - directive @extends on OBJECT | INTERFACE - - directive @key(fields: _FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE - directive @external on FIELD_DEFINITION | OBJECT - directive @link(import: [String!], url: String!) repeatable on SCHEMA - directive @shareable on OBJECT | FIELD_DEFINITION - directive @tag(name: String!) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION - directive @override(from: String!) on FIELD_DEFINITION - directive @inaccessible on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION -`, BuiltIn: true}, - {Name: "../../federation/entity.graphql", Input: ` -# a union of all types that use the @key directive -union _Entity = Account | User - -# fake type to build resolver interfaces for users to implement -type Entity { - findAccountByName(name: String!,): Account! - findUserByID(id: ID!,): User! - -} - -type _Service { - sdl: String -} - -extend type Query { - _entities(representations: [_Any!]!): [_Entity]! - _service: _Service! -} -`, BuiltIn: true}, -} -var parsedSchema = gqlparser.MustLoadSchema(sources...) - -// endregion ************************** generated!.gotpl ************************** - -// region ***************************** args.gotpl ***************************** - -func (ec *executionContext) field_Entity_findAccountByName_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Entity_findUserByID_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 repos.ID - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_finance_activateAccount_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_finance_createAccount_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - var arg1 string - if tmp, ok := rawArgs["displayName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("displayName")) - arg1, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["displayName"] = arg1 - return args, nil -} - -func (ec *executionContext) field_Mutation_finance_deactivateAccount_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_finance_deleteAccount_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_finance_deleteInvitation_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - var arg1 string - if tmp, ok := rawArgs["email"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) - arg1, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["email"] = arg1 - return args, nil -} - -func (ec *executionContext) field_Mutation_finance_inviteUser_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - var arg1 *string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg1, err = ec.unmarshalOString2ᚖstring(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg1 - var arg2 string - if tmp, ok := rawArgs["email"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) - arg2, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["email"] = arg2 - var arg3 string - if tmp, ok := rawArgs["role"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("role")) - arg3, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["role"] = arg3 - return args, nil -} - -func (ec *executionContext) field_Mutation_finance_removeAccountMember_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - var arg1 repos.ID - if tmp, ok := rawArgs["userId"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) - arg1, err = ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["userId"] = arg1 - return args, nil -} - -func (ec *executionContext) field_Mutation_finance_updateAccountMember_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - var arg1 repos.ID - if tmp, ok := rawArgs["userId"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) - arg1, err = ec.unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["userId"] = arg1 - var arg2 string - if tmp, ok := rawArgs["role"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("role")) - arg2, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["role"] = arg2 - return args, nil -} - -func (ec *executionContext) field_Mutation_finance_updateAccount_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - var arg1 *string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg1, err = ec.unmarshalOString2ᚖstring(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg1 - var arg2 *string - if tmp, ok := rawArgs["contactEmail"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("contactEmail")) - arg2, err = ec.unmarshalOString2ᚖstring(ctx, tmp) - if err != nil { - return nil, err - } - } - args["contactEmail"] = arg2 - return args, nil -} - -func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query__entities_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 []map[string]interface{} - if tmp, ok := rawArgs["representations"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("representations")) - arg0, err = ec.unmarshalN_Any2ᚕmapᚄ(ctx, tmp) - if err != nil { - return nil, err - } - } - args["representations"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_finance_account_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_finance_listInvitations_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_finance_reSyncAccount_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - return args, nil -} - -func (ec *executionContext) field_User_accountMembership_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["accountName"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountName")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["accountName"] = arg0 - return args, nil -} - -func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -// endregion ***************************** args.gotpl ***************************** - -// region ************************** directives.gotpl ************************** - -// endregion ************************** directives.gotpl ************************** - -// region **************************** field.gotpl ***************************** - -func (ec *executionContext) _Account_name(ctx context.Context, field graphql.CollectedField, obj *model.Account) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Account_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_Account_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Account", - 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) _Account_displayName(ctx context.Context, field graphql.CollectedField, obj *model.Account) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Account_displayName(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.DisplayName, 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_Account_displayName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Account", - 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) _Account_billing(ctx context.Context, field graphql.CollectedField, obj *model.Account) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Account_billing(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.Billing, 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.(*model.Billing) - fc.Result = res - return ec.marshalNBilling2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐBilling(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Account_billing(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Account", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "cardholderName": - return ec.fieldContext_Billing_cardholderName(ctx, field) - case "address": - return ec.fieldContext_Billing_address(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Billing", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Account_isActive(ctx context.Context, field graphql.CollectedField, obj *model.Account) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Account_isActive(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.IsActive, 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Account_isActive(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Account", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Account_contactEmail(ctx context.Context, field graphql.CollectedField, obj *model.Account) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Account_contactEmail(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.ContactEmail, 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_Account_contactEmail(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Account", - 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) _Account_readableId(ctx context.Context, field graphql.CollectedField, obj *model.Account) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Account_readableId(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.ReadableID, 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.(repos.ID) - fc.Result = res - return ec.marshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Account_readableId(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Account", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Account_memberships(ctx context.Context, field graphql.CollectedField, obj *model.Account) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Account_memberships(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.Account().Memberships(rctx, obj) - }) - 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.([]*model.AccountMembership) - fc.Result = res - return ec.marshalNAccountMembership2ᚕᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccountMembershipᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Account_memberships(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Account", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "user": - return ec.fieldContext_AccountMembership_user(ctx, field) - case "role": - return ec.fieldContext_AccountMembership_role(ctx, field) - case "account": - return ec.fieldContext_AccountMembership_account(ctx, field) - case "accepted": - return ec.fieldContext_AccountMembership_accepted(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AccountMembership", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Account_created(ctx context.Context, field graphql.CollectedField, obj *model.Account) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Account_created(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.Created, 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.marshalNDate2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Account_created(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Account", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Date does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Account_outstandingAmount(ctx context.Context, field graphql.CollectedField, obj *model.Account) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Account_outstandingAmount(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.OutstandingAmount, 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_Account_outstandingAmount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Account", - 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) _AccountMembership_user(ctx context.Context, field graphql.CollectedField, obj *model.AccountMembership) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AccountMembership_user(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.AccountMembership().User(rctx, obj) - }) - 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.(*model.User) - fc.Result = res - return ec.marshalNUser2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AccountMembership_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AccountMembership", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "accountMemberships": - return ec.fieldContext_User_accountMemberships(ctx, field) - case "accountMembership": - return ec.fieldContext_User_accountMembership(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _AccountMembership_role(ctx context.Context, field graphql.CollectedField, obj *model.AccountMembership) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AccountMembership_role(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.Role, 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_AccountMembership_role(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AccountMembership", - 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) _AccountMembership_account(ctx context.Context, field graphql.CollectedField, obj *model.AccountMembership) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AccountMembership_account(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.AccountMembership().Account(rctx, obj) - }) - 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.(*model.Account) - fc.Result = res - return ec.marshalNAccount2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AccountMembership_account(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AccountMembership", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext_Account_name(ctx, field) - case "displayName": - return ec.fieldContext_Account_displayName(ctx, field) - case "billing": - return ec.fieldContext_Account_billing(ctx, field) - case "isActive": - return ec.fieldContext_Account_isActive(ctx, field) - case "contactEmail": - return ec.fieldContext_Account_contactEmail(ctx, field) - case "readableId": - return ec.fieldContext_Account_readableId(ctx, field) - case "memberships": - return ec.fieldContext_Account_memberships(ctx, field) - case "created": - return ec.fieldContext_Account_created(ctx, field) - case "outstandingAmount": - return ec.fieldContext_Account_outstandingAmount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Account", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _AccountMembership_accepted(ctx context.Context, field graphql.CollectedField, obj *model.AccountMembership) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AccountMembership_accepted(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.Accepted, 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AccountMembership_accepted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AccountMembership", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Billing_cardholderName(ctx context.Context, field graphql.CollectedField, obj *model.Billing) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Billing_cardholderName(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.CardholderName, 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_Billing_cardholderName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Billing", - 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) _Billing_address(ctx context.Context, field graphql.CollectedField, obj *model.Billing) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Billing_address(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.Address, 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.(map[string]interface{}) - fc.Result = res - return ec.marshalNJson2map(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Billing_address(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Billing", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Json does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Entity_findAccountByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Entity_findAccountByName(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.Entity().FindAccountByName(rctx, fc.Args["name"].(string)) - }) - 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.(*model.Account) - fc.Result = res - return ec.marshalNAccount2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Entity_findAccountByName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Entity", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext_Account_name(ctx, field) - case "displayName": - return ec.fieldContext_Account_displayName(ctx, field) - case "billing": - return ec.fieldContext_Account_billing(ctx, field) - case "isActive": - return ec.fieldContext_Account_isActive(ctx, field) - case "contactEmail": - return ec.fieldContext_Account_contactEmail(ctx, field) - case "readableId": - return ec.fieldContext_Account_readableId(ctx, field) - case "memberships": - return ec.fieldContext_Account_memberships(ctx, field) - case "created": - return ec.fieldContext_Account_created(ctx, field) - case "outstandingAmount": - return ec.fieldContext_Account_outstandingAmount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Account", 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_Entity_findAccountByName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Entity_findUserByID(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.Entity().FindUserByID(rctx, fc.Args["id"].(repos.ID)) - }) - 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.(*model.User) - fc.Result = res - return ec.marshalNUser2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Entity", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "accountMemberships": - return ec.fieldContext_User_accountMemberships(ctx, field) - case "accountMembership": - return ec.fieldContext_User_accountMembership(ctx, field) - } - 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_Entity_findUserByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_finance_createAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_finance_createAccount(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FinanceCreateAccount(rctx, fc.Args["name"].(string), fc.Args["displayName"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*model.Account); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *kloudlite.io/apps/finance_deprecated/internal/app/graph/model.Account`, tmp) - }) - 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.(*model.Account) - fc.Result = res - return ec.marshalNAccount2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_finance_createAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext_Account_name(ctx, field) - case "displayName": - return ec.fieldContext_Account_displayName(ctx, field) - case "billing": - return ec.fieldContext_Account_billing(ctx, field) - case "isActive": - return ec.fieldContext_Account_isActive(ctx, field) - case "contactEmail": - return ec.fieldContext_Account_contactEmail(ctx, field) - case "readableId": - return ec.fieldContext_Account_readableId(ctx, field) - case "memberships": - return ec.fieldContext_Account_memberships(ctx, field) - case "created": - return ec.fieldContext_Account_created(ctx, field) - case "outstandingAmount": - return ec.fieldContext_Account_outstandingAmount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Account", 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_finance_createAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_finance_updateAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_finance_updateAccount(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FinanceUpdateAccount(rctx, fc.Args["accountName"].(string), fc.Args["name"].(*string), fc.Args["contactEmail"].(*string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*model.Account); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *kloudlite.io/apps/finance_deprecated/internal/app/graph/model.Account`, tmp) - }) - 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.(*model.Account) - fc.Result = res - return ec.marshalNAccount2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_finance_updateAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext_Account_name(ctx, field) - case "displayName": - return ec.fieldContext_Account_displayName(ctx, field) - case "billing": - return ec.fieldContext_Account_billing(ctx, field) - case "isActive": - return ec.fieldContext_Account_isActive(ctx, field) - case "contactEmail": - return ec.fieldContext_Account_contactEmail(ctx, field) - case "readableId": - return ec.fieldContext_Account_readableId(ctx, field) - case "memberships": - return ec.fieldContext_Account_memberships(ctx, field) - case "created": - return ec.fieldContext_Account_created(ctx, field) - case "outstandingAmount": - return ec.fieldContext_Account_outstandingAmount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Account", 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_finance_updateAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_finance_removeAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_finance_removeAccountMember(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FinanceRemoveAccountMember(rctx, fc.Args["accountName"].(string), fc.Args["userId"].(repos.ID)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_finance_removeAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_finance_removeAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_finance_updateAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_finance_updateAccountMember(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FinanceUpdateAccountMember(rctx, fc.Args["accountName"].(string), fc.Args["userId"].(repos.ID), fc.Args["role"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_finance_updateAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_finance_updateAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_finance_deactivateAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_finance_deactivateAccount(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FinanceDeactivateAccount(rctx, fc.Args["accountName"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_finance_deactivateAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_finance_deactivateAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_finance_activateAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_finance_activateAccount(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FinanceActivateAccount(rctx, fc.Args["accountName"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_finance_activateAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_finance_activateAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_finance_deleteAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_finance_deleteAccount(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FinanceDeleteAccount(rctx, fc.Args["accountName"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_finance_deleteAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_finance_deleteAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_finance_inviteUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_finance_inviteUser(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FinanceInviteUser(rctx, fc.Args["accountName"].(string), fc.Args["name"].(*string), fc.Args["email"].(string), fc.Args["role"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_finance_inviteUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_finance_inviteUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Mutation_finance_deleteInvitation(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_finance_deleteInvitation(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FinanceDeleteInvitation(rctx, fc.Args["accountName"].(string), fc.Args["email"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_finance_deleteInvitation(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_finance_deleteInvitation_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Query_finance_listAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_finance_listAccounts(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().FinanceListAccounts(rctx) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.([]*model.Account); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*kloudlite.io/apps/finance_deprecated/internal/app/graph/model.Account`, tmp) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*model.Account) - fc.Result = res - return ec.marshalOAccount2ᚕᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_finance_listAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext_Account_name(ctx, field) - case "displayName": - return ec.fieldContext_Account_displayName(ctx, field) - case "billing": - return ec.fieldContext_Account_billing(ctx, field) - case "isActive": - return ec.fieldContext_Account_isActive(ctx, field) - case "contactEmail": - return ec.fieldContext_Account_contactEmail(ctx, field) - case "readableId": - return ec.fieldContext_Account_readableId(ctx, field) - case "memberships": - return ec.fieldContext_Account_memberships(ctx, field) - case "created": - return ec.fieldContext_Account_created(ctx, field) - case "outstandingAmount": - return ec.fieldContext_Account_outstandingAmount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Account", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_finance_account(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_finance_account(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().FinanceAccount(rctx, fc.Args["accountName"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*model.Account); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *kloudlite.io/apps/finance_deprecated/internal/app/graph/model.Account`, tmp) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*model.Account) - fc.Result = res - return ec.marshalOAccount2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_finance_account(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext_Account_name(ctx, field) - case "displayName": - return ec.fieldContext_Account_displayName(ctx, field) - case "billing": - return ec.fieldContext_Account_billing(ctx, field) - case "isActive": - return ec.fieldContext_Account_isActive(ctx, field) - case "contactEmail": - return ec.fieldContext_Account_contactEmail(ctx, field) - case "readableId": - return ec.fieldContext_Account_readableId(ctx, field) - case "memberships": - return ec.fieldContext_Account_memberships(ctx, field) - case "created": - return ec.fieldContext_Account_created(ctx, field) - case "outstandingAmount": - return ec.fieldContext_Account_outstandingAmount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Account", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_finance_account_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Query_finance_listInvitations(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_finance_listInvitations(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().FinanceListInvitations(rctx, fc.Args["accountName"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.([]*model.AccountMembership); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*kloudlite.io/apps/finance_deprecated/internal/app/graph/model.AccountMembership`, tmp) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*model.AccountMembership) - fc.Result = res - return ec.marshalOAccountMembership2ᚕᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccountMembership(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_finance_listInvitations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "user": - return ec.fieldContext_AccountMembership_user(ctx, field) - case "role": - return ec.fieldContext_AccountMembership_role(ctx, field) - case "account": - return ec.fieldContext_AccountMembership_account(ctx, field) - case "accepted": - return ec.fieldContext_AccountMembership_accepted(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AccountMembership", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_finance_listInvitations_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Query_finance_reSyncAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_finance_reSyncAccount(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().FinanceReSyncAccount(rctx, fc.Args["accountName"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_finance_reSyncAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_finance_reSyncAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query__entities(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.__resolve_entities(ctx, fc.Args["representations"].([]map[string]interface{})), 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.([]fedruntime.Entity) - fc.Result = res - return ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query__entities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type _Entity does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query__entities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query__service(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.__resolve__service(ctx) - }) - 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.(fedruntime.Service) - fc.Result = res - return ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "sdl": - return ec.fieldContext__Service_sdl(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___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 ec.introspectType(fc.Args["name"].(string)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(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.introspectSchema() - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_id(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.ID, 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.(repos.ID) - fc.Result = res - return ec.marshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "User", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _User_accountMemberships(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_accountMemberships(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().AccountMemberships(rctx, obj) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, obj, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.([]*model.AccountMembership); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*kloudlite.io/apps/finance_deprecated/internal/app/graph/model.AccountMembership`, tmp) - }) - 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.([]*model.AccountMembership) - fc.Result = res - return ec.marshalNAccountMembership2ᚕᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccountMembershipᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_User_accountMemberships(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "User", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "user": - return ec.fieldContext_AccountMembership_user(ctx, field) - case "role": - return ec.fieldContext_AccountMembership_role(ctx, field) - case "account": - return ec.fieldContext_AccountMembership_account(ctx, field) - case "accepted": - return ec.fieldContext_AccountMembership_accepted(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AccountMembership", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _User_accountMembership(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_accountMembership(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) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().AccountMembership(rctx, obj, fc.Args["accountName"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.IsLoggedIn == nil { - return nil, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, obj, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*model.AccountMembership); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *kloudlite.io/apps/finance_deprecated/internal/app/graph/model.AccountMembership`, tmp) - }) - 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.(*model.AccountMembership) - fc.Result = res - return ec.marshalNAccountMembership2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccountMembership(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_User_accountMembership(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "User", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "user": - return ec.fieldContext_AccountMembership_user(ctx, field) - case "role": - return ec.fieldContext_AccountMembership_role(ctx, field) - case "account": - return ec.fieldContext_AccountMembership_account(ctx, field) - case "accepted": - return ec.fieldContext_AccountMembership_accepted(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AccountMembership", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_User_accountMembership_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { - fc, err := ec.fieldContext__Service_sdl(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.SDL, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext__Service_sdl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "_Service", - 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) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_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___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - 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) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_description(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.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_locations(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.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __DirectiveLocation does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_args(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.Args, 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.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_isRepeatable(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.IsRepeatable, 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_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___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - 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) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_description(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.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_isDeprecated(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.IsDeprecated(), 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_deprecationReason(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.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_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___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - 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) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_description(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.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_args(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.Args, 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.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_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.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_isDeprecated(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.IsDeprecated(), 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_deprecationReason(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.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_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___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - 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) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_description(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.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_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.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_defaultValue(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.DefaultValue, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_description(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.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_types(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.Types(), 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.([]introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_queryType(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.QueryType(), 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.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_mutationType(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.MutationType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_subscriptionType(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.SubscriptionType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_directives(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.Directives(), 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.([]introspection.Directive) - fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Directive_name(ctx, field) - case "description": - return ec.fieldContext___Directive_description(ctx, field) - case "locations": - return ec.fieldContext___Directive_locations(ctx, field) - case "args": - return ec.fieldContext___Directive_args(ctx, field) - case "isRepeatable": - return ec.fieldContext___Directive_isRepeatable(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_kind(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.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __TypeKind does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_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 { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_description(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.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_fields(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.Fields(fc.Args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Field_name(ctx, field) - case "description": - return ec.fieldContext___Field_description(ctx, field) - case "args": - return ec.fieldContext___Field_args(ctx, field) - case "type": - return ec.fieldContext___Field_type(ctx, field) - case "isDeprecated": - return ec.fieldContext___Field_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___Field_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Field", 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___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_interfaces(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.Interfaces(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_possibleTypes(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.PossibleTypes(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_enumValues(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.EnumValues(fc.Args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.EnumValue) - fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___EnumValue_name(ctx, field) - case "description": - return ec.fieldContext___EnumValue_description(ctx, field) - case "isDeprecated": - return ec.fieldContext___EnumValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___EnumValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __EnumValue", 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___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } - return fc, nil -} - -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_inputFields(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.InputFields(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_ofType(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.OfType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_specifiedByURL(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.SpecifiedByURL(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputBillingInput(ctx context.Context, obj interface{}) (model.BillingInput, error) { - var it model.BillingInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"stripePaymentMethodId", "cardholderName", "address"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "stripePaymentMethodId": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stripePaymentMethodId")) - it.StripePaymentMethodID, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "cardholderName": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cardholderName")) - it.CardholderName, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "address": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("address")) - it.Address, err = ec.unmarshalNJson2map(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** - -func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler { - switch obj := (obj).(type) { - case nil: - return graphql.Null - case model.Account: - return ec._Account(ctx, sel, &obj) - case *model.Account: - if obj == nil { - return graphql.Null - } - return ec._Account(ctx, sel, obj) - case model.User: - return ec._User(ctx, sel, &obj) - case *model.User: - if obj == nil { - return graphql.Null - } - return ec._User(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } -} - -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - -var accountImplementors = []string{"Account", "_Entity"} - -func (ec *executionContext) _Account(ctx context.Context, sel ast.SelectionSet, obj *model.Account) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, accountImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Account") - case "name": - - out.Values[i] = ec._Account_name(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "displayName": - - out.Values[i] = ec._Account_displayName(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "billing": - - out.Values[i] = ec._Account_billing(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "isActive": - - out.Values[i] = ec._Account_isActive(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "contactEmail": - - out.Values[i] = ec._Account_contactEmail(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "readableId": - - out.Values[i] = ec._Account_readableId(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "memberships": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Account_memberships(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) - - }) - case "created": - - out.Values[i] = ec._Account_created(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "outstandingAmount": - - out.Values[i] = ec._Account_outstandingAmount(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var accountMembershipImplementors = []string{"AccountMembership"} - -func (ec *executionContext) _AccountMembership(ctx context.Context, sel ast.SelectionSet, obj *model.AccountMembership) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, accountMembershipImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("AccountMembership") - case "user": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._AccountMembership_user(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) - - }) - case "role": - - out.Values[i] = ec._AccountMembership_role(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "account": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._AccountMembership_account(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) - - }) - case "accepted": - - out.Values[i] = ec._AccountMembership_accepted(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var billingImplementors = []string{"Billing"} - -func (ec *executionContext) _Billing(ctx context.Context, sel ast.SelectionSet, obj *model.Billing) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, billingImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Billing") - case "cardholderName": - - out.Values[i] = ec._Billing_cardholderName(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "address": - - out.Values[i] = ec._Billing_address(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var entityImplementors = []string{"Entity"} - -func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Entity", - }) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Entity") - case "findAccountByName": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Entity_findAccountByName(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "findUserByID": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Entity_findUserByID(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var mutationImplementors = []string{"Mutation"} - -func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Mutation", - }) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Mutation") - case "finance_createAccount": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_finance_createAccount(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "finance_updateAccount": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_finance_updateAccount(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "finance_removeAccountMember": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_finance_removeAccountMember(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "finance_updateAccountMember": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_finance_updateAccountMember(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "finance_deactivateAccount": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_finance_deactivateAccount(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "finance_activateAccount": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_finance_activateAccount(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "finance_deleteAccount": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_finance_deleteAccount(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "finance_inviteUser": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_finance_inviteUser(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "finance_deleteInvitation": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_finance_deleteInvitation(ctx, field) - }) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var queryImplementors = []string{"Query"} - -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "finance_listAccounts": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_finance_listAccounts(ctx, field) - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "finance_account": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_finance_account(ctx, field) - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "finance_listInvitations": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_finance_listInvitations(ctx, field) - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "finance_reSyncAccount": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_finance_reSyncAccount(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "_entities": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query__entities(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "_service": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query__service(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "__type": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___type(ctx, field) - }) - - case "__schema": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___schema(ctx, field) - }) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var userImplementors = []string{"User", "_Entity"} - -func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("User") - case "id": - - out.Values[i] = ec._User_id(ctx, field, obj) - - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "accountMemberships": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._User_accountMemberships(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) - - }) - case "accountMembership": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._User_accountMembership(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) - - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var _ServiceImplementors = []string{"_Service"} - -func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, obj *fedruntime.Service) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, _ServiceImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("_Service") - case "sdl": - - out.Values[i] = ec.__Service_sdl(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __DirectiveImplementors = []string{"__Directive"} - -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - - out.Values[i] = ec.___Directive_name(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - - out.Values[i] = ec.___Directive_description(ctx, field, obj) - - case "locations": - - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "args": - - out.Values[i] = ec.___Directive_args(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "isRepeatable": - - out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __EnumValueImplementors = []string{"__EnumValue"} - -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - - case "isDeprecated": - - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "deprecationReason": - - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __FieldImplementors = []string{"__Field"} - -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - - out.Values[i] = ec.___Field_name(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - - out.Values[i] = ec.___Field_description(ctx, field, obj) - - case "args": - - out.Values[i] = ec.___Field_args(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "type": - - out.Values[i] = ec.___Field_type(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "isDeprecated": - - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "deprecationReason": - - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __InputValueImplementors = []string{"__InputValue"} - -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - - case "type": - - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "defaultValue": - - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __SchemaImplementors = []string{"__Schema"} - -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "description": - - out.Values[i] = ec.___Schema_description(ctx, field, obj) - - case "types": - - out.Values[i] = ec.___Schema_types(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "queryType": - - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "mutationType": - - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - - case "subscriptionType": - - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - - case "directives": - - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __TypeImplementors = []string{"__Type"} - -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - - out.Values[i] = ec.___Type_kind(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "name": - - out.Values[i] = ec.___Type_name(ctx, field, obj) - - case "description": - - out.Values[i] = ec.___Type_description(ctx, field, obj) - - case "fields": - - out.Values[i] = ec.___Type_fields(ctx, field, obj) - - case "interfaces": - - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - - case "possibleTypes": - - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - - case "enumValues": - - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - - case "inputFields": - - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - - case "ofType": - - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - - case "specifiedByURL": - - out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -// endregion **************************** object.gotpl **************************** - -// region ***************************** type.gotpl ***************************** - -func (ec *executionContext) marshalNAccount2kloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx context.Context, sel ast.SelectionSet, v model.Account) graphql.Marshaler { - return ec._Account(ctx, sel, &v) -} - -func (ec *executionContext) marshalNAccount2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx context.Context, sel ast.SelectionSet, v *model.Account) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._Account(ctx, sel, v) -} - -func (ec *executionContext) marshalNAccountMembership2kloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccountMembership(ctx context.Context, sel ast.SelectionSet, v model.AccountMembership) graphql.Marshaler { - return ec._AccountMembership(ctx, sel, &v) -} - -func (ec *executionContext) marshalNAccountMembership2ᚕᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccountMembershipᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.AccountMembership) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAccountMembership2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccountMembership(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNAccountMembership2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccountMembership(ctx context.Context, sel ast.SelectionSet, v *model.AccountMembership) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._AccountMembership(ctx, sel, v) -} - -func (ec *executionContext) marshalNBilling2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐBilling(ctx context.Context, sel ast.SelectionSet, v *model.Billing) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._Billing(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(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) unmarshalNDate2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNDate2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(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) 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) unmarshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx context.Context, v interface{}) (repos.ID, error) { - tmp, err := graphql.UnmarshalString(v) - res := repos.ID(tmp) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNID2kloudliteᚗioᚋpkgᚋreposᚐID(ctx context.Context, sel ast.SelectionSet, v repos.ID) 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) unmarshalNJson2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { - res, err := graphql.UnmarshalMap(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNJson2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - res := graphql.MarshalMap(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) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(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) marshalNUser2kloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { - return ec._User(ctx, sel, &v) -} - -func (ec *executionContext) marshalNUser2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._User(ctx, sel, v) -} - -func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { - res, err := graphql.UnmarshalMap(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - res := graphql.MarshalMap(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) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]map[string]interface{}, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalN_Any2map(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.SelectionSet, v []map[string]interface{}) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalN_Any2map(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(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) marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { - return ec.__Service(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(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) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(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) marshalOAccount2ᚕᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx context.Context, sel ast.SelectionSet, v []*model.Account) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOAccount2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOAccount2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccount(ctx context.Context, sel ast.SelectionSet, v *model.Account) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Account(ctx, sel, v) -} - -func (ec *executionContext) marshalOAccountMembership2ᚕᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccountMembership(ctx context.Context, sel ast.SelectionSet, v []*model.AccountMembership) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOAccountMembership2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccountMembership(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOAccountMembership2ᚖkloudliteᚗioᚋappsᚋfinanceᚋinternalᚋappᚋgraphᚋmodelᚐAccountMembership(ctx context.Context, sel ast.SelectionSet, v *model.AccountMembership) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._AccountMembership(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) - return res -} - -func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalBoolean(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalBoolean(*v) - return res -} - -func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - return res -} - -func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNString2string(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalString(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalString(*v) - return res -} - -func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.__Entity(ctx, sel, v) -} - -func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) -} - -func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -// endregion ***************************** type.gotpl ***************************** diff --git a/apps/finance_deprecated/internal/app/graph/helper.go b/apps/finance_deprecated/internal/app/graph/helper.go deleted file mode 100644 index 95aa47748..000000000 --- a/apps/finance_deprecated/internal/app/graph/helper.go +++ /dev/null @@ -1,35 +0,0 @@ -package graph - -import ( - "context" - "fmt" - - "kloudlite.io/apps/finance_deprecated/internal/app/graph/model" - "kloudlite.io/apps/finance_deprecated/internal/domain" - fn "kloudlite.io/pkg/functions" -) - -func AccountModelFromEntity(account *domain.Account) *model.Account { - if account == nil { - return nil - } - return &model.Account{ - // ID: account.Id, - Name: account.Name, - Billing: &model.Billing{ - CardholderName: account.Billing.CardholderName, - Address: account.Billing.Address, - }, - IsActive: fn.DefaultIfNil(account.IsActive, false), - ContactEmail: account.ContactEmail, - ReadableID: account.ReadableId, - Created: account.CreatedAt.String(), - } -} - -func toFinanceContext(ctx context.Context) domain.FinanceContext { - if cc, ok := ctx.Value("kl-finance-ctx").(domain.FinanceContext); ok { - return cc - } - panic(fmt.Errorf("context values '%s' is missing", "kl-finance-ctx")) -} diff --git a/apps/finance_deprecated/internal/app/graph/model/models_gen.go b/apps/finance_deprecated/internal/app/graph/model/models_gen.go deleted file mode 100644 index c55a3847c..000000000 --- a/apps/finance_deprecated/internal/app/graph/model/models_gen.go +++ /dev/null @@ -1,47 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package model - -import ( - "kloudlite.io/pkg/repos" -) - -type Account struct { - Name string `json:"name"` - DisplayName string `json:"displayName"` - Billing *Billing `json:"billing"` - IsActive bool `json:"isActive"` - ContactEmail string `json:"contactEmail"` - ReadableID repos.ID `json:"readableId"` - Memberships []*AccountMembership `json:"memberships"` - Created string `json:"created"` - OutstandingAmount float64 `json:"outstandingAmount"` -} - -func (Account) IsEntity() {} - -type AccountMembership struct { - User *User `json:"user"` - Role string `json:"role"` - Account *Account `json:"account"` - Accepted bool `json:"accepted"` -} - -type Billing struct { - CardholderName string `json:"cardholderName"` - Address map[string]interface{} `json:"address"` -} - -type BillingInput struct { - StripePaymentMethodID string `json:"stripePaymentMethodId"` - CardholderName string `json:"cardholderName"` - Address map[string]interface{} `json:"address"` -} - -type User struct { - ID repos.ID `json:"id"` - AccountMemberships []*AccountMembership `json:"accountMemberships"` - AccountMembership *AccountMembership `json:"accountMembership"` -} - -func (User) IsEntity() {} diff --git a/apps/finance_deprecated/internal/app/graph/resolver.go b/apps/finance_deprecated/internal/app/graph/resolver.go deleted file mode 100644 index 10ef4506d..000000000 --- a/apps/finance_deprecated/internal/app/graph/resolver.go +++ /dev/null @@ -1,17 +0,0 @@ -package graph - -import "kloudlite.io/apps/finance_deprecated/internal/domain" - -// This file will not be regenerated automatically. -// -// It serves as dependency injection for your app, add any dependencies you require here. - -type Resolver struct { - domain domain.Domain -} - -func NewResolver(domain domain.Domain) *Resolver { - return &Resolver{ - domain: domain, - } -} diff --git a/apps/finance_deprecated/internal/app/graph/schema.graphqls b/apps/finance_deprecated/internal/app/graph/schema.graphqls deleted file mode 100644 index 15b320f19..000000000 --- a/apps/finance_deprecated/internal/app/graph/schema.graphqls +++ /dev/null @@ -1,88 +0,0 @@ -directive @isLoggedIn on FIELD_DEFINITION - -type Query { - finance_listAccounts: [Account] @isLoggedIn - finance_account(accountName: String!): Account @isLoggedIn - finance_listInvitations(accountName: String!): [AccountMembership] @isLoggedIn - - # finance_stripeSetupIntent: String # user-access - # finance_testStripe(accountId: ID!): Boolean! #private - - finance_reSyncAccount(accountName: String!): Boolean! @isLoggedIn -} - -type Mutation { - finance_createAccount(name: String!, displayName: String!): Account! @isLoggedIn - finance_updateAccount(accountName: String!, name: String, contactEmail: String): Account! @isLoggedIn - # finance_updateAccountBilling(accountId: ID!, billing: BillingInput!): Account! # account-admin-access, account-owner-access - finance_removeAccountMember(accountName: String!, userId: ID!): Boolean! @isLoggedIn - finance_updateAccountMember(accountName: String!, userId: ID!, role: String!): Boolean! @isLoggedIn - finance_deactivateAccount(accountName: String!): Boolean! @isLoggedIn - finance_activateAccount(accountName: String!): Boolean! @isLoggedIn - finance_deleteAccount(accountName: String!): Boolean! @isLoggedIn - # finance_attachToCluster(accountId: ID!, clusterId: ID!): Boolean! - - finance_inviteUser(accountName: String!, name: String, email: String!, role: String!): Boolean! @isLoggedIn - finance_deleteInvitation(accountName: String!, email: String!): Boolean! @isLoggedIn -} - -scalar Json -scalar Date - -type Account @key(fields: "name") { - name: String! - displayName: String! - billing: Billing! - isActive: Boolean! - contactEmail: String! - readableId: ID! - memberships: [AccountMembership!]! # account-admin-access, account-owner-access - created: Date! - outstandingAmount: Float! -} - -# extend type Account @key(fields: "name") { -# name: String! -# memberships: [AccountMembership!]! # account-admin-access, account-owner-access -# } - -# extend type StoragePlan @key(fields: "name"){ -# name: String! @external -# pricePerGB: Float! -# } -# -# extend type ComputePlan @key(fields: "name"){ -# name: String! @external -# sharedPrice: Float! -# dedicatedPrice: Float! -# } -# -# extend type LambdaPlan @key(fields: "name"){ -# name: String! @external -# freeTier: Int! -# pricePerGBHr: Float! -# } - -extend type User @key(fields: "id") { - id: ID! @external - accountMemberships:[AccountMembership!]! @isLoggedIn # user-access - accountMembership(accountName: String!):AccountMembership! @isLoggedIn # user-access -} - -type AccountMembership { - user: User! - role: String! - account: Account! - accepted: Boolean! -} - -type Billing { - cardholderName: String! - address: Json! -} - -input BillingInput { - stripePaymentMethodId: String! - cardholderName: String! - address: Json! -} diff --git a/apps/finance_deprecated/internal/app/graph/schema.resolvers.go b/apps/finance_deprecated/internal/app/graph/schema.resolvers.go deleted file mode 100644 index c2aeb0d0f..000000000 --- a/apps/finance_deprecated/internal/app/graph/schema.resolvers.go +++ /dev/null @@ -1,228 +0,0 @@ -package graph - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.28 - -import ( - "context" - "errors" - "fmt" - - "kloudlite.io/apps/finance_deprecated/internal/app/graph/generated" - "kloudlite.io/apps/finance_deprecated/internal/app/graph/model" - "kloudlite.io/apps/finance_deprecated/internal/domain" - iamT "kloudlite.io/apps/iam/types" - "kloudlite.io/pkg/repos" -) - -// Memberships is the resolver for the memberships field. -func (r *accountResolver) Memberships(ctx context.Context, obj *model.Account) ([]*model.AccountMembership, error) { - entities, err := r.domain.GetUserMemberships(toFinanceContext(ctx), iamT.NewResourceRef(obj.Name, iamT.ResourceAccount, obj.Name)) - accountMemberships := make([]*model.AccountMembership, len(entities)) - for i, entity := range entities { - accountMemberships[i] = &model.AccountMembership{ - Account: &model.Account{ - Name: entity.AccountName, - }, - User: &model.User{ - ID: entity.UserId, - }, - Role: string(entity.Role), - Accepted: entity.Accepted, - } - } - return accountMemberships, err -} - -// User is the resolver for the user field. -func (r *accountMembershipResolver) User(ctx context.Context, obj *model.AccountMembership) (*model.User, error) { - return &model.User{ - ID: obj.User.ID, - }, nil -} - -// Account is the resolver for the account field. -func (r *accountMembershipResolver) Account(ctx context.Context, obj *model.AccountMembership) (*model.Account, error) { - acc, err := r.domain.GetAccount(toFinanceContext(ctx), obj.Account.Name) - if err != nil { - return nil, err - } - if acc == nil { - return nil, errors.New("account not found") - } - return AccountModelFromEntity(acc), nil -} - -// FinanceCreateAccount is the resolver for the finance_createAccount field. -func (r *mutationResolver) FinanceCreateAccount(ctx context.Context, name string, displayName string) (*model.Account, error) { - account, err := r.domain.CreateAccount(toFinanceContext(ctx), name, displayName) - if err != nil { - return nil, err - } - return AccountModelFromEntity(account), nil -} - -// FinanceUpdateAccount is the resolver for the finance_updateAccount field. -func (r *mutationResolver) FinanceUpdateAccount(ctx context.Context, accountName string, name *string, contactEmail *string) (*model.Account, error) { - account, err := r.domain.UpdateAccount(toFinanceContext(ctx), accountName, contactEmail) - if err != nil { - return nil, err - } - return AccountModelFromEntity(account), nil -} - -// FinanceRemoveAccountMember is the resolver for the finance_removeAccountMember field. -func (r *mutationResolver) FinanceRemoveAccountMember(ctx context.Context, accountName string, userID repos.ID) (bool, error) { - return r.domain.RemoveAccountMember(toFinanceContext(ctx), accountName, userID) -} - -// FinanceUpdateAccountMember is the resolver for the finance_updateAccountMember field. -func (r *mutationResolver) FinanceUpdateAccountMember(ctx context.Context, accountName string, userID repos.ID, role string) (bool, error) { - return r.domain.UpdateAccountMember(toFinanceContext(ctx), accountName, userID, role) -} - -// FinanceDeactivateAccount is the resolver for the finance_deactivateAccount field. -func (r *mutationResolver) FinanceDeactivateAccount(ctx context.Context, accountName string) (bool, error) { - return r.domain.DeactivateAccount(toFinanceContext(ctx), accountName) -} - -// FinanceActivateAccount is the resolver for the finance_activateAccount field. -func (r *mutationResolver) FinanceActivateAccount(ctx context.Context, accountName string) (bool, error) { - return r.domain.ActivateAccount(toFinanceContext(ctx), accountName) -} - -// FinanceDeleteAccount is the resolver for the finance_deleteAccount field. -func (r *mutationResolver) FinanceDeleteAccount(ctx context.Context, accountName string) (bool, error) { - return r.domain.DeleteAccount(toFinanceContext(ctx), accountName) -} - -// FinanceInviteUser is the resolver for the finance_inviteUser field. -func (r *mutationResolver) FinanceInviteUser(ctx context.Context, accountName string, name *string, email string, role string) (bool, error) { - return r.domain.InviteUser(toFinanceContext(ctx), accountName, email, iamT.Role(role)) -} - -// FinanceDeleteInvitation is the resolver for the finance_deleteInvitation field. -func (r *mutationResolver) FinanceDeleteInvitation(ctx context.Context, accountName string, email string) (bool, error) { - panic(fmt.Errorf("not implemented")) -} - -// FinanceListAccounts is the resolver for the finance_listAccounts field. -func (r *queryResolver) FinanceListAccounts(ctx context.Context) ([]*model.Account, error) { - acc, err := r.domain.ListAccounts(toFinanceContext(ctx)) - if err != nil || acc == nil { - return make([]*model.Account, 0), err - } - - m := make([]*model.Account, len(acc)) - for i := range acc { - m[i] = &model.Account{ - Name: acc[i].Name, - Billing: &model.Billing{ - CardholderName: acc[i].Billing.CardholderName, - Address: acc[i].Billing.Address, - }, - // IsActive: fn.DefaultIfNil(acc[i].IsActive, false), - ContactEmail: acc[i].ContactEmail, - ReadableID: acc[i].ReadableId, - } - } - - return m, nil -} - -// FinanceAccount is the resolver for the finance_account field. -func (r *queryResolver) FinanceAccount(ctx context.Context, accountName string) (*model.Account, error) { - accountEntity, err := r.domain.GetAccount(toFinanceContext(ctx), accountName) - return AccountModelFromEntity(accountEntity), err -} - -// FinanceListInvitations is the resolver for the finance_listInvitations field. -func (r *queryResolver) FinanceListInvitations(ctx context.Context, accountName string) ([]*model.AccountMembership, error) { - m, err := r.domain.ListInvitations(toFinanceContext(ctx), accountName) - if err != nil { - return nil, err - } - - am := make([]*model.AccountMembership, len(m)) - for i := range m { - am[i] = &model.AccountMembership{ - User: &model.User{ - ID: m[i].UserId, - }, - Role: string(m[i].Role), - Account: &model.Account{ - Name: m[i].AccountName, - }, - Accepted: m[i].Accepted, - } - } - return am, nil -} - -// FinanceReSyncAccount is the resolver for the finance_reSyncAccount field. -func (r *queryResolver) FinanceReSyncAccount(ctx context.Context, accountName string) (bool, error) { - if err := r.domain.ReSyncToK8s(toFinanceContext(ctx), accountName); err != nil { - return false, err - } - return true, nil -} - -// AccountMemberships is the resolver for the accountMemberships field. -func (r *userResolver) AccountMemberships(ctx context.Context, obj *model.User) ([]*model.AccountMembership, error) { - // entities, err := r.domain.GetAccountMemberships(toFinanceContext(ctx), obj.ID) - entities, err := r.domain.GetAccountMemberships(domain.FinanceContext{Context: ctx, UserId: obj.ID}) - accountMemberships := make([]*model.AccountMembership, len(entities)) - for i, entity := range entities { - accountMemberships[i] = &model.AccountMembership{ - Account: &model.Account{ - Name: entity.AccountName, - }, - User: &model.User{ - ID: entity.UserId, - }, - Role: string(entity.Role), - } - } - return accountMemberships, err -} - -// AccountMembership is the resolver for the accountMembership field. -func (r *userResolver) AccountMembership(ctx context.Context, obj *model.User, accountName string) (*model.AccountMembership, error) { - membership, err := r.domain.GetAccountMembership(domain.FinanceContext{UserId: obj.ID, Context: ctx}, accountName) - if err != nil { - return nil, err - } - return &model.AccountMembership{ - Account: &model.Account{ - Name: membership.AccountName, - }, - User: &model.User{ - ID: membership.UserId, - }, - Role: string(membership.Role), - }, nil -} - -// Account returns generated.AccountResolver implementation. -func (r *Resolver) Account() generated.AccountResolver { return &accountResolver{r} } - -// AccountMembership returns generated.AccountMembershipResolver implementation. -func (r *Resolver) AccountMembership() generated.AccountMembershipResolver { - return &accountMembershipResolver{r} -} - -// Mutation returns generated.MutationResolver implementation. -func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } - -// Query returns generated.QueryResolver implementation. -func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } - -// User returns generated.UserResolver implementation. -func (r *Resolver) User() generated.UserResolver { return &userResolver{r} } - -type accountResolver struct{ *Resolver } -type accountMembershipResolver struct{ *Resolver } -type mutationResolver struct{ *Resolver } -type queryResolver struct{ *Resolver } -type userResolver struct{ *Resolver } diff --git a/apps/finance_deprecated/internal/app/grpc-client.go b/apps/finance_deprecated/internal/app/grpc-client.go deleted file mode 100644 index ccabe0a65..000000000 --- a/apps/finance_deprecated/internal/app/grpc-client.go +++ /dev/null @@ -1,39 +0,0 @@ -package app - -import ( - "go.uber.org/fx" - "google.golang.org/grpc" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/auth" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/comms" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/console" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/container_registry" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/iam" -) - -type AuthGrpcClientConn *grpc.ClientConn -type ConsoleClientConnection *grpc.ClientConn -type ContainerRegistryClientConnection *grpc.ClientConn -type CommsClientConnection *grpc.ClientConn -type IAMClientConnection *grpc.ClientConn - -var ConsoleClientFx = fx.Provide(func(conn ConsoleClientConnection) console.ConsoleClient { - return console.NewConsoleClient((*grpc.ClientConn)(conn)) -}) - -var ContainerRegistryFx = fx.Provide(func(conn ContainerRegistryClientConnection) container_registry.ContainerRegistryClient { - return container_registry.NewContainerRegistryClient((*grpc.ClientConn)(conn)) -}) - -var IAMClientFx = fx.Provide(func(conn IAMClientConnection) iam.IAMClient { - return iam.NewIAMClient((*grpc.ClientConn)(conn)) -}) - -var CommsClientFx = fx.Provide(func(conn CommsClientConnection) comms.CommsClient { - return comms.NewCommsClient((*grpc.ClientConn)(conn)) -}) - -var AuthClientFx = fx.Provide( - func(conn AuthGrpcClientConn) auth.AuthClient { - return auth.NewAuthClient((*grpc.ClientConn)(conn)) - }, -) diff --git a/apps/finance_deprecated/internal/app/grpc-server.go b/apps/finance_deprecated/internal/app/grpc-server.go deleted file mode 100644 index b5459aa9e..000000000 --- a/apps/finance_deprecated/internal/app/grpc-server.go +++ /dev/null @@ -1,37 +0,0 @@ -package app - -import ( - "context" - - "kloudlite.io/apps/finance_deprecated/internal/domain" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/finance" -) - -type financeServerImpl struct { - finance.UnimplementedFinanceServer - d domain.Domain -} - -func (f financeServerImpl) StartBillable(ctx context.Context, in *finance.StartBillableIn) (*finance.StartBillableOut, error) { - // TODO implement me - panic("implement me") -} - -func (f financeServerImpl) StopBillable(ctx context.Context, in *finance.StopBillableIn) (*finance.StopBillableOut, error) { - // TODO implement me - panic("implement me") -} - -func (f financeServerImpl) GetAttachedCluster(ctx context.Context, in *finance.GetAttachedClusterIn) (*finance.GetAttachedClusterOut, error) { - account, err := f.d.GetAccount(domain.FinanceContext{Context: ctx, UserId: ""}, in.AccountName) - if err != nil { - return nil, err - } - return &finance.GetAttachedClusterOut{ClusterId: string(account.ClusterID)}, nil -} - -func fxFinanceGrpcServer(domain domain.Domain) finance.FinanceServer { - return &financeServerImpl{ - d: domain, - } -} diff --git a/apps/finance_deprecated/internal/app/main.go b/apps/finance_deprecated/internal/app/main.go deleted file mode 100644 index b6da6ec2d..000000000 --- a/apps/finance_deprecated/internal/app/main.go +++ /dev/null @@ -1,138 +0,0 @@ -package app - -import ( - "context" - - "kloudlite.io/constants" - - "github.com/99designs/gqlgen/graphql" - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" - "google.golang.org/grpc" - "kloudlite.io/apps/finance_deprecated/internal/app/graph" - "kloudlite.io/apps/finance_deprecated/internal/app/graph/generated" - "kloudlite.io/apps/finance_deprecated/internal/domain" - "kloudlite.io/apps/finance_deprecated/internal/env" - "kloudlite.io/common" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/finance" - "kloudlite.io/pkg/cache" - httpServer "kloudlite.io/pkg/http-server" - "kloudlite.io/pkg/repos" -) - -// type Env struct { -// CookieDomain string `env:"COOKIE_DOMAIN" required:"true"` -// StripePublicKey string `env:"STRIPE_PUBLIC_KEY" required:"true"` -// StripeSecretKey string `env:"STRIPE_SECRET_KEY" required:"true"` -// } - -// func (e *WorkloadFinanceConsumerEnv) GetSubscriptionTopics() []string { -// return []string{ -// e.Topic, -// } -// } -// -// func (*WorkloadFinanceConsumerEnv) GetConsumerGroupId() string { -// return "console-workload-finance-consumer-2" -// } - -type AuthCacheClient cache.Client - -var Module = fx.Module( - "application", - // config.EnvFx[Env](), - repos.NewFxMongoRepo[*domain.Account]("accounts", "acc", domain.AccountIndexes), - repos.NewFxMongoRepo[*domain.AccountBilling]("account_billings", "accbill", domain.BillableIndexes), - repos.NewFxMongoRepo[*domain.BillingInvoice]("account_invoices", "inv", domain.BillingInvoiceIndexes), - cache.NewFxRepo[*domain.AccountInviteToken](), - IAMClientFx, - ConsoleClientFx, - ContainerRegistryFx, - AuthClientFx, - CommsClientFx, - fx.Invoke( - func(server *fiber.App, d domain.Domain, env *env.Env, cacheClient AuthCacheClient) { - gqlConfig := generated.Config{Resolvers: graph.NewResolver(d)} - - gqlConfig.Directives.IsLoggedIn = func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { - sess := httpServer.GetSession[*common.AuthSession](ctx) - if sess == nil { - return nil, fiber.ErrUnauthorized - } - - cc := domain.FinanceContext{Context: ctx, UserId: sess.UserId} - return next(context.WithValue(ctx, "kl-finance-ctx", cc)) - } - - schema := generated.NewExecutableSchema(gqlConfig) - httpServer.SetupGQLServer( - server, - schema, - httpServer.NewSessionMiddleware[*common.AuthSession]( - cacheClient, - constants.CookieName, - env.CookieDomain, - constants.CacheSessionPrefix, - ), - ) - }, - ), - - // config.EnvFx[WorkloadFinanceConsumerEnv](), - // fx.Provide( - // func(env *Env) *stripe.Client { - // return stripe.NewClient(env.StripeSecretKey) - // }, - // ), - fx.Invoke( - func(server *fiber.App) { - // server.Get( - // "/stripe/get-setup-intent", func(ctx *fiber.Ctx) error { - // intentClientSecret, err := ds.GetSetupIntent() - // if err != nil { - // return err - // } - // return ctx.JSON( - // map[string]any{ - // "client-secret": intentClientSecret, - // }, - // ) - // }, - // ) - - // server.Post( - // "/stripe/create-customer", func(ctx *fiber.Ctx) error { - // var j struct { - // AccountId string `json:"accountId"` - // PaymentMethodId string `json:"paymentMethodId"` - // } - // if err := json.Unmarshal(ctx.Body(), &j); err != nil { - // return err - // } - // customer, err := ds.CreateCustomer(j.AccountId, j.PaymentMethodId) - // if err != nil { - // return errors.NewEf(err, "creating customer") - // } - // //payment, err := ds.MakePayment(*customer, j.PaymentMethodId, 20000) - // //if err != nil { - // // return errors.NewEf(err, "making initial payment") - // //} - // return ctx.JSON( - // map[string]any{ - // "customerId": *customer, - // "init-payment": payment, - // }, - // ) - // }, - // ) - }, - ), - - fx.Provide(fxFinanceGrpcServer), - fx.Invoke( - func(server *grpc.Server, financeServer finance.FinanceServer) { - finance.RegisterFinanceServer(server, financeServer) - }, - ), - domain.Module, -) diff --git a/apps/finance_deprecated/internal/domain/api.go b/apps/finance_deprecated/internal/domain/api.go deleted file mode 100644 index a755992fd..000000000 --- a/apps/finance_deprecated/internal/domain/api.go +++ /dev/null @@ -1,39 +0,0 @@ -package domain - -import ( - "context" - - iamT "kloudlite.io/apps/iam/types" - "kloudlite.io/pkg/repos" -) - -type FinanceContext struct { - context.Context - UserId repos.ID -} - -type Domain interface { - // CRUD - CreateAccount(ctx FinanceContext, name string, displayName string) (*Account, error) - ListAccounts(ctx FinanceContext) ([]*Account, error) - GetAccount(ctx FinanceContext, name string) (*Account, error) - UpdateAccount(ctx FinanceContext, name string, email *string) (*Account, error) - DeleteAccount(ctx FinanceContext, name string) (bool, error) - ReSyncToK8s(ctx FinanceContext, name string) error - - DeactivateAccount(ctx FinanceContext, name string) (bool, error) - ActivateAccount(ctx FinanceContext, name string) (bool, error) - - // invitations - InviteUser(ctx FinanceContext, accountName string, email string, role iamT.Role) (bool, error) - ListInvitations(ctx FinanceContext, accountName string) ([]*Membership, error) - DeleteInvitation(ctx FinanceContext, email string) (bool, error) - - // Memberships - RemoveAccountMember(ctx FinanceContext, accountName string, userId repos.ID) (bool, error) - UpdateAccountMember(ctx FinanceContext, accountName string, userId repos.ID, role string) (bool, error) - - GetUserMemberships(ctx FinanceContext, resourceRef string) ([]*Membership, error) - GetAccountMemberships(ctx FinanceContext) ([]*Membership, error) - GetAccountMembership(ctx FinanceContext, accountName string) (*Membership, error) -} diff --git a/apps/finance_deprecated/internal/domain/commons.go b/apps/finance_deprecated/internal/domain/commons.go deleted file mode 100644 index ab6423658..000000000 --- a/apps/finance_deprecated/internal/domain/commons.go +++ /dev/null @@ -1,36 +0,0 @@ -package domain - -import ( - "errors" - - "go.mongodb.org/mongo-driver/mongo" - "kloudlite.io/common" - httpServer "kloudlite.io/pkg/http-server" -) - -// access -const ( - READ_PROJECT = "read_project" - UPDATE_PROJECT = "update_project" - - READ_ACCOUNT = "read_account" - UPDATE_ACCOUNT = "update_account" -) - -func mongoError(err error, descp string) error { - if err != nil { - if err == mongo.ErrNoDocuments { - return errors.New(descp) - } - return err - } - return nil -} - -func GetUser(ctx FinanceContext) (string, error) { - session := httpServer.GetSession[*common.AuthSession](ctx) - if session == nil { - return "", errors.New("Unauthorized") - } - return string(session.UserId), nil -} diff --git a/apps/finance_deprecated/internal/domain/entities.go b/apps/finance_deprecated/internal/domain/entities.go deleted file mode 100644 index 859737e9c..000000000 --- a/apps/finance_deprecated/internal/domain/entities.go +++ /dev/null @@ -1,139 +0,0 @@ -package domain - -import ( - "time" - - iamT "kloudlite.io/apps/iam/types" - "kloudlite.io/pkg/repos" -) - -type AccountInviteToken struct { - Token string `json:"token"` - UserId repos.ID `json:"user_id"` - Role string `json:"role"` - AccountName string `json:"account_name"` -} - -type Billing struct { - StripeCustomerId string `json:"stripe_customer_id" bson:"stripe_customer_id"` - PaymentMethodId string `json:"payment_method_id" bson:"payment_method_id"` - CardholderName string `json:"cardholder_name" bson:"cardholder_name"` - Address map[string]any `json:"address" bson:"address"` -} - -type Account struct { - repos.BaseEntity `bson:",inline"` - Name string `json:"name" bson:"name"` - DisplayName string `json:"display_name" bson:"display_name"` - ContactEmail string `json:"contact_email" bson:"contact_email"` - Billing Billing `json:"billing" bson:"billing"` - IsActive *bool `json:"is_active,omitempty" bson:"is_active"` - IsDeleted *bool `json:"is_deleted" bson:"is_deleted"` - CreatedAt time.Time `json:"created_at" bson:"created_at"` - ReadableId repos.ID `json:"readable_id" bson:"readable_id"` - ClusterID repos.ID `json:"cluster_id" bson:"cluster_id"` -} - -var AccountIndexes = []repos.IndexField{ - { - Field: []repos.IndexKey{ - {Key: "id", Value: repos.IndexAsc}, - }, - Unique: true, - }, - { - Field: []repos.IndexKey{ - {Key: "name", Value: repos.IndexAsc}, - }, - Unique: true, - }, -} - -type Membership struct { - AccountName string - UserId repos.ID - Role iamT.Role - Accepted bool -} - -type Billable struct { - ResourceType string `json:"resource_type" bson:"resource_type"` - Plan string `json:"plan" bson:"plan"` - IsShared bool `json:"is_shared" bson:"is_shared"` - Quantity float64 `json:"quantity" bson:"quantity"` - Count int `json:"count" bson:"count"` -} - -type AccountBilling struct { - repos.BaseEntity `bson:",inline"` - AccountName string `json:"account_id" bson:"account_id"` - ProjectId repos.ID `json:"project_id" bson:"project_id"` - ResourceId repos.ID `json:"resource_id" bson:"resource_id"` - Billables []Billable `json:"billables" bson:"billables"` - StartTime time.Time `json:"start_time" bson:"start_time"` - EndTime *time.Time `json:"end_time" bson:"end_time"` - BillAmount float64 `json:"bill_amount" bson:"bill_amount"` - Month *string `json:"month" bson:"month"` -} - -var BillableIndexes = []repos.IndexField{ - { - Field: []repos.IndexKey{ - {Key: "id", Value: repos.IndexAsc}, - }, - Unique: true, - }, - { - Field: []repos.IndexKey{ - {Key: "account_name", Value: repos.IndexAsc}, - }, - }, - { - Field: []repos.IndexKey{ - {Key: "resource_id", Value: repos.IndexAsc}, - }, - }, -} - -type ComputePlan struct { - Name string `yaml:"name"` - SharedPrice float64 `yaml:"sharedPrice"` - DedicatedPrice float64 `yaml:"dedicatedPrice"` -} - -type LamdaPlan struct { - Name string `yaml:"name"` - PricePerGBHr float64 `yaml:"pricePerGBHr"` - FreeTire int `yaml:"freeTire"` -} - -type StoragePlan struct { - Name string `yaml:"name"` - PricePerGB float64 `yaml:"pricePerGB"` -} - -type BillingEvent struct { - Key string `json:"key"` - Stage string `json:"stage"` - Billing struct { - Name string `json:"name"` - Items []struct { - Type string `json:"type"` - Count int `json:"count"` - Plan string `json:"plan"` - PlanQ float64 `json:"planQuantity"` - IsShared string `json:"isShared"` - } `json:"items"` - } `json:"billing"` - Metadata struct { - ClusterId string `json:"clusterId"` - AccountName string `json:"accountName"` - ProjectId string `json:"projectId"` - ResourceId string `json:"resourceId"` - GroupVersionKind struct { - Group string `json:"Group"` - Version string `json:"Version"` - Kind string `json:"Kind"` - } `json:"groupVersionKind"` - } `json:"metadata"` -} diff --git a/apps/finance_deprecated/internal/domain/impl.go b/apps/finance_deprecated/internal/domain/impl.go deleted file mode 100644 index 0d8636010..000000000 --- a/apps/finance_deprecated/internal/domain/impl.go +++ /dev/null @@ -1,587 +0,0 @@ -package domain - -import ( - "encoding/json" - "fmt" - "math" - "math/rand" - "reflect" - "regexp" - "strings" - "time" - - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/container_registry" - - "github.com/kloudlite/operator/pkg/kubectl" - "kloudlite.io/constants" - - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/auth" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/comms" - "kloudlite.io/pkg/cache" - "kloudlite.io/pkg/logging" - "kloudlite.io/pkg/stripe" - - crdsv1 "github.com/kloudlite/operator/apis/crds/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - iamT "kloudlite.io/apps/iam/types" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/console" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/iam" - "kloudlite.io/pkg/errors" - fn "kloudlite.io/pkg/functions" - "kloudlite.io/pkg/repos" -) - -func generateId(prefix string) string { - id, e := fn.CleanerNanoid(28) - if e != nil { - panic(fmt.Errorf("could not get cleanerNanoid()")) - } - return fmt.Sprintf("%s-%s", prefix, strings.ToLower(id)) -} - -func toK8sAccountCR(acc *Account) ([]byte, error) { - kAcc := crdsv1.Account{ - ObjectMeta: metav1.ObjectMeta{ - Name: acc.Name, - }, - Spec: crdsv1.AccountSpec{ - HarborProjectName: acc.Name, - HarborUsername: acc.Name, - HarborSecretsNamespace: constants.NamespaceCore, - }, - } - kAcc.EnsureGVK() - return json.Marshal(kAcc) -} - -type domainI struct { - invoiceRepo repos.DbRepo[*BillingInvoice] - authClient auth.AuthClient - iamClient iam.IAMClient - consoleClient console.ConsoleClient - containerRegistryClient container_registry.ContainerRegistryClient - accountRepo repos.DbRepo[*Account] - commsClient comms.CommsClient - billablesRepo repos.DbRepo[*AccountBilling] - accountInviteTokenRepo cache.Repo[*AccountInviteToken] - stripeCli *stripe.Client - k8sYamlClient kubectl.YAMLClient - logger logging.Logger -} - -func (d *domainI) ListAccounts(ctx FinanceContext) ([]*Account, error) { - out, err := d.iamClient.ListMembershipsForUser(ctx, &iam.MembershipsForUserIn{ - UserId: string(ctx.UserId), - ResourceType: string(iamT.ResourceAccount), - }) - // out, err := d.iamClient.ListMembershipsByResource(ctx, &iam.MembershipsByResourceIn{ - // ResourceType: string(iamT.ResourceAccount), - // }) - if err != nil { - return nil, err - } - acc := make([]*Account, len(out.RoleBindings)) - for i := range out.RoleBindings { - acc[i] = &Account{ - Name: strings.Split(out.RoleBindings[i].ResourceRef, "/")[0], - } - } - return acc, nil -} - -// ListInvitations implements Domain -func (d *domainI) ListInvitations(ctx FinanceContext, accountName string) ([]*Membership, error) { - mems, err := d.iamClient.ListResourceMemberships(ctx, &iam.ResourceMembershipsIn{ - ResourceType: string(iamT.ResourceAccount), - ResourceRef: iamT.NewResourceRef(accountName, iamT.ResourceAccount, accountName), - }) - if err != nil { - return nil, err - } - - m := make([]*Membership, len(mems.RoleBindings)) - - for i := range mems.RoleBindings { - //body - m[i] = &Membership{ - AccountName: accountName, - UserId: repos.ID(mems.RoleBindings[i].UserId), - Role: iamT.Role(mems.RoleBindings[i].Role), - Accepted: mems.RoleBindings[i].Accepted, - } - } - - return m, nil -} - -func JSONBytesEqual(a, b []byte) (bool, error) { - var j, j2 interface{} - if err := json.Unmarshal(a, &j); err != nil { - return false, err - } - if err := json.Unmarshal(b, &j2); err != nil { - return false, err - } - return reflect.DeepEqual(j2, j), nil -} - -func (d *domainI) ConfirmAccountMembership(ctx FinanceContext, invitationToken string) (bool, error) { - existingToken, err := d.accountInviteTokenRepo.Get(ctx, invitationToken) - if err != nil { - return false, err - } - - if existingToken == nil { - return false, errors.New("invitation token not found") - } - - err = d.accountInviteTokenRepo.Drop(ctx, invitationToken) - if err != nil { - return false, err - } - _, err = d.iamClient.ConfirmMembership( - ctx, &iam.ConfirmMembershipIn{ - UserId: string(existingToken.UserId), - // ResourceId: string(existingToken.AccountName), - // ResourceRef: iamT.NewResourceRef(clusterName string, kind string, namespace string, name string), - Role: existingToken.Role, - }, - ) - if err != nil { - return false, err - } - return true, nil -} - -func (d *domainI) GetAccountMembership(ctx FinanceContext, accountName string) (*Membership, error) { - membership, err := d.iamClient.GetMembership( - ctx, &iam.GetMembershipIn{ - UserId: string(ctx.UserId), - ResourceType: string(iamT.ResourceAccount), - ResourceRef: iamT.NewResourceRef(accountName, iamT.ResourceAccount, accountName), - }, - ) - if err != nil { - return nil, err - } - return &Membership{ - AccountName: accountName, - UserId: repos.ID(membership.UserId), - Role: iamT.Role(membership.Role), - }, nil -} - -func (d *domainI) GetUserMemberships(ctx FinanceContext, resourceRef string) ([]*Membership, error) { - rbs, err := d.iamClient.ListResourceMemberships( - ctx, &iam.ResourceMembershipsIn{ - ResourceType: string(iamT.ResourceAccount), - ResourceRef: resourceRef, - }, - ) - if err != nil { - return nil, err - } - - memberships := make([]*Membership, 0, len(rbs.RoleBindings)) - for _, rb := range rbs.RoleBindings { - memberships = append( - memberships, &Membership{ - AccountName: "", - UserId: repos.ID(rb.UserId), - Role: iamT.Role(rb.Role), - }, - ) - } - - return memberships, nil -} - -func (d *domainI) GetAccountMemberships(ctx FinanceContext) ([]*Membership, error) { - rbs, err := d.iamClient.ListUserMemberships( - ctx, &iam.UserMembershipsIn{ - UserId: string(ctx.UserId), - ResourceType: string(iamT.ResourceAccount), - }, - ) - if err != nil { - return nil, err - } - - var memberships []*Membership - for _, rb := range rbs.RoleBindings { - memberships = append( - memberships, &Membership{ - AccountName: strings.Split(rb.ResourceRef, "/")[0], - UserId: repos.ID(rb.UserId), - Role: iamT.Role(rb.Role), - Accepted: rb.Accepted, - }, - ) - } - - if err != nil { - return nil, err - } - return memberships, nil -} - -func generateReadable(name string) string { - compile := regexp.MustCompile(`[^\da-zA-Z:,/s]+`) - allString := compile.ReplaceAllString(strings.ToLower(name), "") - m := math.Min(10, float64(len(allString))) - return fmt.Sprintf("%v_%v", allString[:int(m)], rand.Intn(9999)) -} - -func (d *domainI) CreateAccount(ctx FinanceContext, name string, displayName string) (*Account, error) { - uid, err := GetUser(ctx) - if err != nil { - return nil, err - } - if uid != string(ctx.UserId) { - return nil, errors.New("you don't have permission to perform this operation") - } - - id := d.accountRepo.NewId() - - acc, err := d.accountRepo.Create( - ctx, &Account{ - BaseEntity: repos.BaseEntity{Id: id}, - Name: name, - DisplayName: displayName, - IsActive: fn.New(true), - CreatedAt: time.Now(), - ReadableId: repos.ID(generateReadable(name)), - }, - ) - if err != nil { - return nil, err - } - - _, err = d.iamClient.AddMembership( - ctx, &iam.AddMembershipIn{ - UserId: string(ctx.UserId), - ResourceType: string(iamT.ResourceAccount), - ResourceRef: iamT.NewResourceRef(acc.Name, iamT.ResourceAccount, acc.Name), - Role: string(iamT.RoleAccountAdmin), - }, - ) - if err != nil { - return nil, err - } - - b, err := toK8sAccountCR(acc) - if err != nil { - return nil, err - } - - if _, err = d.k8sYamlClient.ApplyYAML(ctx, b); err != nil { - return nil, err - } - - // creating account namespace - ns, err := d.k8sYamlClient.K8sClient.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{ - ObjectMeta: metav1.ObjectMeta{ - Name: "acc-" + acc.Name, - Labels: map[string]string{ - constants.AccountNameKey: acc.Name, - }, - }, - }, metav1.CreateOptions{}) - if err != nil { - return nil, err - } - - d.logger.Infof("created namespace (%s) for account (%s)", ns.Name, acc.Name) - - return acc, err -} - -func (d *domainI) UpdateAccount(ctx FinanceContext, accountName string, contactEmail *string) (*Account, error) { - if err := d.checkAccountAccess(ctx, accountName, iamT.UpdateAccount); err != nil { - return nil, err - } - - acc, err := d.findAccount(ctx, accountName) - if err != nil { - return nil, err - } - - if contactEmail != nil { - acc.ContactEmail = *contactEmail - } - return d.accountRepo.UpdateById(ctx, acc.Id, acc) -} - -func (d *domainI) UpdateAccountBilling(ctx FinanceContext, accountName string, b *Billing) (*Account, error) { - if err := d.checkAccountAccess(ctx, accountName, "update_account"); err != nil { - return nil, err - } - - acc, err := d.findAccount(ctx, accountName) - if err != nil { - return nil, err - } - - acc.Billing = Billing{ - PaymentMethodId: b.PaymentMethodId, - CardholderName: b.CardholderName, - Address: b.Address, - } - - return d.accountRepo.UpdateById(ctx, acc.Id, acc) -} - -// Invitation - -func (d *domainI) DeleteInvitation(ctx FinanceContext, email string) (bool, error) { - panic("not implemented") -} - -func (d *domainI) InviteUser(ctx FinanceContext, accountName string, email string, role iamT.Role) (bool, error) { - switch role { - case "account-member": - if err := d.checkAccountAccess(ctx, accountName, iamT.InviteAccountMember); err != nil { - return false, err - } - case "account-admin": - if err := d.checkAccountAccess(ctx, accountName, iamT.InviteAccountAdmin); err != nil { - return false, err - } - default: - return false, errors.New("role must be one of [account-member, account-admin]") - } - - acc, err := d.findAccount(ctx, accountName) - if err != nil { - return false, err - } - - invitedUser, err := d.authClient.EnsureUserByEmail(ctx, &auth.GetUserByEmailRequest{Email: email}) - if err != nil { - return false, err - } - - _, err = d.iamClient.InviteMembership( - ctx, &iam.AddMembershipIn{ - UserId: string(invitedUser.UserId), - ResourceType: string(iamT.ResourceAccount), - ResourceRef: iamT.NewResourceRef(accountName, iamT.ResourceAccount, accountName), - Role: string(role), - }, - ) - if err != nil { - return false, err - } - - token := generateId("acc-invite") - if err := d.accountInviteTokenRepo.Set( - ctx, token, &AccountInviteToken{ - Token: token, - UserId: ctx.UserId, - Role: string(role), - AccountName: accountName, - }, - ); err != nil { - return false, err - } - - if _, err = d.commsClient.SendAccountMemberInviteEmail( - ctx, &comms.AccountMemberInviteEmailInput{ - AccountName: acc.Name, - InvitationToken: token, - Email: email, - Name: "", - }, - ); err != nil { - return false, err - } - - return true, nil -} - -func (d *domainI) RemoveAccountMember( - ctx FinanceContext, - accountName string, - userId repos.ID, -) (bool, error) { - _, err := d.iamClient.RemoveMembership( - ctx, &iam.RemoveMembershipIn{ - UserId: string(userId), - ResourceRef: iamT.NewResourceRef(accountName, iamT.ResourceAccount, accountName), - }, - ) - if err != nil { - return false, err - } - return true, nil -} - -func (d *domainI) checkAccountAccess(ctx FinanceContext, accountName string, action iamT.Action) error { - co, err := d.iamClient.Can(ctx, &iam.CanIn{ - UserId: string(ctx.UserId), - ResourceRefs: []string{iamT.NewResourceRef(accountName, iamT.ResourceAccount, accountName)}, - Action: string(iamT.GetAccount), - }) - - if err != nil { - return err - } - - if !co.Status { - return fmt.Errorf("unauthorized to access this account") - } - - return nil -} - -func (d *domainI) findAccount(ctx FinanceContext, name string) (*Account, error) { - acc, err := d.accountRepo.FindOne(ctx, repos.Filter{"name": name}) - if err != nil { - return nil, err - } - - if acc == nil { - return nil, fmt.Errorf("account with name=%q not found", name) - } - return acc, nil -} - -func (d *domainI) UpdateAccountMember( - ctx FinanceContext, - accountName string, - userId repos.ID, - role string, -) (bool, error) { - - if err := d.checkAccountAccess(ctx, accountName, iamT.UpdateAccount); err != nil { - return false, err - } - - _, err := d.iamClient.AddMembership( - ctx, &iam.AddMembershipIn{ - UserId: string(userId), - ResourceType: string(constants.ResourceAccount), - Role: role, - }, - ) - if err != nil { - return false, err - } - return true, nil -} - -func (d *domainI) DeactivateAccount(ctx FinanceContext, accountName string) (bool, error) { - if err := d.checkAccountAccess(ctx, accountName, iamT.ActivateAccount); err != nil { - return false, err - } - - acc, err := d.findAccount(ctx, accountName) - if err != nil { - return false, err - } - - acc.IsActive = fn.New(false) - _, err = d.accountRepo.UpdateById(ctx, acc.Id, acc) - if err != nil { - return false, err - } - return true, nil -} - -func (d *domainI) ActivateAccount(ctx FinanceContext, accountName string) (bool, error) { - if err := d.checkAccountAccess(ctx, accountName, iamT.ActivateAccount); err != nil { - return false, err - } - - acc, err := d.findAccount(ctx, accountName) - if err != nil { - return false, err - } - - acc.IsActive = fn.New(true) - _, err = d.accountRepo.UpdateById(ctx, acc.Id, acc) - if err != nil { - return false, err - } - - return true, nil -} - -func (d *domainI) DeleteAccount(ctx FinanceContext, accountName string) (bool, error) { - // TODO: delete harbor project - if err := d.checkAccountAccess(ctx, accountName, iamT.DeleteAccount); err != nil { - return false, err - } - - acc, err := d.findAccount(ctx, accountName) - if err != nil { - return false, err - } - acc.IsDeleted = fn.New(true) - _, err = d.accountRepo.UpdateById(ctx, acc.Id, acc) - if err != nil { - return false, err - } - return true, nil -} - -func (d *domainI) GetAccount(ctx FinanceContext, accountName string) (*Account, error) { - // _, err := GetUser(ctx) - // if err != nil { - // return nil, err - // } - if err := d.checkAccountAccess(ctx, accountName, iamT.GetAccount); err != nil { - return nil, err - } - return d.findAccount(ctx, accountName) -} - -func (d *domainI) ReSyncToK8s(ctx FinanceContext, accountName string) error { - if err := d.checkAccountAccess(ctx, accountName, iamT.GetAccount); err != nil { - return err - } - acc, err := d.findAccount(ctx, accountName) - if err != nil { - return err - } - - b, err := toK8sAccountCR(acc) - if err != nil { - return err - } - - if _, err := d.k8sYamlClient.ApplyYAML(ctx, b); err != nil { - return err - } - - return nil -} - -func fxDomain( - accountRepo repos.DbRepo[*Account], - billablesRepo repos.DbRepo[*AccountBilling], - invoiceRepo repos.DbRepo[*BillingInvoice], - iamCli iam.IAMClient, - consoleClient console.ConsoleClient, - containerRegistryClient container_registry.ContainerRegistryClient, - authClient auth.AuthClient, - commsClient comms.CommsClient, - accountInviteTokenRepo cache.Repo[*AccountInviteToken], - // stripeCli *stripe.Client, - k8sYamlClient kubectl.YAMLClient, - logger logging.Logger, -) Domain { - return &domainI{ - invoiceRepo: invoiceRepo, - authClient: authClient, - iamClient: iamCli, - consoleClient: consoleClient, - containerRegistryClient: containerRegistryClient, - accountRepo: accountRepo, - commsClient: commsClient, - accountInviteTokenRepo: accountInviteTokenRepo, - k8sYamlClient: k8sYamlClient, - logger: logger, - } -} diff --git a/apps/finance_deprecated/internal/domain/invoice-entities.go b/apps/finance_deprecated/internal/domain/invoice-entities.go deleted file mode 100644 index 04888d551..000000000 --- a/apps/finance_deprecated/internal/domain/invoice-entities.go +++ /dev/null @@ -1,59 +0,0 @@ -package domain - -import ( - "time" - - "kloudlite.io/pkg/repos" -) - -type ProjectInvoice struct { - ProjectName string `json:"project_name"` - BillAmount float64 `json:"bill_amount" bson:"bill_amount"` - ResourceBillings map[repos.ID]ResourceInvoice `json:"resource_billings" bson:"resource_billings"` -} - -type ResourceInvoice struct { - ReadableName string `json:"readable_name" bson:"readable_name"` - BillAmount float64 `json:"bill_amount" bson:"bill_amount"` - Consumptions map[string]ConsumptionInvoice `json:"consumptions" bson:"consumptions"` -} - -type ConsumptionInvoice struct { - Plan float64 `json:"plan" bson:"plan"` - Size float64 `json:"size" bson:"size"` - Quantity float64 `json:"quantity" bson:"quantity"` - Duration int `json:"duration" bson:"duration"` - Amount float64 `json:"amount" bson:"amount"` -} - -type BillingInvoice struct { - AccountId repos.ID `json:"account_id" bson:"account_id"` - Amount float64 `json:"amount" bson:"amount"` - CreatedAt time.Time `json:"created_at" bson:"created_at"` - Month string `json:"month" bson:"month"` - Year int `json:"year" bson:"year"` - Projects map[repos.ID]ProjectInvoice `json:"projects" bson:"projects"` - repos.BaseEntity `bson:",inline"` -} - -var BillingInvoiceIndexes = []repos.IndexField{ - { - Field: []repos.IndexKey{ - {Key: "id", Value: repos.IndexAsc}, - }, - Unique: true, - }, - { - Field: []repos.IndexKey{ - {Key: "account_id", Value: repos.IndexAsc}, - {Key: "month", Value: repos.IndexAsc}, - {Key: "year", Value: repos.IndexAsc}, - }, - Unique: true, - }, - { - Field: []repos.IndexKey{ - {Key: "account_id", Value: repos.IndexAsc}, - }, - }, -} diff --git a/apps/finance_deprecated/internal/domain/main.go b/apps/finance_deprecated/internal/domain/main.go deleted file mode 100644 index f41fda77b..000000000 --- a/apps/finance_deprecated/internal/domain/main.go +++ /dev/null @@ -1,16 +0,0 @@ -package domain - -import ( - "go.uber.org/fx" -) - -// type Env struct { -// InventoryPath string `env:"INVENTORY_PATH"` -// CurrClusterConfigNS string `env:"CURR_CLUSTER_CONFIG_NAMESPACE" required:"true"` -// CurrClusterConfigName string `env:"CURR_CLUSTER_CONFIG_NAME" required:"true"` -// CurrClusterConfigClusterIdKey string `env:"CURR_CLUSTER_CONFIG_CLUSTER_ID_KEY" required:"true"` -// } -var Module = fx.Module("domain", - fx.Provide(fxDomain), - // config.EnvFx[Env](), -) diff --git a/apps/finance_deprecated/internal/env/env.go b/apps/finance_deprecated/internal/env/env.go deleted file mode 100644 index f1b628fc1..000000000 --- a/apps/finance_deprecated/internal/env/env.go +++ /dev/null @@ -1,34 +0,0 @@ -package env - -import "github.com/codingconcepts/env" - -type Env struct { - HttpPort uint16 `env:"HTTP_PORT" required:"true"` - HttpCors string `env:"ORIGINS"` - GrpcPort uint16 `env:"GRPC_PORT" required:"true"` - - DBName string `env:"MONGO_DB_NAME" required:"true"` - DBUrl string `env:"MONGO_URI" required:"true"` - - RedisHosts string `env:"REDIS_HOSTS" required:"true"` - RedisUsername string `env:"REDIS_USERNAME" required:"true"` - RedisPassword string `env:"REDIS_PASSWORD" required:"true"` - RedisPrefix string `env:"REDIS_PREFIX" required:"true"` - - AuthRedisHosts string `env:"REDIS_AUTH_HOSTS" required:"true"` - AuthRedisUserName string `env:"REDIS_AUTH_USERNAME" required:"true"` - AuthRedisPassword string `env:"REDIS_AUTH_PASSWORD" required:"true"` - AuthRedisPrefix string `env:"REDIS_AUTH_PREFIX" required:"true"` - - CookieDomain string `env:"COOKIE_DOMAIN" required:"true"` - // StripePublicKey string `env:"STRIPE_PUBLIC_KEY" required:"true"` - // StripeSecretKey string `env:"STRIPE_SECRET_KEY" required:"true"` -} - -func LoadEnvOrDie() (*Env, error) { - var ev Env - if err := env.Set(&ev); err != nil { - return nil, err - } - return &ev, nil -} diff --git a/apps/finance_deprecated/internal/framework/main.go b/apps/finance_deprecated/internal/framework/main.go deleted file mode 100644 index e749cdbb6..000000000 --- a/apps/finance_deprecated/internal/framework/main.go +++ /dev/null @@ -1,118 +0,0 @@ -package framework - -import ( - "go.uber.org/fx" - "kloudlite.io/apps/finance_deprecated/internal/app" - "kloudlite.io/apps/finance_deprecated/internal/env" - "kloudlite.io/pkg/cache" - "kloudlite.io/pkg/config" - rpc "kloudlite.io/pkg/grpc" - httpServer "kloudlite.io/pkg/http-server" - "kloudlite.io/pkg/repos" -) - -type AuthGRPCEnv struct { - AuthService string `env:"AUTH_SERVICE"` -} - -func (e *AuthGRPCEnv) GetGRPCServerURL() string { - return e.AuthService -} - -type CommsGRPCEnv struct { - CommsGrpcService string `env:"COMMS_SERVICE"` -} - -func (e *CommsGRPCEnv) GetGRPCServerURL() string { - return e.CommsGrpcService -} - -type ContainerRegistryGRPCEnv struct { - ContainerRegistryGrpcService string `env:"CONTAINER_REGISTRY_SERVICE"` -} - -func (e *ContainerRegistryGRPCEnv) GetGRPCServerURL() string { - return e.ContainerRegistryGrpcService -} - -type ConsoleGRPCEnv struct { - ConsoleGrpcService string `env:"CONSOLE_SERVICE"` -} - -func (e *ConsoleGRPCEnv) GetGRPCServerURL() string { - return e.ConsoleGrpcService -} - -type IAMGRPCEnv struct { - IAMService string `env:"IAM_SERVICE"` -} - -func (e *IAMGRPCEnv) GetGRPCServerURL() string { - return e.IAMService -} - -type fm struct { - *env.Env -} - -func (f *fm) GetGRPCPort() uint16 { - return f.GrpcPort -} - -func (f *fm) GetMongoConfig() (url string, dbName string) { - return f.DBUrl, f.DBName -} - -func (f *fm) RedisOptions() (hosts, username, password, basePrefix string) { - return f.RedisHosts, f.RedisUsername, f.RedisPassword, f.RedisPrefix -} - -func (f *fm) GetHttpPort() uint16 { - return f.HttpPort -} - -func (f *fm) GetHttpCors() string { - return f.HttpCors -} - -var Module fx.Option = fx.Module( - "framework", - fx.Provide(func(ev *env.Env) *fm { - return &fm{Env: ev} - }), - - // config.EnvFx[Env](), - config.EnvFx[ConsoleGRPCEnv](), - config.EnvFx[CommsGRPCEnv](), - config.EnvFx[IAMGRPCEnv](), - config.EnvFx[AuthGRPCEnv](), - config.EnvFx[ContainerRegistryGRPCEnv](), - rpc.NewGrpcServerFx[*fm](), - rpc.NewGrpcClientFx[*ConsoleGRPCEnv, app.ConsoleClientConnection](), - rpc.NewGrpcClientFx[*ContainerRegistryGRPCEnv, app.ContainerRegistryClientConnection](), - rpc.NewGrpcClientFx[*CommsGRPCEnv, app.CommsClientConnection](), - rpc.NewGrpcClientFx[*IAMGRPCEnv, app.IAMClientConnection](), - rpc.NewGrpcClientFx[*AuthGRPCEnv, app.AuthGrpcClientConn](), - repos.NewMongoClientFx[*fm](), - fx.Provide( - func(env *fm) app.AuthCacheClient { - return cache.NewRedisClient( - env.AuthRedisHosts, - env.AuthRedisUserName, - env.AuthRedisPassword, - env.AuthRedisPrefix, - ) - }, - ), - cache.FxLifeCycle[app.AuthCacheClient](), - - fx.Provide( - func(f *fm) cache.Client { - return cache.NewRedisClient(f.RedisOptions()) - }, - ), - - cache.FxLifeCycle[cache.Client](), - httpServer.NewHttpServerFx[*fm](), - app.Module, -) diff --git a/apps/finance_deprecated/inventory.yaml b/apps/finance_deprecated/inventory.yaml deleted file mode 100644 index 29b91a5ca..000000000 --- a/apps/finance_deprecated/inventory.yaml +++ /dev/null @@ -1,29 +0,0 @@ -- type: Storage - name: BlockStorage - unit: 100GB - pricePerHour: - quantity: 0.0138 - currency: $ - pricePerMonth: - quantity: 10 - currency: $ - -- type: Storage - name: ObjectStorage - provider: do - desc: 100 GB - pricePerHour: - quantity: 0.0138 - currency: $ - pricePerMonth: - quantity: 10 - currency: $ - - -- type: CiHours - name: Tekton Hours - price_per_min: 0.00006$ - -- type: UserAccess - price_per_day: 0.5$ - price_per_month: 15$ diff --git a/apps/finance_deprecated/inventory/block-storage.yaml b/apps/finance_deprecated/inventory/block-storage.yaml deleted file mode 100644 index 29f033517..000000000 --- a/apps/finance_deprecated/inventory/block-storage.yaml +++ /dev/null @@ -1,2 +0,0 @@ -- name: Default - pricePerGB: 0.1 diff --git a/apps/finance_deprecated/inventory/ci.yaml b/apps/finance_deprecated/inventory/ci.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/apps/finance_deprecated/inventory/compute.yaml b/apps/finance_deprecated/inventory/compute.yaml deleted file mode 100644 index 2805fef59..000000000 --- a/apps/finance_deprecated/inventory/compute.yaml +++ /dev/null @@ -1,11 +0,0 @@ -- name: Basic - sharedPrice: 10.2 - dedicatedPrice: -1 - -- name: General - sharedPrice: 12.6 - dedicatedPrice: 28.2 - -- name: HighMemory - sharedPrice: 17.4 - dedicatedPrice: 40 diff --git a/apps/finance_deprecated/inventory/lambda.yaml b/apps/finance_deprecated/inventory/lambda.yaml deleted file mode 100644 index a3cec90c0..000000000 --- a/apps/finance_deprecated/inventory/lambda.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- name: Default - pricePerGBHr: 0.05 - freeTire: 1000 diff --git a/apps/finance_deprecated/main.go b/apps/finance_deprecated/main.go deleted file mode 100644 index 9c0c12c6a..000000000 --- a/apps/finance_deprecated/main.go +++ /dev/null @@ -1,50 +0,0 @@ -package main - -import ( - "flag" - - "github.com/kloudlite/operator/pkg/kubectl" - "go.uber.org/fx" - "k8s.io/client-go/rest" - "kloudlite.io/apps/finance_deprecated/internal/env" - "kloudlite.io/apps/finance_deprecated/internal/framework" - "kloudlite.io/pkg/k8s" - "kloudlite.io/pkg/logging" -) - -func main() { - var isDev bool - flag.BoolVar(&isDev, "dev", false, "--dev") - flag.Parse() - - fx.New( - fx.Provide( - func() (logging.Logger, error) { - return logging.New(&logging.Options{Name: "finance", Dev: isDev}) - }, - ), - - fx.Provide(func() (*env.Env, error) { - return env.LoadEnvOrDie() - }), - - fx.Provide(func() (*rest.Config, error) { - if isDev { - return &rest.Config{Host: "localhost:8080"}, nil - } - return rest.InClusterConfig() - }), - - fx.Provide( - func(restCfg *rest.Config) (*k8s.YAMLClient, error) { - return k8s.NewYAMLClient(restCfg) - }, - ), - - fx.Provide(func(restCfg *rest.Config) (kubectl.YAMLClient, error) { - return kubectl.NewYAMLClient(restCfg) - }), - - framework.Module, - ).Run() -} diff --git a/apps/gateway/Taskfile.yml b/apps/gateway/Taskfile.yml index af565f3ad..4e6d678e3 100644 --- a/apps/gateway/Taskfile.yml +++ b/apps/gateway/Taskfile.yml @@ -18,6 +18,6 @@ tasks: - sh: test -n '{{.Tag}}' msg: 'var Tag must be defined' cmds: - - docker build . -t {{.Image}} - - docker push {{.Image}} + - podman build . -t {{.Image}} + - podman push {{.Image}} diff --git a/apps/infra/Taskfile.yml b/apps/infra/Taskfile.yml index 9bdae0733..2feabebbc 100644 --- a/apps/infra/Taskfile.yml +++ b/apps/infra/Taskfile.yml @@ -16,6 +16,8 @@ tasks: build: env: CGO_ENABLED: 0 + GOOS: linux + GOARCH: amd64 vars: BuiltAt: sh: date | sed 's/\s/_/g' diff --git a/apps/js-eval/.env b/apps/js-eval/.env deleted file mode 100644 index 2fc80e3a4..000000000 --- a/apps/js-eval/.env +++ /dev/null @@ -1 +0,0 @@ -PORT=3000 diff --git a/apps/js-eval/Dockerfile b/apps/js-eval/Dockerfile deleted file mode 100644 index 46c0041c2..000000000 --- a/apps/js-eval/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -# context-dir: -FROM golang:buster AS base -USER 1001 -ENV GOPATH=/tmp/go -ENV GOCACHE=/tmp/go-cache -WORKDIR /tmp/app -# COPY --chown=1001 ./go.mod ./go.sum ./tools.go pkg common grpc-interfaces ./ -COPY --chown=1001 ./ ./ -ARG APP_DIR -WORKDIR $APP_DIR -RUN go build -tags musl -o /tmp/bin/js-eval ./main.go -RUN chmod +x /tmp/bin/js-eval - -FROM golang:buster -RUN mkdir /tmp/app -RUN chown -R 1001 /tmp/app -USER 1001 -WORKDIR /tmp/app -COPY --from=base --chown=1001 /tmp/bin/js-eval ./ -ENTRYPOINT ["./js-eval"] diff --git a/apps/js-eval/Taskfile.yml b/apps/js-eval/Taskfile.yml deleted file mode 100644 index 71ea68dfd..000000000 --- a/apps/js-eval/Taskfile.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: "3" - -dotenv: [".secrets/env"] - -tasks: - run: - env: - PRICING_PATH: ./price/ - sources: - - ./main.go - cmds: - - go version - - nodemon -e go --signal SIGKILL --exec 'go run -tags dynamic main.go --dev || exit 1' - - docker-build: - dir: ../.. - vars: - IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/js-eval:{{.Tag}} - APP_DIR: ./apps/js-eval - cmds: - - docker buildx build -f ./{{.APP_DIR}}/Dockerfile -t {{.IMAGE}} . --platform linux/amd64 --build-arg APP_DIR={{.APP_DIR}} - - docker push {{.IMAGE}} - diff --git a/apps/js-eval/go.json b/apps/js-eval/go.json deleted file mode 100644 index f045d4ad1..000000000 --- a/apps/js-eval/go.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "inputstring":"{\"cpu\": 1, \"size\": 1}", - "functionstring":"function (inputs) {\n const defaultPlan = \"Basic\"\n return {\n annotation: {\n \"kloudlite.io/billing-plan\": defaultPlan,\n \"kloudlite.io/billable-quantity\": inputs.cpu,\n \"kloudlite.io/is-shared\": true,\n },\n inputs: {\n ...inputs,\n cpu: `${inputs.cpu * 1000}m`,\n size: `${inputs.size}Gi`,\n },\n };\n}" -} diff --git a/apps/js-eval/main.go b/apps/js-eval/main.go deleted file mode 100644 index 0c6fbd953..000000000 --- a/apps/js-eval/main.go +++ /dev/null @@ -1,56 +0,0 @@ -package main - -import ( - "context" - "fmt" - "google.golang.org/grpc" - "google.golang.org/protobuf/types/known/anypb" - "kloudlite.io/grpc-interfaces/kloudlite.io/rpc/jseval" - "net" - "os" - v8 "rogchap.com/v8go" - "sync" -) - -type JsServer struct { - jseval.UnimplementedJSEvalServer -} - -func (s *JsServer) Eval(c context.Context, in *jseval.EvalIn) (*jseval.EvalOut, error) { - f := in.FunName + `(` + string(in.Inputs.Value) + `)` - ctx := v8.NewContext() - ctx.RunScript(in.Init, "eval.js") - val, err := ctx.RunScript(f, "eval.js") - if err != nil { - return nil, err - } - marshalJSON, err := val.MarshalJSON() - return &jseval.EvalOut{Output: &anypb.Any{ - TypeUrl: "", - Value: marshalJSON, - }}, nil -} - -func main() { - port := os.Getenv("PORT") - if port == "" { - port = "3000" - } - listen, err := net.Listen("tcp", fmt.Sprintf(":%s", port)) - if err != nil { - panic(err) - } else { - server := grpc.NewServer() - jseval.RegisterJSEvalServer(server, &JsServer{}) - var wg sync.WaitGroup - wg.Add(1) - go func() { - err := server.Serve(listen) - wg.Done() - if err != nil { - panic(err) - } - }() - wg.Wait() - } -} diff --git a/apps/message-office/internal/app/grpc-server.go b/apps/message-office/internal/app/grpc-server.go index ef231c7c2..7c49bd4fc 100644 --- a/apps/message-office/internal/app/grpc-server.go +++ b/apps/message-office/internal/app/grpc-server.go @@ -234,6 +234,11 @@ func (g *grpcServer) SendActions(request *messages.Empty, server messages.Messag g.logger.WithKV("subject", msg.Subject).Infof("dispatched message to agent") }() return server.Send(&messages.Action{Message: msg.Payload}) + }, types.ConsumeOpts{ + OnError: func(err error) error { + g.logger.Errorf(err, "consumer error") + return nil + }, }) return nil diff --git a/apps/messages-distribution-worker/.dockerignore b/apps/messages-distribution-worker/.dockerignore deleted file mode 100644 index b30fec26f..000000000 --- a/apps/messages-distribution-worker/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -** -!main.go -!internal diff --git a/apps/messages-distribution-worker/Containerfile.local b/apps/messages-distribution-worker/Containerfile.local deleted file mode 100644 index d9a236327..000000000 --- a/apps/messages-distribution-worker/Containerfile.local +++ /dev/null @@ -1,13 +0,0 @@ -# FROM gcr.io/distroless/static-debian12:nonroot -FROM alpine:3.16 - -RUN apk add bash -COPY --from=docker.io/vectorized/redpanda:v22.1.6 /usr/bin/rpk /usr/local/bin/rpk -COPY --from=docker.io/vectorized/redpanda:v22.1.6 /opt/redpanda/libexec/rpk /opt/redpanda/libexec/rpk - -WORKDIR /app - -ARG binpath -COPY --from=local-builder ${binpath} ./messages-distribution-worker -USER 65535:65535 -ENTRYPOINT [ "./messages-distribution-worker" ] diff --git a/apps/messages-distribution-worker/Taskfile.yml b/apps/messages-distribution-worker/Taskfile.yml deleted file mode 100644 index c152eccb7..000000000 --- a/apps/messages-distribution-worker/Taskfile.yml +++ /dev/null @@ -1,46 +0,0 @@ -version: 3 - -dotenv: - - .secrets/env - -vars: - ImagePrefix: ghcr.io/kloudlite/platform - -tasks: - run:dev: - cmds: - # - go run . --dev - - fwatcher --exec 'go run . --dev' --ext '.go' - - build: - env: - CGO_ENABLED: 0 - GOOS: linux - GOARCH: amd64 - vars: - BuiltAt: - sh: date | sed 's/\s/_/g' - preconditions: - - sh: '[ -n "{{.Out}}" ]' - msg: var Out must have a value - cmds: - - go build -ldflags="-s -w -X kloudlite.io/common.BuiltAt=\"{{.BuiltAt}}\"" -o {{.Out}} - - upx {{.Out}} - - - local-build: - vars: - APP: workers/messages-distribution-worker - IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}" - preconditions: - - sh: '[[ -n "{{.Tag}}" ]]' - msg: 'var Tag must have a value' - silent: true - cmds: - - |+ - tdir=$(mktemp -d) - task build Out=$tdir/{{.APP}} - - podman buildx build -f ./Containerfile.local -t {{.IMAGE}} . --build-context local-builder=${tdir} --build-arg binpath="{{.APP}}" - podman push {{.IMAGE}} - rm -rf $tdir diff --git a/apps/messages-distribution-worker/internal/app/app.go b/apps/messages-distribution-worker/internal/app/app.go deleted file mode 100644 index 516c518bc..000000000 --- a/apps/messages-distribution-worker/internal/app/app.go +++ /dev/null @@ -1,68 +0,0 @@ -package app - -import ( - "context" - "kloudlite.io/apps/messages-distribution-worker/internal/env" - "kloudlite.io/pkg/kafka" - - "go.uber.org/fx" - "kloudlite.io/pkg/logging" -) - -type KafkaConn kafka.Conn - -type ( - WaitQueueConsumer kafka.Consumer - MessagesDistributor kafka.Producer -) - -var Module = fx.Module( - "app", - - fx.Provide(func(conn KafkaConn, ev *env.Env, logger logging.Logger) (WaitQueueConsumer, error) { - return kafka.NewConsumer(conn, ev.WaitQueueKafkaConsumerGroup, []string{ev.WaitQueueKafkaTopic}, kafka.ConsumerOpts{ - Logger: logger, - }) - }), - fx.Invoke(func(lf fx.Lifecycle, consumer WaitQueueConsumer) { - lf.Append(fx.Hook{ - OnStart: func(ctx context.Context) error { - return consumer.LifecycleOnStart(ctx) - }, - OnStop: func(ctx context.Context) error { - return consumer.LifecycleOnStop(ctx) - }, - }) - }), - - fx.Provide(func(conn KafkaConn, logger logging.Logger) (MessagesDistributor, error) { - return kafka.NewProducer(conn, kafka.ProducerOpts{Logger: logger}) - }), - fx.Invoke(func(lf fx.Lifecycle, producer MessagesDistributor) { - lf.Append(fx.Hook{ - OnStart: func(ctx context.Context) error { - return producer.LifecycleOnStart(ctx) - }, - OnStop: func(ctx context.Context) error { - return producer.LifecycleOnStop(ctx) - }, - }) - }), - - fx.Provide(func(consumer WaitQueueConsumer, producer MessagesDistributor, ev *env.Env, logger logging.Logger) *DistributorClient { - return NewDistributor(consumer, producer, ev, logger) - }), - - fx.Invoke(func(lf fx.Lifecycle, distributor *DistributorClient) { - lf.Append(fx.Hook{ - OnStart: func(context.Context) error { - go distributor.StartDistributing() - return nil - }, - OnStop: func(context.Context) error { - distributor.StopDistributing() - return nil - }, - }) - }), -) diff --git a/apps/messages-distribution-worker/internal/app/distribute-messages.go b/apps/messages-distribution-worker/internal/app/distribute-messages.go deleted file mode 100644 index 52bcd35fb..000000000 --- a/apps/messages-distribution-worker/internal/app/distribute-messages.go +++ /dev/null @@ -1,118 +0,0 @@ -package app - -import ( - "encoding/json" - "fmt" - "io" - "net/http" - "os/exec" - "time" - - "kloudlite.io/apps/messages-distribution-worker/internal/env" - "kloudlite.io/pkg/kafka" - "kloudlite.io/pkg/logging" -) - -type DistributorClient struct { - envVars *env.Env - counter int64 - consumer WaitQueueConsumer - producer MessagesDistributor - logger logging.Logger - - topicsMap map[string]struct{} -} - -func (d *DistributorClient) listTopics() error { - req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://%s/topics", d.envVars.RedpandaHttpAddr), nil) - if err != nil { - return err - } - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return err - } - - b, err := io.ReadAll(resp.Body) - if err != nil { - return err - } - - var topics []string - if err := json.Unmarshal(b, &topics); err != nil { - return err - } - - topicsMap := make(map[string]struct{}, len(topics)) - for _, topic := range topics { - topicsMap[topic] = struct{}{} - } - - d.topicsMap = topicsMap - d.logger.Debugf("listing topics, cleared cache: (total: %d)", len(topics)) - return nil -} - -func (d *DistributorClient) topicExists(topicName string) bool { - if d.topicsMap == nil { - d.logger.Infof("topics map is nil, this should not have happened") - return false - } - - if _, ok := d.topicsMap[topicName]; ok { - return true - } - - return false -} - -func (d *DistributorClient) StartDistributing() { - d.listTopics() - go func() { - for { - time.Sleep(5 * time.Second) - d.listTopics() - } - }() - - d.consumer.StartConsuming(func(ctx kafka.ConsumerContext, topic string, value []byte, metadata kafka.RecordMetadata) error { - topicName := string(metadata.Headers["topic"]) - - if !d.topicExists(topicName) { - ctx.Logger.Infof("topic %s does not exist, creating ...", topicName) - if b, err := exec.Command("rpk", "topic", "create", topicName, "-p", d.envVars.NewTopicPartitionsCount, "-r", d.envVars.NewTopicReplicationCount, "--brokers", d.envVars.KafkaBrokers).CombinedOutput(); err != nil { - ctx.Logger.Errorf(err, string(b)) - // return err - } - d.listTopics() // updating topics cache - } - - ctx.Logger.Debugf("topic %s exists, about to produce message ...", topicName) - if _, err := d.producer.Produce(ctx, topicName, value, kafka.MessageArgs{ - Key: metadata.Key, - Headers: nil, - }); err != nil { - ctx.Logger.Errorf(err, "error while producing message to topic %s", topicName) - return err - } - d.counter += 1 - ctx.Logger.Infof("[%d] mirrored message from (topic: %s) to (topic: %s)", d.counter, topic, topicName) - return nil - }) -} - -func (d *DistributorClient) StopDistributing() { - d.consumer.StopConsuming() -} - -func NewDistributor(consumer WaitQueueConsumer, producer MessagesDistributor, ev *env.Env, logger logging.Logger) *DistributorClient { - return &DistributorClient{ - counter: 0, - envVars: ev, - consumer: consumer, - producer: producer, - logger: logger, - topicsMap: map[string]struct{}{}, - } -} diff --git a/apps/messages-distribution-worker/internal/env/env.go b/apps/messages-distribution-worker/internal/env/env.go deleted file mode 100644 index 7fc93c803..000000000 --- a/apps/messages-distribution-worker/internal/env/env.go +++ /dev/null @@ -1,22 +0,0 @@ -package env - -import "github.com/codingconcepts/env" - -type Env struct { - KafkaBrokers string `env:"KAFKA_BROKERS" required:"true"` - WaitQueueKafkaTopic string `env:"WAIT_QUEUE_KAFKA_TOPIC" required:"true"` - WaitQueueKafkaConsumerGroup string `env:"WAIT_QUEUE_KAFKA_CONSUMER_GROUP" required:"true"` - - RedpandaHttpAddr string `env:"REDPANDA_HTTP_ADDR" required:"true"` - - NewTopicPartitionsCount string `env:"NEW_TOPIC_PARTITIONS_COUNT" required:"true"` - NewTopicReplicationCount string `env:"NEW_TOPIC_REPLICATION_COUNT" required:"true"` -} - -func LoadEnv() (*Env, error) { - var ev Env - if err := env.Set(&ev); err != nil { - return nil, err - } - return &ev, nil -} diff --git a/apps/messages-distribution-worker/internal/framework/framework.go b/apps/messages-distribution-worker/internal/framework/framework.go deleted file mode 100644 index 32e54d00c..000000000 --- a/apps/messages-distribution-worker/internal/framework/framework.go +++ /dev/null @@ -1,16 +0,0 @@ -package framework - -import ( - "go.uber.org/fx" - "kloudlite.io/apps/messages-distribution-worker/internal/app" - "kloudlite.io/apps/messages-distribution-worker/internal/env" - "kloudlite.io/pkg/kafka" -) - -var Module = fx.Module( - "framework", - fx.Provide(func(ev *env.Env) (app.KafkaConn, error) { - return kafka.Connect(ev.KafkaBrokers, kafka.ConnectOpts{}) - }), - app.Module, -) diff --git a/apps/messages-distribution-worker/main.go b/apps/messages-distribution-worker/main.go deleted file mode 100644 index f67dd42f5..000000000 --- a/apps/messages-distribution-worker/main.go +++ /dev/null @@ -1,50 +0,0 @@ -package main - -import ( - "context" - "flag" - "os" - "time" - - "go.uber.org/fx" - "kloudlite.io/apps/messages-distribution-worker/internal/env" - "kloudlite.io/apps/messages-distribution-worker/internal/framework" - "kloudlite.io/common" - "kloudlite.io/pkg/logging" -) - -func main() { - var isDev bool - flag.BoolVar(&isDev, "dev", false, "--dev") - flag.Parse() - - logger, err := logging.New(&logging.Options{Name: "message-distributor", Dev: isDev}) - if err != nil { - panic(err) - } - - app := fx.New( - fx.NopLogger, - - fx.Provide(func() logging.Logger { - return logger - }), - - fx.Provide(func() (*env.Env, error) { - return env.LoadEnv() - }), - - framework.Module, - ) - - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - - if err := app.Start(ctx); err != nil { - logger.Errorf(err, "failed to start app") - os.Exit(1) - } - - common.PrintReadyBanner() - <-app.Done() -} diff --git a/apps/nodectrl/Dockerfile b/apps/nodectrl/Dockerfile deleted file mode 100644 index 4aab26baf..000000000 --- a/apps/nodectrl/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# syntax=docker/dockerfile:1.4 -FROM golang:1.18.3-alpine3.16 AS base -USER 1001 -ENV GOPATH=/tmp/go -ENV GOCACHE=/tmp/go-cache -WORKDIR /tmp/app -COPY --chown=1001 --from=project-root ./go.mod ./go.sum ./tools.go ./ -RUN go mod download -x -COPY --chown=1001 --from=project-root pkg ./pkg -ARG APP -RUN mkdir -p ./apps/$APP -WORKDIR /tmp/app/apps/$APP -COPY --chown=1001 ./ ./ -RUN CGO_ENABLED=0 go build -o /tmp/bin/$APP ./main.go -RUN chmod +x /tmp/bin/$APP - -#FROM gcr.io/distroless/static-debian11 -FROM alpine -RUN adduser -D -h /home/nonroot nonroot -RUN apk add curl git openssh-client -RUN cd /usr/local/bin && curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && chmod +x kubectl -RUN cd /usr/local/bin && curl -o tf.zip https://releases.hashicorp.com/terraform/1.2.9/terraform_1.2.9_linux_amd64.zip && unzip tf.zip && rm tf.zip -# USER nonroot -WORKDIR /tmp/app -COPY --chown=nonroot --from=base /tmp/bin/nodectrl ./nodectrl -RUN mkdir -p ./templates -COPY --chown=nonroot ./terraform ./templates/terraform -CMD ["./nodectrl"] diff --git a/apps/nodectrl/Taskfile.yml b/apps/nodectrl/Taskfile.yml deleted file mode 100644 index e2ac68982..000000000 --- a/apps/nodectrl/Taskfile.yml +++ /dev/null @@ -1,85 +0,0 @@ -version: "3" - -dotenv: - - .secrets/env - -vars: - ImagePrefix: ghcr.io/kloudlite/platform/apis - -tasks: - gen-sec: - sources: - - ./internal/**/*.go - - ./main.go - cmds: - - cd ./.secrets && go run main.go - - run: - sources: - - ./internal/**/*.go - - ./main.go - cmds: - - nodemon -e go --signal SIGKILL --exec 'go run main.go --dev || exit 1' - - docker-build: - vars: - APP: nodectrl - IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}:{{.Tag}} - preconditions: - - sh: '[[ -n "{{.Tag}}" ]]' - msg: 'var Tag must have a value' - - - sh: '[[ "{{.EnvName}}" == "development" ]] || [[ "{{.EnvName}}" == "staging" ]] || [[ "{{.EnvName}}" == "production" ]]' - msg: 'var EnvName must have one of [development, staging, production] as its value' - cmds: - - docker buildx build -f ./Dockerfile -t {{.IMAGE}} . --build-arg APP={{.APP}} --platform linux/amd64 --build-context project-root=../.. - - docker push {{.IMAGE}} - - build: - env: - CGO_ENABLED: 0 - GOOS: linux - GOARCH: amd64 - preconditions: - - sh: '[ -n "{{.Out}}" ]' - msg: var Out must have a value - cmds: - - go build -ldflags="-s -w" -o {{.Out}} - # - upx {{.Out}} - - local-build: - vars: - APP: nodectrl - IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}" - preconditions: - - sh: '[[ -n "{{.Tag}}" ]]' - msg: 'var Tag must have a value' - cmds: - - |+ - lineNumbers=$(cat Dockerfile | grep -i '^FROM' -n | tail +2 | awk -F: '{print $1}') - - startLineNo=$(echo "$lineNumbers" | head -n+1) - finalLineNo=$(echo "$lineNumbers" | tail -1) - - tDir=$(mktemp -d) - - # nDockerfile=$(cat Dockerfile | tail --lines=+$startLineNo | grep -i --invert-match 'from=base') - nDockerfile=$(cat Dockerfile | tail --lines=+$startLineNo) - echo "$nDockerfile" | sed "1 i # syntax=docker/dockerfile:1.4" > $tDir/Dockerfile.base - - lineNo=$(cat $tDir/Dockerfile.base | grep -i '[-][-]from=base' -n | awk -F: '{print $1}') - - echo "line no. is $lineNo" - - cat $tDir/Dockerfile.base | grep -i --invert-match 'from=base' > $tDir/Dockerfile.base2 - - cat $tDir/Dockerfile.base2 | sed "$lineNo i COPY --from=local-builder ./{{.APP}} ./{{.APP}}" > $tDir/Dockerfile - cat $tDir/Dockerfile - - echo "building application ..." - task build Out=$tDir/{{.APP}} - - docker buildx build -f $tDir/Dockerfile -t {{.IMAGE}} . --build-context local-builder=${tDir} - docker push {{.IMAGE}} - rm -rf $tDir - diff --git a/apps/nodectrl/internal/app/main.go b/apps/nodectrl/internal/app/main.go deleted file mode 100644 index d2c2ceab5..000000000 --- a/apps/nodectrl/internal/app/main.go +++ /dev/null @@ -1,92 +0,0 @@ -package app - -import ( - "context" - "fmt" - - "go.uber.org/fx" - - "kloudlite.io/apps/nodectrl/internal/domain" - "kloudlite.io/apps/nodectrl/internal/domain/common" - "kloudlite.io/apps/nodectrl/internal/domain/utils" - "kloudlite.io/apps/nodectrl/internal/env" -) - -var Module = fx.Module("app", - domain.Module, - fx.Invoke( - func(env *env.Env, pc common.ProviderClient, shutdowner fx.Shutdowner, lifecycle fx.Lifecycle) { - lifecycle.Append(fx.Hook{ - OnStart: func(context.Context) error { - runner := func() error { - ctx := context.Background() - if err := utils.SetupGetWorkDir(); err != nil { - return err - } - - err := func() error { - switch env.Action { - case "create-cluster": - fmt.Println("needs to create node") - if err := pc.CreateCluster(ctx); err != nil { - return err - } - case "add-master": - fmt.Println("needs to attach master") - if err := pc.AddMaster(ctx); err != nil { - return err - } - - case "add-worker": - fmt.Println("needs to attach worker") - if err := pc.AddWorker(ctx); err != nil { - return err - } - - case "delete": - fmt.Println("needs to delete node") - if err := pc.DeleteNode(ctx, false); err != nil { - return err - } - - case "force-delete": - fmt.Println("needs to delete node") - if err := pc.DeleteNode(ctx, true); err != nil { - return err - } - - case "": - return fmt.Errorf("ACTION not provided, supported actions {create, delete} ") - default: - return fmt.Errorf("not supported actions '%s' please provide one of supported action like { create, delete }", env.Action) - - } - fmt.Println(utils.ColorText("\n🙃 Successfully Exited 🙃\n", 5)) - shutdowner.Shutdown() - return nil - }() - if err != nil { - fmt.Println(utils.ColorText(fmt.Sprint("\n", "Error: ", err, "\n"), 1)) - return err - } - return nil - } - - go func() { - if err := runner(); err != nil { - panic(err) - } - if err := shutdowner.Shutdown(); err != nil { - panic(err) - } - }() - - return nil - }, - OnStop: func(context.Context) error { - return nil - }, - }) - }, - ), -) diff --git a/apps/nodectrl/internal/domain/aws/add-master.go b/apps/nodectrl/internal/domain/aws/add-master.go deleted file mode 100644 index e1008f698..000000000 --- a/apps/nodectrl/internal/domain/aws/add-master.go +++ /dev/null @@ -1,108 +0,0 @@ -package aws - -import ( - "context" - "fmt" - "os" - "path" - "strings" - "time" - - "gopkg.in/yaml.v2" - - "kloudlite.io/apps/nodectrl/internal/domain/utils" -) - -func (a AwsClient) ensureForMasters() error { - switch a.node.ProvisionMode { - case "spot": - return fmt.Errorf("spot is not supported as a master") - default: - return nil - } -} - -// AddMaster implements common.ProviderClient. -func (a AwsClient) AddMaster(ctx context.Context) error { - if err := a.ensureForMasters(); err != nil { - return err - } - - if err := a.ensurePaths(); err != nil { - return err - } - - // fetch token - sshPath := path.Join("/tmp/ssh", a.accountName) - tokenFileName := fmt.Sprintf("%s-config.yaml", a.accountName) - - if err := a.awsS3Client.IsFileExists(tokenFileName); err != nil { - return err - } - - tokenPath := path.Join(sshPath, "config.yaml") - if err := a.awsS3Client.DownloadFile(tokenPath, tokenFileName); err != nil { - return err - } - - b, err := os.ReadFile(tokenPath) - if err != nil { - return err - } - - kc := TokenAndKubeconfig{} - if err := yaml.Unmarshal(b, &kc); err != nil { - return err - } - - // setup ssh - if err := a.SetupSSH(); err != nil { - return err - } - defer a.saveForSure() - - // create node and wait for ready - if err := a.NewNode(ctx); err != nil { - return err - } - - ip, err := utils.GetOutput(path.Join(utils.Workdir, a.node.NodeName), "node-ip") - if err != nil { - return err - } - - count := 0 - for { - if e := utils.ExecCmd( - fmt.Sprintf("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s root@%s ls", - fmt.Sprintf("%v/access", sshPath), - string(ip), - ), - "checking if node is ready"); e == nil { - break - } - - count++ - if count > 24 { - return fmt.Errorf("node is not ready even after 6 minutes") - } - time.Sleep(time.Second * 5) - } - - // attach to cluster as master - cmd := fmt.Sprintf( - "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s/access root@%s sudo sh /tmp/k3s-install.sh server --server https://%s:6443 --token %s --node-external-ip %s --flannel-backend wireguard-native --flannel-external-ip --disable traefik --node-name=%s", - sshPath, - string(ip), - kc.ServerIp, - strings.TrimSpace(string(kc.Token)), - string(ip), - a.node.NodeName, - ) - - if err := utils.ExecCmd(cmd, "attaching to cluster as a master"); err != nil { - return err - } - - return nil -} diff --git a/apps/nodectrl/internal/domain/aws/add-worker.go b/apps/nodectrl/internal/domain/aws/add-worker.go deleted file mode 100644 index 6c0a5cfd0..000000000 --- a/apps/nodectrl/internal/domain/aws/add-worker.go +++ /dev/null @@ -1,128 +0,0 @@ -package aws - -import ( - "context" - "fmt" - "os" - "path" - "strings" - "time" - - "github.com/kloudlite/operator/pkg/constants" - "gopkg.in/yaml.v2" - - "kloudlite.io/apps/nodectrl/internal/domain/utils" -) - -func (a AwsClient) AddWorker(ctx context.Context) error { - if err := a.ensurePaths(); err != nil { - return err - } - - sshPath := path.Join("/tmp/ssh", a.accountName) - tokenFileName := fmt.Sprintf("%s-config.yaml", a.accountName) - - if err := a.awsS3Client.IsFileExists(tokenFileName); err != nil { - return err - } - - tokenPath := path.Join(sshPath, "config.yaml") - if err := a.awsS3Client.DownloadFile(tokenPath, tokenFileName); err != nil { - return err - } - - b, err := os.ReadFile(tokenPath) - if err != nil { - return err - } - - kc := TokenAndKubeconfig{} - if err := yaml.Unmarshal(b, &kc); err != nil { - return err - } - - // setup ssh - if err := a.SetupSSH(); err != nil { - return err - } - defer a.saveForSure() - - if a.node.ProvisionMode == "spot" { - if err := a.writeNodeConfig(kc); err != nil { - return err - } - } - - // create node and wait for ready - if err := a.NewNode(ctx); err != nil { - return err - } - - if a.node.ProvisionMode == "spot" { - return nil - } - - ip, err := utils.GetOutput(path.Join(utils.Workdir, a.node.NodeName), "node-ip") - if err != nil { - return err - } - - count := 0 - for { - if e := utils.ExecCmd( - fmt.Sprintf("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s root@%s ls", - fmt.Sprintf("%s/access", sshPath), - string(ip), - ), - "checking if node ready"); e == nil { - break - } - - count++ - if count > 24 { - return fmt.Errorf("node is not ready even after 6 minutes") - } - time.Sleep(time.Second * 5) - } - - labels := func() []string { - l := []string{} - for k, v := range map[string]string{ - constants.PublicIpKey: string(ip), - } { - l = append(l, fmt.Sprintf("--node-label %s=%s", k, v)) - } - - for k, v := range a.labels { - l = append(l, fmt.Sprintf("--node-label %s=%s", k, v)) - } - return l - }() - - // attach to cluster as workernode - - cmd := fmt.Sprintf( - "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s/access root@%s sudo sh /tmp/k3s-install.sh agent --server https://%s:6443 --token=%s --node-external-ip %s --node-name %s %s %s", - sshPath, - ip, - kc.ServerIp, - strings.TrimSpace(string(kc.Token)), - ip, - a.node.NodeName, - strings.Join(labels, " "), - func() string { - if a.node.IsGpu { - // TODO: gpu node not considerd yet - // return "--docker" - return "" - } - return "" - }(), - ) - - if err := utils.ExecCmd(cmd, "attaching to cluster as a worker node"); err != nil { - return err - } - - return nil -} diff --git a/apps/nodectrl/internal/domain/aws/create-cluster.go b/apps/nodectrl/internal/domain/aws/create-cluster.go deleted file mode 100644 index d2c97b567..000000000 --- a/apps/nodectrl/internal/domain/aws/create-cluster.go +++ /dev/null @@ -1,272 +0,0 @@ -package aws - -import ( - "context" - "fmt" - "io/fs" - "os" - "path" - "time" - - guuid "github.com/google/uuid" - "gopkg.in/yaml.v2" - "k8s.io/client-go/tools/clientcmd" - - "kloudlite.io/apps/nodectrl/internal/domain/common" - "kloudlite.io/apps/nodectrl/internal/domain/utils" - "kloudlite.io/pkg/k8s" -) - -// CreateCluster implements common.ProviderClient -func (a AwsClient) CreateCluster(ctx context.Context) error { - - if a.OperatorsHelmValues == "" && a.AgentHelmValues == "" { - return fmt.Errorf("'operator helm values' and 'agent helm values' not provided") - } - if a.OperatorsHelmValues == "" { - return fmt.Errorf("operators helm values not provided") - } - if a.AgentHelmValues == "" { - return fmt.Errorf("agent helm values not provided") - } - - /* - create node - check for rediness - install k3s - check for rediness - install maaster - */ - sshPath := path.Join("/tmp/ssh", a.accountName) - - if err := a.ensureForMasters(); err != nil { - return err - } - - if err := a.SetupSSH(); err != nil { - return err - } - defer a.saveForSure() - - if err := a.NewNode(ctx); err != nil { - return err - } - - ip, err := utils.GetOutput(path.Join(utils.Workdir, a.node.NodeName), "node-ip") - if err != nil { - return err - } - - count := 0 - for { - if e := utils.ExecCmd( - fmt.Sprintf("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s root@%s ls", - fmt.Sprintf("%v/access", sshPath), - string(ip), - ), - "checking is node is ready"); e == nil { - break - } - - count++ - if count > 24 { - return fmt.Errorf("node is not ready even after 6 minutes") - } - time.Sleep(time.Second * 5) - } - - masterToken := guuid.New() - - _, err = utils.ExecCmdWithOutput(fmt.Sprintf("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s/access root@%s cat /etc/rancher/k3s/k3s.yaml", sshPath, string(ip)), "checking if k3s already installed.") - if err != nil { - - // install k3s - cmd := fmt.Sprintf( - "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s/access root@%s sudo sh /tmp/k3s-install.sh server --token=%s --node-external-ip %s --flannel-backend wireguard-native --flannel-external-ip --disable traefik --node-name=%s --cluster-init", - sshPath, - string(ip), - masterToken.String(), - string(ip), - a.node.NodeName, - ) - - if err := utils.ExecCmd(cmd, "installing k3s"); err != nil { - return err - } - } else { - // install k3s - cmd := fmt.Sprintf( - "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s/access root@%s systemctl restart k3s.service", - sshPath, - string(ip), - ) - - if err := utils.ExecCmd(cmd, "restarting k3s"); err != nil { - return err - } - } - - // needed to fetch kubeconfig - - configOut, err := utils.ExecCmdWithOutput(fmt.Sprintf("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s/access root@%s cat /etc/rancher/k3s/k3s.yaml", sshPath, string(ip)), "fetching kubeconfig from the cluster") - if err != nil { - return err - } - - var kubeconfig common.KubeConfigType - if err := yaml.Unmarshal(configOut, &kubeconfig); err != nil { - return err - } - for i := range kubeconfig.Clusters { - kubeconfig.Clusters[i].Cluster.Server = fmt.Sprintf("https://%s:6443", string(ip)) - } - - kc, err := yaml.Marshal(kubeconfig) - if err != nil { - return err - } - - tokenOut, err := utils.ExecCmdWithOutput(fmt.Sprintf("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s/access root@%s cat /var/lib/rancher/k3s/server/node-token", sshPath, string(ip)), "fetching node token from the cluster") - if err != nil { - return err - } - - st := TokenAndKubeconfig{ - Token: string(tokenOut), - Kubeconfig: string(kc), - ServerIp: string(ip), - MasterToken: masterToken.String(), - } - b, err := yaml.Marshal(st) - if err != nil { - return err - } - - tokenPath := path.Join(sshPath, "config.yaml") - if err := os.WriteFile(tokenPath, b, os.ModePerm); err != nil { - return err - } - - if err := a.awsS3Client.UploadFile(tokenPath, fmt.Sprintf("%s-config.yaml", a.accountName)); err != nil { - return err - } - - // TODO: have to install agent and the operator as target cluster - - if err := a.installAgent(kc); err != nil { - return err - } - - return nil -} - -func (a AwsClient) installAgent(kubeconfig []byte) error { - - // adding helm repo - if err := utils.ExecCmd("helm repo add kloudlite https://kloudlite.github.io/helm-charts", ""); err != nil { - return err - } - - // updating repo - if err := utils.ExecCmd("helm repo update", ""); err != nil { - return err - } - - // installing operator crds - crdsYamls, err := utils.ExecCmdWithOutput("curl -L0 https://github.com/kloudlite/helm-charts/releases/download/kloudlite-crds-1.0.5-nightly/crds.yml", "") - if err != nil { - return err - } - - config, err := clientcmd.RESTConfigFromKubeConfig(kubeconfig) - if err != nil { - return err - } - - y, err := k8s.NewYAMLClient(config) - if err != nil { - return err - } - - if err = y.ApplyYAML(context.TODO(), crdsYamls); err != nil { - return err - } - - sshPath := path.Join("/tmp/ssh", a.accountName) - // write helm values - if err := os.WriteFile(path.Join(sshPath, "values.yaml"), []byte(a.OperatorsHelmValues), fs.ModePerm); err != nil { - return err - } - - // installing operators - // not values required for now in operator - if err := utils.ExecCmd("helm install kl_v1 kloudlite/kloudlite-operators --namespace kl-core --create-namespace", ""); err != nil { - return err - } - - values := map[string]string{ - "accountName": "", - } - - val := "--set " - - for k, v := range values { - val += fmt.Sprintf("%s=%s", k, v) - } - - if err := os.WriteFile(path.Join(sshPath, "values.yaml"), []byte(a.AgentHelmValues), fs.ModePerm); err != nil { - return err - } - - // installing agent - if err := utils.ExecCmd("helm install kl_v1 kloudlite/kloudlite-agent --namespace kl-core --create-namespace", ""); err != nil { - return err - } - - return nil -} - -func parseValues(a AwsClient, sshPath string) (map[string]any, error) { - returnError := func(errorFor string) (map[string]any, error) { - return nil, fmt.Errorf("required value %q not provided", errorFor) - } - - values := map[string]any{} - - values["access_key"] = a.accessKey - values["secret_key"] = a.accessSecret - - values["keys_path"] = sshPath - - if a.node.Region == nil { - return returnError("region") - } - values["region"] = *a.node.Region - - if a.node.NodeName == "" { - return returnError("nodename") - } - values["node_name"] = a.node.NodeName - - if a.node.ProvisionMode != "spot" { - if a.node.OnDemandSpecs == nil { - return returnError("onDemandSpecs") - } - values["instance_type"] = a.node.OnDemandSpecs.InstanceType - - } - - if a.node.ProvisionMode == "spot" { - values["cpu_min"] = fmt.Sprintf("%d", a.node.SpotSpecs.CpuMin) - values["cpu_max"] = fmt.Sprintf("%d", a.node.SpotSpecs.CpuMax) - - values["mem_min"] = fmt.Sprintf("%d", a.node.SpotSpecs.MemMin) - values["mem_max"] = fmt.Sprintf("%d", a.node.SpotSpecs.MemMax) - } - - if a.node.ImageId != nil { - values["ami"] = *a.node.ImageId - } - - return values, nil -} diff --git a/apps/nodectrl/internal/domain/aws/main.go b/apps/nodectrl/internal/domain/aws/main.go deleted file mode 100644 index 30a49f0d7..000000000 --- a/apps/nodectrl/internal/domain/aws/main.go +++ /dev/null @@ -1,354 +0,0 @@ -package aws - -import ( - "context" - "fmt" - "os" - "path" - "time" - - "gopkg.in/yaml.v2" - - clustersv1 "github.com/kloudlite/operator/apis/clusters/v1" - "kloudlite.io/apps/nodectrl/internal/domain/common" - "kloudlite.io/apps/nodectrl/internal/domain/utils" - awss3 "kloudlite.io/pkg/aws-s3" -) - -type AwsProviderConfig struct { - AccessKey string `yaml:"accessKey"` - AccessSecret string `yaml:"accessSecret"` - AccountName string `yaml:"accountName"` -} -type AWSNodeConfig struct { - clustersv1.AWSNodeConfig `json:",inline"` - NodeName string `json:"nodeName"` -} - -type AwsClient struct { - node AWSNodeConfig - awsS3Client awss3.AwsS3 - - accessKey string - accessSecret string - accountName string - - tfTemplates string - labels map[string]string - taints []string - AgentHelmValues string - OperatorsHelmValues string -} - -type TokenAndKubeconfig struct { - Token string `json:"token"` - Kubeconfig string `json:"kubeconfig"` - ServerIp string `json:"serverIp"` - MasterToken string `json:"masterToken"` -} - -type NodeConfig struct { - ServerIP string `yaml:"serverIp"` - Token string `yaml:"token"` - NodeName string `yaml:"nodeName"` - Taints []string `yaml:"taints"` - Labels map[string]string `yaml:"labels"` -} - -func (a AwsClient) ensurePaths() error { - workDir := path.Join("/tmp", a.node.NodeName) - if _, err := os.Stat(workDir); err != nil { - if err := os.Mkdir(workDir, os.ModePerm); err != nil { - return err - } - } - - const sshDir = "/tmp/ssh" - sshPath := path.Join(sshDir, a.accountName) - if _, err := os.Stat(sshDir); err != nil { - if err := os.Mkdir(sshDir, os.ModePerm); err != nil { - return err - } - } - - if _, err := os.Stat(sshPath); err != nil { - if err := os.Mkdir(sshPath, os.ModePerm); err != nil { - return err - } - } - - return nil -} - -func (a AwsClient) writeNodeConfig(kc TokenAndKubeconfig) error { - if err := a.ensurePaths(); err != nil { - return err - } - - const sshDir = "/tmp/ssh" - sshPath := path.Join(sshDir, a.accountName) - dataPath := path.Join(sshPath, "data.yaml") - - out, err := yaml.Marshal(NodeConfig{ - ServerIP: kc.ServerIp, - Token: kc.Token, - NodeName: a.node.NodeName, - Taints: []string{}, - Labels: map[string]string{}, - }) - if err != nil { - return err - } - - return os.WriteFile(dataPath, out, os.ModePerm) -} - -func (a AwsClient) SetupSSH() error { - const sshDir = "/tmp/ssh" - if err := a.ensurePaths(); err != nil { - return err - } - - destDir := path.Join(sshDir, a.accountName) - fileName := fmt.Sprintf("%s.zip", a.accountName) - if err := a.awsS3Client.IsFileExists(fileName); err != nil { - if _, err := os.Stat(destDir); err == nil { - if err := os.RemoveAll(destDir); err != nil { - return err - } - } - - if e := os.Mkdir(destDir, os.ModePerm); e != nil { - return e - } - - privateKeyBytes, publicKeyBytes, err := utils.GenerateKeys() - if err != nil { - return err - } - - if err := os.WriteFile(fmt.Sprintf("%s/access.pub", destDir), publicKeyBytes, os.ModePerm); err != nil { - return err - } - - if err := os.WriteFile(fmt.Sprintf("%s/access", destDir), privateKeyBytes, 0400); err != nil { - return err - } - - return nil - } - - if err := os.RemoveAll(destDir); err != nil { - return err - } - - err := a.awsS3Client.DownloadFile(path.Join(sshDir, fileName), fileName) - if err != nil { - return err - } - - _, err = utils.Unzip(path.Join(sshDir, fileName), sshDir) - if err != nil { - return err - } - - return nil -} - -func (a AwsClient) saveForSure() error { - count := 0 - for { - if err := a.saveSSH(); err == nil { - return nil - } - if count >= 10 { - return fmt.Errorf("coudn't save the state") - } - - time.Sleep(time.Second * 20) - count++ - } -} - -func (a AwsClient) saveSSH() error { - const sshDir = "/tmp/ssh" - destDir := path.Join(sshDir, a.accountName) - fileName := fmt.Sprintf("%s.zip", a.accountName) - - if err := utils.ZipSource(destDir, path.Join(sshDir, fileName)); err != nil { - return err - } - - if err := a.awsS3Client.UploadFile(path.Join(sshDir, fileName), fileName); err != nil { - return err - } - - return nil -} - -func (a AwsClient) SaveToDbGuranteed(ctx context.Context) { - for { - if err := utils.SaveToDb(a.node.NodeName, a.awsS3Client); err == nil { - break - } else { - fmt.Println(err) - } - time.Sleep(time.Second * 20) - } -} - -func (a AwsClient) getAwsTemplatePath() string { - return path.Join(a.tfTemplates, func() string { - switch a.node.ProvisionMode { - case "spot": - return "aws-spot" - default: - return "aws" - } - }(), - ) -} - -// NewNode implements ProviderClient -func (a AwsClient) NewNode(ctx context.Context) error { - sshPath := path.Join("/tmp/ssh", a.accountName) - values, err := parseValues(a, sshPath) - if err != nil { - return err - } - - if err := utils.MakeTfWorkFileReady(a.node.NodeName, a.getAwsTemplatePath(), a.awsS3Client, true); err != nil { - return err - } - - // upload the final state to the db, upsert if db is already present - defer a.SaveToDbGuranteed(ctx) - - // apply the tf file - if err := func() error { - if err := utils.InitTFdir(path.Join(utils.Workdir, a.node.NodeName)); err != nil { - return err - } - - if err := utils.ApplyTF(path.Join(utils.Workdir, a.node.NodeName), values); err != nil { - return err - } - - return nil - }(); err != nil { - return err - } - - return nil -} - -// DeleteNode implements ProviderClient -func (a AwsClient) DeleteNode(ctx context.Context, force bool) error { - sshPath := path.Join("/tmp/ssh", a.accountName) - - // ensure all required paths created if not exists - if err := a.ensurePaths(); err != nil { - return err - } - - // parse all values from the awsclient to pass as tf variables - values, err := parseValues(a, sshPath) - if err != nil { - return err - } - - // fetch kubeconfig - kc, err := func() ([]byte, error) { - sshPath := path.Join("/tmp/ssh", a.accountName) - - configFileName := fmt.Sprintf("%s-config.yaml", a.accountName) - if err := a.awsS3Client.IsFileExists(configFileName); err != nil { - return nil, err - } - - configPath := path.Join(sshPath, "config.yaml") - if err := a.awsS3Client.DownloadFile(configPath, configFileName); err != nil { - return nil, err - } - - b, err := os.ReadFile(configPath) - if err != nil { - return nil, err - } - - kc := TokenAndKubeconfig{} - if err := yaml.Unmarshal(b, &kc); err != nil { - return nil, err - } - - out, err := yaml.Marshal(kc.Kubeconfig) - return out, err - }() - if err != nil { - return err - } - - // drain and delete node befor destroying - if a.node.ProvisionMode != "spot" { - // drain - if err := utils.Drain(kc, a.node.NodeName); err != nil { - if !force { - fmt.Println(err.Error()) - fmt.Println(utils.ColorText("ignoring error because of force delete", 2)) - - return nil - } - return err - } - time.Sleep(time.Second * 15) - - // delete from cluster - if err := utils.DeleteNode(kc, a.node.NodeName); err != nil { - if !force { - fmt.Println(err.Error()) - fmt.Println(utils.ColorText("ignoring error because of force delete", 2)) - return nil - - } - return err - } - } - - // setup ssh so nodes can be accesed [generate rsa for first time] - if err := a.SetupSSH(); err != nil { - return err - } - - // initiate the tf_template and init the tf_directory to sync the tf_plugin - if err := utils.MakeTfWorkFileReady(a.node.NodeName, a.getAwsTemplatePath(), a.awsS3Client, false); err != nil { - return err - } - - // destroy node [using terraform] - if err := utils.DestroyNode(a.node.NodeName, values); err != nil { - return err - } - - return nil -} - -func NewAwsProviderClient(node AWSNodeConfig, cpd common.CommonProviderData, apc AwsProviderConfig, agentHelmValues, operatorsHelmValues string) (common.ProviderClient, error) { - awsS3Client, err := awss3.NewAwsS3Client(apc.AccessKey, apc.AccessSecret, apc.AccountName) - if err != nil { - fmt.Println(utils.ColorText(err.Error(), 1)) - return nil, err - } - - return AwsClient{ - node: node, - awsS3Client: awsS3Client, - accessKey: apc.AccessKey, - accessSecret: apc.AccessSecret, - accountName: apc.AccountName, - tfTemplates: cpd.TfTemplates, - labels: cpd.Labels, - taints: cpd.Taints, - AgentHelmValues: agentHelmValues, - OperatorsHelmValues: operatorsHelmValues, - }, nil -} diff --git a/apps/nodectrl/internal/domain/azure/azure.go b/apps/nodectrl/internal/domain/azure/azure.go deleted file mode 100644 index 4188b5afd..000000000 --- a/apps/nodectrl/internal/domain/azure/azure.go +++ /dev/null @@ -1 +0,0 @@ -package domain diff --git a/apps/nodectrl/internal/domain/common/common.go b/apps/nodectrl/internal/domain/common/common.go deleted file mode 100644 index a1834895d..000000000 --- a/apps/nodectrl/internal/domain/common/common.go +++ /dev/null @@ -1,36 +0,0 @@ -package common - -type CommonProviderData struct { - TfTemplates string `yaml:"tfTemplates"` - Labels map[string]string `yaml:"labels"` - Taints []string `yaml:"taints"` - SSHPath string `yaml:"sshPath"` -} - -type KubeConfigType struct { - APIVersion string `yaml:"apiVersion"` - Clusters []struct { - Cluster struct { - CertificateAuthorityData string `yaml:"certificate-authority-data"` - Server string `yaml:"server"` - } `yaml:"cluster"` - Name string `yaml:"name"` - } `yaml:"clusters"` - Contexts []struct { - Context struct { - Cluster string `yaml:"cluster"` - User string `yaml:"user"` - } `yaml:"context"` - Name string `yaml:"name"` - } `yaml:"contexts"` - CurrentContext string `yaml:"current-context"` - Kind string `yaml:"kind"` - Preferences struct{} `yaml:"preferences"` - Users []struct { - Name string `yaml:"name"` - User struct { - ClientCertificateData string `yaml:"client-certificate-data"` - ClientKeyData string `yaml:"client-key-data"` - } `yaml:"user"` - } `yaml:"users"` -} diff --git a/apps/nodectrl/internal/domain/common/interface.go b/apps/nodectrl/internal/domain/common/interface.go deleted file mode 100644 index ca989eff0..000000000 --- a/apps/nodectrl/internal/domain/common/interface.go +++ /dev/null @@ -1,14 +0,0 @@ -package common - -import "context" - -type ProviderClient interface { - NewNode(ctx context.Context) error - DeleteNode(ctx context.Context, force bool) error - SaveToDbGuranteed(ctx context.Context) - - CreateCluster(ctx context.Context) error - - AddWorker(ctx context.Context) error - AddMaster(ctx context.Context) error -} diff --git a/apps/nodectrl/internal/domain/do/main.go b/apps/nodectrl/internal/domain/do/main.go deleted file mode 100644 index 6c9c68ff3..000000000 --- a/apps/nodectrl/internal/domain/do/main.go +++ /dev/null @@ -1,25 +0,0 @@ -package do - -type DoProviderConfig struct { - ApiToken string `yaml:"apiToken"` - AccountId string `yaml:"accountId"` -} - -type DoNode struct { - Region string `yaml:"region"` - Size string `yaml:"size"` - NodeId string `yaml:"nodeId"` - ImageId string `yaml:"imageId"` -} - -type doClient struct { - node DoNode - - apiToken string - - SSHPath string - accountId string - tfTemplates string - labels map[string]string - taints []string -} diff --git a/apps/nodectrl/internal/domain/gcp/gcp.go b/apps/nodectrl/internal/domain/gcp/gcp.go deleted file mode 100644 index 4188b5afd..000000000 --- a/apps/nodectrl/internal/domain/gcp/gcp.go +++ /dev/null @@ -1 +0,0 @@ -package domain diff --git a/apps/nodectrl/internal/domain/main.go b/apps/nodectrl/internal/domain/main.go deleted file mode 100644 index a4aada84c..000000000 --- a/apps/nodectrl/internal/domain/main.go +++ /dev/null @@ -1,26 +0,0 @@ -package domain - -import ( - "go.uber.org/fx" - - "kloudlite.io/apps/nodectrl/internal/env" -) - -type domain struct { - env *env.Env -} - -func (d domain) GetEnv() *env.Env { - return d.env -} - -var Module = fx.Module("domain", - fx.Provide( - func(env *env.Env) Domain { - return domain{ - env: env, - } - }, - ), - ProviderClientFx, -) diff --git a/apps/nodectrl/internal/domain/port.go b/apps/nodectrl/internal/domain/port.go deleted file mode 100644 index 76c8e5115..000000000 --- a/apps/nodectrl/internal/domain/port.go +++ /dev/null @@ -1,9 +0,0 @@ -package domain - -import ( - "kloudlite.io/apps/nodectrl/internal/env" -) - -type Domain interface { - GetEnv() *env.Env -} diff --git a/apps/nodectrl/internal/domain/provider-client-fx.go b/apps/nodectrl/internal/domain/provider-client-fx.go deleted file mode 100644 index e041c8483..000000000 --- a/apps/nodectrl/internal/domain/provider-client-fx.go +++ /dev/null @@ -1,62 +0,0 @@ -package domain - -import ( - "os" - - "go.uber.org/fx" - - "kloudlite.io/apps/nodectrl/internal/domain/aws" - "kloudlite.io/apps/nodectrl/internal/domain/common" - "kloudlite.io/apps/nodectrl/internal/domain/do" - "kloudlite.io/apps/nodectrl/internal/domain/utils" - "kloudlite.io/apps/nodectrl/internal/env" -) - -var ProviderClientFx = fx.Module("provider-client-fx", - fx.Provide(func(env *env.Env) (common.ProviderClient, error) { - const sshDir = "/tmp/ssh" - - if _, err := os.Stat(sshDir); err != nil { - if e := os.Mkdir(sshDir, os.ModePerm); e != nil { - return nil, e - } - } - - cpd := common.CommonProviderData{} - if err := utils.Base64YamlDecode(env.ProviderConfig, &cpd); err != nil { - return nil, err - } - - switch env.CloudProvider { - case "aws": - node := aws.AWSNodeConfig{} - if err := utils.Base64YamlDecode(env.NodeConfig, &node); err != nil { - return nil, err - } - - apc := aws.AwsProviderConfig{} - if err := utils.Base64YamlDecode(env.AWSProviderConfig, &apc); err != nil { - return nil, err - } - - return aws.NewAwsProviderClient(node, cpd, apc, env.AgentHelmValues, env.OperatorsHelmValues) - case "azure": - panic("not implemented") - case "do": - node := do.DoNode{} - if err := utils.Base64YamlDecode(env.NodeConfig, &node); err != nil { - return nil, err - } - - dpc := do.DoProviderConfig{} - if err := utils.Base64YamlDecode(env.DoProviderConfig, &dpc); err != nil { - return nil, err - } - - case "gcp": - panic("not implemented") - } - - return nil, nil - }), -) diff --git a/apps/nodectrl/internal/domain/utils/fs.go b/apps/nodectrl/internal/domain/utils/fs.go deleted file mode 100644 index dd05d7370..000000000 --- a/apps/nodectrl/internal/domain/utils/fs.go +++ /dev/null @@ -1,106 +0,0 @@ -package utils - -import ( - "fmt" - "os" - "path" - - "github.com/containerd/continuity/fs" - - awss3 "kloudlite.io/pkg/aws-s3" -) - -func CreateNodeWorkDir(nodeId string) error { - dir := path.Join(Workdir, nodeId) - if _, err := os.Stat(dir); err != nil { - return os.Mkdir(dir, os.ModePerm) - } - - if enableClear { - if err := os.RemoveAll(dir); err != nil { - return err - } - - return os.Mkdir(dir, os.ModePerm) - } else { - return nil - } -} - -func SetupGetWorkDir() error { - if _, err := os.Stat(Workdir); err != nil { - return os.Mkdir(Workdir, os.ModePerm) - } - - return nil -} - -func MakeTfWorkFileReady(nodeId, tfPath string, awss3client awss3.AwsS3, createIfNotExists bool) error { - filename := fmt.Sprintf("%s.zip", nodeId) - // check if file exists in db - err := awss3client.IsFileExists(filename) - if err != nil { - if !createIfNotExists { - return fmt.Errorf("no state file found with the nodeId %s to operate", nodeId) - } - - if err := CreateNodeWorkDir(nodeId); err != nil { - return err - } - - if err := fs.CopyDir(path.Join(Workdir, nodeId), tfPath); err != nil { - return err - } - - return nil - } - - // found file in db, download and extract to the workdir - fmt.Println("-> tfstate found in s3, downloading and extracting it") - source := path.Join(Workdir, filename) - // Download from db - if err := awss3client.DownloadFile(source, filename); err != nil { - return err - } - - if _, err := Unzip(source, path.Join(Workdir)); err != nil { - return err - } - - return nil -} - -func SaveToDb(nodeId string, awss3client awss3.AwsS3) error { - - dir := path.Join(Workdir, nodeId) - filename := fmt.Sprintf("%s.zip", nodeId) - - // compress the workdir and upsert to db - if err := func() error { - if _, err := os.Stat(dir); err != nil { - return err - } - - source := fmt.Sprintf("%s.zip", dir) - - // compress - if err := ZipSource(dir, source); err != nil { - return err - } - - if err := awss3client.UploadFile(source, filename); err != nil { - return err - } - - return nil - }(); err != nil { - fmt.Println(ColorText(fmt.Sprint("Error: ", err), 1)) - return err - } - - return nil -} - -const ( - enableClear bool = false -) diff --git a/apps/nodectrl/internal/domain/utils/k8s.go b/apps/nodectrl/internal/domain/utils/k8s.go deleted file mode 100644 index f9af0d45c..000000000 --- a/apps/nodectrl/internal/domain/utils/k8s.go +++ /dev/null @@ -1,97 +0,0 @@ -package utils - -import ( - "context" - "fmt" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/tools/clientcmd" -) - -func Drain(kubeconfig []byte, nodeName string) error { - - clientset, err := getClientSet(kubeconfig) - if err != nil { - return err - } - - // Cordon the node - if err := cordonNode(clientset, nodeName); err != nil { - return fmt.Errorf("Error cordoning node: %s\n", err.Error()) - } - - // Delete all pods on the node - if err := deletePodsOnNode(clientset, nodeName); err != nil { - return fmt.Errorf("Error deleting pods on node: %s\n", err.Error()) - } - - return nil -} - -func cordonNode(clientset *kubernetes.Clientset, nodeName string) error { - ctx := context.TODO() - node, err := clientset.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{}) - if err != nil { - return err - } - - if node.Spec.Unschedulable { - fmt.Printf("Node '%s' is already cordoned\n", nodeName) - return nil - } - - node.Spec.Unschedulable = true - _, err = clientset.CoreV1().Nodes().Update(ctx, node, v1.UpdateOptions{}) - return err -} - -func deletePodsOnNode(clientset *kubernetes.Clientset, nodeName string) error { - ctx := context.TODO() - pods, err := clientset.CoreV1().Pods("").List(ctx, metav1.ListOptions{ - FieldSelector: "spec.nodeName=" + nodeName, - }) - if err != nil { - return err - } - - for _, pod := range pods.Items { - err = clientset.CoreV1().Pods(pod.Namespace).Delete(ctx, pod.Name, metav1.DeleteOptions{}) - if err != nil { - return err - } - } - return nil -} - -func DeleteNode(kubeconfig []byte, nodeName string) error { - - clientset, err := getClientSet(kubeconfig) - if err != nil { - return err - } - - // Delete the node - err = clientset.CoreV1().Nodes().Delete(context.TODO(), nodeName, v1.DeleteOptions{}) - if err != nil { - return err - } - - return nil -} - -func getClientSet(kubeconfig []byte) (*kubernetes.Clientset, error) { - config, err := clientcmd.RESTConfigFromKubeConfig(kubeconfig) - if err != nil { - return nil, err - } - - clientset, err := kubernetes.NewForConfig(config) - if err != nil { - return nil, err - } - - return clientset, nil -} diff --git a/apps/nodectrl/internal/domain/utils/main.go b/apps/nodectrl/internal/domain/utils/main.go deleted file mode 100644 index 632717471..000000000 --- a/apps/nodectrl/internal/domain/utils/main.go +++ /dev/null @@ -1,73 +0,0 @@ -package utils - -import ( - "encoding/base64" - "encoding/csv" - "fmt" - "os" - "os/exec" - "strings" - - "gopkg.in/yaml.v2" -) - -const ( - Workdir string = "/tmp/tf-workdir" -) - -func Base64YamlDecode(in string, out interface{}) error { - rawDecodedText, err := base64.StdEncoding.DecodeString(in) - if err != nil { - return err - } - - return yaml.Unmarshal(rawDecodedText, out) -} - -func ColorText(text interface{}, code int) string { - return fmt.Sprintf("\033[38;05;%dm%v\033[0m", code, text) -} - -func ExecCmd(cmdString string, logStr string) error { - r := csv.NewReader(strings.NewReader(cmdString)) - r.Comma = ' ' - cmdArr, err := r.Read() - if err != nil { - return err - } - - if logStr != "" { - fmt.Printf("[#] %s\n", logStr) - } else { - fmt.Printf("[#] %s\n", strings.Join(cmdArr, " ")) - } - - cmd := exec.Command(cmdArr[0], cmdArr[1:]...) - cmd.Stderr = os.Stderr - - if err := cmd.Run(); err != nil { - fmt.Printf("err occurred: %v\n", err.Error()) - return err - } - return nil -} - -func ExecCmdWithOutput(cmdString string, logStr string) ([]byte, error) { - r := csv.NewReader(strings.NewReader(cmdString)) - r.Comma = ' ' - cmdArr, err := r.Read() - if err != nil { - return nil, err - } - - if logStr != "" { - fmt.Printf("[#] %s\n", logStr) - } else { - fmt.Printf("[#] %s\n", strings.Join(cmdArr, " ")) - } - - cmd := exec.Command(cmdArr[0], cmdArr[1:]...) - cmd.Stderr = os.Stderr - - return cmd.Output() -} diff --git a/apps/nodectrl/internal/domain/utils/ssh.go b/apps/nodectrl/internal/domain/utils/ssh.go deleted file mode 100644 index a0ee15311..000000000 --- a/apps/nodectrl/internal/domain/utils/ssh.go +++ /dev/null @@ -1,78 +0,0 @@ -package utils - -import ( - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "encoding/pem" - - "golang.org/x/crypto/ssh" -) - -func GenerateKeys() (privateKeyBytes []byte, publicKeyBytes []byte, err error) { - bitSize := 4096 - - privateKey, err := generatePrivateKey(bitSize) - if err != nil { - return nil, nil, err - } - - publicKeyBytes, err = generatePublicKey(&privateKey.PublicKey) - if err != nil { - return nil, nil, err - } - - privateKeyBytes = encodePrivateKeyToPEM(privateKey) - - return privateKeyBytes, publicKeyBytes, nil -} - -// generatePrivateKey creates a RSA Private Key of specified byte size -func generatePrivateKey(bitSize int) (*rsa.PrivateKey, error) { - // Private Key generation - privateKey, err := rsa.GenerateKey(rand.Reader, bitSize) - if err != nil { - return nil, err - } - - // Validate Private Key - err = privateKey.Validate() - if err != nil { - return nil, err - } - - // log.Println("Private Key generated") - return privateKey, nil -} - -// encodePrivateKeyToPEM encodes Private Key from RSA to PEM format -func encodePrivateKeyToPEM(privateKey *rsa.PrivateKey) []byte { - // Get ASN.1 DER format - privDER := x509.MarshalPKCS1PrivateKey(privateKey) - - // pem.Block - privBlock := pem.Block{ - Type: "RSA PRIVATE KEY", - Headers: nil, - Bytes: privDER, - } - - // Private key in PEM format - privatePEM := pem.EncodeToMemory(&privBlock) - - return privatePEM -} - -// generatePublicKey take a rsa.PublicKey and return bytes suitable for writing to .pub file -// returns in the format "ssh-rsa ..." -func generatePublicKey(privatekey *rsa.PublicKey) ([]byte, error) { - publicRsaKey, err := ssh.NewPublicKey(privatekey) - if err != nil { - return nil, err - } - - pubKeyBytes := ssh.MarshalAuthorizedKey(publicRsaKey) - - // log.Println("Public key generated") - return pubKeyBytes, nil -} diff --git a/apps/nodectrl/internal/domain/utils/tf.go b/apps/nodectrl/internal/domain/utils/tf.go deleted file mode 100644 index e9195d5d5..000000000 --- a/apps/nodectrl/internal/domain/utils/tf.go +++ /dev/null @@ -1,116 +0,0 @@ -package utils - -import ( - "encoding/json" - "fmt" - "os" - "os/exec" - "path" - "strings" -) - -func GetOutput(folder, key string) ([]byte, error) { - vars := []string{"output", "-json"} - fmt.Printf("[#] terraform %s\n", strings.Join(vars, " ")) - cmd := exec.Command("terraform", vars...) - cmd.Dir = folder - - // cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - out, err := cmd.Output() - if err != nil { - return nil, err - } - - var resp map[string]struct { - Value string `json:"value"` - } - - err = json.Unmarshal(out, &resp) - if err != nil { - return nil, err - } - - return []byte(resp[key].Value), nil -} - -// destroyNode implements doProviderClient -func DestroyNode(nodeId string, values map[string]any) error { - dest := path.Join(Workdir, nodeId) - vars := []string{"destroy", "-auto-approve"} - - for k, v := range values { - vars = append(vars, fmt.Sprintf("-var=%s=%s", k, v)) - } - - cmd := exec.Command("terraform", vars...) - cmd.Dir = dest - - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - err := cmd.Run() - if err != nil { - fmt.Println(err) - return err - } - return nil -} - -// applyTF implements doProviderClient -func ApplyTF(folder string, values map[string]any) error { - vars := []string{"apply", "-auto-approve"} - - for k, v := range values { - vars = append(vars, fmt.Sprintf("-var=%s=%s", k, v)) - } - - fmt.Printf("[#] terraform %s", strings.Join(vars, " ")) - - cmd := exec.Command("terraform", vars...) - cmd.Dir = folder - - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - cmd.Dir = folder - - return cmd.Run() -} - -func getOutput(folder, key string) ([]byte, error) { - vars := []string{"output", "-json"} - fmt.Printf("[#] terraform %s\n", strings.Join(vars, " ")) - cmd := exec.Command("terraform", vars...) - cmd.Dir = folder - - // cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - out, err := cmd.Output() - if err != nil { - return nil, err - } - - var resp map[string]struct { - Value string `json:"value"` - } - - err = json.Unmarshal(out, &resp) - if err != nil { - return nil, err - } - - return []byte(resp[key].Value), nil -} - -func InitTFdir(dir string) error { - cmd := exec.Command("terraform", "init") - cmd.Dir = dir - - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - return cmd.Run() -} diff --git a/apps/nodectrl/internal/domain/utils/zipper.go b/apps/nodectrl/internal/domain/utils/zipper.go deleted file mode 100644 index b8ae8a200..000000000 --- a/apps/nodectrl/internal/domain/utils/zipper.go +++ /dev/null @@ -1,193 +0,0 @@ -package utils - -import ( - "archive/zip" - "fmt" - "io" - "io/ioutil" - "log" - "os" - "path" - "path/filepath" - "strings" - - "github.com/otiai10/copy" -) - -func ZipSource(source, target string) error { - fmt.Printf("\n[#] compressing %s -> %s\n", source, target) - defer fmt.Printf("\n[#] compressed %s -> %s\n", source, target) - - // 1. Create a ZIP file and zip.Writer - f, err := os.Create(target) - if err != nil { - return err - } - defer f.Close() - - writer := zip.NewWriter(f) - defer writer.Close() - - // 2. Go through all the files of the source - return filepath.Walk(source, func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - - // 3. Create a local file header - header, err := zip.FileInfoHeader(info) - if err != nil { - return err - } - - // set compression - header.Method = zip.Deflate - - // 4. Set relative path of a file as the header name - header.Name, err = filepath.Rel(filepath.Dir(source), path) - if err != nil { - return err - } - if info.IsDir() { - header.Name += "/" - } - - // 5. Create writer for the file header and save content of the file - headerWriter, err := writer.CreateHeader(header) - if err != nil { - return err - } - - if info.IsDir() { - return nil - } - - f, err := os.Open(path) - if err != nil { - return err - } - defer f.Close() - - _, err = io.Copy(headerWriter, f) - return err - }) -} - -func Unzip(src string, destination string) ([]string, error) { - fmt.Printf("\n[#] extracting %s -> %s\n", src, destination) - defer fmt.Printf("\n[#] extracted %s -> %s\n", src, destination) - var filenames []string - r, err := zip.OpenReader(src) - if err != nil { - return filenames, err - } - defer r.Close() - - for _, f := range r.File { - // Store "path/filename" for returning and using later on - fpath := filepath.Join(destination, f.Name) - - // Checking for any invalid file paths - if !strings.HasPrefix(fpath, filepath.Clean(destination)+string(os.PathSeparator)) { - return filenames, fmt.Errorf("%s is an illegal filepath", fpath) - } - - filenames = append(filenames, fpath) - - if f.FileInfo().IsDir() { - - os.MkdirAll(fpath, os.ModePerm) - continue - } - - if err = os.MkdirAll(filepath.Dir(fpath), os.ModePerm); err != nil { - return filenames, err - } - - outFile, err := os.OpenFile(fpath, - os.O_WRONLY|os.O_CREATE|os.O_TRUNC, - f.Mode()) - if err != nil { - return filenames, err - } - - rc, err := f.Open() - if err != nil { - return filenames, err - } - - _, err = io.Copy(outFile, rc) - - outFile.Close() - rc.Close() - - if err != nil { - return filenames, err - } - } - - return filenames, nil -} - -func ExtractZip(src, destination string) error { - fmt.Printf("[#] extracting %s -> %s", src, destination) - defer fmt.Printf("[#] extracted %s -> %s", src, destination) - - if _, err := os.Stat(destination); err == nil { - if er := os.RemoveAll(destination); er != nil { - return err - } - } - - if _, err := os.Stat(src); err != nil { - if e := os.Mkdir(destination, os.ModePerm); e != nil { - return e - } - } else { - - tempDirName, err := ioutil.TempDir("/tmp", "zip_") - if err != nil { - return err - } - defer os.RemoveAll(tempDirName) - - if _, err := Unzip(src, tempDirName); err != nil { - return err - } else { - // fmt.Println(names) - if err := copy.Copy(path.Join(tempDirName, destination), destination); err != nil { - return err - } - } - - } - - return nil -} - -func mutateOperation() error { - file, err := ioutil.TempFile("out", "prefix_") - if err != nil { - return err - } - - return os.WriteFile(file.Name(), []byte("hi"), os.ModePerm) -} - -func TestZip() error { - zipName, dirName := "ram.zip", "out" - if err := ExtractZip(zipName, dirName); err != nil { - return err - } - - if err := mutateOperation(); err != nil { - return err - } - - defer func() { - if err := ZipSource(dirName, zipName); err != nil { - log.Fatal(err) - } - }() - return nil -} diff --git a/apps/nodectrl/internal/env/env.go b/apps/nodectrl/internal/env/env.go deleted file mode 100644 index 60d263368..000000000 --- a/apps/nodectrl/internal/env/env.go +++ /dev/null @@ -1,27 +0,0 @@ -package env - -import "github.com/codingconcepts/env" - -type Env struct { - CloudProvider string `env:"CLOUD_PROVIDER" required:"true"` - Action string `env:"ACTION" required:"true"` - - NodeConfig string `env:"NODE_CONFIG" required:"true"` - ProviderConfig string `env:"PROVIDER_CONFIG" required:"true"` - - AWSProviderConfig string `env:"AWS_PROVIDER_CONFIG"` - GCPProviderConfig string `env:"GCP_PROVIDER_CONFIG"` - AzureProviderConfig string `env:"AZURE_PROVIDER_CONFIG"` - DoProviderConfig string `env:"DO_PROVIDER_CONFIG"` - - AgentHelmValues string `env:"AGENT_HELM_VALUES"` - OperatorsHelmValues string `env:"OPERATORS_HELM_VALUES"` -} - -func LoadEnv() (*Env, error) { - var e Env - if err := env.Set(&e); err != nil { - return nil, err - } - return &e, nil -} diff --git a/apps/nodectrl/internal/framework/main.go b/apps/nodectrl/internal/framework/main.go deleted file mode 100644 index f10b1c1ac..000000000 --- a/apps/nodectrl/internal/framework/main.go +++ /dev/null @@ -1,20 +0,0 @@ -package framework - -import ( - "go.uber.org/fx" - - "kloudlite.io/apps/nodectrl/internal/app" - "kloudlite.io/apps/nodectrl/internal/env" -) - -type fm struct { - env *env.Env -} - -var Module = fx.Module( - "framework", - fx.Provide(func(env *env.Env) *fm { - return &fm{env} - }), - app.Module, -) diff --git a/apps/nodectrl/main.go b/apps/nodectrl/main.go deleted file mode 100644 index 61401013b..000000000 --- a/apps/nodectrl/main.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "flag" - - "go.uber.org/fx" - - "kloudlite.io/apps/nodectrl/internal/env" - "kloudlite.io/apps/nodectrl/internal/framework" - "kloudlite.io/pkg/logging" -) - -func main() { - var isDev bool - flag.BoolVar(&isDev, "dev", false, "--dev") - flag.Parse() - fx.New( - // fn.FxErrorHandler(), - // fx.NopLogger, - fx.Provide(env.LoadEnv), - fx.Provide( - func() (logging.Logger, error) { - return logging.New(&logging.Options{Name: "nodectrl", Dev: isDev}) - }, - ), - framework.Module, - ).Run() -} diff --git a/apps/nodectrl/task.txt b/apps/nodectrl/task.txt deleted file mode 100644 index dcc8876f6..000000000 --- a/apps/nodectrl/task.txt +++ /dev/null @@ -1 +0,0 @@ -1. diff --git a/apps/nodectrl/terraform/aws-spot/init.sh b/apps/nodectrl/terraform/aws-spot/init.sh deleted file mode 100644 index 2c2ad0a7c..000000000 --- a/apps/nodectrl/terraform/aws-spot/init.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -mkdir /k3s -cat >> /k3s/data.yaml << EOF -${nodeConfigYaml} -EOF - -cat >> /root/.ssh/authorized_keys << EOF -${pubkey} -EOF diff --git a/apps/nodectrl/terraform/aws-spot/resource.tf b/apps/nodectrl/terraform/aws-spot/resource.tf deleted file mode 100644 index 7fbf2255b..000000000 --- a/apps/nodectrl/terraform/aws-spot/resource.tf +++ /dev/null @@ -1,180 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 5.3.0" - } - } - required_version = ">= 1.2.0" -} - -provider "aws" { - region = var.region - access_key = var.access_key - secret_key = var.secret_key -} - -output "node-name" { - value = var.node_name -} - - -data "aws_caller_identity" "current" {} - -resource "aws_security_group" "sg" { - - name = var.node_name - - ingress { - from_port = 22 - protocol = "tcp" - to_port = 22 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 2379 - protocol = "tcp" - to_port = 2379 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 2380 - protocol = "tcp" - to_port = 2380 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 6443 - protocol = "tcp" - to_port = 6443 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 8472 - protocol = "udp" - to_port = 8472 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 9100 - protocol = "tcp" - to_port = 9100 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 51820 - protocol = "udp" - to_port = 51820 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 51821 - protocol = "udp" - to_port = 51821 - cidr_blocks = ["0.0.0.0/0"] - } - - - ingress { - from_port = 10250 - protocol = "tcp" - to_port = 10250 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 80 - protocol = "tcp" - to_port = 80 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 443 - protocol = "tcp" - to_port = 443 - cidr_blocks = ["0.0.0.0/0"] - } - - - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } - -} - - -resource "aws_launch_template" "spot-template" { - name = var.node_name - image_id = var.ami - - - user_data = base64encode(templatefile("./init.sh", { - pubkey = file("${var.keys_path}/access.pub") - nodeConfigYaml = file("${var.keys_path}/data.yaml") - })) - - - - block_device_mappings { - device_name = "/dev/sda1" - ebs { - volume_size = 40 - } - } - - network_interfaces { - associate_public_ip_address = true - security_groups = [aws_security_group.sg.id] - } - - tag_specifications { - resource_type = "instance" - tags = { - Name = var.node_name - } - } -} - - - -resource "aws_spot_fleet_request" "byoc-spot-node" { - iam_fleet_role = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-ec2-spot-fleet-tagging-role" - - target_capacity = 1 - - terminate_instances_on_delete = true - on_demand_target_capacity = 0 - allocation_strategy = "priceCapacityOptimized" - on_demand_allocation_strategy = "lowestPrice" - - - launch_template_config { - launch_template_specification { - id = aws_launch_template.spot-template.id - version = "1" - } - overrides { - instance_requirements { - vcpu_count { - min = var.cpu_min - max = var.cpu_max - } - memory_mib { - min = var.mem_min - max = var.mem_max - } - } - } - } -} diff --git a/apps/nodectrl/terraform/aws-spot/variables.tf b/apps/nodectrl/terraform/aws-spot/variables.tf deleted file mode 100644 index b87af2909..000000000 --- a/apps/nodectrl/terraform/aws-spot/variables.tf +++ /dev/null @@ -1,39 +0,0 @@ -variable "access_key" { - default = "" -} - -variable "secret_key" { - default = "" -} - -variable "region" { - default = "" -} - -variable "node_name" { - default = "" -} - -variable "ami" { - default = "" -} - -variable "keys_path" { - default = "" -} - -variable "cpu_min" { - default = "" -} - -variable "cpu_max" { - default = "" -} - -variable "mem_min" { - default = "" -} - -variable "mem_max" { - default = "" -} diff --git a/apps/nodectrl/terraform/aws/init.sh b/apps/nodectrl/terraform/aws/init.sh deleted file mode 100644 index e11d92caf..000000000 --- a/apps/nodectrl/terraform/aws/init.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -cat >>/root/.ssh/authorized_keys </tmp/k3s-install.sh && chomod +x /tmp/k3s-install.sh diff --git a/apps/nodectrl/terraform/aws/resource.tf b/apps/nodectrl/terraform/aws/resource.tf deleted file mode 100644 index 3cd90fa0f..000000000 --- a/apps/nodectrl/terraform/aws/resource.tf +++ /dev/null @@ -1,173 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 4.16" - } - } - - required_version = ">= 1.2.0" -} - -provider "aws" { - region = var.region - access_key = var.access_key - secret_key = var.secret_key -} - - -data "aws_ami" "latest-ubuntu" { - most_recent = true - owners = ["099720109477"] # Canonical - - filter { - name = "name" - values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] - } - - filter { - name = "virtualization-type" - values = ["hvm"] - } -} - - -resource "aws_security_group" "sg" { - # name = "${var.node_name}-sg" - - ingress { - from_port = 22 - protocol = "tcp" - to_port = 22 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 2379 - protocol = "tcp" - to_port = 2379 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 2380 - protocol = "tcp" - to_port = 2380 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 6443 - protocol = "tcp" - to_port = 6443 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 8472 - protocol = "udp" - to_port = 8472 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 9100 - protocol = "tcp" - to_port = 9100 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 51820 - protocol = "udp" - to_port = 51820 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 51821 - protocol = "udp" - to_port = 51821 - cidr_blocks = ["0.0.0.0/0"] - } - - - ingress { - from_port = 10250 - protocol = "tcp" - to_port = 10250 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 80 - protocol = "tcp" - to_port = 80 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 443 - protocol = "tcp" - to_port = 443 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 30000 - protocol = "tcp" - to_port = 32768 - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 30000 - protocol = "udp" - to_port = 32768 - cidr_blocks = ["0.0.0.0/0"] - } - - - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } - - # lifecycle { - # create_before_destroy = true - # } -} - - - -resource "aws_instance" "byoc-node" { - ami = var.ami == "" ? "${data.aws_ami.latest-ubuntu.id}" : var.ami - instance_type = var.instance_type - security_groups = [aws_security_group.sg.name] - - user_data = templatefile("./init.sh", { - pubkey = file("${var.keys_path}/access.pub") - }) - - tags = { - Name = var.node_name - } - - root_block_device { - volume_size = 100 # in GB <<----- I increased this! - volume_type = "standard" - encrypted = false - # kms_key_id = data.aws_kms_key.customer_master_key.arn - } - -} - -output "node-ip" { - value = aws_instance.byoc-node.public_ip -} - -output "node-name" { - value = var.node_name -} diff --git a/apps/nodectrl/terraform/aws/variables.tf b/apps/nodectrl/terraform/aws/variables.tf deleted file mode 100644 index 374970829..000000000 --- a/apps/nodectrl/terraform/aws/variables.tf +++ /dev/null @@ -1,31 +0,0 @@ -variable "access_key" { - default = "" -} - -variable "secret_key" { - default = "" -} - -variable "region" { - default = "" -} - -variable "node_name" { - default = "" -} - -variable "instance_type" { - default = "" -} - -variable "pubkey" { - default = "" -} - -variable "keys_path" { - default = "" -} - -variable "ami" { - default = "" -} diff --git a/apps/nodectrl/terraform/do/init.sh b/apps/nodectrl/terraform/do/init.sh deleted file mode 100644 index e0a23d369..000000000 --- a/apps/nodectrl/terraform/do/init.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -cat > /root/.ssh/authorized_keys << EOF -${pubkey} -EOF - -echo "curl -sfL https://get.k3s.io | sh -s - \$@" > /tmp/k3s-install.sh && chomod +x /tmp/k3s-install.sh diff --git a/apps/nodectrl/terraform/do/resource.tf b/apps/nodectrl/terraform/do/resource.tf deleted file mode 100644 index 792dfdea0..000000000 --- a/apps/nodectrl/terraform/do/resource.tf +++ /dev/null @@ -1,36 +0,0 @@ -terraform { - required_providers { - digitalocean = { - source = "digitalocean/digitalocean" - version = "2.22.3" - } - tls = { - source = "hashicorp/tls" - version = "4.0.3" - } - } -} - -provider "digitalocean" { - token = var.do-token -} - -resource "digitalocean_droplet" "byoc-node" { - image = var.do-image-id - name = var.nodeId - region = var.region - size = var.size - ssh_keys = var.ssh_keys - user_data = templatefile("./init.sh", { - pubkey = file("${var.keys-path}/access.pub") - }) - -} - -output "node-ip" { - value = digitalocean_droplet.byoc-node.ipv4_address -} - -output "node-name" { - value = digitalocean_droplet.byoc-node.name -} diff --git a/apps/nodectrl/terraform/do/variables.tf b/apps/nodectrl/terraform/do/variables.tf deleted file mode 100644 index f78fac56b..000000000 --- a/apps/nodectrl/terraform/do/variables.tf +++ /dev/null @@ -1,40 +0,0 @@ -variable "cluster-id" { - default = "kl" -} - -variable "do-token" { - default = "" -} - -variable "accountId" { - default = "" -} - -variable "nodeId" { - default = "" -} - -variable "size" { - default = "s-4vcpu-8gb" -} - -variable "region" { - default = "blr1" -} - -variable "keys-path" { - # default = "" -} - -# variable "pubkey" { -# # default = "" -# } - -variable "do-image-id" { - default = "ubuntu-22-10-x64" - # default = "105910703" -} - -variable "ssh_keys" { - default = ["25:d8:56:2b:70:15:43:c5:dd:e2:ff:d7:47:1b:68:22"] -} diff --git a/apps/slack-notifier/internal/app/slack.go b/apps/slack-notifier/internal/app/slack.go deleted file mode 100644 index 6a8d52726..000000000 --- a/apps/slack-notifier/internal/app/slack.go +++ /dev/null @@ -1,61 +0,0 @@ -package app - -import ( - "fmt" - - "github.com/gofiber/fiber/v2" - "github.com/slack-go/slack" - "go.uber.org/fx" - "kloudlite.io/apps/slack-notifier/internal/env" -) - -func fxSlackRoutes() fx.Option { - return fx.Invoke( - func(app *fiber.App, slackApi *slack.Client, ev *env.Env) { - app.Get( - "/", func(ctx *fiber.Ctx) error { - channels, _, err := slackApi.GetConversations(&slack.GetConversationsParameters{}) - if err != nil { - return err - } - return ctx.JSON(channels) - }, - ) - - app.Post( - "/chat", func(ctx *fiber.Ctx) error { - message, s, err := slackApi.PostMessage( - ev.SlackChannelID, slack.MsgOptionCompose( - slack.MsgOptionText("hi sample", true), - slack.MsgOptionBlocks( - slack.SectionBlock{ - Type: slack.MBTSection, - Text: &slack.TextBlockObject{ - Type: slack.MarkdownType, - Text: "## Hi\n**are you watching this**, _really_", - Emoji: false, - Verbatim: false, - }, - BlockID: "", - Fields: nil, - Accessory: nil, - }, - ), - ), - ) - if err != nil { - return err - } - fmt.Println(s) - return ctx.JSON(message) - }, - ) - - }, - ) -} - -var Module = fx.Module( - "app", - fxSlackRoutes(), -) diff --git a/apps/slack-notifier/internal/env/env.go b/apps/slack-notifier/internal/env/env.go deleted file mode 100644 index ceaf321e2..000000000 --- a/apps/slack-notifier/internal/env/env.go +++ /dev/null @@ -1,14 +0,0 @@ -package env - -type Env struct { - SlackAppToken string `env:"SLACK_APP_TOKEN" required:"true"` - SlackChannelID string `env:"SLACK_CHANNEL_ID" required:"true"` - HttpPort uint16 `env:"HTTP_PORT" required:"true"` - HttpCors string `env:"HTTP_CORS"` -} - -type DevMode bool - -func (m DevMode) Value() bool { - return bool(m) -} diff --git a/apps/slack-notifier/internal/framework/framework.go b/apps/slack-notifier/internal/framework/framework.go deleted file mode 100644 index 720c1952d..000000000 --- a/apps/slack-notifier/internal/framework/framework.go +++ /dev/null @@ -1,37 +0,0 @@ -package framework - -import ( - "github.com/slack-go/slack" - "go.uber.org/fx" - "kloudlite.io/apps/slack-notifier/internal/app" - "kloudlite.io/apps/slack-notifier/internal/env" - httpServer "kloudlite.io/pkg/http-server" -) - -type fm struct { - ev *env.Env -} - -func (f fm) GetHttpPort() uint16 { - return f.ev.HttpPort -} - -func (f fm) GetHttpCors() string { - return f.ev.HttpCors -} - -var Module = fx.Module( - "framework", - fx.Provide( - func(ev *env.Env) *fm { - return &fm{ev: ev} - }, - ), - fx.Provide( - func(ev *env.Env, devMode env.DevMode) *slack.Client { - return slack.New(ev.SlackAppToken, slack.OptionDebug(devMode.Value())) - }, - ), - httpServer.NewHttpServerFx[*fm](), - app.Module, -) diff --git a/apps/slack-notifier/main.go b/apps/slack-notifier/main.go deleted file mode 100644 index 35b6a7556..000000000 --- a/apps/slack-notifier/main.go +++ /dev/null @@ -1,56 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "time" - - "go.uber.org/fx" - "kloudlite.io/apps/slack-notifier/internal/env" - "kloudlite.io/apps/slack-notifier/internal/framework" - "kloudlite.io/pkg/config" - fn "kloudlite.io/pkg/functions" - "kloudlite.io/pkg/logging" -) - -func main() { - var isDev bool - flag.BoolVar(&isDev, "dev", false, "--dev") - flag.Parse() - - app := fx.New( - fx.NopLogger, - fx.Provide( - func() (logging.Logger, error) { - return logging.New(&logging.Options{Name: "slack-notifier", Dev: isDev}) - }, - ), - config.EnvFx[env.Env](), - fx.Provide( - func() env.DevMode { - return env.DevMode(isDev) - }, - ), - framework.Module, - fn.FxErrorHandler(), - ) - - ctx, cancelFn := context.WithTimeout(context.Background(), 3*time.Second) - defer cancelFn() - if err := app.Start(ctx); err != nil { - panic(err) - } - - fmt.Println( - ` -██████ ███████ █████ ██████ ██ ██ -██ ██ ██ ██ ██ ██ ██ ██ ██ -██████ █████ ███████ ██ ██ ████ -██ ██ ██ ██ ██ ██ ██ ██ -██ ██ ███████ ██ ██ ██████ ██ - `, - ) - - <-app.Done() -} diff --git a/apps/webhooks/Taskfile.yml b/apps/webhooks/Taskfile.yml index ff33b24ec..708068697 100644 --- a/apps/webhooks/Taskfile.yml +++ b/apps/webhooks/Taskfile.yml @@ -16,6 +16,8 @@ tasks: build: env: CGO_ENABLED: 0 + GOOS: linux + GOARCH: amd64 preconditions: - sh: '[ -n "{{.Out}}" ]' msg: var Out must have a value diff --git a/apps/webhooks/internal/app/git-webhook.go b/apps/webhooks/internal/app/git-webhook.go index 08fc1e975..501332467 100644 --- a/apps/webhooks/internal/app/git-webhook.go +++ b/apps/webhooks/internal/app/git-webhook.go @@ -22,7 +22,7 @@ import ( func validateGithubHook(ctx *fiber.Ctx, envVars *env.Env) (bool, error) { headers := ctx.GetReqHeaders() if v, ok := headers["X-Kloudlite-Trigger"]; ok { - if len(v) != len(envVars.KlHookTriggerAuthzSecret) || v != envVars.KlHookTriggerAuthzSecret { + if len(v) != len(envVars.KlHookTriggerAuthzSecret) || v[0] != envVars.KlHookTriggerAuthzSecret { return false, errors.Newf("signature (%s) is invalid, sorry would need to drop the message", v) } return true, nil @@ -33,7 +33,7 @@ func validateGithubHook(ctx *fiber.Ctx, envVars *env.Env) (bool, error) { cHash := "sha256=" + hex.EncodeToString(hash.Sum(nil)) ghSignature := headers["X-Hub-Signature-256"] - if len(cHash) != len(ghSignature) || cHash != ghSignature { + if len(cHash) != len(ghSignature) || cHash != ghSignature[0] { return false, errors.Newf("signature (%s) is invalid, sorry would need to drop the message", ghSignature) } return true, nil @@ -42,14 +42,14 @@ func validateGithubHook(ctx *fiber.Ctx, envVars *env.Env) (bool, error) { func validateGitlabHook(ctx *fiber.Ctx, envVars *env.Env) (bool, error) { headers := ctx.GetReqHeaders() if v, ok := headers["X-Kloudlite-Trigger"]; ok { - if len(v) != len(envVars.KlHookTriggerAuthzSecret) || v != envVars.KlHookTriggerAuthzSecret { + if len(v) != len(envVars.KlHookTriggerAuthzSecret) || v[0] != envVars.KlHookTriggerAuthzSecret { return false, errors.Newf("signature (%s) is invalid, sorry would need to drop the message", v) } return true, nil } gToken := headers["X-Gitlab-Token"] - if len(envVars.GitlabAuthzSecret) != len(gToken) || envVars.GitlabAuthzSecret != gToken { + if len(envVars.GitlabAuthzSecret) != len(gToken) || envVars.GitlabAuthzSecret != gToken[0] { return false, errors.Newf("signature (%s) is invalid, sorry would need to drop the message", gToken) } return true, nil diff --git a/apps/webhooks/internal/framework/main.go b/apps/webhooks/internal/framework/main.go index f2e0eaf97..263a61d06 100644 --- a/apps/webhooks/internal/framework/main.go +++ b/apps/webhooks/internal/framework/main.go @@ -1,10 +1,13 @@ package framework import ( + "context" + "fmt" "go.uber.org/fx" "kloudlite.io/apps/webhooks/internal/app" "kloudlite.io/apps/webhooks/internal/env" httpServer "kloudlite.io/pkg/http-server" + "kloudlite.io/pkg/logging" "kloudlite.io/pkg/redpanda" ) @@ -42,6 +45,20 @@ var Module = fx.Module( ), redpanda.NewClientFx[*fm](), - httpServer.NewHttpServerFx[*fm](), + fx.Provide(func(logger logging.Logger) httpServer.Server { + corsOrigins := "https://studio.apollographql.com" + return httpServer.NewServer(httpServer.ServerArgs{Logger: logger, CorsAllowOrigins: &corsOrigins}) + }), + + fx.Invoke(func(lf fx.Lifecycle, server httpServer.Server, ev *env.Env) { + lf.Append(fx.Hook{ + OnStart: func(context.Context) error { + return server.Listen(fmt.Sprintf(":%d", ev.HttpPort)) + }, + OnStop: func(context.Context) error { + return server.Close() + }, + }) + }), app.Module, ) diff --git a/apps/wg-proxy/Dockerfile b/apps/wg-proxy/Dockerfile deleted file mode 100644 index 5c70cbf61..000000000 --- a/apps/wg-proxy/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -# context-dir: -FROM golang:1.18.3-alpine3.16 AS base -RUN apk add make gcc libc-dev -USER 1001 -ENV GOPATH=/tmp/go -ENV GOCACHE=/tmp/go-cache -WORKDIR /tmp/app -# COPY --chown=1001 ./go.mod ./go.sum ./tools.go pkg common grpc-interfaces ./ -COPY --chown=1001 ./ ./ -ARG APP_DIR -WORKDIR $APP_DIR -RUN go build -tags musl -o /tmp/bin/wg-proxy ./main.go -RUN chmod +x /tmp/bin/wg-proxy - -FROM golang:1.18.3-alpine3.16 -RUN mkdir /tmp/app -RUN chown -R 1001 /tmp/app -USER 1001 -WORKDIR /tmp/app -COPY --from=base --chown=1001 /tmp/bin/wg-proxy ./ -ENTRYPOINT ["./wg-proxy"] diff --git a/apps/wg-proxy/Taskfile.yml b/apps/wg-proxy/Taskfile.yml deleted file mode 100644 index ef51234bc..000000000 --- a/apps/wg-proxy/Taskfile.yml +++ /dev/null @@ -1,86 +0,0 @@ -version: "3" - -dotenv: [".secrets/env"] - -vars: - ImagePrefix: ghcr.io/kloudlite/platform/apis - -tasks: - gql: - dir: ./internal/app - cmds: - - go run -tags dynamic github.com/99designs/gqlgen generate - run: - env: - CONFIG_FILE: ./.local-conf.json - sources: - - ./internal/**/*.go - - ./main.go - cmds: - - go version -# - nodemon -e go --signal SIGKILL --exec 'go run -tags dynamic main.go --dev || exit 1' - - go run -tags dynamic main.go --dev - - docker-build: - vars: - APP: wg-proxy - IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}:{{.Tag}} - preconditions: - - sh: '[[ -n "{{.Tag}}" ]]' - msg: 'var Tag must have a value' - - - sh: '[[ "{{.EnvName}}" == "development" ]] || [[ "{{.EnvName}}" == "staging" ]] || [[ "{{.EnvName}}" == "production" ]]' - msg: 'var EnvName must have one of [development, staging, production] as its value' - cmds: - - docker buildx build -f ./Dockerfile -t {{.IMAGE}} . --build-arg APP={{.APP}} --platform linux/amd64 --build-context project-root=../.. - - docker push {{.IMAGE}} - - build: - env: - CGO_ENABLED: 0 - GOOS: linux - GOARCH: amd64 - preconditions: - - sh: '[ -n "{{.Out}}" ]' - msg: var Out must have a value - cmds: - - go build -ldflags="-s -w" -o {{.Out}} - # - upx {{.Out}} - - local-build: - vars: - APP: wg-proxy - IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}" - preconditions: - - sh: '[[ -n "{{.Tag}}" ]]' - msg: 'var Tag must have a value' - cmds: - - |+ - lineNumbers=$(cat Dockerfile | grep -i '^FROM' -n | tail +2 | awk -F: '{print $1}') - - startLineNo=$(echo "$lineNumbers" | head -n+1) - finalLineNo=$(echo "$lineNumbers" | tail -1) - - tDir=$(mktemp -d) - - # nDockerfile=$(cat Dockerfile | tail --lines=+$startLineNo | grep -i --invert-match 'from=base') - nDockerfile=$(cat Dockerfile | tail --lines=+$startLineNo) - echo "$nDockerfile" | sed "1 i # syntax=docker/dockerfile:1.4" > $tDir/Dockerfile.base - - lineNo=$(cat $tDir/Dockerfile.base | grep -i '[-][-]from=base' -n | awk -F: '{print $1}') - - echo "line no. is $lineNo" - - cat $tDir/Dockerfile.base | grep -i --invert-match 'from=base' > $tDir/Dockerfile.base2 - - cat $tDir/Dockerfile.base2 | sed "$lineNo i COPY --from=local-builder ./{{.APP}} ./{{.APP}}" > $tDir/Dockerfile - cat $tDir/Dockerfile - - echo "building application ..." - task build Out=$tDir/{{.APP}} - - docker buildx build -f $tDir/Dockerfile -t {{.IMAGE}} . --build-context local-builder=${tDir} - docker push {{.IMAGE}} - rm -rf $tDir - - diff --git a/apps/wg-proxy/conf.json b/apps/wg-proxy/conf.json deleted file mode 100644 index e1737a5d4..000000000 --- a/apps/wg-proxy/conf.json +++ /dev/null @@ -1 +0,0 @@ -{"services":[{"id":"localdev","name":"htp://grafana.kl-core.svc.cluster.local:3000/login","servicePort":31491,"proxyPort":5000}]} diff --git a/apps/wg-proxy/main.go b/apps/wg-proxy/main.go deleted file mode 100644 index ab500171a..000000000 --- a/apps/wg-proxy/main.go +++ /dev/null @@ -1,143 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "io" - "net" - "os" - "sync" - - "github.com/gofiber/fiber/v2" -) - -type Service struct { - Name string `json:"name"` - Target int `json:"servicePort"` - Port int `json:"proxyPort"` - Listener net.Listener - Closed bool -} - -var ServiceMap map[string]*Service - -func reloadConfig(configData []byte) error { - var data struct { - Services []Service `json:"services"` - } - if configData == nil { - confFile := os.Getenv("CONFIG_FILE") - configData, err := os.ReadFile(confFile) - if err != nil { - return err - } - err = json.Unmarshal(configData, &data) - } else { - err := json.Unmarshal(configData, &data) - if err != nil { - return err - } - } - oldServiceMap := make(map[string]*Service) - for _, service := range ServiceMap { - oldServiceMap[getKey(service)] = service - } - ServiceMap = make(map[string]*Service) - for key, _ := range data.Services { - s := data.Services[key] - if _, ok := oldServiceMap[getKey(&s)]; !ok { - ServiceMap[getKey(&s)] = &s - } else { - ServiceMap[getKey(&s)] = oldServiceMap[getKey(&s)] - } - } - - for key, _ := range oldServiceMap { - s := oldServiceMap[key] - if _, ok := ServiceMap[key]; !ok { - err := stopService(s) - if err != nil { - return err - } - } - } - for key, _ := range ServiceMap { - s := ServiceMap[key] - if _, ok := oldServiceMap[getKey(s)]; !ok { - err := startService(s) - if err != nil { - return err - } - } - } - return nil -} -func getKey(service *Service) string { - return fmt.Sprint(service.Name, ":", service.Port, ":", service.Target) -} -func stopService(service *Service) error { - if service.Listener != nil { - err := service.Listener.Close() - service.Closed = true - fmt.Println("- stopping :: ", getKey(service)) - return err - } - return nil -} -func startService(service *Service) error { - listener, err := net.Listen("tcp", fmt.Sprintf(":%d", service.Port)) - if err != nil { - return err - } - service.Listener = listener - service.Closed = false - go runLoop(service) - return nil -} -func runLoop(service *Service) error { - fmt.Println("+ starting :: ", getKey(service)) - for { - if service.Closed || service.Listener == nil { - return nil - } - conn, err := service.Listener.Accept() - if err != nil { - return err - } - go func() { - upconn, err := net.Dial("tcp", fmt.Sprint(service.Name, ":", service.Target)) - if err != nil { - conn.Close() - return - } - defer upconn.Close() - defer conn.Close() - go io.Copy(upconn, conn) - io.Copy(conn, upconn) - }() - } -} -func startApi() { - app := fiber.New(fiber.Config{ - DisableStartupMessage: true, - }) - app.Post("/post", func(c *fiber.Ctx) error { - err := reloadConfig(c.Body()) - if err != nil { - return err - } - c.Send([]byte("done")) - return nil - }) - app.Listen(":2999") -} -func main() { - go startApi() - err := reloadConfig(nil) - if err != nil { - panic(err) - } - var wg sync.WaitGroup - wg.Add(1) - wg.Wait() -} diff --git a/apps/wg-proxy/sample.json b/apps/wg-proxy/sample.json deleted file mode 100644 index 241c3eb36..000000000 --- a/apps/wg-proxy/sample.json +++ /dev/null @@ -1 +0,0 @@ -{"services":[{"id":"id","name":"service","servicePort":3000,"proxyPort":300}]} diff --git a/apps/wg-restart/.dockerignore b/apps/wg-restart/.dockerignore deleted file mode 100644 index 94143827e..000000000 --- a/apps/wg-restart/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -Dockerfile diff --git a/apps/wg-restart/Dockerfile b/apps/wg-restart/Dockerfile deleted file mode 100644 index afd4c6cd6..000000000 --- a/apps/wg-restart/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -# context-dir: -FROM golang:1.18.3-alpine3.16 AS base -RUN apk add make gcc libc-dev -USER root -ENV GOPATH=/tmp/go -ENV GOCACHE=/tmp/go-cache -WORKDIR /tmp/app -# COPY --chown=1001 ./go.mod ./go.sum ./tools.go pkg common grpc-interfaces ./ -COPY --chown=1001 ./ ./ -ARG APP_DIR -WORKDIR $APP_DIR -ENV CGO_ENABLED=0 -RUN go build -tags musl -o /tmp/bin/wg-restart ./main.go -RUN chmod +x /tmp/bin/wg-restart - -FROM ghcr.io/linuxserver/wireguard:latest -WORKDIR /tmp/bin -COPY --from=base /tmp/bin/wg-restart ./ -ENTRYPOINT ["./wg-restart"] diff --git a/apps/wg-restart/Dockerfile.ci b/apps/wg-restart/Dockerfile.ci deleted file mode 100644 index 640d08fe1..000000000 --- a/apps/wg-restart/Dockerfile.ci +++ /dev/null @@ -1,19 +0,0 @@ -# # context-dir: -# FROM golang:1.18.3-alpine3.16 AS base -# RUN apk add make gcc libc-dev -# USER root -# ENV GOPATH=/tmp/go -# ENV GOCACHE=/tmp/go-cache -# WORKDIR /tmp/app -# # COPY --chown=1001 ./go.mod ./go.sum ./tools.go pkg common grpc-interfaces ./ -# COPY --chown=1001 ./ ./ -# ARG APP_DIR -# WORKDIR $APP_DIR -# ENV CGO_ENABLED=0 -# RUN go build -o /tmp/bin/wg-restart ./main.go -# RUN chmod +x /tmp/bin/wg-restart - -FROM ghcr.io/linuxserver/wireguard:latest -WORKDIR /tmp/bin -COPY --from=builder --chown=1001 ./wg-restart ./wg-restart -ENTRYPOINT ["./wg-restart"] diff --git a/apps/wg-restart/Taskfile.yml b/apps/wg-restart/Taskfile.yml deleted file mode 100644 index e4dfde4c6..000000000 --- a/apps/wg-restart/Taskfile.yml +++ /dev/null @@ -1,65 +0,0 @@ -version: "3" - -dotenv: [".secrets/env"] - -vars: - ImagePrefix: ghcr.io/kloudlite/platform/apis - -tasks: - - local-build: - vars: - APP: wg-restart - IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}" - preconditions: - - sh: '[[ -n "{{.Tag}}" ]]' - msg: 'var Tag must have a value' - silent: true - cmds: - - |+ - tdir=$(mktemp -d) - task build Out=$tdir/{{.APP}} - - docker buildx build -f ./Dockerfile.ci -t {{.IMAGE}} . --build-context builder=${tdir} --build-arg APP="{{.APP}}" - docker push {{.IMAGE}} - rm -rf $tdir - - - gql: - dir: ./internal/app - cmds: - - go run -tags dynamic github.com/99designs/gqlgen generate - run: - env: - CONFIG_FILE: ./conf.json - sources: - - ./internal/**/*.go - - ./main.go - cmds: - - go version -# - nodemon -e go --signal SIGKILL --exec 'go run -tags dynamic main.go --dev || exit 1' - - go run -tags dynamic main.go --dev - - docker-build: - vars: - APP: wg-restart - IMAGE: ghcr.io/kloudlite/platform/apis/{{.APP}}:{{.Tag}} - preconditions: - - sh: '[[ -n "{{.Tag}}" ]]' - msg: 'var Tag must have a value' - - cmds: - - docker buildx build -f ./Dockerfile -t {{.IMAGE}} . --build-arg APP={{.APP}} --platform linux/amd64 --build-context project-root=../.. - - docker push {{.IMAGE}} - - build: - env: - CGO_ENABLED: 0 - GOOS: linux - GOARCH: amd64 - preconditions: - - sh: '[ -n "{{.Out}}" ]' - msg: var Out must have a value - cmds: - - go build -ldflags="-s -w" -o {{.Out}} - # - upx {{.Out}} diff --git a/apps/wg-restart/main.go b/apps/wg-restart/main.go deleted file mode 100644 index 79c7707ae..000000000 --- a/apps/wg-restart/main.go +++ /dev/null @@ -1,118 +0,0 @@ -package main - -import ( - "fmt" - "io/fs" - "net" - "os" - "os/exec" - "strings" - "sync" - - "github.com/gofiber/fiber/v2" -) - -type Service struct { - Name string `json:"name"` - Target int `json:"servicePort"` - Port int `json:"proxyPort"` - Listener net.Listener - Closed bool -} - -const ( - WgFileName = "wg0" - WgFileNameSecondary = "sample" - WgFile = "/etc/wireguard/" + WgFileName + ".conf" - WgFileSecondary = "/etc/wireguard/" + WgFileNameSecondary + ".conf" -) - -func reloadConfig(conf []byte) error { - isFirstTime := conf == nil - if conf == nil { - var err error - conf, err = os.ReadFile(WgFile) - if err != nil { - return err - } - } - - err := os.WriteFile(WgFileSecondary, conf, fs.ModeAppend) - if err != nil { - return err - } - - if isFirstTime { - fmt.Println("[#] Wireguard Server Starting") - - cmds := strings.Fields("wg-quick up " + WgFileNameSecondary) - - cmd := exec.Command(cmds[0], cmds[1:]...) - cmd.Stdout = os.Stdout - cmd.Stdin = os.Stdin - cmd.Stderr = os.Stderr - - err = cmd.Run() - if err != nil { - return err - } - - fmt.Println("[#] Wireguard Server Started") - return err - } - - fmt.Println("[#] Wireguard Server Restarting") - // cmds := strings.Fields("wg-quick strip " + WgFileNameSecondary) - cmd := exec.Command("bash", "-c", fmt.Sprintf("wg-quick strip %s > a.txt && wg syncconf %s a.txt", WgFileNameSecondary, WgFileNameSecondary)) - cmd.Stdout = os.Stdout - cmd.Stdin = os.Stdin - cmd.Stderr = os.Stderr - - err = cmd.Run() - if err != nil { - fmt.Println(err) - } - - if err != nil { - return err - } - - fmt.Println("[#] Wireguard Server Restarted") - return nil -} - -func startApi() error { - app := fiber.New(fiber.Config{ - DisableStartupMessage: true, - }) - - app.Post("/post", func(c *fiber.Ctx) error { - err := reloadConfig(c.Body()) - if err != nil { - return err - } - err = c.Send([]byte("done")) - if err != nil { - return err - } - return nil - }) - err := app.Listen(":2998") - if err != nil { - return err - } - return nil -} - -func main() { - go func() { - _ = startApi() - }() - err := reloadConfig(nil) - if err != nil { - panic(err) - } - var wg sync.WaitGroup - wg.Add(1) - wg.Wait() -} diff --git a/flake.nix b/flake.nix index 4dcdd6a8e..dfb7605a2 100644 --- a/flake.nix +++ b/flake.nix @@ -9,15 +9,9 @@ flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; - # -- function with 0 arguments - dir = {}: (builtins.getEnv "PPOJECT_ROOT"); in { packages = { - example = pkgs.writeScriptBin "example" '' - echo this ${dir{}}; - ''; - mocki = pkgs.writeScriptBin "mocki" '' $PROJECT_ROOT/cmd/mocki/bin/mocki "$@" ''; @@ -25,19 +19,13 @@ $PROJECT_ROOT/cmd/nats-manager/bin/nats-manager --url "nats://nats.kloudlite.svc.cluster.local:4222" --stream "resource-sync" "$@" ''; }; - formatter = pkgs.nixpkgs-fmt; devShells.default = pkgs.mkShell { packages = [ - self.packages.${system}.example - self.packages.${system}.mocki self.packages.${system}.nats-manager ]; hardeningDisable = [ "all" ]; - buildInputs = with pkgs; [ - # INFO; search packages at https://search.nixos.org/packages - # cli tools curl jq @@ -51,12 +39,10 @@ ggshield ])) - # programming tools go_1_21 operator-sdk - mongosh # -- mongodb client - redli # -- redis client + mongosh natscli # kubernetes specific tools @@ -76,7 +62,6 @@ shellHook = '' export PROJECT_ROOT="$PWD" - # exec fish # -- not needed if using direnv as it will automatically load current shell ''; }; } diff --git a/go.mod b/go.mod index 2968806af..a20dfdf76 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/aws/aws-sdk-go v1.45.11 github.com/bradleyfalzon/ghinstallation/v2 v2.0.4 github.com/codingconcepts/env v0.0.0-20200821220118-a8fbf8d84482 - github.com/containerd/continuity v0.4.1 github.com/go-redis/redis/v8 v8.11.5 github.com/gobuffalo/flect v1.0.2 github.com/gofiber/adaptor/v2 v2.1.23 @@ -17,15 +16,13 @@ require ( github.com/google/go-github/v43 v43.0.0 github.com/google/go-github/v45 v45.2.0 github.com/gorilla/websocket v1.5.0 - github.com/kloudlite/operator v0.0.0-20231122102406-f6459bc7a96a + github.com/kloudlite/operator v0.0.0-20231206054547-f41e4bfa411f github.com/matoous/go-nanoid/v2 v2.0.0 github.com/miekg/dns v1.1.54 - github.com/otiai10/copy v1.11.0 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.29.1 github.com/sendgrid/sendgrid-go v3.11.1+incompatible github.com/signintech/gopdf v0.12.0 - github.com/slack-go/slack v0.11.4 github.com/stripe/stripe-go v70.15.0+incompatible github.com/tektoncd/triggers v0.22.1 github.com/twmb/franz-go v1.14.4 @@ -46,7 +43,6 @@ require ( k8s.io/apiextensions-apiserver v0.28.1 k8s.io/apimachinery v0.28.1 k8s.io/client-go v0.28.1 - rogchap.com/v8go v0.8.0 sigs.k8s.io/controller-runtime v0.16.1 sigs.k8s.io/yaml v1.3.0 ) @@ -91,7 +87,6 @@ require ( contrib.go.opencensus.io/exporter/prometheus v0.4.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.2.0 // indirect - github.com/Microsoft/go-winio v0.6.0 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect github.com/andybalholm/brotli v1.0.5 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -122,7 +117,7 @@ require ( github.com/google/go-github/v41 v41.0.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.3.1 + github.com/google/uuid v1.3.1 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect @@ -155,7 +150,6 @@ require ( github.com/savsgio/gotils v0.0.0-20211223103454-d0aaa54c5899 // indirect github.com/sendgrid/rest v2.6.9+incompatible // indirect github.com/shopspring/decimal v1.3.1 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/spf13/pflag v1.0.5 github.com/tektoncd/pipeline v0.43.2 // indirect @@ -175,7 +169,7 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/dig v1.14.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.14.0 + golang.org/x/crypto v0.14.0 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/term v0.13.0 // indirect diff --git a/go.sum b/go.sum index 8710d577d..b368913cc 100644 --- a/go.sum +++ b/go.sum @@ -49,8 +49,6 @@ github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7Y github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= -github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= -github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= @@ -97,8 +95,6 @@ github.com/cloudevents/sdk-go/v2 v2.12.0/go.mod h1:xDmKfzNjM8gBvjaF8ijFjM1VYOVUE github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/codingconcepts/env v0.0.0-20200821220118-a8fbf8d84482 h1:5/aEFreBh9hH/0G+33xtczJCvMaulqsm9nDuu2BZUEo= github.com/codingconcepts/env v0.0.0-20200821220118-a8fbf8d84482/go.mod h1:TM9ug+H/2cI3EjyIDr5xKCkFGyNE59URgH1wu5NyU8E= -github.com/containerd/continuity v0.4.1 h1:wQnVrjIyQ8vhU2sgOiL5T07jo+ouqc2bnKsv5/EqGhU= -github.com/containerd/continuity v0.4.1/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -161,8 +157,6 @@ github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= -github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -234,7 +228,6 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-containerregistry v0.12.1 h1:W1mzdNUTx4Zla4JaixCRLhORcR7G6KxE5hHl5fkPsp8= @@ -269,7 +262,6 @@ github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= @@ -331,6 +323,8 @@ github.com/kloudlite/container-registry-authorizer v0.0.0-20231021122509-161dc30 github.com/kloudlite/container-registry-authorizer v0.0.0-20231021122509-161dc30fde55/go.mod h1:GZj3wZmIw/qCciclRhgQTgmGiqe8wxoVzMXQjbOfnbc= github.com/kloudlite/operator v0.0.0-20231122102406-f6459bc7a96a h1:4bLqedXrd2Ht0OK6C+vteimGMjm5h5HOSt0hBCUHux4= github.com/kloudlite/operator v0.0.0-20231122102406-f6459bc7a96a/go.mod h1:P3q1mIkMOQvyftrV5t7RP2nrYMEUzg8Z0rd+DwQZGzg= +github.com/kloudlite/operator v0.0.0-20231206054547-f41e4bfa411f h1:69puLWpV2TIPZw/x53QdF1qQI6Huc/hiHeiic6an3wg= +github.com/kloudlite/operator v0.0.0-20231206054547-f41e4bfa411f/go.mod h1:P3q1mIkMOQvyftrV5t7RP2nrYMEUzg8Z0rd+DwQZGzg= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -402,10 +396,6 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/openzipkin/zipkin-go v0.3.0 h1:XtuXmOLIXLjiU2XduuWREDT0LOKtSgos/g7i7RYyoZQ= github.com/openzipkin/zipkin-go v0.3.0/go.mod h1:4c3sLeE8xjNqehmF5RpAFLPLJxXscc0R4l6Zg0P1tTQ= -github.com/otiai10/copy v1.11.0 h1:OKBD80J/mLBrwnzXqGtFCzprFSGioo30JcmR4APsNwc= -github.com/otiai10/copy v1.11.0/go.mod h1:rSaLseMUsZFFbsFGc7wCJnnkTAvdc5L6VWxPE4308Ww= -github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks= -github.com/otiai10/mint v1.5.1/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM= github.com/phpdave11/gofpdi v1.0.11 h1:wsBNx+3S0wy1dEp6fzv281S74ogZGgIdYWV2PugWgho= github.com/phpdave11/gofpdi v1.0.11/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ= @@ -476,8 +466,6 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/slack-go/slack v0.11.4 h1:ojSa7KlPm3PqY2AomX4VTxEsK5eci5JaxCjlzGV5zoM= -github.com/slack-go/slack v0.11.4/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= @@ -496,7 +484,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -735,7 +722,6 @@ golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -970,8 +956,6 @@ knative.dev/pkg v0.0.0-20221011175852-714b7630a836 h1:0N7Zo/O+xeUUebJPm9keBaGclr knative.dev/pkg v0.0.0-20221011175852-714b7630a836/go.mod h1:DMTRDJ5WRxf/DrlOPzohzfhSuJggscLZ8EavOq9O/x8= knative.dev/serving v0.30.1-0.20220402124840-21c05dc9d9a4 h1:iRFWsFKsA5ddhi+eKZVJdf8gPBomTfjIyRAKk9Uh7Ko= knative.dev/serving v0.30.1-0.20220402124840-21c05dc9d9a4/go.mod h1:TIKeQ1Dvn/wfmgth1fpBeYi1Qf0TPlulnwUDwOdZN50= -rogchap.com/v8go v0.8.0 h1:/crDEiga68kOtbIqw3K9Rt9OztYz0LhAPHm2e3wK7Q4= -rogchap.com/v8go v0.8.0/go.mod h1:MxgP3pL2MW4dpme/72QRs8sgNMmM0pRc8DPhcuLWPAs= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/pkg/types/hook-types.go b/pkg/types/hook-types.go index ce423095c..ae671575d 100644 --- a/pkg/types/hook-types.go +++ b/pkg/types/hook-types.go @@ -1,11 +1,11 @@ package types type HttpHook struct { - Body []byte `json:"body"` - Headers map[string]string `json:"headers"` - Url string `json:"url"` - QueryParams []byte `json:"queryParams,omitempty"` - Metadata map[string]string `json:"metadata,omitempty"` + Body []byte `json:"body"` + Headers map[string][]string `json:"headers"` + Url string `json:"url"` + QueryParams []byte `json:"queryParams,omitempty"` + Metadata map[string]string `json:"metadata,omitempty"` } type GitHttpHook struct {